Skip to content

Commit 5ff89bc

Browse files
committed
add utility functinos for parsing the frequency support section of an
ALMA table
1 parent af56480 commit 5ff89bc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

astroquery/alma/core.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,40 @@ def unique(seq):
832832
seen = set()
833833
seen_add = seen.add
834834
return [x for x in seq if not (x in seen or seen_add(x))]
835+
836+
def parse_frequency_support(frequency_support_str):
837+
"""
838+
ALMA "Frequency Support" strings have the form:
839+
[100.63..101.57GHz,488.28kHz, XX YY] U [102.43..103.37GHz,488.28kHz, XX YY] U [112.74..113.68GHz,488.28kHz, XX YY] U [114.45..115.38GHz,488.28kHz, XX YY]
840+
at least, as far as we have seen. The "U" is meant to be the Union symbol.
841+
This function will parse such a string into a list of pairs of astropy
842+
Quantities representing the frequency range. It will ignore the resolution
843+
and polarizations.
844+
"""
845+
supports = frequency_support_str.split("U")
846+
freq_ranges = [(float(sup.strip('[] ').split("..")[0]),
847+
float(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.letters)))
848+
*u.Unit(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.punctuation+string.digits))
849+
for sup in supports]
850+
return freq_ranges
851+
852+
def approximate_primary_beam_sizes(frequency_support_str, dish_diameter=12*u.m, first_null=1.220):
853+
"""
854+
Using parse_frequency_support, determine the mean primary beam size in each
855+
observed band
856+
857+
Parameters
858+
----------
859+
frequency_support_str : str
860+
The frequency support string, see `parse_frequency_support`
861+
dish_diameter : `~astropy.units.Quantity`
862+
Meter-equivalent unit. The diameter of the dish.
863+
first_null : float
864+
The position of the first null of an Airy. Used to compute resolution
865+
as :math:`R = 1.22 \lambda/D`
866+
"""
867+
freq_ranges = parse_frequency_support(frequency_support_str)
868+
beam_sizes = [(first_null*fr.mean().to(u.m, u.spectral())/(dish_diameter)).to(u.arcsec,
869+
u.dimensionless_angles())
870+
for fr in freq_ranges]
871+
return beam_sizes

0 commit comments

Comments
 (0)