Skip to content

Instantly share code, notes, and snippets.

@d3v-null
Last active July 5, 2024 07:50
Show Gist options
  • Save d3v-null/e4f545a497d5b53c8f453d7d32652d3f to your computer and use it in GitHub Desktop.
Save d3v-null/e4f545a497d5b53c8f453d7d32652d3f to your computer and use it in GitHub Desktop.
# wget -O "1392414360.metafits" $'http://ws.mwatelescope.org/metadata/fits?obs_id=1392414360' # compact
# wget -O "1204135512.metafits" $'http://ws.mwatelescope.org/metadata/fits?obs_id=1204135512' # extended
from astropy.io import fits
import numpy as np
extended = fits.open('1204135512.metafits')
compact = fits.open('1392414360.metafits')
# delete any rows from compact that have a `TileName` that already exists in extended
extended_names = np.unique(extended['TILEDATA'].data['TileName'])
dedup_compact = compact['TILEDATA'].data[~np.in1d(compact['TILEDATA'].data['TileName'], extended_names)]
# append extended['TILEDATA'].data and dedup_compact
combined = np.append(extended['TILEDATA'].data, dedup_compact)
print(len(np.unique(combined['TileName'])), "unique tiles")
# enumerate the rows of the combined table into the Input column
combined['Input'] = np.arange(len(combined))
# populate the Antenna field with a number that is unique to each TileName
# as a heuristic, assume that each pair of rows has the same tileName
combined['Antenna'] = np.arange(len(combined)) // 2
extended['TILEDATA'].data = combined
extended['PRIMARY'].header['NINPUTS'] = len(combined)
extended.writeto('gen_257T.metafits', overwrite=True)
# wget https://github.com/JLBLine/srclists/raw/master/srclist_pumav3_EoR0LoBES_EoR1pietro_CenA-GP_2023-11-07.yaml
# hyperdrive vis-sim --metafits gen_257T.metafits -o gen_257T.uvfits -s srclist_pumav3_EoR0LoBES_EoR1pietro_CenA-GP_2023-11-07.yaml -n 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment