Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_imfit.py: 23%
22 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 image
4from casatasks import casalog
5from .ialib import write_image_history
7def imfit(
8 imagename, box, region, chans, stokes,
9 mask, includepix, excludepix, residual,
10 model, estimates, logfile, append,
11 newestimates, complist, overwrite, dooff,
12 offset, fixoffset, stretch, rms, noisefwhm,
13 summary
14):
15 casalog.origin('imfit')
16 myia = image()
17 try:
18 myia.dohistory(False)
19 if (not myia.open(imagename)):
20 raise Exception("Cannot create image analysis tool using %s" % imagename)
21 result_dict = myia.fitcomponents(
22 box=box, region=region, chans=chans, stokes=stokes,
23 mask=mask, includepix=includepix,
24 excludepix=excludepix, residual=residual,
25 model=model, estimates=estimates, logfile=logfile,
26 append=append, newestimates=newestimates,
27 complist=complist, overwrite=overwrite, dooff=dooff,
28 offset=offset, fixoffset=fixoffset, stretch=stretch,
29 rms=rms, noisefwhm=noisefwhm, summary=summary
30 )
31 try:
32 param_names = imfit.__code__.co_varnames[:imfit.__code__.co_argcount]
33 vars = locals()
34 param_vals = [vars[p] for p in param_names]
35 for im in [residual, model]:
36 write_image_history(
37 im, sys._getframe().f_code.co_name,
38 param_names, param_vals, casalog
39 )
40 except Exception as instance:
41 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')
43 return result_dict
45 finally:
46 myia.done()