Metadata-Version: 2.4
Name: skynoise
Version: 0.2.0
Summary: Compute antenna noise temperature from a NEC model file
Author-email: John Sager <john@sager.me.uk>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Topic :: Communications :: Ham Radio
Description-Content-Type: text/markdown
License-File: LICENCE
Requires-Dist: numpy>=1.26.0
Requires-Dist: astropy>=6.0.0
Requires-Dist: astropy-healpix>=1.0.0
Requires-Dist: astronomy-engine>=2.1.0
Dynamic: license-file

# Skynoise

## Contents
 - [Introduction](#introduction)
 - [User Guide](#userguide)
 - [Description](#description)

<a name="introduction"></a>
## Introduction

Skynoise computes the average sky temperature seen by an antenna from radiation pattern data produced by the NEC2 or NEC4 electromagnetic modelling software from a NEC model of the antenna.

<a name="userguide"></a>
## User Guide

### Installation

#### Windows

If Python is not installed, with a browser go to python.org

Hover over ‘Downloads’, and select ‘Windows’

Click on the ‘Latest Python Install Manager’ link and on the page that loads, click the button ‘Download Installer (MSIX)’

When it downloads, open the downloaded msix file and follow instructions to install Python. Note that you should do this in non-administrator mode so that Python installs under your normal user name (in Users\&lt;username&gt;\AppData\Local\Python)

Once Python is installed bring up a command window or Powershell window and do the following:
```
py -m pip install skynoise
```
Besides skynoise several other packages - Numpy, Astropy, Astropy-healpix and Astronomy-engine - as required by skynoise, will also be installed if not already installed.

#### Linux

Normally Python is already installed in most distributions. If not, search online for instructions on how to install Python in your distribution. If you are still using Python version 2 then to run skynoise you will need also to install a recent version of Python3.

To use skynoise and other tools, they will be installed in a virtual environment (venv), which is the modern way to use Python in Linux.

Create a directory to work in with skynoise. In that directory do:
```
python -m venv venv
```
This will create a ‘venv’ directory in your working directory. Then do:
```
source venv/bin/activate
```
You will now see (venv) in front of the **name@host$** prompt to remind you that you are in venv mode. Then do:
```
pip install skynoise
```
This will install skynoise plus any of the dependent libraries if not already installed. To exit from the venv environment, just type **deactivate**. To get back in then do:
```
source venv/bin/activate
```
again as above. You will need to have the virtual environment activated to use skynoise.

#### MacOS

Not having an Apple Mac to test, these instructions may not be quite correct.

With a browser, go to 'python.org'

Hover over ‘Downloads’, and select ‘macOS’

Click on the ‘Latest Python Release’ link and on the page that loads, click the button ‘Download macOS Installer’. This will download a standard macOS .pkg file. Install this .pkg file in the usual way.

Open a Terminal window and follow the instructions for Linux above from the sentence starting *To use skynoise …*. skynoise on macOS will use a virtual environment (venv) as on Linux.

### Using Skynoise

Skynoise is a command line program so it needs to be used from a terminal window. Type:
```
skynoise --help
```
This will produce the following:
```
usage: skynoise [-h] [-c CONF] [-f FREQ] [-t TFILE] modelfile

Calculate the Antenna temperature from the input model

positional arguments:
  modelfile

options:
  -h, --help            show this help message and exit
  -c CONF, --conf CONF  Additional configuration file
  -f FREQ, --freq FREQ  Sky temperature to use 144 or 432. Default=144
  -t TFILE, --tfile TFILE  Tracking file - for temperature of moon positions
```
modelfile is required. This is the output file from the NEC2 or NEC4 electromagnetic modelling software. It specifically requires the 'RADIATION PATTERNS' data, which is produced by including a 'RP' line in the input model data to NEC. The recommended RP line is:
```
RP 0 181 360 1000 0 0 1 1
```
This will produce radiation pattern vectors at 1 degree intervals in both &theta; and &phi;. The genetic optimiser wrapper program for NEC, *4NEC2*, already generates radiation pattern data in the correct format.

The program assumes that the model is constructed such that the direction of maximum gain (boresight) is along the positive X axis (&theta; = 90, &phi; = 0). So for a Yagi the boom direction is along the positive X axis and the elements extend in the Y (horizontal) or Z (vertical) directions.

The default configuration of Skynoise includes default Location and Observation data that will point the antenna model towards a low noise portion of the sky in the Northern Hemisphere at Right Ascension 142.0 degrees, Declination 30 degrees.  The **-c** option takes an additional configuration file to provide Location and Observation data which supersede sections in the default configuration.
The file is in *toml* format (https://toml.io):
```TOML
[Location]
# example QTH Lat +ve North, Lon +ve East
Lat = 52.2
Lon = 1.4

[Observation]
# example pointing and date/time
Azimuth = 270.0
Elevation = 40.0
# must be UTC without a timezone offset field or Z suffix
ObTime = 2026-01-01T13:00:00
```
The **-f** option takes one of the two values 144 or 432. The default is 144 which selects sky noise data for 144MHz. 432 selects sky noise data for 432MHz.

The **-t** option takes a file of moon positions generated by the auxiliary program *moontrack* (see below). skynoise then generates an output file of the input moon positions with the calculated sky temperature appended.

#### Moontrack
This is the output from ```moontrack --help```:
```
usage: moontrack [-h] [-l LOCFILE] [-i INTERVAL] [-p PERIOD] [-e MINELEVATION]
                 [latlon] starttime

Generate a list of Moon azimuth and elevation

positional arguments:
  latlon                Latitude & Longitude in the form lat:lon, Default =
                        52.2:1.4
  starttime

options:
  -h, --help            show this help message and exit
  -l LOCFILE, --locfile LOCFILE
                        File with location information
  -i INTERVAL, --interval INTERVAL
                        Interval between records. Default = 15 minutes
  -p PERIOD, --period PERIOD
                        Period of records, Default = 31 days
  -e MINELEVATION, --minelevation MINELEVATION
                        Minimum Elevation to track, Default = 10.0 degrees
```
The start time is a date of the form *2026-02-01*. With the default values the program produces a list of moon positions from that date, every 15 minutes while the moon elevation is above 10 degrees, for 31 days. Each record looks like e.g.:
```
2026-02-01T00:15:00:00.000Z   122.851   22.864   204.545   58.997
```
The fields are in the order: Time, Right Ascension, Declination, Azimuth, Elevation.

The **-l** option takes a *toml* format file with location information in the same format as used in the configuration file for skynoise, described above. The same information can be supplied on the command line before the start time:
```
moontrack 52.2:1.4 2026-02-01 >mpoints_202602.txt
```
Note that the latitude and longitude values are separated by a colon (:)

The **-i**, **-p** and **-e** options are explained in the **--help** listing above.

<a name="description"></a>
## Description

Sky noise temperature data for the VHF/UHF frequency bands was produced by an all-sky survey by Haslam et al at 408MHz in 1982. Most subsequent releases of data are still based on that survey. For this program, a re-processing of the Haslam data by Remazeilles et al in 2014 has been used. This data is available on [NASA's Lambda server](https://lambda.gsfc.nasa.gov/product/foreground/fg_2014_haslam_408_get.html). The particular file used is *haslam408_ds_Remazeilles2014.fits*.

The file is in HEALPix (Hierarchical Equal Area isoLatitude Pixelization) format in Galactic coordinates with over 3 million data points at 408MHz. The pixel density of the data is reduced to 196,608 pixels and transformed to Equatorial (RA, Dec) coordinates. That temperature data is finally transformed to the frequencies of interest - 144MHz and 432MHz - by the following equation:

T<sub>f</sub> = kT<sub>408</sub> + C

Where k = (408/f)<sup>2.56</sup> and C is a correction factor for extra-galactic noise.

When skynoise runs it reads the radiation pattern data, producing an xyz vector for each gain point. With the RP line described above there are 64442 vectors and gain points in total. For each point the gain is multiplied by sin(&theta;) to allow for the fact that points towards the &theta; = 0 and &theta; = 180 poles of the pattern represent reducing areas on the sphere. As sin(&theta;) = 0 at 0 and 180 degrees, these &theta; values are ignored during this process and the gains for those two polar points are accounted for at the end.

Each pattern vector is then rotated to put the boresight direction (+X axis) in the azimuth and elevation direction and the Right Ascension and Declination for each vector is calculated from the QTH latitude, longitude and the observation time. For vectors pointing above the horizon the sky temperature in that direction is interpolated from the sky noise data, and for vectors pointing on or below the horizon the standard temperature of 290K is used. The average temperature is then calculated as:

T =(&Sum;temperature&lowast;gain) / (&Sum;gain)

As output the program produces e.g.:
```
Boresight RA,Dec: 142.000 30.000
Average Temperature: 190.688K
Gain Average: 0.976
```
The Gain Average is (&Sum;gain)/(&Sum;sin(&theta;)) and is similar to the *EFFICIENCY* figure in the *POWER BUDGET* section of the NEC output file.

John C Sager G8ONH March 2026

