filenames = _immath_filenames(filenames, tmpfilenames, varnames, mode)
expr = expr.replace(' ', '')
expr = _immath_dospix(len(filenames), varnames)
filenames, outfile, tmpFilePrefix, mask, region,
box, chans, stokes, stretch, polithresh, _myia
elif mode == 'poli' or mode == 'lpoli' or mode == 'tpoli':
filenames, outfile, tmpFilePrefix, mask, region,
box, chans, stokes, stretch, sigma, _myia
box, chans, stokes, stretch, sigma, _myia, mode
if box or chans or stokes or region or mask:
(subImages, file_map) = _immath_createsubimages(
box, chans, stokes, region, mask,
stretch, filenames, _myia, tmpFilePrefix
"Specifying region, box, chan, or stokes will "
+ "create smaller sub-images. The image "
+ "metadata specified in imagemd will have to "
+ "conform to the output, not the input image "
+ "dimensions. Please check your output image "
+ "for accurate header definition.", 'WARN'
if box or chans or stokes or region or mask:
(subImages, file_map) = _immath_createsubimages(
box, chans, stokes, region, mask,
stretch, filenames, _myia, tmpFilePrefix
"Specifying region, box, chan, or stokes will "
+ "create smaller sub-images. The image "
+ "metadata specified in imagemd will have to "
+ "conform to the output, not the input image "
+ "dimensions. Please check your output image "
+ "for accurate header definition.", 'WARN'
(expr, varnames, subImages) = _immath_updateexpr(
expr, varnames, subImages, filenames, file_map
imagename, expr, outfile, imagemd, _myia
# If the user didn't give any region or mask information
# then just evaluated the expression with the filenames in it.
imagename, imagemd, outfile, mode, expr,
varnames, filenames, _myia
(expr, varnames, subImages) = _immath_updateexpr(
expr, varnames, subImages, filenames, file_map
imagename, expr, outfile, imagemd, _myia
# If the user didn't give any region or mask information
# then just evaluated the expression with the filenames in it.
imagename, imagemd, outfile, mode, expr,
varnames, filenames, _myia
raise(Exception, "Unsupported mode " + str(mode))
param_names = immath.func_code.co_varnames[:immath.func_code.co_argcount]
param_vals = [eval(p) for p in param_names]
outia, sys._getframe().f_code.co_name,
param_names, param_vals, casalog
except Exception, instance:
casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')
casalog.post("Unable to process expression " + expr, 'SEVERE')
casalog.post("Unable to process expression " + expr, 'SEVERE')
casalog.post("Error running immath", 'SEVERE')
casalog.post("Exception caught was: " + str(error), 'SEVERE')
_immath_cleanup(tmpFilePrefix)
def _immath_concat_stokes(filenames, target, _myia):
_myia.calcmask(name='mask0', mask=myexpr)
'Calculated mask based on linear polarization threshold '
filenames, outfile, tmpFilePrefix, mask, region,
box, chans, stokes, stretch, sigma, _myia
box, chans, stokes, stretch, sigma, _myia, mode
target = tmpFilePrefix + "_concat_for_poli"
_immath_concat_stokes(filenames, target, _myia)
for p in ["Q", "U", "V"]:
"Stokes " + p + " is required for mode tpoli but was not found"
qsigma = qa.quantity(sigma)
if qa.getvalue(qsigma)[0] > 0:
sigmaunit = qa.getunit(qsigma)
iunit = _myia.brightnessunit()
raise Exception, 'Unable to get brightness unit from image file ' + filenames[0]
newsigma = qa.convert(qsigma,iunit)
myreg = _immath_getregion(region, box, chans, stokes, "poli", _myia, target)
numeric_sigma = qa.getvalue(qa.quantity(newsigma))
debias=debias, sigma=numeric_sigma, outfile=outfile,
region=myreg, mask=mask, stretch=stretch
if mode == 'tpoli' or mode == 'poli':
debias=debias, sigma=numeric_sigma, outfile=outfile,
region=myreg, mask=mask, stretch=stretch
debias=debias, sigma=numeric_sigma, outfile=outfile,
region=myreg, mask=mask, stretch=stretch
raise Exception("Logic Error: Unhandled mode " + mode)
imagename, expr, outfile, imagemd, _myia
pixels=expr, outfile=outfile,
imagemd=_immath_translate_imagemd(imagename, imagemd)