Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiSPW - Should all channels in a band have the same SPW #120

Closed
y-mhiri opened this issue Nov 8, 2024 · 5 comments
Closed

MultiSPW - Should all channels in a band have the same SPW #120

y-mhiri opened this issue Nov 8, 2024 · 5 comments

Comments

@y-mhiri
Copy link
Collaborator

y-mhiri commented Nov 8, 2024

The freq_mapping divide the channels in multiple bands according to the channels-per-integration option but no division according to the SPW is done. When cpi is fixed to -1, there is only one band that results from the frequency mapping in which all the SPW's are. It results in an error in the grid worker in the image_data_products() call in which all frequency channels should be the same accross the band (gridder.py l.380).

assert (ds.FREQ.values == freq).all()

A simple fix a tried is to use the ddids to create the band along the SPW :

            for ti, (tlow, tcounts) in titr:

                It = slice(tlow, tlow + tcounts)
                ridx = row_mapping[ms][idt]['start_indices'][It]
                rcnts = row_mapping[ms][idt]['counts'][It]
                # select all rows for output dataset
                Irow = slice(ridx[0], ridx[-1] + rcnts[-1])

                fitr = enumerate(zip(freq_mapping[ms][idt]['start_indices'],
                                    freq_mapping[ms][idt]['counts']))
                nfi = len(freq_mapping[ms][idt]['start_indices'])
                for fi, (flow, fcounts) in fitr:
                    Inu = slice(flow, flow + fcounts)

                    subds = ds[{'row': Irow, 'chan': Inu}]
                    subds = subds.chunk({'row':-1, 'chan': -1})
                    if opts.gain_table is not None:
                        # Only DI gains currently supported
                        subgds = gds[ids][{'gain_time': It, 'gain_freq': Inu}]
                        subgds = subgds.chunk({'gain_time': -1, 'gain_freq': -1})
                        jones = subgds.gains.data
                    else:
                        jones = None

                    datasets.append([subds,
                                    jones,
                                    freqs[ms][idt][Inu],
                                    chan_widths[ms][idt][Inu],
                                    utimes[ms][idt][It],
                                    ridx, rcnts,
                                    radecs[ms][idt], ddid*nfi+fi,
                                     ti, ims, ms])

    futures = []
    associated_workers = {}
    idle_workers = set(client.scheduler_info()['workers'].keys())
    n_launched = 0
    nds = len(datasets)
    while idle_workers and len(datasets):   # Seed each worker with a task.
        # pop so len(datasets) -> 0
        (subds, jones, freqsi, chan_widthi, utimesi, ridx, rcnts,
         radeci, bi, ti, ims, ms) = datasets.pop(0)

        worker = idle_workers.pop()
        future = client.submit(single_stokes,
                        dc1=dc1,
                        dc2=dc2,
                        operator=operator,
                        ds=subds,
                        jones=jones,
                        opts=opts,
                        freq=freqsi,
                        chan_width=chan_widthi,
                        utime=utimesi,
                        tbin_idx=ridx,
                        tbin_counts=rcnts,
                        radec=radeci,
                        antpos=antpos[ms],
                        poltype=poltype[ms],
                        xds_store=xds_store.url,
                        bandid=bi,
                        timeid=ti,
                        msid=ims,
                        wid=worker,
                        pure=False,
                        workers=worker,
                        key='image-'+uuid4().hex)
@landmanbester
Copy link
Collaborator

I seem to have broken the frequency<->band mapping in the multiple SPW case. I will attempt a fix shortly

@landmanbester
Copy link
Collaborator

I made a slight adjustment to your strategy above to allow imaging multiple measurement sets with different frequency coverages together. This will go into main in #117 when the tests pass. With #121 this should allow you to redo your experiments on the VLA data we were looking at. Would appreciate if you could test drive it when you have a chance @y-mhiri

@y-mhiri
Copy link
Collaborator Author

y-mhiri commented Nov 12, 2024

All right, I'll keep an eye on when the #117 and #121 passes and test again the VLA data.

@y-mhiri
Copy link
Collaborator Author

y-mhiri commented Nov 19, 2024

I tried to image on the VLA data after the merge and everything went smoothly, no errors. I get an image that strongly what I got back then.

Now I'm going to reproduce the results I got using l2reweight.

@landmanbester
Copy link
Collaborator

Great, thanks for confirming @y-mhiri. Please close this issue when you consider it resolved

@y-mhiri y-mhiri closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants