tp2vis / distribute

10 stars 10 forks source link

def wtstat needs ms.selectinit(reset=True) inside loop over more than 1 spectral window #1

Open adeleplunkett opened 6 years ago

adeleplunkett commented 6 years ago

In def wtstat, I believe that there needs to be a line ms.selectinit(reset=True) inside the loop over several spectral windows. Otherwise, anytime I have a dataset with several spectral windows, I get an error 2018-09-03 13:04:31 WARN ms::selectinit selectinit failed for datadescid 1

# Define stat outputs
# -------------------
def wtstat(mslist,comment=''):
    print "%-4s%18s %4s %4s %4s %8s %8s %12s %12s %12s %12s" \
        % (comment,'name','spw#','npnt','npol','nvis',\
               'fwidth','min','max','mean','std')

    for ims in mslist:

        ms.open(ims,nomodify=True)          # open MS
        **ms.selectinit(reset=True)           # all spws**
        spwinfo= ms.getspectralwindowinfo() # get spw info
        spwlist= spwinfo.keys()             # list of SPWs

        for ispw in spwlist:                # get SPW info and WEIGHT
            **ms.selectinit(reset=True)           # all spws**
            spwid     = spwinfo[ispw]['SpectralWindowId']
            numchan   = spwinfo[ispw]['NumChan']
            chan1freq = spwinfo[ispw]['Chan1Freq'] / 1.0e9 # GHz
            chanwidth = spwinfo[ispw]['ChanWidth'] / 1.0e9 # GHz
adeleplunkett commented 6 years ago

This should also be the case in L1348, called when using tp2vispl:

    # Loop over SPWs
    # --------------
    for ispw in spwlist:

        # SPW info and set constraints to reduce data to load
        ms.selectinit(reset=True)               # all spws
adeleplunkett commented 6 years ago

Check near line L1000 also, when oper == 'beammatch':

    # Sumup the weights of INT visibilities [/GHz/pnt/arcmin2]
    # --------------------------------------------------------
    sumw = 0.0
    for ims in msINT:
        ms.open(ims,nomodify=True)              # open MS
        ms.selectinit(reset=True)               # all spws
        spwinfo   = ms.getspectralwindowinfo()  # get spw info
        spwlist   = spwinfo.keys()              # list of SPWs
        iarray    = guessarray(ims)             # array name [e.g. ALMA12]
        fwhm0 = t2v_arrays[iarray]['fwhm100']   # beam FHWM @100GHz[arcsec]
        for ispw in spwlist:                    # loop over SPWs
            ms.selectinit(reset=True)               # all spws
            spwid     = spwinfo[ispw]['SpectralWindowId']  # spw #
teuben commented 6 years ago

In the development version there are numerous examples, they all highly splitting by SPW, partially because that's how we usually get the data. So Im not surprised these issues come up, we simply haven't been using it in this mode.

Do you have a good use case where you need to run it over spw's?

adeleplunkett commented 6 years ago

In the datasets I have, then each execution is assigned a different spectral window (and therefore the concat *.ms file has several SPWs). All should have the same frequency. But, the tp2vispl and tp2viswt will not work with more than 1 "SPW" in the .ms file, at least that's my experience. So, the option is either to take only the first SPW, or actually loop over all of them. Right?