Source
#feather(imagename = 'tmp_jointplane', highres = 'tmp_intplane', lowres = 'tmp_sdplane', sdfactor = sdgain, effdishdiam=freqdishdia)
from __future__ import absolute_import
from __future__ import print_function
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 image, quanta, table, imager
from casatasks import casalog, imsubimage, feather
else:
from taskinit import *
from tasks import *
image = iatool
imager = imtool
quanta = qatool
casalog = casac.logsink()
_ia = image()
_qa = quanta()
class SDINT_helper:
# def __init__(self):
# print 'Init Helper'
################################################
def getFreqList(self,imname=''):
print("imname=",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;
return freqlist
################################################
def copy_restoringbeam(self,fromthis='',tothis=''):
_ib = image()
# ia.open(fromthis);
# ib.open(tothis)
freqlist = self.getFreqList(fromthis)
# print freqlist
for i in range(len(freqlist)):
_ia.open(fromthis);
beam = _ia.restoringbeam(channel = i);
_ia.close()
#print beam
_ia.open(tothis)
_ia.setrestoringbeam(beam = beam, channel = i, polarization = 0);
_ia.close()
# ib.close();
# ia.close();
################################################
def feather_int_sd(self,sdcube='', intcube='', jointcube='',sdgain=1.0,dishdia=100.0, usedata='sdint'):
#, 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....
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)