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

30 statements  

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

1import os 

2 

3from casatasks import casalog 

4from casatools import atcafiller 

5from .mstools import write_history 

6 

7def importatca ( 

8 files=None, 

9 vis=None, 

10 options=None, 

11 spw=None, 

12 nscans=None, 

13 lowfreq=None, 

14 highfreq=None, 

15 fields=None, 

16 edge=8 

17 ): 

18 """Convert an RPFITS file into a CASA visibility file (MS). 

19 The conversion of the RPFITS format into a measurement set.  

20 This version has been tested for both old ATCA and CABB data. 

21................  

22 Keyword arguments: 

23 files -- Name of input RPFITS file(s) 

24 default: none; example: file='2010-01-02_1234.c999' 

25 

26.... vis -- Output ms name, note a postfix (.ms) is NOT appended to this name 

27 default: none 

28  

29.... options -- Processing options, comma separated list 

30 birdie - flag parts of spectrum known to be bad 

31 reweight - (pre-CABB) reweight lag spectrum to avoid ringing 

32 noautoflag - don't apply automatic flags (e.g. pointing scans) 

33 noxycorr - don't apply xyphase correction 

34 fastmosaic - use for large mosaics to speed up data access 

35 hires - turn time binned data into fast sampled data 

36 notsys - undo online Tsys calibration 

37 noac - don't load autocorrelations 

38.... spw -- specify the input spectral windows to use. For CABB the order is 

39 first continuum, 2nd continuum, then any zooms for first band, 

40 followed by zooms for 2nd band. Pre-CABB data just has 0 and 1. 

41 The output may have more spectral windows if there are frequency 

42 changes. 

43........ default: all 

44 

45.... nscans -- Number of scans to skip followed by number of scans to read 

46.... default: 0,0 (read all) 

47 

48.... lowfreq -- Lowest reference frequency to select 

49.... default: 0 (all) 

50 

51.... highfreq -- highest reference frequency to select 

52.... default: 0 (all) 

53 

54.... fields -- List of field names to select 

55........ default: all 

56 

57.... edge -- Percentage of edge channels to flag. For combined zooms, this  

58 specifies the percentage for a single zoom 

59........ default: 8 (flags 4% of channels at lower and upper edge) 

60  

61 """ 

62 

63 # Python script 

64 myaf = atcafiller() 

65 try: 

66 try: 

67 casalog.origin('importatca') 

68 # ----------------------------------------- 

69 # beginning of importatca implementation 

70 # ----------------------------------------- 

71 myaf.open(vis,files,options) 

72 firstscan=0 

73 lastscan=9999 

74 if (nscans != None): 

75 if len(nscans)>0: 

76 firstscan=nscans[0] 

77 if len(nscans)>1: 

78 lastscan=nscans[1] 

79 myaf.select(firstscan,lastscan,spw,lowfreq,highfreq, 

80 fields,edge) 

81 myaf.fill() 

82 except Exception as e: 

83 raise RuntimeError("Failed to import atca rpfits file(s) %s" % files) 

84 

85 # Write the args to HISTORY. 

86 try: 

87 param_names = importatca.__code__.co_varnames[:importatca.__code__.co_argcount] 

88 vars = locals( ) 

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

90 write_history( 

91 myaf, vis, 'importatca', param_names, 

92 param_vals, casalog 

93 ) 

94 except Exception: 

95 casalog.post("Failed to updated HISTORY", 'WARN') 

96 

97 finally: 

98 if (myaf): 

99 del myaf 

100 # ----------------------------------- 

101 # end of importatca implementation 

102 # ----------------------------------- 

103