Browse Source

antabfs_nominal.py 4.2 and updated SEFD table

polconvert
Benito Marcote 4 years ago
parent
commit
acdc183c18
  1. 46
      antabfs_nominal.py
  2. 24
      sefd_values.txt

46
antabfs_nominal.py

@ -1,15 +1,18 @@ @@ -1,15 +1,18 @@
#!/usr/bin/python3
#!/opt/local/bin/python3
####!/usr/bin/python3
"""
Python port of Bob Campbell's IDL script to make nominal tsys tables.
It takes the nominal SEFD values from the sefd_values.txt table and generates an ANTAB file using
these values. Gains will be set to 1/SEFD, and all Tsys to 1.0.
Note that it will overwrite any existing ANTAB file in the current path.
Version: 4.0
Version: 4.2
Date: June 2018
Author: Benito Marcote (marcote@jive.eu) & Jay Blanchard (blanchard@jive.eu)
version 4.2 changes
- Explicit error if antenna or freq. is not known
version 4.1 changes
- Minor issues (ordering input arguments, version)
version 4.0 changes
@ -29,7 +32,7 @@ from math import floor @@ -29,7 +32,7 @@ from math import floor
from collections import defaultdict
__version__ = 4.2
help_str = """Writes a nominal SEFD ANTAB file. Gain will be set to 1/SEFD, and all Tsys to 1.0.
It will overwrite any previous antab file in the current path.
antabfs_nominal.py uses the SEFD information from sefd_values.txt to compute the nominal values.
@ -40,7 +43,7 @@ parser = argparse.ArgumentParser(description=help_str, prog='antabfs_nominal.py' @@ -40,7 +43,7 @@ parser = argparse.ArgumentParser(description=help_str, prog='antabfs_nominal.py'
parser.add_argument('antenna', type=str, default=None, help='Antenna name (two-letters syntax, except for Jb1 Jb2 Ro7 Ro3)')
parser.add_argument('experiment', type=str, default=None, help='Experiment name')
parser.add_argument('start', type=str, default=None, help='Start time (DOY/HH:MM, YYYY/DOY/HH:MM or YYYY/MM/DD/HH:MM)')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 4.1')
parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(__version__))
parser.add_argument('-b', '--band', type=str, default=None, help='Observed band (in cm). REQUIRED unless SEFD provided')
parser.add_argument('-d', '--duration', type=float, default=24, help='Duration of the experiment (in hours). Default: 24 h')
parser.add_argument('-fr', '--freqrange', type=str, default='100,100000', help='Frequency range where the ANTAB is applicable (lower and upper limit, in MHz). Default 100,100000 (please, do not use spaces between the numbers).')
@ -52,14 +55,14 @@ args = parser.parse_args() @@ -52,14 +55,14 @@ args = parser.parse_args()
i_already_warn_about_seconds = False
# def read_sefd_table(tablename='sefd_values.txt'):#'/jop83_0/pipe/in/marcote/scripts/sefd_values.txt'):
def read_sefd_table(tablename='/jop83_0/pipe/in/marcote/scripts/sefd_values.txt'):
# def read_sefd_table(tablename='/jop83_0/pipe/in/marcote/scripts/sefd_values.txt'):
def read_sefd_table(tablename='sefd_values.txt'):
sefd_table = open(tablename, 'r')
titles = sefd_table.readline().strip().split('|')
titles = [t.strip() for t in titles]
sefd_dict = defaultdict(dict)
for an_ant in sefd_table.readlines():
values = [ t.strip() for t in an_ant.strip().split('|')]
values = [t.strip() for t in an_ant.strip().split('|')]
for i in range(1, len(values)):
if values[i] != '':
sefd_dict[values[0].lower()][titles[i]] = float(values[i])
@ -68,15 +71,16 @@ def read_sefd_table(tablename='/jop83_0/pipe/in/marcote/scripts/sefd_values.txt' @@ -68,15 +71,16 @@ def read_sefd_table(tablename='/jop83_0/pipe/in/marcote/scripts/sefd_values.txt'
def read_sefd_values(table, antenna, band):
try:
return table[antenna][band]
except KeyError:
if antenna not in table:
print('ERROR: {} is not available.\n'.format(antenna))
print('The available antennas are: ', ' '.join(table.keys()))
else:
print('ERROR: antenna {} does not have SEFD information for {}-cm observations'.format(antenna, band))
if antenna not in table:
print('ERROR: {} is not available.\n'.format(antenna))
print('The available antennas are: {}'.format(' '.join(table.keys())))
sys.exit(1)
elif band not in table[antenna]:
print('ERROR: antenna {} does not have SEFD information for {}-cm observations'.format(antenna, band))
print('{} only has SEFD information for {} cm'.format(antenna, ', '.join(table[antenna].keys())))
sys.exit(1)
else:
return table[antenna][band]
def index_header():
@ -96,8 +100,9 @@ def get_header(antenna, gain, freqrange): @@ -96,8 +100,9 @@ def get_header(antenna, gain, freqrange):
The gain (in 1/Jy) for this antenna
"""
generic_header = '''!
! Nominal calibration data for {ant} by tsys_nominal.py.
! tsys_nominal.py version 2.0, 2016 August 3, BM & JB
! Nominal calibration data for {ant} created by
! antabfs_nominal.py (version {version})
! Script at JIVE done by Benito Marcote & Jay Blanchard
!
GAIN {ant} ELEV DPFU={gain},{gain} POLY=1.0 FREQ={freqrange}
/
@ -105,7 +110,7 @@ TSYS {ant} FT=1.0 TIMEOFF=0 @@ -105,7 +110,7 @@ TSYS {ant} FT=1.0 TIMEOFF=0
INDEX = {indexes}
/'''
return generic_header.format(ant=antenna[:2].upper(), gain=gain, indexes=index_header(),
freqrange=','.join([str(i) for i in freqrange]))
version=__version__, freqrange=','.join([str(i) for i in freqrange]))
def hm2hhmmss(hhmm):
@ -123,6 +128,7 @@ def hm2hhmmss(hhmm): @@ -123,6 +128,7 @@ def hm2hhmmss(hhmm):
second = int((minute-floor(minute))*60)
return int(hour), int(floor(minute)), second
def date2datetime(date):
"""Convert the given date to DOY, HH, MM.
Inputs:
@ -140,12 +146,11 @@ def date2datetime(date): @@ -140,12 +146,11 @@ def date2datetime(date):
year, month, day, hhmm = date.split('/')
return dt.datetime(int(year), int(month), int(day), *hm2hhmmss(hhmm))
else:
print('Error: date must have the following format: DOY/HH:MM, YYYY/DOY/HH:MM or YYYY/MM/DD:HH:MM')
print('ERROR: date must have the following format: DOY/HH:MM, YYYY/DOY/HH:MM or YYYY/MM/DD:HH:MM')
raise SyntaxError
def date2string(datetime):
"""Return a string with the date in the correct ANTAB format
"""
@ -196,7 +201,6 @@ if not (args.freqrange[0] < 30*1000/float(args.band) < args.freqrange[1]): @@ -196,7 +201,6 @@ if not (args.freqrange[0] < 30*1000/float(args.band) < args.freqrange[1]):
sefd_info = read_sefd_table()
start_time = date2datetime(args.start)
end_time = start_time + dt.timedelta(args.duration/24.)
a_time = date2datetime(args.start)

24
sefd_values.txt

@ -3,22 +3,22 @@ Jb1 | 132 | 83 | | 36 | 65 | | 80 | | | | @@ -3,22 +3,22 @@ Jb1 | 132 | 83 | | 36 | 65 | | 80 | | | |
Jb2 | | | | 350 | 320 | | 320 | 300 | | 910 |
Cm | | | | 220 | 212 | | 136 | 410 | | 720 |
Wb |2100 | |1680 | 420 | 560 | 840 |1680 |1600 |1680 | |
Ef | 600 | 600 | 65 | 20 | 19 | 300 | 20 | 25 | 20 | 90 | 200
Ef | 600 | 600 | 65 | 20 | 19 | 300 | 20 | 25 | 20 | 70 | 200
Mc | | | | 490 | 700 | 400 | 170 | 840 | 320 | 700 |
Nt | | | | 820 | 784 | 770 | 260 |1100 | 770 | 800 | 900
Nk | | | | | | |1800 |1800 | | |
Nk | | | | | | |1800 |1800 | | |
Sr | | | | 67 | 67 | | | 50 | | 138 |
O8 | | | 900 | 320 | 320 | | 600 |1500 | | |
O6 | | | | | |1110 | | |1000 |1380 | 1310
O8 | | | 900 | 350 | 350 | | 480 | 850 | | |
O6 | | | | | |1110 | | | 785 |1200 | 1310
Sh | | | | | 670 | 800 | 720 |1500 | 800 | |
T6 | | | | 39 | 39 | 46 | 26 | 26 | 48 | |
T6 | | | | 39 | 39 | 46 | 26 | 26 | 48 | 70 | 120
Ur | | | | 300 | 300 | 560 | 250 | | 350 | 850 |
Tr | | |2000 | 250 | 300 | | 220 | 650 | | 500 |
Mh | | | | | |4500 | | |3200 |2608 | 4500
Ys | | | | | | | 160 |160 | 200 | 200 | 480
Ar | 12 | | 3 | 3.5 | 3 | 3 | 5 | 5 | 6 | |
Ys | | | | | |1400 | 160 | 160 | 200 | 200 | 480
Ar | 12 | | 3 | 3.5 | 3 | 3 | 5 | 5 | 6 | |
Wz | | | | | |1250 | | | 750 | |
Hh | | | | | 430 | 410 | 650 | 700 | 630 | |
Hh | | | | | 430 | 410 | 650 | 700 | 630 |1800 |
Ht | | | | | |1050 | | |1400 | |
Sv | | | | 360 | 360 | 330 | 250 | | 200 | 710 |
Zc | | | | 300 | 300 | 330 | 400 | | 200 | 710 |
@ -26,12 +26,12 @@ Bd | | | | 330 | 330 | 330 | 200 | | 200 | 710 | @@ -26,12 +26,12 @@ Bd | | | | 330 | 330 | 330 | 200 | | 200 | 710 |
Ky | | | | | | | | | |1288 | 1919
Ku | | | | | | | | | |1288 | 1919
Kt | | | | | | | | | |1288 | 1919
My | | | | | | | | | | |
Km | | | | | | 350 | 400 | 400 | 480 | |
Ro7 | | | | | 35 | 20 | | | 18 | 83 |
My | 9 | 9 | | | | 9 | | | 9 | |
Km | | | | | | 350 | 17 | 17 | 480 | |
Ro7 | | | | | 35 | 20 | | | 18 | 83 |
Ro3 | | | | | | 150 | | | 106 | |
Ny | | | | | | 850 | | |1255 | |
Ir | | | | |3600 | | 430 | 430 | | |
Ir | | | | |3600 | | 430 | 480 |1300 | |
Ho | | | | 470 | 420 | 650 | 640 | 800 | 560 |1800 |
At | | | | 340 | 340 | 530 | 350 | 850 | 430 | 530 |
Mp | | | | 340 | 340 | 530 | 350 | 850 | 430 | 900 |

Loading…
Cancel
Save