JLBLine / WODEN

CUDA code designed to simulate interferometric data using point, Gaussian, and shapelet sky models
https://woden.readthedocs.io/en/latest/
Mozilla Public License 2.0
5 stars 0 forks source link

Feature request: autocorrelation output #23

Closed telegraphic closed 11 months ago

telegraphic commented 2 years ago

Hi @JLBLine,

Can you pretty please add autocorrelation output to WODEN?

I think uvfits can happily support autocorrelations, as baseline index is just idx = 256 * b1 + b2, but allowing for b1 == b2. So I think in run_woden.py:make_baseline_date_arrays() you would need to change:

    num_baselines = int(((num_antennas - 1)*num_antennas) / 2) + num_antennas
    template_baselines = np.empty(num_baselines)

    ##Loop over all antenna combinations and encode the baseline pair
    baseline_ind = 0
    for b1 in np.arange(num_antennas):
        for b2 in np.arange(b1,num_antennas):
            template_baselines[baseline_ind] = RTS_encode_baseline(b1+1, b2+1)
            baseline_ind += 1

Couldn't quite figure out what you'd need to change on the C/CUDA side (aka the difficult bit).

The use case is for simulating global 21-cm cosmology experiments with interferometers -- the signal might be accessible from within the autocorrelations if the right calibration technique can be found.

JLBLine commented 2 years ago

Hey @telegraphic I didn't write anything here as I talked to you in the real world, but I'll note here for posterity that I shall implement this once the JOSS paper has been accepted (hopefully soon!), so I can work off that version of the code. While I'm thinking about it, I'll write down what needs to be done so I don't have to think again in the future.

It shouldn't be too hard to implement this in a dumb way; I could just edit the C function src/array_layout::calc_XYZ_diffs to have an option to include the same antenna as ant1 and ant2 in the loops that make all the baselines. This should essentially add in the appropriate number of X_diff,Y_diff, Z_diff = 0,0,0 coordinates, which in turn should make u,v,w = 0,0,0, turning the measurement equation into an auto-correlation (I think that's what it would do anyway). This means I don't have to edit any CUDA code at all, just the function you mentioned so the BASELINE array in the uvfits references the autocorrelations as well. This method is wasteful in that it adds unneccesary computations of the measurement equation, but it will be far faster to develop. If it causes problems we can revisit it.

I will also mention that for now, the primary beam of all antennas are identical, and so the autocorrelations will be identical for all the antennas. I have plans to be able to add gain errors to each antenna so this could change in the future.

JLBLine commented 2 years ago

Yo @telegraphic a heads up (and @nicholebarry, you wanted autos as well), I have just finished up an implementation of auto-correlations in the auto_correlations branch. To the best of my understanding, things are working correctly. For each time step and frequency, all the autos are the same at the moment, as the primary beam is the same for every antenna (aka tile for MWA). Happy to chat if you wanna revisit using WODEN at some point. Even better if you want to have a go with this branch before I merge it into master. I'm pretty sure it works, but I've never used auto-correlations before so not sure if there are any subtleties I should be wary of (the auto-uvfits image fine through WSClean and load into pyuvdata fine which is nice).

JLBLine commented 11 months ago

This is done and we all seem happy with it