Source
xxxxxxxxxx
casalog.post('The cube for major cycles has '+str(len(freqlist))+' channels. For wideband continuum imaging, it may be possible to reduce the number of channels to (say) one per spectral window to preserve frequency dependent intensity and weight information but also minimize the number of channels in the image cubes. MFS imaging will be performed within each channel. This will reduce the sizes of the image cubes as well as the compute time used for feathering each plane separately. Note that a minimum of nterms=' + str(pars['nterms']) + ' channels is required for an accurate polynomial fit, but where possible at least 5 to 10 channels that span the frequency range are prefered in order to properly encode frequency dependent intensity and weights.', "WARN", "task_sdintimaging")
from __future__ import absolute_import
from scipy import fftpack
import numpy as np
import shutil
import os
import time
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import quanta, table, image, regionmanager, imager
from casatasks import casalog, imsubimage, feather
else:
from taskinit import *
from tasks import *
image = iatool
imager = imtool
quanta = qatool
regionmanager = rgtool
table = tbtool
_ia = image()
_qa = quanta()
_rg = regionmanager()
_mytb = table()
class SDINT_helper:
# def __init__(self):
# casalog.post('Init Helper')
################################################
def getFreqList(self,imname=''):
_ia.open(imname)
csys =_ia.coordsys()
shp = _ia.shape()
_ia.close()
if(csys.axiscoordinatetypes()[3] == 'Spectral'):
restfreq = csys.referencevalue()['numeric'][3]#/1.0e+09; # convert more generally..
freqincrement = csys.increment()['numeric'][3]# /1.0e+09;
freqlist = [];
for chan in range(0,shp[3]):
freqlist.append(restfreq + chan * freqincrement);
elif(csys.axiscoordinatetypes()[3] == 'Tabular'):
freqlist = (csys.torecord()['tabular2']['worldvalues']) # /1.0e+09;
else:
casalog.post('Unknown frequency axis. Exiting.','SEVERE');
return False;
csys.done()
return freqlist
################################################
def copy_restoringbeam(self,fromthis='',tothis=''):
# _ib = image()
# ia.open(fromthis);
# ib.open(tothis)
freqlist = self.getFreqList(fromthis)
# casalog.post(freqlist)
for i in range(len(freqlist)):
_ia.open(fromthis);
beam = _ia.restoringbeam(channel = i);
_ia.close()
# casalog.post(beam)
_ia.open(tothis)
_ia.setrestoringbeam(beam = beam, channel = i, polarization = 0);
_ia.close()
################################################
def feather_int_sd(self,sdcube='', intcube='', jointcube='',sdgain=1.0,dishdia=100.0, usedata='sdint', chanwt=''):
#, pbcube='',applypb=False, pblimit=0.2):
"""
Run the feather task to combine the SD and INT Cubes.
There's a bug in feather for cubes. Hence, do each channel separately.
FIX feather and then change this. CAS-5883 is the JIRA ticket that contains a fix for this issue....
TODO : Add the effdishdia usage to get freq-indep feathering.
"""
### Do the feathering.
if usedata=='sdint':
## Feather runs in a loop on chans internally, but there are issues with open tablecache images
## Also, no way to set effective dish dia separately for each channel.
#feather(imagename = jointcube, highres = intcube, lowres = sdcube, sdfactor = sdgain, effdishdiam=-1)