- Timestamp:
- 12/28/11 19:58:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapgrid.py
r2390 r2391 8 8 9 9 class asapgrid: 10 """ 11 The asapgrid class is defined to convolve data onto regular 12 spatial grid. Typical usage is as follows: 13 14 # create asapgrid instance with two input data 15 g = asapgrid( ['testimage1.asap','testimage2.asap'] ) 16 # set IFNO if necessary 17 g.setIF( 0 ) 18 # set POLNOs if necessary 19 g.setPolList( [0,1] ) 20 # set SCANNOs if necessary 21 g.setScanList( [22,23,24] ) 22 # define image with full specification 23 # you can skip some parameters (see help for defineImage) 24 g.defineImage( nx=12, ny=12, cellx='10arcsec', celly='10arcsec', 25 center='J2000 10h10m10s -5d05m05s' ) 26 # set convolution function 27 g.setFunc( func='sf', width=3 ) 28 # actual gridding 29 g.grid() 30 # save result 31 g.save( outfile='grid.asap' ) 32 # plot result 33 g.plot( plotchan=1246, plotpol=-1, plotgrid=True, plotobs=True ) 34 """ 10 35 def __init__( self, infile ): 36 """ 37 Create asapgrid instance. 38 39 infile -- input data as a string or string list if you want 40 to grid more than one data at once. 41 """ 11 42 self.outfile = None 12 43 self.ifno = None … … 15 46 16 47 def setData( self, infile ): 48 """ 49 Set data to be processed. 50 51 infile -- input data as a string or string list if you want 52 to grid more than one data at once. 53 """ 17 54 if isinstance( infile, str ): 18 55 self.gridder._setin( infile ) … … 22 59 23 60 def setIF( self, ifno ): 61 """ 62 Set IFNO to be processed. Currently, asapgrid allows to process 63 only one IFNO for one gridding run even if the data contains 64 multiple IFs. If you didn't specify IFNO, default value, which 65 is IFNO in the first spectrum, will be processed. 66 67 ifno -- IFNO to be processed. 68 """ 24 69 self.ifno = ifno 25 70 self.gridder._setif( self.ifno ) 26 71 27 72 def setPolList( self, pollist ): 73 """ 74 Set list of polarization components you want to process. 75 If not specified, all POLNOs will be processed. 76 77 pollist -- list of POLNOs. 78 """ 28 79 self.gridder._setpollist( pollist ) 29 80 30 81 def setScanList( self, scanlist ): 82 """ 83 Set list of scans you want to process. If not specified, all 84 scans will be processed. 85 86 scanlist -- list of SCANNOs. 87 """ 31 88 self.gridder._setscanlist( scanlist ) 32 89 33 90 def defineImage( self, nx=-1, ny=-1, cellx='', celly='', center='' ): 91 """ 92 Define spatial grid. 93 94 First two parameters, nx and ny, define number of pixels of 95 the grid. If which of those is not specified, it will be set 96 to the same value as the other. If none of them are specified, 97 it will be determined from map extent and cell size. 98 99 Next two parameters, cellx and celly, define size of pixel. 100 You should set those parameters as string, which is constructed 101 numerical value and unit, e.g. '0.5arcmin', or numerical value. 102 If those values are specified as numerical value, their units 103 will be assumed to 'arcmin'. If which of those is not specified, 104 it will be set to the same value as the other. If none of them 105 are specified, it will be determined from map extent and number 106 of pixels, or set to '1arcmin' if neither nx nor ny is set. 107 108 The last parameter, center, define the central coordinate of 109 the grid. You should specify its value as a string, like, 110 111 'J2000 05h08m50s -16d23m30s' 112 113 or 114 115 'J2000 05:08:50 -16.23.30' 116 117 You can omit equinox when you specify center coordinate. In that 118 case, J2000 is assumed. If center is not specified, it will be 119 determined from the observed positions of input data. 120 121 nx -- number of pixels along x (R.A.) direction. 122 ny -- number of pixels along y (Dec.) direction. 123 cellx -- size of pixel in x (R.A.) direction. 124 celly -- size of pixel in y (Dec.) direction. 125 center -- central position of the grid. 126 """ 127 if not isinstance( cellx, str ): 128 cellx = '%sarcmin'%(cellx) 129 if not isinstance( celly, str ): 130 celly = '%sarcmin'%(celly) 34 131 self.gridder._defineimage( nx, ny, cellx, celly, center ) 35 132 36 133 def setFunc( self, func='box', width=-1 ): 134 """ 135 Set convolution function. Possible options are 'box' (Box-car, 136 default), 'sf' (prolate spheroidal), and 'gauss' (Gaussian). 137 Width of convolution function can be set using width parameter. 138 By default (-1), width is automatically set depending on each 139 convolution function. Default values for width are: 140 141 'box': 1 pixel 142 'sf': 3 pixels 143 'gauss': 3 pixels (width is used as HWHM) 144 145 func -- Function type ('box', 'sf', 'gauss'). 146 width -- Width of convolution function. Default (-1) is to 147 choose pre-defined value for each convolution function. 148 """ 37 149 self.gridder._setfunc( func, width ) 38 150 39 151 def setWeight( self, weightType='uniform' ): 152 """ 153 Set weight type. Possible options are 'uniform' (default), 154 'tint' (weight by integration time), 'tsys' (weight by 155 Tsys: 1/Tsys**2), and 'tintsys' (weight by integration time 156 as well as Tsys: tint/Tsys**2). 157 158 weightType -- weight type ('uniform', 'tint', 'tsys', 'tintsys') 159 """ 40 160 self.gridder._setweight( weightType ) 41 161 42 162 def grid( self ): 163 """ 164 Actual gridding which will be done based on several user inputs. 165 """ 43 166 self.gridder._grid() 44 167 45 168 def save( self, outfile='' ): 169 """ 170 Save result. By default, output data name will be constructed 171 from first element of input data name list (e.g. 'input.asap.grid'). 172 173 outfile -- output data name. 174 """ 46 175 self.outfile = self.gridder._save( outfile ) 47 176 48 177 def plot( self, plotchan=-1, plotpol=-1, plotobs=False, plotgrid=False ): 178 """ 179 Plot gridded data. 180 181 plotchan -- Which channel you want to plot. Default (-1) is 182 to average all the channels. 183 plotpol -- Which polarization component you want to plot. 184 Default (-1) is to average all the polarization 185 components. 186 plotobs -- Also plot observed position if True. Default 187 is False. Setting True for large amount of spectra 188 might be time consuming. 189 plotgrid -- Also plot grid center if True. Default is False. 190 Setting True for large number of grids might be 191 time consuming. 192 """ 49 193 import time 50 194 t0=time.time()
Note:
See TracChangeset
for help on using the changeset viewer.