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

27 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 17:39 +0000

1##################### generated by xml-casa (v2) from plotbandpass.xml ############## 

2##################### 6e5fc5594be7f2b7f3b7377f38fdecc1 ############################## 

3from __future__ import absolute_import 

4import numpy 

5from casatools.typecheck import CasaValidator as _val_ctor 

6_pc = _val_ctor( ) 

7from casatools.coercetype import coerce as _coerce 

8from casatools.errors import create_error_string 

9from .private.task_plotbandpass import plotbandpass as _plotbandpass_t 

10from casatasks.private.task_logging import start_log as _start_log 

11from casatasks.private.task_logging import end_log as _end_log 

12from casatasks.private.task_logging import except_log as _except_log 

13 

14class _plotbandpass: 

15 """ 

16 plotbandpass ---- Makes detailed plots of Tsys and bandpass solutions. 

17 

18 Developed at the NAASC, this is a generic task to display CASA 

19 Tsys and bandpass solution tables with options to overlay them in various 

20 combinations, and/or with an atmospheric transmission or sky temperature 

21 model. It works with both the 'new' (casa 3.4) and 'old' calibration 

22 table formats, and allows for mixed mode spws (e.g. TDM and FDM for ALMA). 

23 It uses the new msmd tool to access the information about an ms. This 

24 task is still being developed as new ALMA observing modes are commissioned. 

25 So if you encounter problems, please report them. 

26  

27 

28 --------- parameter descriptions --------------------------------------------- 

29 

30 caltable Input table name, either a bandpass solution or a Tsys solution 

31 antenna A comma-delimited string list of antennas (either names or integer indices) for which to display solutions. Default = all antennas. 

32 field A comma-delimited string list of fields (either names or integer indices) for which to display solutions. Default = all fields. 

33 spw A comma-delimited string list of spws for which to display solutions. Default = all spws. 

34 yaxis The quantity to plot on the y-axis ("amp", "phase", "both", "tsys", append "db" for dB). 

35 xaxis The quantity to plot on the x-axis ("chan" or "freq"). 

36 figfile The name of the plot file to produce. 

37 plotrange The axes limits to use [x0,x1,y0,y1]. 

38 caltable2 A second cal table, of type BPOLY or B, to overlay on a B table 

39 overlay Show multiple solutions in same frame in different colors (time, antenna, spw, baseband, or time,antenna) 

40 showflagged Show the values of the solution, even if flagged 

41 timeranges Show only these timeranges, the first timerange being 0 

42 buildpdf If True, assemble all the pngs into a pdf 

43 caltable3 A third cal table, of type BPOLY, to overlay on the first two tables 

44 markersize Size of points 

45 density dpi to use in creating PNGs and PDFs (default=108) 

46 interactive if False, then run to completion automatically without pause 

47 showpoints Draw points for the data (default=F for amp, T for phase) 

48 showlines Draw lines connecting the data (default=T for amp, F for phase) 

49 subplot 11..81,22,32 or 42 for RowsxColumns (default=22), any 3rd digit is ignored 

50 zoom "intersect" will zoom to overlap region of caltable with caltable2 

51 poln Polarizations to plot: "" = all, or "RR","RL","LR","LL","XX","XY","YX","YY","RR,LL","XX,YY" 

52 showatm Compute and overlay the atmospheric transmission curve 

53 pwv Define the pwv to use for the showatm option: "auto" or value in mm 

54 gs For buildpdf=T, full path for ghostscript command (in case it is not found) 

55 convert For buildpdf=T, full path for the ImageMagick convert command (in case it is not found) 

56 chanrange Set xrange ("5~100") over which to autoscale y-axis for xaxis="freq" 

57 solutionTimeThresholdSeconds Consider 2 solutions simultaneous if within this interval in seconds 

58 debug Print verbose messages for debugging purposes 

59 phase The y-axis limits to use for phase plots when yaxis="both" 

60 vis name of the ms for this table, in case it does not match the string in the caltable 

61 showtsky Compute and overlay the sky temperature curve instead of transmission 

62 showfdm when showing TDM spws, draw the locations of the corresponding FDM spws 

63 showatmfield for overlay="time", use first observation of this fieldID or name 

64 lo1 specify the LO1 setting (in GHz) for the observation ('' = automatic) 

65 showimage also show the atmospheric curve for the image sideband (in black) 

66 showatmpoints Draw atmospheric curve with points instead of a line 

67 parentms if showimage=T, name of the parent ms (only needed if the ms has been previously split) 

68 pdftk For buildpdf=T, full path for pdftk command (in case it is not found) 

69 channeldiff Set to a value > 0 (sigma) to plot derivatives of the solutions 

70 edge The number of edge channels to ignore in finding outliers (for channeldiff>0) 

71 resample The channel expansion factor to use when computing MAD of derivative (for channeldiff>0) 

72 platformingThreshold if platformingSigma=0, then declare platforming if the amplitude derivative exceeds this percentage of the median 

73 platformingSigma declare platforming if the amplitude derivative exceeds this many times the MAD 

74 basebands A baseband number or list of baseband numbers for which to display solutions. Default = all. 

75 showBasebandNumber Put the baseband converter number (BBC_NO) in the title of each plot 

76 scans A scan or list of scans for which to display solutions. Default = all. Does not work with overlay="time". 

77 figfileSequential naming scheme for pngs: False: name by spw/antenna (default), True: figfile.000.png, figfile.001.png, etc. 

78 chanrangeSetXrange If True, then chanrange also sets the xrange to display 

79 RETURNS variant 

80 

81 --------- examples ----------------------------------------------------------- 

82 

83  

84  

85 plotbandpass('X3c1.tsys',overlay='antenna',yaxis='amp',field='0~1,4',xaxis='chan',figfile='tsys.png') 

86  

87 plotbandpass('bandpass.bcal',caltable2='bandpass.bcal_smooth',xaxis='freq') 

88  

89 plotbandpass('bandpass.bcal',caltable2='bandpass.bcal_smooth',xaxis='freq',poln='X',showatm=T) 

90  

91 plotbandpass('bandpass.bcal',channeldiff='5') 

92  

93 This task returns void unless the channeldiff option is selected, in which case it returns a 

94 dictionary containing the statistics of the solutions, keyed by the antenna name, followed 

95 by the spw, timerange, polarization, and finally 'amp' and/or 'phase' depending 

96 on the yaxis selection. 

97  

98 Keyword arguments: 

99  

100 antenna: must be either an ID (int or string or list), or a single antenna name or list 

101 basebands: show only spws from the specified baseband or list of basebands (default: ''=[]=all) 

102 buildpdf: True/False, if True and figfile is set, assemble pngs into a pdf 

103 caltable: a bandpass table, of type B or BPOLY 

104 caltable2: a second cal table, of type BPOLY or B, to overlay on a B table 

105 caltable3: a third cal table, of type BPOLY, to overlay on the first two 

106 channeldiff: set to value > 0 to plot derivatives of amplitude, the value is also used as sigma, and any outliers beyond this sigma will be printed to the logger 

107 chanrange: set xrange (e.g. "5~100") over which to autoscale y-axis for xaxis='freq' 

108 chanrangeSetXrange: if True, then chanrange also sets the xrange to display 

109 convert: full path for convert command (in case it's not found) 

110 density: dpi to use in creating PNGs and PDFs (default=108) 

111 edge: the number of edge channels to ignore in finding outliers (for channeldiff>0) 

112 field: must be an ID, source name, or list thereof; can use trailing *: 'J*' 

113 figfile: the base_name of the png files to save: base_name.antX.spwY.png 

114 figfileSequential: naming scheme, False: name by spw/antenna (default) 

115 True: figfile.1.png, figfile.2.png, etc. 

116 gs: full path for ghostscript command (in case it's not found) 

117 interactive: if False, then figfile will run to completion automatically 

118 lo1: specify the LO1 setting (in GHz) for the observation 

119 overlay: 'antenna','time','spw', or 'baseband', make 1 plot with different items in colors 

120 markersize: size of points (default=3) 

121 ms: name of the ms for this table, in case it does not match the string in the caltable 

122 parentms: name of the parent ms, in case the ms has been previously split 

123 pdftk: full path for pdftk command (in case it's not found) 

124 phase: the y-axis limits to use for phase plots when yaxis='both' 

125 platformingSigma: declare platforming if the amplitude derivative exceeds this many times the MAD 

126 platformingThreshold: if platformingSigma=0, then declare platforming if the amplitude 

127 derivative exceeds this percentage of the median 

128 plotrange: define axis limits: [x0,x1,y0,y1] where 0,0 means auto 

129 poln: polarizations to plot (e.g. 'XX','YY','RR','LL' or '' for both) 

130 pwv: define the pwv to use for the showatm option: 'auto' or value in mm 

131 resample: channel expansion factor to use when computing MAD of derivative (for channeldiff>0) 

132 scans: show only solutions for the specified scans (int, list, or string) 

133 showatm: compute and overlay the atmospheric transmission curve (on B or Tsys solutions) 

134 showatmfield: use first observation of this fieldID or name 

135 showatmPoints: draw atmospheric curve with points instead of a line 

136 showBasebandNumber: put the BBC_NO in the title of each plot 

137 showfdm: when showing TDM spws with xaxis='freq', draw locations of FDM spws 

138 showflagged: show the values of data, even if flagged 

139 showimage: also show the atmospheric curve for the image sideband (in black) 

140 showtsky: compute and overlay the sky temperature curve instead of transmission 

141 showlines: draw lines connecting the data (default=T for amp, F for phase) 

142 showpoints: draw points for the data (default=F for amp, T for phase) 

143 solutionTimeThresholdSeconds: consider 2 solutions simultaneous if within this interval (default=60) 

144 spw: must be single ID or list or range (e.g. 0~4, not the original ID) 

145 subplot: 11..81,22,32 or 42 for RowsxColumns (default=22), any 3rd digit is ignored 

146 timeranges: show only these timeranges, the first timerange being 0 

147 xaxis: 'chan' or 'freq' 

148 yaxis: 'amp', 'tsys', 'phase', or 'both' amp+phase == 'ap'. Append 'db' for dB 

149 zoom: 'intersect' will zoom to overlap region of caltable with caltable2 

150  

151  

152 

153 

154 """ 

155 

156 _info_group_ = """visualization, calibration""" 

157 _info_desc_ = """Makes detailed plots of Tsys and bandpass solutions.""" 

158 

159 def __call__( self, caltable='', antenna='', field='', spw='', yaxis='amp', xaxis='chan', figfile='', plotrange=[ float(0),float(0),float(0),float(0) ], caltable2='', overlay='', showflagged=False, timeranges='', buildpdf=False, caltable3='', markersize=int(3), density=int(108), interactive=True, showpoints='auto', showlines='auto', subplot='22', zoom='', poln='', showatm=False, pwv='auto', gs='gs', convert='convert', chanrange='', solutionTimeThresholdSeconds=float(30.0), debug=False, phase='', vis='', showtsky=False, showfdm=False, showatmfield='', lo1='', showimage=False, showatmpoints=False, parentms='', pdftk='pdftk', channeldiff=False, edge=int(8), resample=int(1), platformingThreshold=float(10.0), platformingSigma=float(10.0), basebands='', showBasebandNumber=False, scans='', figfileSequential=False, chanrangeSetXrange=False ): 

160 schema = {'caltable': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'antenna': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'field': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'spw': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'yaxis': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'tsys', 'bothdb', 'ap', 'apdb', 'phase', 'amp', 'ampdb', 'both' ]}, 'xaxis': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'chan', 'freq' ]}, 'figfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'plotrange': {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}, 'caltable2': {'type': 'cStr', 'coerce': _coerce.to_str}, 'overlay': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'antenna,time', 'antenna', 'time,antenna', 'baseband', 'spw', '', 'time' ]}, 'showflagged': {'type': 'cBool'}, 'timeranges': {'type': 'cStr', 'coerce': _coerce.to_str}, 'buildpdf': {'type': 'cBool'}, 'caltable3': {'type': 'cStr', 'coerce': _coerce.to_str}, 'markersize': {'type': 'cInt'}, 'density': {'type': 'cInt'}, 'interactive': {'type': 'cBool'}, 'showpoints': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cBool'}]}, 'showlines': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cBool'}]}, 'subplot': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cInt'}]}, 'zoom': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'intersect', '' ]}, 'poln': {'anyof': [{'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'showatm': {'type': 'cBool'}, 'pwv': {'anyof': [{'type': 'cFloat', 'coerce': _coerce.to_float}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'gs': {'type': 'cStr', 'coerce': _coerce.to_str}, 'convert': {'type': 'cStr', 'coerce': _coerce.to_str}, 'chanrange': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'solutionTimeThresholdSeconds': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'debug': {'type': 'cBool'}, 'phase': {'anyof': [{'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'vis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'showtsky': {'type': 'cBool'}, 'showfdm': {'type': 'cBool'}, 'showatmfield': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}]}, 'lo1': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'showimage': {'type': 'cBool'}, 'showatmpoints': {'type': 'cBool'}, 'parentms': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pdftk': {'type': 'cStr', 'coerce': _coerce.to_str}, 'channeldiff': {'anyof': [{'type': 'cBool'}, {'type': 'cFloat', 'coerce': _coerce.to_float}]}, 'edge': {'type': 'cInt'}, 'resample': {'type': 'cInt'}, 'platformingThreshold': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'platformingSigma': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'basebands': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'showBasebandNumber': {'type': 'cBool'}, 'scans': {'anyof': [{'type': 'cInt'}, {'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}]}, 'figfileSequential': {'type': 'cBool'}, 'chanrangeSetXrange': {'type': 'cBool'}} 

161 doc = {'caltable': caltable, 'antenna': antenna, 'field': field, 'spw': spw, 'yaxis': yaxis, 'xaxis': xaxis, 'figfile': figfile, 'plotrange': plotrange, 'caltable2': caltable2, 'overlay': overlay, 'showflagged': showflagged, 'timeranges': timeranges, 'buildpdf': buildpdf, 'caltable3': caltable3, 'markersize': markersize, 'density': density, 'interactive': interactive, 'showpoints': showpoints, 'showlines': showlines, 'subplot': subplot, 'zoom': zoom, 'poln': poln, 'showatm': showatm, 'pwv': pwv, 'gs': gs, 'convert': convert, 'chanrange': chanrange, 'solutionTimeThresholdSeconds': solutionTimeThresholdSeconds, 'debug': debug, 'phase': phase, 'vis': vis, 'showtsky': showtsky, 'showfdm': showfdm, 'showatmfield': showatmfield, 'lo1': lo1, 'showimage': showimage, 'showatmpoints': showatmpoints, 'parentms': parentms, 'pdftk': pdftk, 'channeldiff': channeldiff, 'edge': edge, 'resample': resample, 'platformingThreshold': platformingThreshold, 'platformingSigma': platformingSigma, 'basebands': basebands, 'showBasebandNumber': showBasebandNumber, 'scans': scans, 'figfileSequential': figfileSequential, 'chanrangeSetXrange': chanrangeSetXrange} 

162 assert _pc.validate(doc,schema), create_error_string(_pc.errors) 

163 _logging_state_ = _start_log( 'plotbandpass', [ 'caltable=' + repr(_pc.document['caltable']), 'antenna=' + repr(_pc.document['antenna']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'yaxis=' + repr(_pc.document['yaxis']), 'xaxis=' + repr(_pc.document['xaxis']), 'figfile=' + repr(_pc.document['figfile']), 'plotrange=' + repr(_pc.document['plotrange']), 'caltable2=' + repr(_pc.document['caltable2']), 'overlay=' + repr(_pc.document['overlay']), 'showflagged=' + repr(_pc.document['showflagged']), 'timeranges=' + repr(_pc.document['timeranges']), 'buildpdf=' + repr(_pc.document['buildpdf']), 'caltable3=' + repr(_pc.document['caltable3']), 'markersize=' + repr(_pc.document['markersize']), 'density=' + repr(_pc.document['density']), 'interactive=' + repr(_pc.document['interactive']), 'showpoints=' + repr(_pc.document['showpoints']), 'showlines=' + repr(_pc.document['showlines']), 'subplot=' + repr(_pc.document['subplot']), 'zoom=' + repr(_pc.document['zoom']), 'poln=' + repr(_pc.document['poln']), 'showatm=' + repr(_pc.document['showatm']), 'pwv=' + repr(_pc.document['pwv']), 'gs=' + repr(_pc.document['gs']), 'convert=' + repr(_pc.document['convert']), 'chanrange=' + repr(_pc.document['chanrange']), 'solutionTimeThresholdSeconds=' + repr(_pc.document['solutionTimeThresholdSeconds']), 'debug=' + repr(_pc.document['debug']), 'phase=' + repr(_pc.document['phase']), 'vis=' + repr(_pc.document['vis']), 'showtsky=' + repr(_pc.document['showtsky']), 'showfdm=' + repr(_pc.document['showfdm']), 'showatmfield=' + repr(_pc.document['showatmfield']), 'lo1=' + repr(_pc.document['lo1']), 'showimage=' + repr(_pc.document['showimage']), 'showatmpoints=' + repr(_pc.document['showatmpoints']), 'parentms=' + repr(_pc.document['parentms']), 'pdftk=' + repr(_pc.document['pdftk']), 'channeldiff=' + repr(_pc.document['channeldiff']), 'edge=' + repr(_pc.document['edge']), 'resample=' + repr(_pc.document['resample']), 'platformingThreshold=' + repr(_pc.document['platformingThreshold']), 'platformingSigma=' + repr(_pc.document['platformingSigma']), 'basebands=' + repr(_pc.document['basebands']), 'showBasebandNumber=' + repr(_pc.document['showBasebandNumber']), 'scans=' + repr(_pc.document['scans']), 'figfileSequential=' + repr(_pc.document['figfileSequential']), 'chanrangeSetXrange=' + repr(_pc.document['chanrangeSetXrange']) ] ) 

164 task_result = None 

165 try: 

166 task_result = _plotbandpass_t( _pc.document['caltable'], _pc.document['antenna'], _pc.document['field'], _pc.document['spw'], _pc.document['yaxis'], _pc.document['xaxis'], _pc.document['figfile'], _pc.document['plotrange'], _pc.document['caltable2'], _pc.document['overlay'], _pc.document['showflagged'], _pc.document['timeranges'], _pc.document['buildpdf'], _pc.document['caltable3'], _pc.document['markersize'], _pc.document['density'], _pc.document['interactive'], _pc.document['showpoints'], _pc.document['showlines'], _pc.document['subplot'], _pc.document['zoom'], _pc.document['poln'], _pc.document['showatm'], _pc.document['pwv'], _pc.document['gs'], _pc.document['convert'], _pc.document['chanrange'], _pc.document['solutionTimeThresholdSeconds'], _pc.document['debug'], _pc.document['phase'], _pc.document['vis'], _pc.document['showtsky'], _pc.document['showfdm'], _pc.document['showatmfield'], _pc.document['lo1'], _pc.document['showimage'], _pc.document['showatmpoints'], _pc.document['parentms'], _pc.document['pdftk'], _pc.document['channeldiff'], _pc.document['edge'], _pc.document['resample'], _pc.document['platformingThreshold'], _pc.document['platformingSigma'], _pc.document['basebands'], _pc.document['showBasebandNumber'], _pc.document['scans'], _pc.document['figfileSequential'], _pc.document['chanrangeSetXrange'] ) 

167 except Exception as exc: 

168 _except_log('plotbandpass', exc) 

169 raise 

170 finally: 

171 task_result = _end_log( _logging_state_, 'plotbandpass', task_result ) 

172 return task_result 

173 

174plotbandpass = _plotbandpass( ) 

175