Browse Source

More sharing between IDI and UVF

sfxc
haavee 3 years ago
parent
commit
8e831008e6
  1. 22
      compare-ms-idi.py

22
compare-ms-idi.py

@ -251,6 +251,13 @@ mk_idi_antab = mk_idi_lut('ANTENNA', ['ANTENNA_NO', 'ANNAME'], "Antenna#{0}".fo
mk_idi_srctab = mk_idi_lut('SOURCE' , ['SOURCE_ID' , 'SOURCE'], "Source#{0}".format)
get_idi_stats = compose(Star(analyze_uvdata_table), pam(*list(map(GetN, ['BASELINE', 'SOURCE_ID', 'INTTIM', 'FLUX']))), GetA('data'), GetN('UV_DATA'))
def aggregate(antab, srctab):
def do_aggregate(a, item):
a1, a2 = divmod(item[0][0], 256)
a[ (antab[a1]+antab[a2], srctab[item[0][1]]) ] += item[1]
return a
return do_aggregate
# Actually process a series of FITS-IDI file(s)
def process_idi(list_of_idis):
# reduction of a single FITS-IDI file
@ -261,11 +268,7 @@ def process_idi(list_of_idis):
antab, srctab = pam(mk_idi_antab, mk_idi_srctab)(idi)
# aggregate items we found in this IDI into the global accumulator
# in the process we unmap (baseline, source_id) to ('Anname1Anname2', 'Sourcename')
def aggregate(a, item):
a1, a2 = divmod(item[0][0], 256)
a[ (antab[a1]+antab[a2], srctab[item[0][1]]) ] += item[1]
return a
return reduce(aggregate, drain_dict(stats), acc)
return reduce(aggregate(antab, srctab), drain_dict(stats), acc)
# reduce all IDI files and set the source attribute on the returned object to tell whence these came
return SetSource(reduce(process_one_idi, list_of_idis, DefaultDict(Statistics)), Source(format='idi', location=summarize(list_of_idis)))
@ -277,7 +280,7 @@ def process_idi(list_of_idis):
# Create a function which creates a LUT based on enumeration in stead of taking the index from a column
mk_enum_lut = lambda tbl, col, unk: compose(partial(WrapLookup, unknown=unk), dict, ZipStar,
pam(const(itertools.count(1)),
pam(lambda _: itertools.count(1),
compose(Map(compose(str.capitalize, str)), GetN(col))),
GetA('data'), GetN(tbl))
mk_uvf_antab = mk_enum_lut('AIPS AN', 'ANNAME', "Antenna#{0}".format)
@ -291,12 +294,9 @@ def process_uvf(path_to_one_uvf):
uvf = open_idi(path_to_one_uvf)
# construct antenna, source unmappers
antab, srctab = pam(mk_uvf_antab, mk_uvf_srctab)(uvf)
print(antab.LUT)
# We post-process the statistics - unmap (baseline, source_id) to ('Anname1Anname2', 'Sourcename')
def aggregate(a, item):
a1, a2 = divmod(item[0][0], 256)
a[ (antab[a1]+antab[a2], srctab[item[0][1]]) ] += item[1]
return a
return SetSource(reduce(aggregate, drain_dict(get_uvf_stats(uvf)), DefaultDict(Statistics)),
return SetSource(reduce(aggregate(antab, srctab), drain_dict(get_uvf_stats(uvf)), DefaultDict(Statistics)),
Source(format='uvf', location=path_to_one_uvf))

Loading…
Cancel
Save