pyuvdata icon indicating copy to clipboard operation
pyuvdata copied to clipboard

add CASA cal table read/write functionality

Open bhazelton opened this issue 8 years ago • 13 comments
trafficstars

bhazelton avatar Apr 05 '17 18:04 bhazelton

There is evidence @nkern knows how to read these, so I'm assigning him.

adampbeardsley avatar Dec 06 '17 21:12 adampbeardsley

@nkern I'm happy to help you get your exisiting code integrated into the pyuvdata structures if you want, just let me know.

bhazelton avatar Dec 06 '17 21:12 bhazelton

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.

nkern avatar Dec 07 '17 03:12 nkern

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.

bhazelton avatar Dec 07 '17 03:12 bhazelton

@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.

SaulAryehKohn avatar Dec 07 '17 03:12 SaulAryehKohn

@bhazelton ah sorry, yeah the title of my script caltable2calfits.py is a little misleading...

nkern avatar Dec 07 '17 03:12 nkern

@SaulAryehKohn Ok, thanks for the heads up! I am not using that, but I should probably be using cal_formats.

nkern avatar Dec 07 '17 03:12 nkern

@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.

bhazelton avatar Dec 07 '17 03:12 bhazelton

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".

SaulAryehKohn avatar Dec 07 '17 03:12 SaulAryehKohn

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.

bhazelton avatar Dec 07 '17 03:12 bhazelton

I'll take a look!

SaulAryehKohn avatar Dec 07 '17 03:12 SaulAryehKohn

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.)

theo-kunicki avatar Jul 16 '20 16:07 theo-kunicki

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).

kartographer avatar Feb 05 '24 20:02 kartographer