Changeset 706 for trunk/python
- Timestamp:
- 11/02/05 13:17:39 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r702 r706 28 28 * environ var ASAPRC 29 29 * HOME/.asaprc 30 30 31 31 """ 32 32 … … 47 47 return fname 48 48 return None 49 49 50 50 51 51 defaultParams = { … … 54 54 'useplotter' : [True, _validate_bool], 55 55 'insitu' : [True, _validate_bool], 56 56 57 57 # plotting 58 'plotter.gui' : [True, _validate_bool], 58 59 'plotter.stacking' : ['p', str], 59 60 'plotter.panelling' : ['s', str], 60 61 'plotter.colours' : ['', str], 61 62 'plotter.linestyles' : ['', str], 62 63 63 64 # scantable 64 65 'scantable.save' : ['ASAP', str], … … 73 74 74 75 def list_rcparameters(): 75 76 76 77 print """ 77 78 # general … … 84 85 # apply operations on the input scantable or return new one 85 86 insitu : True 87 88 # plotting 86 89 87 # plotting 90 # do we want a GUI or plot to a file 91 plotter.gui : True 92 88 93 # default mode for colour stacking 89 94 plotter.stacking : Pol … … 94 99 # default colours/linestyles 95 100 plotter.colours : 96 plotter.linestyles : 101 plotter.linestyles : 97 102 98 103 # scantable … … 107 112 108 113 # apply action to all axes not just the cursor location 109 scantable.allaxes : True 114 scantable.allaxes : True 110 115 111 116 # use internal plotter … … 114 119 # Control the level of information printed by summary 115 120 scantable.verbosesummary : False 116 117 # Fitter 118 """ 119 121 122 # Fitter 123 """ 124 120 125 def rc_params(): 121 126 'Return the default params updated from the values in the rc file' 122 127 123 128 fname = _asap_fname() 124 129 125 130 if fname is None or not os.path.exists(fname): 126 131 message = 'could not find rc file; returning defaults' … … 128 133 #print message 129 134 return ret 130 135 131 136 cnt = 0 132 137 for line in file(fname): … … 139 144 print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname)) 140 145 continue 141 146 142 147 key, val = tup 143 148 key = key.strip() … … 145 150 print ('Bad key "%s" on line %d in %s' % (key, cnt, fname)) 146 151 continue 147 152 148 153 default, converter = defaultParams[key] 149 154 … … 167 172 168 173 # this is the instance used by the asap classes 169 rcParams = rc_params() 174 rcParams = rc_params() 170 175 171 176 rcParamsDefault = dict(rcParams.items()) # a copy … … 181 186 182 187 sets the current rc params and is equivalent to 183 188 184 189 rcParams['scantable.save'] = 'SDFITS' 185 190 … … 188 193 189 194 aliases = {} 190 195 191 196 for k,v in kwargs.items(): 192 197 name = aliases.get(k) or k … … 194 199 if not rcParams.has_key(key): 195 200 raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' % (key, group, name)) 196 201 197 202 rcParams[key] = v 198 203 … … 228 233 229 234 if rcParams['useplotter']: 230 if os.environ.has_key('DISPLAY'): 231 print "Initialising asapplotter with the name 'plotter' ..." 232 import asapplotter 233 plotter = asapplotter.asapplotter() 234 else: 235 print "No $DISPLAY set. Disabling plotter.\n" 236 235 from asapplotter import * 236 if rcParams['verbose']: 237 print "Initialising GUI asapplotter with the name 'plotter' ..." 238 gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui'] 239 plotter = asapplotter(gui) 237 240 238 241 __date__ = '$Date$'.split()[1] 239 __version__ = '1.1' 240 241 def list_scans(t = scantable): 242 import sys, types 243 globs = sys.modules['__main__'].__dict__.iteritems() 244 print "The user created scantables are:" 245 sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs)) 246 print filter(lambda x: not x.startswith('_'), sts) 242 __version__ = '1.2' 243 244 if rcParams['verbose']: 245 def list_scans(t = scantable): 246 import sys, types 247 globs = sys.modules['__main__'].__dict__.iteritems() 248 print "The user created scantables are:" 249 sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs)) 250 print filter(lambda x: not x.startswith('_'), sts) 251 return 252 else: 253 pass 247 254 248 255 def commands(): 249 x = """ 256 x = """ 250 257 [The scan container] 251 258 scantable - a container for integrations/scans … … 286 293 history - print the history of the scantable 287 294 get_fit - get a fit which has been stored witnh the data 288 average_time - return the (weighted) time average of a scan 295 average_time - return the (weighted) time average of a scan 289 296 or a list of scans 290 297 average_pol - average the polarisations together. … … 296 303 quotient - return the on/off quotient 297 304 scale - return a scan scaled by a given factor 298 add - return a scan with given value added 305 add - return a scan with given value added 299 306 bin - return a scan with binned channels 300 307 resample - return a scan with resampled channels 301 308 smooth - return the spectrally smoothed scan 302 309 poly_baseline - fit a polynomial baseline to all Beams/IFs/Pols 303 auto_poly_baseline - automatically fit a polynomial baseline 310 auto_poly_baseline - automatically fit a polynomial baseline 304 311 gain_el - apply gain-elevation correction 305 312 opacity - apply opacity correction … … 312 319 [Math] Mainly functions which operate on more than one scantable 313 320 314 average_time - return the (weighted) time average 321 average_time - return the (weighted) time average 315 322 of a list of scans 316 323 quotient - return the on/off quotient … … 350 357 set_abcissa - specify a user label for the abcissa 351 358 set_layout - specify the multi-panel layout (rows,cols) 352 359 353 360 [Reading files] 354 361 reader - access rpfits/sdfits files … … 370 377 mask_not - boolean operations on masks created with 371 378 scantable.create_mask 372 379 373 380 Note: 374 381 How to use this with help: … … 376 383 [xxx] is just a category 377 384 Every 'sub-level' in this list should be replaces by a '.' Period when 378 using help 385 using help 379 386 Example: 380 387 ASAP> help scantable # to get info on ths scantable … … 386 393 return 387 394 388 print """Welcome to ASAP v%s (%s) - the ATNF Spectral Analysis Package 395 def welcome(): 396 return """Welcome to ASAP v%s (%s) - the ATNF Spectral Analysis Package 389 397 390 398 Please report any bugs to: … … 392 400 393 401 [IMPORTANT: ASAP is 0-based] 394 Type commands() to get a list of all available ASAP commands. 395 """ % (__version__, __date__) 402 Type commands() to get a list of all available ASAP commands.""" % (__version__, __date__)
Note:
See TracChangeset
for help on using the changeset viewer.