Example #1
0
def set_impars(impars, line_name, vis, spwnames=None):
    if line_name not in ('full', ) + spwnames:
        local_impars = {}
        if 'width' in linpars:
            local_impars['width'] = linpars['width']
        else:
            # calculate the channel width
            chanwidths = []
            for vv in vis:
                msmd.open(vv)
                count_spws = len(msmd.spwsforfield(field))
                chanwidth = np.max([np.abs(
                    effectiveResolutionAtFreq(vv,
                                              spw='{0}'.format(i),
                                              freq=u.Quantity(linpars['restfreq']).to(u.GHz),
                                              kms=True)) for i in
                    range(count_spws)])

                # second awful check b/c Todd's script failed for some cases
                for spw in range(count_spws):
                    chanwidths_hz = msmd.chanwidths(int(spw))
                    chanfreqs_hz = msmd.chanfreqs(int(spw))
                    ckms = constants.c.to(u.km/u.s).value
                    if any(chanwidths_hz > (chanwidth / ckms)*chanfreqs_hz):
                        chanwidth = np.max(chanwidths_hz/chanfreqs_hz * ckms)
                msmd.close()

                chanwidths.append(chanwidth)

            # chanwidth: mean? max?
            chanwidth = np.mean(chanwidths)
            logprint("Channel widths were {0}, mean = {1}".format(chanwidths,
                                                                  chanwidth),
                     origin="almaimf_line_imaging")
            if np.any(np.array(chanwidths) - chanwidth > 1e-4):
                raise ValueError("Varying channel widths.")
            local_impars['width'] = '{0:.2f}km/s'.format(np.round(chanwidth, 2))

        local_impars['restfreq'] = linpars['restfreq']
        # calculate vstart
        vstart = u.Quantity(linpars['vlsr'])-u.Quantity(linpars['cubewidth'])/2
        local_impars['start'] = '{0:.1f}km/s'.format(vstart.value)
        local_impars['chanchunks'] = int(chanchunks)

        local_impars['nchan'] = int((u.Quantity(line_parameters[field][line_name]['cubewidth'])
                                    / u.Quantity(local_impars['width'])).value)
        if local_impars['nchan'] < local_impars['chanchunks']:
            local_impars['chanchunks'] = local_impars['nchan']
        impars.update(local_impars)
    else:
        impars['chanchunks'] = int(chanchunks)

    if 'nchan' in impars:
        # apparently you can't have nchan % chanchunks > 0
        cc = impars['chanchunks']
        while impars['nchan'] % cc > 0:
            cc -= 1
        impars['chanchunks'] = cc

    return impars
Example #2
0
            if line_name not in ('full', ) + spwnames:
                local_impars = {}
                if 'width' in linpars:
                    local_impars['width'] = linpars['width']
                else:
                    # calculate the channel width
                    chanwidths = []
                    for vv in vis:
                        msmd.open(vv)
                        count_spws = len(msmd.spwsforfield(field))
                        chanwidth = np.max([
                            np.abs(
                                effectiveResolutionAtFreq(
                                    vv,
                                    spw='{0}'.format(i),
                                    freq=u.Quantity(linpars['restfreq']).to(
                                        u.GHz),
                                    kms=True)) for i in range(count_spws)
                        ])

                        # second awful check b/c Todd's script failed for some cases
                        for spw in range(count_spws):
                            chanwidths_hz = msmd.chanwidths(int(spw))
                            chanfreqs_hz = msmd.chanfreqs(int(spw))
                            ckms = constants.c.to(u.km / u.s).value
                            if any(chanwidths_hz > (chanwidth / ckms) *
                                   chanfreqs_hz):
                                chanwidth = np.max(chanwidths_hz /
                                                   chanfreqs_hz * ckms)
                        msmd.close()
Example #3
0
        min_pixscale=0.1,  # arcsec
    )
    imsize = [int(dra), int(ddec)]
    cellsize = ['{0:0.2f}arcsec'.format(pixscale)] * 2

    dirty_tclean_made_residual = False

    # calculate the channel width
    chanwidths = []
    msmd.open(vis)
    count_spws = len(msmd.spwsforfield(field))
    msmd.close()
    chanwidth = np.max([
        np.abs(
            effectiveResolutionAtFreq(vis,
                                      spw='{0}'.format(ii),
                                      freq=reference_frequency * u.Hz,
                                      kms=True).max()) for ii in spw_list
    ])
    chanwidths.append(chanwidth)
    chanwidth = np.mean(chanwidths)
    logprint("Channel widths were {0}, mean = {1}".format(
        chanwidths, chanwidth),
             origin="almaimf_line_imaging")

    impars = {
        'niter': 100000,
        'robust': 0.0,
        'weighting': 'briggs',
        'scales': [
            0,
            3,