pyuvdata
pyuvdata copied to clipboard
add CASA cal table read/write functionality
There is evidence @nkern knows how to read these, so I'm assigning him.
@nkern I'm happy to help you get your exisiting code integrated into the pyuvdata structures if you want, just let me know.
so the tricky thing is: my code is a two part system. the first half is a CASA pipeline that extracts the .cal/ data and writes it out to .csv files, and the other half (which I talked about in the telecon today) is just a script that reformats that .csv into calfits. I think we already have the tools to do the latter. We don't however have the tools to do the former purely within a Python environment, which is I think what people want here.
Oh, ok. I was hoping you were reading the cal table directly. We do something like that to read measurement sets into UVData (see ms.py), but we don't yet have code to read the cal stuff into UVCal. I got excited when I thought you had the code to do that.
@nkern I think we're in similar places from two different directions. Tasha and I have the same CASA-side pipe from .cal to .npz, and then a separate step to go from .npz to .calfits. Do note that @plaplant and I found a bug in hera_cal.cal_formats that we fixed this morning, if that's what you're using to construct your calfits files.
@bhazelton ah sorry, yeah the title of my script caltable2calfits.py is a little misleading...
@SaulAryehKohn Ok, thanks for the heads up! I am not using that, but I should probably be using cal_formats.
@nkern @SaulAryehKohn If the casa export part is pretty standard, we could imagine adding directions on how to do it to the docs and then using your code to read in the resulting file into UVCal. It's sort of a half-way solution, but it's probably better than the nothing we have now.
It's pretty painless in CASA, it's just annoying that you have to be in CASA to be able to call their "table" library tb. e.g. :
# in CASA
tb.open('blah.B.cal')
gain = tb.getcol('CPARAM') # for .K.cal use 'FPARAM'
np.savez('blah.B.npz',gains=gain)
which, in the unpolarized case, will hand you gain as a (2 x nant x nfreq) array where you only want the [0, :, :] array (the 1th one is just all ones). In the polarized case, the 0th index is "X" and the 1st is "Y".
I don't know if you're up for the work, but we actually do access their table library in ms.py, so we could probably translate your casa script to pyuvdata.
I'll take a look!
I'm commenting here since this might be relevant to me. (Also, let me know if there's an easier way to "bookmark" issues in github than just commenting or assigning myself -- the former seems sloppy and the latter seems like too big a leap.)
Nothing quite like reviving a 7-year old thread... I've got a draft PR (above) that at least seems to be reading in/writing out correctly MS calibration tables, in that I can write out MS cal tables and see them in plotms just fine. That's obviously a pretty limited test, so if any folks here are eager and willing, happy to have some people test this new functionality out (on something other than an SMA dataset, which is most of my life at the moment).