RF Antenna Parameters

A collection of utilities to help convert RF engineering/communications terms into radio astronomy terms. This module is geared toward taking antenna parameters in dBi or dBd and converting them into meaningful RA gains in K/Jy and then using those to get a system equivalent flux density.

New in version 1.0.3.

lsl.misc.rfutil.dBd2dBi(dBd)

Convert an antenna gain in dBb (gain relative to the maximum gain of a half-wave dipole) into a gain in dBi (gain relative to an isotropic antenna).

lsl.misc.rfutil.dBd2dBi(dBd)

Convert an antenna gain in dBb (gain relative to the maximum gain of a half-wave dipole) into a gain in dBi (gain relative to an isotropic antenna).

lsl.misc.rfutil.dBi2gain(dBi, frequency)

Convert an antenna gain in dBi (gain relative to an isotropic antenna) at a particular frequency in Hz into a gain in K/Jy.

lsl.misc.rfutil.dBd2gain(dBd, frequency)

Convert an antenna gain in dBd (gain relative to the maximum gain of a half-wave dipole) at a particular frequency in Hz into a gain in K/Jy

lsl.misc.rfutil.gain2dBi(gain, frequency)

Convert an antenna gain in K/Jy at a particular frequency in Hz into a gain in dBi (gain relative to an isotropic antenna).

lsl.misc.rfutil.gain2dBd(gain, frequency)

Convert an antenna gain in K/Jy at a particular frequency in Hz into a gain in dBd (gain relative to the maximum gain of a half-wave dipole).

lsl.misc.rfutil.calculateSEFD(Tsys, gain=None, area=None, efficiency=None)

Given a variety of parameters, calculate the system equivalent flux density in Jy for an antenna. The parameters are: * Tsys - system temperature in K - required * gain - antenna gain in K/Jy - optional * area - antenna collecting area in m^2 - optional * efficiency - aperture efficiency - optional

Of the optional parameters either ‘gain’ needs to be supplied or both ‘area’ and ‘efficiency’.

lsl.misc.rfutil.calculateEffectiveArea(gain)

Given the gain of an antenna in K/Jy, calculate the effective collecting area in square meters.

lsl.misc.rfutil.Jy2dBm(flux, bandwidth, gain)

Convert a flux density in Jy into a received signal strength in dBm under the assumptions of: * signal bandwidth in Hz * antenna gain in K/Jy

lsl.misc.rfutil.dBm2Jy(dBm, bandwidth, gain)

Convert a received signal strength in dBm into a flux density in Jy under the assumptions of: * signal bandwidth in Hz * antenna gain in K/Jy

Simulated Stand Response

lsl.sim.nec_util.CloseTo(x, y, epsilon=0.005)

Return True if two numbers are within a specified fractional, not absolute, tolerance of each other. Tolerance epsilon is a keyword parameter with a default of 0.005.

lsl.sim.nec_util.open_and_get_nec_freq(fname)

Open a NEC output file and return a tuple containing the open file object and the first frequency found in the file (MHz).

lsl.sim.nec_util.change_nec_freq(necname, freq)

Modify the FR card in a NEC input file to run at freq.

lsl.sim.nec_util.calcIME(necname, myfreqs=None, zpre=100)

Compute the impedance mismatch efficiency (IME), for a given NEC run and write out the results in a file. Assumes a default preamplifier input impedance of 100 ohms, unless overridden by the zpre keyword argument. Returns the frequencies calculated by NEC, unless myfreqs is set, in which case it interpolates onto that frequency grid.

class lsl.sim.nec_util.NECImpedance(necname)

NECImpedance: Python class to read an array of impedance values from a NEC2 .out file The .nec file should loop over a range of frequencies with an FR card like this:

FR 0 91 0 0 10.0 1.0

The RP card should be minimal to keep the runtime and output file size from growing huge. For example:

RP 0,91,1,1000,0.,0.,1.0,1.0
class lsl.sim.nec_util.NECPattern(necname, freq, rerun=True)

NECPattern: Python class to read the pattern from a NEC2 .out file. Note that the .nec file should have an RP or EX card to run over the full pattern, like this:

RP 0,91,360,1000,0.,0.,1.0,1.0,0.

The FR card should be a simple single frequency run:

FR 0,1,0,0,74.0,1

Changed in version 1.2.0: Added a new “antenna_pat_complex attribute to store the complex antenna pattern

lsl.sim.nec_util.whichNEC4()

Return the path to the nec4d executable if it can be found in the current path. None otherwise. This is useful for making sure that NEC is installed before trying to run something.

Geodesy

New in version 0.3.

Module for querying the earth orientation parameters for a given date/list of dates.

Changed in version 1.0.3: Added a fallback to the backup MAIA server ‘toshi.nofs.navy.mil’ if the primary server at ‘toshi.nofs.navy.mil’ cannot be reached

Changed in version 1.0.0: Added caching of MAIA results to speed up subsequent calls to getEOP(). Removed getEOPRange() since getEOP() can do the same thing.

class lsl.misc.geodesy.EOP(mjd=0.0, x=0.0, y=0.0, dx=0.0, dy=0.0, utDiff=0.0, type='final')

Object for storing the geodetic parameters relevant for DiFX input files: * mjd - modified Julian Date of the measurement/prediction * x - difference between the celestial ephemeric pole (CEP) and the

international reference pole (IRP) in the direction of the IERS meridian [arc seconds]
  • y - difference between the CEP and IRP in the direction of 90 degrees

    west longitude [arc seconds]

  • dx - dX with respect to IAU2000A Nutation [arc seconds]

  • dy - dY with respect to IAU2000A Nutation [arc seconds]

  • UT1-UTC - difference between rotation angle about the pole and UTC

    [seconds]

  • type - whether the values for the given MJD are observed (final/IERS) or

    predicted.

Changed in version 1.0.0: Added extra attributes to store dX (dx) and dY (dy) in arc seconds.

fromMAIA(line)

Given a line from a MAIA standard rapid EOP data (IAU2000) file, fill in the object’s values with the needed information.

lsl.misc.geodesy.getEOP(mjd=None, timeout=120)

Return a list of earth orientation parameter objects for the specified MJDs. A MJD of ‘None’ returns the values for today’s date.

Changed in version 0.5.2: Added the `timeout’ keyword to deal with failures download EOP data. The default value is 120 seconds.

Changed in version 1.0.0: Added caching of EOP values to speed up subsequent calls.

Ionospheric and Geomagnetic Field Models

New in version 1.1.0.

lsl.misc.ionosphere.getMagneticField(lat, lng, elev, mjd=None, ecef=False)

Given a geodetic location described by a latitude in degrees (North positive), a longitude in degrees (West negative), an elevation in meters and an MJD value, compute the Earth’s magnetic field in that location and return a three-element tuple of the magnetic field’s components in nT. By default these are in topocentric coordinates of (North, East, Up). To return values in ECEF, set the ‘ecef’ keyword to True. If the MJD file is None, the current time is used.

Note

The convention used for the topocentric coordinates differs from what the IGRF uses in the sense that the zenith direction points up rather than down.

lsl.misc.ionosphere.computeMagneticDeclination(Bn, Be, Bz)

Given the topocentric output of getMagneticField(), compute and return the magnetic declination (deviation between magnetic north and true north) in degrees.

Note

The declination is poorly defined (NaN) around the magnetic poles where the horizontal field strength is less than 100 nT.

lsl.misc.ionosphere.computeMagneticInclination(Bn, Be, Bz)

Given the topocentric output of getMagneticField(), compute and return the magnetic inclination or magnetic dip (angle between the magnetic field and the horizontal) in degrees.

lsl.misc.ionosphere.getTECValue(mjd, lat=None, lng=None, includeRMS=False, timeout=120, type='IGS')

Given an MJD value and, optionally, a latitude and longitude in degrees, compute the TEC value in TECU above that location using data from the IGS or CODE (depending on the value of the ‘type’ keyword). If the ‘includeRMS’ keyword is set to True, also return the RMS in the TEC value.

lsl.misc.ionosphere.getIonosphericPiercePoint(site, az, el, height=450000.0, verbose=False)

Given a site and a pointing direction (azimuth and elevation in degrees), compute the location of the ionospheric pierce point. Since the height assumed for the ionosphere is model-dependent the ‘height’ keyword sets the elevation to use in meters. Returns a three-element tuple of latitude (degrees, North is positive), longitude (degrees, East is positive), and elevation (meters).

Autostereograms

New in version 0.5.3.

lsl.misc.autostereogram.getASG(data, patternWidth=100, patternPad=1, maxDepth=30)

Given a 2-D numpy array of data (image, elevation, etc.), convert the data into a random dot autostereogram. The options control the size of the pattern in the final image, the amount of padding around the image, and how the input data is converted to a depth map. The output is a three-element tuple of the depth map, input random dot image, and auto- stereogram.

Note

The output autostereogram is a 3-D numpy array with width, depth, and color channel.

lsl.misc.autostereogram.getDepthMap(final)

Given an autostereogram image (width x heigth x color channel), determine the depth map and return it. This function uses the padding area around the input image to determine the pattern width and then uses that width to look for relative shifts.

Conversion Helper Functions for argparse

New in version 1.2.4.

lsl.misc.parser.positive_or_zero_int(string)

Convert a string to a positive (>=0) integer.

lsl.misc.parser.positive_int(string)

Convert a string to a positive (>0) integer.

lsl.misc.parser.positive_or_zero_float(string)

Convert a string to a positive (>=0.0) float.

lsl.misc.parser.positive_float(string)

Convert a string to a positive (>0.0) float.

lsl.misc.parser.frequency(string)

Convert a frequency to a float Hz value. This function accepts a variety of string formats:

  • pure float values are intepreted to be in MHz (45.0 -> 45e6)

  • number/unit pairs are allowed so long as they are in:
    • [prefix]m, A, or ang for wavelength and
    • [prefix]Hz for frequency
lsl.misc.parser.frequency_range(string)

Convert a frequency to a float Hz value. This function accepts a variety of string formats:

  • a ‘number~number’ is interpretted as a range in MHz
  • a ‘number/unit~number/unit’ is converted to a range in Hz

Note

For ranges, a two-element list is returned where the first value is less than the second.

lsl.misc.parser.wavelength(string)

Convert a wavelength to a float m value. This function accepts a variety of string formats:

  • pure float values are intepreted to be in m (45.0 -> 45.0)

  • number/unit pairs are allowed so long as they are in:
    • [prefix]m, A, or ang for wavelength and
    • [prefix]Hz for frequency
lsl.misc.parser.wavelength_range(string)

Convert a wavelength to a float m value. This function accepts a variety of string formats:

  • a ‘number~number’ is interpretted as a range in m
  • a ‘number/unit~number/unit’ is converted to a range in m

Note

For ranges, a two-element list is returned where the first value is less than the second.

lsl.misc.parser.date(string)

Convert a data as either a YYYY[-/]MM[-/]DD or MJD string into a YYYY/MM/DD string.

lsl.misc.parser.mjd(string)

Convert a data as either a YYYY[-/]MM[-/]DD or MJD string into an integer MJD.

lsl.misc.parser.time(string)

Covnert a time as HH:MM:SS[.SSS] or MPM string into a HH:MM:SS.SSSSSS string.

lsl.misc.parser.mpm(string)

Covnert a time as HH:MM:SS[.SSS] or MPM string into an MPM integer.

lsl.misc.parser.hours(string)

Convert a ‘HH[:MM[:SS[.SSS]]]’ string into an ephem.hours instance.

lsl.misc.parser.csv_hours_list(string)

Convert a comma-separated list of ‘HH[:MM[:SS.[SSS]]]’ string into a list of ephem.hours instances.

lsl.misc.parser.degrees(string)

Convert a ‘sDD[:MM[:SS[.SSS]]]’ string into an ephem.degrees instance.

lsl.misc.parser.csv_degrees_list(string)

Convert a comma-separated list of ‘sDD[:MM[:SS.[SSS]]]’ string into a list of ephem.degrees instances.

lsl.misc.parser.csv_int_list(string)

Convert a comma-separated list of integers into a list of integers. This function also allows for ranges to be specifed using the ‘~’ character. This formatting converts ‘start~stop’ to ‘range(start, stop+1)’.

lsl.misc.parser.csv_baseline_list(string)

Convert a comma-separated list of baslines pairs into a list of baseline pairs. Baseline pairs are defined as ‘antenna1-antenna2’ where ‘antenna1’ and ‘antenna2’ are both integers or ranges denoted by the ‘~’ character.

lsl.misc.parser.csv_hostname_list(string)

Convert a comma-separated list of IPv4 addresses/hostnames into a list IPv4 addresses/hostnames. This function support indexing with the ‘~’ character so long as:

  • the character is in any one of the IPv4 bytes or
  • the character is at the end of a hostname which ends with a number

Table Of Contents

Previous topic

Fake Data

Next topic

General Utilities

This Page