| [100] | 1 | """
 | 
|---|
 | 2 | This is the ATNF Single Dish Analysis package.
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | """
 | 
|---|
| [1080] | 5 | import os,sys,shutil, platform
 | 
|---|
| [226] | 6 | 
 | 
|---|
| [1080] | 7 | # Set up AIPSPATH and first time use of asap i.e. ~/.asap/*
 | 
|---|
 | 8 | plf = None
 | 
|---|
 | 9 | if sys.platform == "linux2":
 | 
|---|
 | 10 |     if platform.architecture()[0] == '64bit':
 | 
|---|
 | 11 |         plf = 'linux_64b'
 | 
|---|
 | 12 |     else:
 | 
|---|
 | 13 |         plf = 'linux_gnu'
 | 
|---|
 | 14 | elif sys.platform == 'darwin':
 | 
|---|
 | 15 |     plf = 'darwin'
 | 
|---|
 | 16 | else:
 | 
|---|
 | 17 |     # Shouldn't happen - default to linux
 | 
|---|
 | 18 |     plf = 'linux'
 | 
|---|
 | 19 | asapdata = __path__[-1]
 | 
|---|
 | 20 | os.environ["AIPSPATH"] = "%s %s somwhere" % ( asapdata, plf)
 | 
|---|
 | 21 | userdir = os.environ["HOME"]+"/.asap"
 | 
|---|
 | 22 | if not os.path.exists(userdir):
 | 
|---|
 | 23 |     print 'First time ASAP use. Setting up ~/.asap'
 | 
|---|
 | 24 |     os.mkdir(userdir)
 | 
|---|
 | 25 |     shutil.copyfile(asapdata+"/data/ipythonrc-asap", userdir+"/ipythonrc-asap")
 | 
|---|
 | 26 |     f = file(userdir+"/asapuserfuncs.py", "w")
 | 
|---|
 | 27 |     f.close()
 | 
|---|
 | 28 |     f = file(userdir+"/ipythonrc", "w")
 | 
|---|
 | 29 |     f.close()
 | 
|---|
 | 30 | del asapdata, userdir, shutil, platform
 | 
|---|
 | 31 | 
 | 
|---|
| [513] | 32 | def _validate_bool(b):
 | 
|---|
| [226] | 33 |     'Convert b to a boolean or raise'
 | 
|---|
 | 34 |     bl = b.lower()
 | 
|---|
 | 35 |     if bl in ('f', 'no', 'false', '0', 0): return False
 | 
|---|
 | 36 |     elif bl in ('t', 'yes', 'true', '1', 1): return True
 | 
|---|
 | 37 |     else:
 | 
|---|
 | 38 |         raise ValueError('Could not convert "%s" to boolean' % b)
 | 
|---|
 | 39 | 
 | 
|---|
| [513] | 40 | def _validate_int(s):
 | 
|---|
| [226] | 41 |     'convert s to int or raise'
 | 
|---|
 | 42 |     try: return int(s)
 | 
|---|
 | 43 |     except ValueError:
 | 
|---|
 | 44 |         raise ValueError('Could not convert "%s" to int' % s)
 | 
|---|
 | 45 | 
 | 
|---|
| [513] | 46 | def _asap_fname():
 | 
|---|
| [226] | 47 |     """
 | 
|---|
 | 48 |     Return the path to the rc file
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 |     Search order:
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |      * current working dir
 | 
|---|
 | 53 |      * environ var ASAPRC
 | 
|---|
| [274] | 54 |      * HOME/.asaprc
 | 
|---|
| [706] | 55 | 
 | 
|---|
| [226] | 56 |     """
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 |     fname = os.path.join( os.getcwd(), '.asaprc')
 | 
|---|
 | 59 |     if os.path.exists(fname): return fname
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 |     if os.environ.has_key('ASAPRC'):
 | 
|---|
 | 62 |         path =  os.environ['ASAPRC']
 | 
|---|
 | 63 |         if os.path.exists(path):
 | 
|---|
 | 64 |             fname = os.path.join(path, '.asaprc')
 | 
|---|
 | 65 |             if os.path.exists(fname):
 | 
|---|
 | 66 |                 return fname
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 |     if os.environ.has_key('HOME'):
 | 
|---|
 | 69 |         home =  os.environ['HOME']
 | 
|---|
 | 70 |         fname = os.path.join(home, '.asaprc')
 | 
|---|
 | 71 |         if os.path.exists(fname):
 | 
|---|
 | 72 |             return fname
 | 
|---|
 | 73 |     return None
 | 
|---|
 | 74 | 
 | 
|---|
| [706] | 75 | 
 | 
|---|
| [226] | 76 | defaultParams = {
 | 
|---|
 | 77 |     # general
 | 
|---|
| [513] | 78 |     'verbose'             : [True, _validate_bool],
 | 
|---|
 | 79 |     'useplotter'          : [True, _validate_bool],
 | 
|---|
| [542] | 80 |     'insitu'              : [True, _validate_bool],
 | 
|---|
| [706] | 81 | 
 | 
|---|
| [226] | 82 |     # plotting
 | 
|---|
| [706] | 83 |     'plotter.gui'         : [True, _validate_bool],
 | 
|---|
| [226] | 84 |     'plotter.stacking'    : ['p', str],
 | 
|---|
 | 85 |     'plotter.panelling'   : ['s', str],
 | 
|---|
| [700] | 86 |     'plotter.colours'     : ['', str],
 | 
|---|
 | 87 |     'plotter.linestyles'  : ['', str],
 | 
|---|
| [710] | 88 |     'plotter.decimate'    : [False, _validate_bool],
 | 
|---|
 | 89 |     'plotter.ganged'      : [True, _validate_bool],
 | 
|---|
| [1022] | 90 |     'plotter.histogram'  : [False, _validate_bool],
 | 
|---|
| [1097] | 91 |     'plotter.papertype'  : ['A4', str],
 | 
|---|
| [710] | 92 | 
 | 
|---|
| [226] | 93 |     # scantable
 | 
|---|
 | 94 |     'scantable.save'      : ['ASAP', str],
 | 
|---|
| [513] | 95 |     'scantable.autoaverage'      : [True, _validate_bool],
 | 
|---|
| [226] | 96 |     'scantable.freqframe' : ['LSRK', str],  #default frequency frame
 | 
|---|
| [1076] | 97 |     'scantable.verbosesummary'   : [False, _validate_bool],
 | 
|---|
 | 98 |     'scantable.storage'   : ['memory', str]
 | 
|---|
| [226] | 99 |     # fitter
 | 
|---|
 | 100 |     }
 | 
|---|
 | 101 | 
 | 
|---|
| [255] | 102 | def list_rcparameters():
 | 
|---|
| [706] | 103 | 
 | 
|---|
| [255] | 104 |     print """
 | 
|---|
| [737] | 105 | # general
 | 
|---|
 | 106 | # print verbose output
 | 
|---|
 | 107 | verbose                    : True
 | 
|---|
| [255] | 108 | 
 | 
|---|
| [737] | 109 | # preload a default plotter
 | 
|---|
 | 110 | useplotter                 : True
 | 
|---|
| [255] | 111 | 
 | 
|---|
| [737] | 112 | # apply operations on the input scantable or return new one
 | 
|---|
 | 113 | insitu                     : True
 | 
|---|
| [706] | 114 | 
 | 
|---|
| [737] | 115 | # plotting
 | 
|---|
| [710] | 116 | 
 | 
|---|
| [737] | 117 | # do we want a GUI or plot to a file
 | 
|---|
 | 118 | plotter.gui                : True
 | 
|---|
| [710] | 119 | 
 | 
|---|
| [737] | 120 | # default mode for colour stacking
 | 
|---|
 | 121 | plotter.stacking           : Pol
 | 
|---|
| [255] | 122 | 
 | 
|---|
| [737] | 123 | # default mode for panelling
 | 
|---|
 | 124 | plotter.panelling          : scan
 | 
|---|
| [255] | 125 | 
 | 
|---|
| [737] | 126 | # push panels together, to share axislabels
 | 
|---|
 | 127 | plotter.ganged             : True
 | 
|---|
| [710] | 128 | 
 | 
|---|
| [737] | 129 | # decimate the number of points plotted bya afactor of
 | 
|---|
 | 130 | # nchan/1024
 | 
|---|
 | 131 | plotter.decimate           : False
 | 
|---|
| [733] | 132 | 
 | 
|---|
| [737] | 133 | # default colours/linestyles
 | 
|---|
 | 134 | plotter.colours            :
 | 
|---|
 | 135 | plotter.linestyles         :
 | 
|---|
| [700] | 136 | 
 | 
|---|
| [1022] | 137 | # enable/disable histogram plotting
 | 
|---|
 | 138 | plotter.histogram          : False
 | 
|---|
 | 139 | 
 | 
|---|
| [1097] | 140 | # ps paper type
 | 
|---|
 | 141 | plotter.papertype          : A4
 | 
|---|
 | 142 | 
 | 
|---|
| [737] | 143 | # scantable
 | 
|---|
| [1076] | 144 | 
 | 
|---|
 | 145 | # default storage of scantable (memory/disk)
 | 
|---|
 | 146 | scantable.storage          : memory
 | 
|---|
| [737] | 147 | # default ouput format when saving
 | 
|---|
 | 148 | scantable.save             : ASAP
 | 
|---|
 | 149 | # auto averaging on read
 | 
|---|
 | 150 | scantable.autoaverage      : True
 | 
|---|
| [255] | 151 | 
 | 
|---|
| [737] | 152 | # default frequency frame to set when function
 | 
|---|
| [1097] | 153 | # scantable.set_freqframe is called
 | 
|---|
| [737] | 154 | scantable.freqframe        : LSRK
 | 
|---|
| [255] | 155 | 
 | 
|---|
| [737] | 156 | # Control the level of information printed by summary
 | 
|---|
 | 157 | scantable.verbosesummary   : False
 | 
|---|
| [706] | 158 | 
 | 
|---|
| [737] | 159 | # Fitter
 | 
|---|
 | 160 | """
 | 
|---|
| [706] | 161 | 
 | 
|---|
| [226] | 162 | def rc_params():
 | 
|---|
 | 163 |     'Return the default params updated from the values in the rc file'
 | 
|---|
| [706] | 164 | 
 | 
|---|
| [513] | 165 |     fname = _asap_fname()
 | 
|---|
| [706] | 166 | 
 | 
|---|
| [226] | 167 |     if fname is None or not os.path.exists(fname):
 | 
|---|
 | 168 |         message = 'could not find rc file; returning defaults'
 | 
|---|
 | 169 |         ret =  dict([ (key, tup[0]) for key, tup in defaultParams.items()])
 | 
|---|
 | 170 |         #print message
 | 
|---|
 | 171 |         return ret
 | 
|---|
| [706] | 172 | 
 | 
|---|
| [226] | 173 |     cnt = 0
 | 
|---|
 | 174 |     for line in file(fname):
 | 
|---|
 | 175 |         cnt +=1
 | 
|---|
 | 176 |         line = line.strip()
 | 
|---|
 | 177 |         if not len(line): continue
 | 
|---|
 | 178 |         if line.startswith('#'): continue
 | 
|---|
 | 179 |         tup = line.split(':',1)
 | 
|---|
 | 180 |         if len(tup) !=2:
 | 
|---|
 | 181 |             print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname))
 | 
|---|
 | 182 |             continue
 | 
|---|
| [706] | 183 | 
 | 
|---|
| [226] | 184 |         key, val = tup
 | 
|---|
 | 185 |         key = key.strip()
 | 
|---|
 | 186 |         if not defaultParams.has_key(key):
 | 
|---|
 | 187 |             print ('Bad key "%s" on line %d in %s' % (key, cnt, fname))
 | 
|---|
 | 188 |             continue
 | 
|---|
| [706] | 189 | 
 | 
|---|
| [226] | 190 |         default, converter =  defaultParams[key]
 | 
|---|
 | 191 | 
 | 
|---|
 | 192 |         ind = val.find('#')
 | 
|---|
 | 193 |         if ind>=0: val = val[:ind]   # ignore trailing comments
 | 
|---|
 | 194 |         val = val.strip()
 | 
|---|
 | 195 |         try: cval = converter(val)   # try to convert to proper type or raise
 | 
|---|
| [1080] | 196 |         except ValueError, msg:
 | 
|---|
| [226] | 197 |             print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg))
 | 
|---|
 | 198 |             continue
 | 
|---|
 | 199 |         else:
 | 
|---|
 | 200 |             # Alles Klar, update dict
 | 
|---|
 | 201 |             defaultParams[key][0] = cval
 | 
|---|
 | 202 | 
 | 
|---|
 | 203 |     # strip the conveter funcs and return
 | 
|---|
 | 204 |     ret =  dict([ (key, tup[0]) for key, tup in defaultParams.items()])
 | 
|---|
| [466] | 205 |     print ('loaded rc file %s'%fname)
 | 
|---|
| [226] | 206 | 
 | 
|---|
 | 207 |     return ret
 | 
|---|
 | 208 | 
 | 
|---|
 | 209 | 
 | 
|---|
 | 210 | # this is the instance used by the asap classes
 | 
|---|
| [706] | 211 | rcParams = rc_params()
 | 
|---|
| [226] | 212 | 
 | 
|---|
 | 213 | rcParamsDefault = dict(rcParams.items()) # a copy
 | 
|---|
 | 214 | 
 | 
|---|
 | 215 | def rc(group, **kwargs):
 | 
|---|
 | 216 |     """
 | 
|---|
 | 217 |     Set the current rc params.  Group is the grouping for the rc, eg
 | 
|---|
| [379] | 218 |     for scantable.save the group is 'scantable', for plotter.stacking, the
 | 
|---|
 | 219 |     group is 'plotter', and so on.  kwargs is a list of attribute
 | 
|---|
| [226] | 220 |     name/value pairs, eg
 | 
|---|
 | 221 | 
 | 
|---|
| [379] | 222 |       rc('scantable', save='SDFITS')
 | 
|---|
| [226] | 223 | 
 | 
|---|
 | 224 |     sets the current rc params and is equivalent to
 | 
|---|
| [706] | 225 | 
 | 
|---|
| [379] | 226 |       rcParams['scantable.save'] = 'SDFITS'
 | 
|---|
| [226] | 227 | 
 | 
|---|
 | 228 |     Use rcdefaults to restore the default rc params after changes.
 | 
|---|
 | 229 |     """
 | 
|---|
 | 230 | 
 | 
|---|
| [379] | 231 |     aliases = {}
 | 
|---|
| [706] | 232 | 
 | 
|---|
| [226] | 233 |     for k,v in kwargs.items():
 | 
|---|
 | 234 |         name = aliases.get(k) or k
 | 
|---|
 | 235 |         key = '%s.%s' % (group, name)
 | 
|---|
 | 236 |         if not rcParams.has_key(key):
 | 
|---|
 | 237 |             raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' % (key, group, name))
 | 
|---|
| [706] | 238 | 
 | 
|---|
| [226] | 239 |         rcParams[key] = v
 | 
|---|
 | 240 | 
 | 
|---|
 | 241 | 
 | 
|---|
 | 242 | def rcdefaults():
 | 
|---|
 | 243 |     """
 | 
|---|
 | 244 |     Restore the default rc params - the ones that were created at
 | 
|---|
 | 245 |     asap load time
 | 
|---|
 | 246 |     """
 | 
|---|
 | 247 |     rcParams.update(rcParamsDefault)
 | 
|---|
 | 248 | 
 | 
|---|
| [513] | 249 | 
 | 
|---|
 | 250 | def _is_sequence_or_number(param, ptype=int):
 | 
|---|
 | 251 |     if isinstance(param,tuple) or isinstance(param,list):
 | 
|---|
| [928] | 252 |         if len(param) == 0: return True # empty list
 | 
|---|
| [513] | 253 |         out = True
 | 
|---|
 | 254 |         for p in param:
 | 
|---|
 | 255 |             out &= isinstance(p,ptype)
 | 
|---|
 | 256 |         return out
 | 
|---|
 | 257 |     elif isinstance(param, ptype):
 | 
|---|
 | 258 |         return True
 | 
|---|
 | 259 |     return False
 | 
|---|
 | 260 | 
 | 
|---|
| [928] | 261 | def _to_list(param, ptype=int):
 | 
|---|
 | 262 |     if isinstance(param, ptype):
 | 
|---|
 | 263 |         if ptype is str: return param.split()
 | 
|---|
 | 264 |         else: return [param]
 | 
|---|
 | 265 |     if _is_sequence_or_number(param, ptype):
 | 
|---|
 | 266 |         return param
 | 
|---|
 | 267 |     return None
 | 
|---|
| [715] | 268 | 
 | 
|---|
| [944] | 269 | def unique(x):
 | 
|---|
| [992] | 270 |     """
 | 
|---|
 | 271 |     Return the unique values in a list
 | 
|---|
 | 272 |     Parameters:
 | 
|---|
 | 273 |         x:      the list to reduce
 | 
|---|
 | 274 |     Examples:
 | 
|---|
 | 275 |         x = [1,2,3,3,4]
 | 
|---|
 | 276 |         print unique(x)
 | 
|---|
 | 277 |         [1,2,3,4]
 | 
|---|
 | 278 |     """
 | 
|---|
| [944] | 279 |     return dict([ (val, 1) for val in x]).keys()
 | 
|---|
 | 280 | 
 | 
|---|
| [992] | 281 | def list_files(path=".",suffix="rpf"):
 | 
|---|
 | 282 |     """
 | 
|---|
 | 283 |     Return a list files readable by asap, such as rpf, sdfits, mbf, asap
 | 
|---|
 | 284 |     Parameters:
 | 
|---|
 | 285 |         path:     The directory to list (default '.')
 | 
|---|
 | 286 |         suffix:   The file extension (default rpf)
 | 
|---|
 | 287 |     Example:
 | 
|---|
 | 288 |         files = list_files("data/","sdfits")
 | 
|---|
 | 289 |         print files
 | 
|---|
 | 290 |         ['data/2001-09-01_0332_P363.sdfits',
 | 
|---|
 | 291 |         'data/2003-04-04_131152_t0002.sdfits',
 | 
|---|
 | 292 |         'data/Sgr_86p262_best_SPC.sdfits']
 | 
|---|
 | 293 |     """
 | 
|---|
 | 294 |     import os
 | 
|---|
 | 295 |     if not os.path.isdir(path):
 | 
|---|
 | 296 |         return None
 | 
|---|
 | 297 |     valid = "rpf sdf sdfits mbf asap".split()
 | 
|---|
 | 298 |     if not suffix in valid:
 | 
|---|
 | 299 |         return None
 | 
|---|
 | 300 |     files = [os.path.expanduser(os.path.expandvars(path+"/"+f)) for f in os.listdir(path)]
 | 
|---|
 | 301 |     return filter(lambda x: x.endswith(suffix),files)
 | 
|---|
 | 302 | 
 | 
|---|
| [715] | 303 | # workaround for ipython, which redirects this if banner=0 in ipythonrc
 | 
|---|
 | 304 | sys.stdout = sys.__stdout__
 | 
|---|
 | 305 | sys.stderr = sys.__stderr__
 | 
|---|
 | 306 | 
 | 
|---|
 | 307 | # Logging
 | 
|---|
 | 308 | from asap._asap import Log as _asaplog
 | 
|---|
 | 309 | global asaplog
 | 
|---|
| [710] | 310 | asaplog=_asaplog()
 | 
|---|
| [715] | 311 | if rcParams['verbose']:
 | 
|---|
 | 312 |     asaplog.enable()
 | 
|---|
 | 313 | else:
 | 
|---|
 | 314 |     asaplog.disable()
 | 
|---|
 | 315 | 
 | 
|---|
 | 316 | def print_log():
 | 
|---|
 | 317 |     log = asaplog.pop()
 | 
|---|
 | 318 |     if len(log) and rcParams['verbose']: print log
 | 
|---|
 | 319 |     return
 | 
|---|
 | 320 | 
 | 
|---|
| [1134] | 321 | try:
 | 
|---|
 | 322 |     import numpy.core as NUM
 | 
|---|
 | 323 | except ImportError:
 | 
|---|
 | 324 |     try:
 | 
|---|
 | 325 |         import numarray as NUM
 | 
|---|
 | 326 |     except ImportError:
 | 
|---|
 | 327 |         raise ImportError("You need to have numpy or numarray installed")
 | 
|---|
 | 328 | 
 | 
|---|
| [1117] | 329 | from asapfitter import fitter
 | 
|---|
| [895] | 330 | from asapreader import reader
 | 
|---|
| [944] | 331 | from selector import selector
 | 
|---|
| [710] | 332 | 
 | 
|---|
| [100] | 333 | from asapmath import *
 | 
|---|
| [1080] | 334 | from scantable import scantable
 | 
|---|
| [1097] | 335 | from asaplinefind import linefinder
 | 
|---|
| [1134] | 336 | from linecatalog import linecatalog
 | 
|---|
| [285] | 337 | 
 | 
|---|
| [1134] | 338 | mask_and = NUM.logical_and
 | 
|---|
 | 339 | mask_or = NUM.logical_or
 | 
|---|
 | 340 | mask_not = NUM.logical_not
 | 
|---|
| [466] | 341 | 
 | 
|---|
| [928] | 342 | if rcParams['useplotter']:
 | 
|---|
| [1097] | 343 |     from  asapplotter import asapplotter
 | 
|---|
| [928] | 344 |     gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui']
 | 
|---|
 | 345 |     plotter = asapplotter(gui)
 | 
|---|
 | 346 |     del gui
 | 
|---|
| [285] | 347 | 
 | 
|---|
| [574] | 348 | __date__ = '$Date: 2006-08-16 05:29:05 +0000 (Wed, 16 Aug 2006) $'.split()[1]
 | 
|---|
| [1069] | 349 | __version__  = '2.1a'
 | 
|---|
| [100] | 350 | 
 | 
|---|
| [706] | 351 | if rcParams['verbose']:
 | 
|---|
| [1014] | 352 |     def version(): print  "ASAP %s(%s)"% (__version__, __date__)
 | 
|---|
| [706] | 353 |     def list_scans(t = scantable):
 | 
|---|
 | 354 |         import sys, types
 | 
|---|
 | 355 |         globs = sys.modules['__main__'].__dict__.iteritems()
 | 
|---|
 | 356 |         print "The user created scantables are:"
 | 
|---|
 | 357 |         sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs))
 | 
|---|
 | 358 |         print filter(lambda x: not x.startswith('_'), sts)
 | 
|---|
 | 359 |         return
 | 
|---|
| [100] | 360 | 
 | 
|---|
| [715] | 361 |     def commands():
 | 
|---|
 | 362 |         x = """
 | 
|---|
| [113] | 363 |     [The scan container]
 | 
|---|
 | 364 |         scantable           - a container for integrations/scans
 | 
|---|
| [182] | 365 |                               (can open asap/rpfits/sdfits and ms files)
 | 
|---|
| [113] | 366 |             copy            - returns a copy of a scan
 | 
|---|
 | 367 |             get_scan        - gets a specific scan out of a scantable
 | 
|---|
| [984] | 368 |                               (by name or number)
 | 
|---|
| [1093] | 369 |             drop_scan       - drops a specific scan out of a scantable
 | 
|---|
 | 370 |                               (by number)
 | 
|---|
| [984] | 371 |             set_selection   - set a new subselection of the data
 | 
|---|
 | 372 |             get_selection   - get the current selection object
 | 
|---|
| [113] | 373 |             summary         - print info about the scantable contents
 | 
|---|
| [182] | 374 |             stats           - get specified statistic of the spectra in
 | 
|---|
 | 375 |                               the scantable
 | 
|---|
 | 376 |             stddev          - get the standard deviation of the spectra
 | 
|---|
 | 377 |                               in the scantable
 | 
|---|
| [113] | 378 |             get_tsys        - get the TSys
 | 
|---|
 | 379 |             get_time        - get the timestamps of the integrations
 | 
|---|
| [733] | 380 |             get_sourcename  - get the source names of the scans
 | 
|---|
| [794] | 381 |             get_azimuth     - get the azimuth of the scans
 | 
|---|
 | 382 |             get_elevation   - get the elevation of the scans
 | 
|---|
 | 383 |             get_parangle    - get the parallactic angle of the scans
 | 
|---|
| [876] | 384 |             get_unit        - get the current unit
 | 
|---|
| [513] | 385 |             set_unit        - set the abcissa unit to be used from this
 | 
|---|
 | 386 |                               point on
 | 
|---|
| [255] | 387 |             get_abcissa     - get the abcissa values and name for a given
 | 
|---|
 | 388 |                               row (time)
 | 
|---|
| [113] | 389 |             set_freqframe   - set the frame info for the Spectral Axis
 | 
|---|
 | 390 |                               (e.g. 'LSRK')
 | 
|---|
| [276] | 391 |             set_doppler     - set the doppler to be used from this point on
 | 
|---|
| [984] | 392 |             set_dirframe    - set the frame for the direction on the sky
 | 
|---|
| [240] | 393 |             set_instrument  - set the instrument name
 | 
|---|
| [255] | 394 |             get_fluxunit    - get the brightness flux unit
 | 
|---|
| [240] | 395 |             set_fluxunit    - set the brightness flux unit
 | 
|---|
| [188] | 396 |             create_mask     - return an mask in the current unit
 | 
|---|
 | 397 |                               for the given region. The specified regions
 | 
|---|
 | 398 |                               are NOT masked
 | 
|---|
| [255] | 399 |             get_restfreqs   - get the current list of rest frequencies
 | 
|---|
 | 400 |             set_restfreqs   - set a list of rest frequencies
 | 
|---|
| [1012] | 401 |             flag            - flag selected channels in the data
 | 
|---|
| [1151] | 402 |             save            - save the scantable to disk as either 'ASAP',
 | 
|---|
 | 403 |                               'SDFITS' or 'ASCII'
 | 
|---|
| [486] | 404 |             nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
 | 
|---|
| [733] | 405 |             nscan           - the number of scans in the scantable
 | 
|---|
| [984] | 406 |             nrow            - te number of spectra in the scantable
 | 
|---|
| [486] | 407 |             history         - print the history of the scantable
 | 
|---|
| [530] | 408 |             get_fit         - get a fit which has been stored witnh the data
 | 
|---|
| [706] | 409 |             average_time    - return the (weighted) time average of a scan
 | 
|---|
| [513] | 410 |                               or a list of scans
 | 
|---|
 | 411 |             average_pol     - average the polarisations together.
 | 
|---|
| [1144] | 412 |             average_beam    - average the beams together.
 | 
|---|
| [992] | 413 |             convert_pol     - convert to a different polarisation type
 | 
|---|
| [690] | 414 |             auto_quotient   - return the on/off quotient with
 | 
|---|
| [1069] | 415 |                               automatic detection of the on/off scans (closest
 | 
|---|
 | 416 |                               in time off is selected)
 | 
|---|
| [1144] | 417 |             mx_quotient     - Form a quotient using MX data (off beams)
 | 
|---|
| [1014] | 418 |             scale, *, /     - return a scan scaled by a given factor
 | 
|---|
 | 419 |             add, +, -       - return a scan with given value added
 | 
|---|
| [513] | 420 |             bin             - return a scan with binned channels
 | 
|---|
 | 421 |             resample        - return a scan with resampled channels
 | 
|---|
 | 422 |             smooth          - return the spectrally smoothed scan
 | 
|---|
 | 423 |             poly_baseline   - fit a polynomial baseline to all Beams/IFs/Pols
 | 
|---|
| [706] | 424 |             auto_poly_baseline - automatically fit a polynomial baseline
 | 
|---|
| [780] | 425 |             recalc_azel     - recalculate azimuth and elevation based on
 | 
|---|
 | 426 |                               the pointing
 | 
|---|
| [513] | 427 |             gain_el         - apply gain-elevation correction
 | 
|---|
 | 428 |             opacity         - apply opacity correction
 | 
|---|
 | 429 |             convert_flux    - convert to and from Jy and Kelvin brightness
 | 
|---|
| [255] | 430 |                               units
 | 
|---|
| [513] | 431 |             freq_align      - align spectra in frequency frame
 | 
|---|
| [1014] | 432 |             invert_phase    - Invert the phase of the cross-correlation
 | 
|---|
 | 433 |             swap_linears    - Swap XX and YY
 | 
|---|
| [513] | 434 |             rotate_xyphase  - rotate XY phase of cross correlation
 | 
|---|
 | 435 |             rotate_linpolphase - rotate the phase of the complex
 | 
|---|
 | 436 |                                  polarization O=Q+iU correlation
 | 
|---|
| [733] | 437 |             freq_switch     - perform frequency switching on the data
 | 
|---|
 | 438 |             stats           - Determine the specified statistic, e.g. 'min'
 | 
|---|
 | 439 |                               'max', 'rms' etc.
 | 
|---|
 | 440 |             stddev          - Determine the standard deviation of the current
 | 
|---|
 | 441 |                               beam/if/pol
 | 
|---|
| [1014] | 442 |      [Selection]
 | 
|---|
 | 443 |          selector              - a selection object to set a subset of a scantable
 | 
|---|
 | 444 |             set_scans          - set (a list of) scans by index
 | 
|---|
 | 445 |             set_cycles         - set (a list of) cycles by index
 | 
|---|
 | 446 |             set_beams          - set (a list of) beamss by index
 | 
|---|
 | 447 |             set_ifs            - set (a list of) ifs by index
 | 
|---|
 | 448 |             set_polarisations  - set (a list of) polarisations by name
 | 
|---|
 | 449 |                                  or by index
 | 
|---|
 | 450 |             set_names          - set a selection by name (wildcards allowed)
 | 
|---|
 | 451 |             set_tsys           - set a selection by tsys thresholds
 | 
|---|
 | 452 |             reset              - unset all selections
 | 
|---|
 | 453 |             +                  - merge to selections
 | 
|---|
| [733] | 454 | 
 | 
|---|
| [513] | 455 |      [Math] Mainly functions which operate on more than one scantable
 | 
|---|
| [100] | 456 | 
 | 
|---|
| [706] | 457 |             average_time    - return the (weighted) time average
 | 
|---|
| [513] | 458 |                               of a list of scans
 | 
|---|
 | 459 |             quotient        - return the on/off quotient
 | 
|---|
 | 460 |             simple_math     - simple mathematical operations on two scantables,
 | 
|---|
 | 461 |                               'add', 'sub', 'mul', 'div'
 | 
|---|
| [1069] | 462 |             quotient        - build quotient of the given on and off scans
 | 
|---|
 | 463 |                               (matched pairs and 1 off/n on are valid)
 | 
|---|
| [1117] | 464 |             merge           - merge a list of scantables
 | 
|---|
| [1069] | 465 | 
 | 
|---|
| [1151] | 466 |      [Line Catalog]
 | 
|---|
 | 467 |         linecatalog              - a linecatalog wrapper, taking an ASCII or
 | 
|---|
 | 468 |                                    internal format table
 | 
|---|
 | 469 |             summary              - print a summary of the current selection
 | 
|---|
 | 470 |             set_name             - select a subset by name pattern, e.g. '*OH*'
 | 
|---|
 | 471 |             set_strength_limits  - select a subset by line strength limits
 | 
|---|
 | 472 |             set_frequency_limits - select a subset by frequency limits
 | 
|---|
 | 473 |             reset                - unset all selections
 | 
|---|
 | 474 |             save                 - save the current subset to a table (internal
 | 
|---|
 | 475 |                                    format)
 | 
|---|
 | 476 |             get_row              - get the name and frequency from a specific
 | 
|---|
 | 477 |                                    row in the table
 | 
|---|
| [513] | 478 |      [Fitting]
 | 
|---|
| [113] | 479 |         fitter
 | 
|---|
 | 480 |             auto_fit        - return a scan where the function is
 | 
|---|
 | 481 |                               applied to all Beams/IFs/Pols.
 | 
|---|
 | 482 |             commit          - return a new scan where the fits have been
 | 
|---|
 | 483 |                               commited.
 | 
|---|
 | 484 |             fit             - execute the actual fitting process
 | 
|---|
| [984] | 485 |             store_fit       - store the fit parameters in the data (scantable)
 | 
|---|
| [113] | 486 |             get_chi2        - get the Chi^2
 | 
|---|
 | 487 |             set_scan        - set the scantable to be fit
 | 
|---|
 | 488 |             set_function    - set the fitting function
 | 
|---|
 | 489 |             set_parameters  - set the parameters for the function(s), and
 | 
|---|
 | 490 |                               set if they should be held fixed during fitting
 | 
|---|
| [513] | 491 |             set_gauss_parameters - same as above but specialised for individual
 | 
|---|
 | 492 |                                    gaussian components
 | 
|---|
| [113] | 493 |             get_parameters  - get the fitted parameters
 | 
|---|
| [513] | 494 |             plot            - plot the resulting fit and/or components and
 | 
|---|
 | 495 |                               residual
 | 
|---|
| [210] | 496 |     [Plotter]
 | 
|---|
 | 497 |         asapplotter         - a plotter for asap, default plotter is
 | 
|---|
 | 498 |                               called 'plotter'
 | 
|---|
| [984] | 499 |             plot            - plot a scantable
 | 
|---|
| [1151] | 500 |             plot_lines      - plot a linecatalog overlay
 | 
|---|
| [378] | 501 |             save            - save the plot to a file ('png' ,'ps' or 'eps')
 | 
|---|
| [210] | 502 |             set_mode        - set the state of the plotter, i.e.
 | 
|---|
 | 503 |                               what is to be plotted 'colour stacked'
 | 
|---|
 | 504 |                               and what 'panelled'
 | 
|---|
| [984] | 505 |             set_selection   - only plot a selected part of the data
 | 
|---|
| [733] | 506 |             set_range       - set a 'zoom' window [xmin,xmax,ymin,ymax]
 | 
|---|
| [255] | 507 |             set_legend      - specify user labels for the legend indeces
 | 
|---|
 | 508 |             set_title       - specify user labels for the panel indeces
 | 
|---|
| [733] | 509 |             set_abcissa     - specify a user label for the abcissa
 | 
|---|
| [255] | 510 |             set_ordinate    - specify a user label for the ordinate
 | 
|---|
| [378] | 511 |             set_layout      - specify the multi-panel layout (rows,cols)
 | 
|---|
| [733] | 512 |             set_colors      - specify a set of colours to use
 | 
|---|
 | 513 |             set_linestyles  - specify a set of linestyles to use if only
 | 
|---|
 | 514 |                               using one color
 | 
|---|
| [1151] | 515 |             set_font        - set general font properties, e.g. 'family'
 | 
|---|
| [1054] | 516 |             set_histogram   - plot in historam style
 | 
|---|
| [733] | 517 |             set_mask        - set a plotting mask for a specific polarization
 | 
|---|
| [706] | 518 | 
 | 
|---|
| [182] | 519 |     [Reading files]
 | 
|---|
 | 520 |         reader              - access rpfits/sdfits files
 | 
|---|
| [984] | 521 |             open            - attach reader to a file
 | 
|---|
 | 522 |             close           - detach reader from file
 | 
|---|
| [182] | 523 |             read            - read in integrations
 | 
|---|
 | 524 |             summary         - list info about all integrations
 | 
|---|
 | 525 | 
 | 
|---|
| [113] | 526 |     [General]
 | 
|---|
 | 527 |         commands            - this command
 | 
|---|
 | 528 |         print               - print details about a variable
 | 
|---|
 | 529 |         list_scans          - list all scantables created bt the user
 | 
|---|
| [992] | 530 |         list_files          - list all files readable by asap (default rpf)
 | 
|---|
| [113] | 531 |         del                 - delete the given variable from memory
 | 
|---|
 | 532 |         range               - create a list of values, e.g.
 | 
|---|
 | 533 |                               range(3) = [0,1,2], range(2,5) = [2,3,4]
 | 
|---|
 | 534 |         help                - print help for one of the listed functions
 | 
|---|
 | 535 |         execfile            - execute an asap script, e.g. execfile('myscript')
 | 
|---|
| [255] | 536 |         list_rcparameters   - print out a list of possible values to be
 | 
|---|
| [274] | 537 |                               put into $HOME/.asaprc
 | 
|---|
| [466] | 538 |         mask_and,mask_or,
 | 
|---|
 | 539 |         mask_not            - boolean operations on masks created with
 | 
|---|
 | 540 |                               scantable.create_mask
 | 
|---|
| [706] | 541 | 
 | 
|---|
| [210] | 542 |     Note:
 | 
|---|
 | 543 |         How to use this with help:
 | 
|---|
 | 544 |                                          # function 'summary'
 | 
|---|
 | 545 |         [xxx] is just a category
 | 
|---|
 | 546 |         Every 'sub-level' in this list should be replaces by a '.' Period when
 | 
|---|
| [706] | 547 |         using help
 | 
|---|
| [210] | 548 |         Example:
 | 
|---|
 | 549 |             ASAP> help scantable # to get info on ths scantable
 | 
|---|
 | 550 |             ASAP> help scantable.summary # to get help on the scantable's
 | 
|---|
 | 551 |             ASAP> help average_time
 | 
|---|
 | 552 | 
 | 
|---|
| [715] | 553 |             """
 | 
|---|
| [1151] | 554 |         if rcParams['verbose']:
 | 
|---|
 | 555 |             try:
 | 
|---|
 | 556 |                 from IPython.genutils import page as pager
 | 
|---|
 | 557 |             except ImportError:
 | 
|---|
 | 558 |                 from pydoc import pager
 | 
|---|
 | 559 |             pager(x)
 | 
|---|
 | 560 |         else:
 | 
|---|
 | 561 |             print x
 | 
|---|
| [715] | 562 |         return
 | 
|---|
| [113] | 563 | 
 | 
|---|
| [706] | 564 | def welcome():
 | 
|---|
 | 565 |     return """Welcome to ASAP v%s (%s) - the ATNF Spectral Analysis Package
 | 
|---|
| [100] | 566 | 
 | 
|---|
| [1035] | 567 | Please report any bugs via:
 | 
|---|
 | 568 | http://sourcecode.atnf.csiro.au/cgi-bin/trac_asap.cgi/newticket
 | 
|---|
| [100] | 569 | 
 | 
|---|
| [378] | 570 | [IMPORTANT: ASAP is 0-based]
 | 
|---|
| [706] | 571 | Type commands() to get a list of all available ASAP commands.""" % (__version__, __date__)
 | 
|---|