Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_imsubimage.py: 17%
35 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 19:53 +0000
1import sys
3from casatools import regionmanager, image
4from casatasks import casalog
5from .ialib import write_image_history
7_rg = regionmanager( )
9def imsubimage(
10 imagename, outfile, box, region, chans, stokes, mask, dropdeg,
11 overwrite, verbose, stretch, keepaxes
12):
13 casalog.origin('imsubimage')
14 myia = image()
15 myia.dohistory(False)
16 outia = None
17 tmp_csys = None
18 try:
19 if (not myia.open(imagename)):
20 raise RuntimeError("Cannot create image analysis tool using " + imagename)
21 if (len(outfile) == 0):
22 raise ValueError("outfile must be specified.")
23 xregion = region
24 if (type(region) != type({})):
25 tmp_csys = myia.coordsys()
26 xregion = _rg.frombcs(
27 csys=tmp_csys.torecord(), shape=myia.shape(), box=box,
28 chans=chans, stokes=stokes, stokescontrol="a", region=region
29 )
30 tmp_csys.done()
31 outia = myia.subimage(
32 outfile=outfile, region=xregion, mask=mask, dropdeg=dropdeg,
33 overwrite=overwrite, list=verbose, stretch=stretch, keepaxes=keepaxes
34 )
35 try:
36 param_names = imsubimage.__code__.co_varnames[:imsubimage.__code__.co_argcount]
37 vars = locals( )
38 param_vals = [vars[p] for p in param_names]
40 write_image_history(
41 outia, sys._getframe().f_code.co_name,
42 param_names, param_vals, casalog
43 )
44 except Exception as instance:
45 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')
47 finally:
48 myia.done()
49 _rg.done()
50 if outia:
51 outia.done()
52 if tmp_csys:
53 tmp_csys.done()