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

26 statements  

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

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

2# task_imtrans.py 

3# 

4# Copyright (C) 2008, 2009 

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 to transpose an image 

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# imtrans => im(age) trans(pose) 

47# </etymology> 

48# 

49# <synopsis> 

50# imtrans transposes an image. It is built on top of ia.reorder() 

51# </synopsis>  

52# 

53# <example> 

54# imtrans(imagename="myim.im", outfile="transposed.im", order="102") 

55# 

56# </example> 

57# 

58# <motivation> 

59# To make users happy, cf https://bugs.aoc.nrao.edu/browse/CAS-607 

60# </motivation> 

61# 

62########################################################################### 

63import sys 

64 

65from casatools import image 

66from casatasks import casalog 

67from .ialib import write_image_history 

68 

69def imtrans(imagename, outfile, order): 

70 casalog.origin('imtrans') 

71 myia = image() 

72 myia.dohistory(False) 

73 outia = None 

74 try: 

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

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

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

78 raise ValueError("outfile parameter must be specified.") 

79 outia = myia.transpose(outfile=outfile, order=order) 

80 try: 

81 param_names = imtrans.__code__.co_varnames[:imtrans.__code__.co_argcount] 

82 vars = locals( ) 

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

84 

85 write_image_history( 

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

87 param_names, param_vals, casalog 

88 ) 

89 except Exception as instance: 

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

91 

92 finally: 

93 if myia: 

94 myia.done() 

95 if outia: 

96 outia.done()