Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_impbcor.py: 83%

24 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-01 07:19 +0000

1########################################################################## 

2# task_impbcor.py 

3# 

4# Copyright (C) 2008, 2009, 2010 

5# Associated Universities, Inc. Washington DC, USA. 

6# 

7# This script is free software; you can redistribute it and/or modify it 

8# under the terms of the GNU Library General Public License as published by 

9# the Free Software Foundation; either version 2 of the License, or (at your 

10# option) any later version. 

11# 

12# This library is distributed in the hope that it will be useful, but WITHOUT 

13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 

14# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 

15# License for more details. 

16# 

17# You should have received a copy of the GNU Library General Public License 

18# along with this library; if not, write to the Free Software Foundation, 

19# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 

20# 

21# Correspondence concerning AIPS++ should be adressed as follows: 

22# Internet email: casa-feedback@nrao.edu. 

23# Postal address: AIPS++ Project Office 

24# National Radio Astronomy Observatory 

25# 520 Edgemont Road 

26# Charlottesville, VA 22903-2475 USA 

27# 

28# <author> 

29# Dave Mehringer 

30# </author> 

31# 

32# <summary> 

33# Task correct an image for primary beam attenuation. 

34# </summary> 

35# 

36# <reviewed reviwer="" date="" tests="" demos=""> 

37# </reviewed> 

38# 

39# <prerequisite> 

40# <ul> 

41# 

42# </ul> 

43# </prerequisite> 

44# 

45# <etymology> 

46# impbcor => im(age) pb(primary beam) cor(rect) 

47# </etymology> 

48# 

49# <synopsis> 

50# impbcor corrects and image for primary beam attenuation. It is built on top of ia.pbcor() 

51# </synopsis>  

52# 

53# <example> 

54# pbcorrected_image_tool = impbcor(imagename="myim.im", pbimage="mypb.im", outfile="corrected.im", wantreturn=true) 

55# 

56# </example> 

57# 

58# <motivation> 

59# https://bugs.aoc.nrao.edu/browse/CAS-3256 

60# </motivation> 

61# 

62 

63########################################################################### 

64import sys 

65 

66from casatools import image 

67from casatasks import casalog 

68from .ialib import write_image_history 

69 

70def impbcor( 

71 imagename=None, pbimage=None, outfile=None, overwrite=None, 

72 box=None, region=None, chans=None, stokes=None, mask=None, 

73 mode=None, cutoff=None, stretch=None 

74): 

75 casalog.origin('impbcor') 

76 myia = image() 

77 try: 

78 myia.dohistory(False) 

79 if (not myia.open(imagename)): 

80 raise RuntimeError("Cannot create image analysis tool using " + imagename) 

81 if (len(outfile) == 0): 

82 raise ValueError("outfile must be specified") 

83 outia = myia.pbcor( 

84 pbimage=pbimage, outfile=outfile, overwrite=overwrite, 

85 box=box, region=region, chans=chans, stokes=stokes, 

86 mask=mask, mode=mode, cutoff=cutoff, stretch=stretch 

87 ) 

88 

89 try: 

90 param_names = impbcor.__code__.co_varnames[:impbcor.__code__.co_argcount] 

91 vars = locals() 

92 param_vals = [vars[p] for p in param_names] 

93 write_image_history( 

94 outia, sys._getframe().f_code.co_name, 

95 param_names, param_vals, casalog 

96 ) 

97 except Exception as instance: 

98 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN') 

99 outia.done() 

100 

101 finally: 

102 if (myia): 

103 myia.done()