Source code for irfpy.swim.swim_fov

''' Collection of functions (syntax sugar) of SWIM FoV module.
'''

from irfpy.swim import SwimEnergy
from irfpy.swim import SwimFov
import logging

from irfpy.util import utc

import irfpy.cy1orb.pvat

[docs]def velocity16x16sc(): ''' Returns velocity vector array for SWIM in km/s. This is the simplest way to get FoV vector corresponding SWIM FOVs. SWIM FOV bins consists of E=16 and D=16 maximumly. The latest calibration value is used. USAGE: vel_vecs = velocity16x16sc() # 16x16-element array of irfpy.util.vector3d.Vector3d object. print vel_vecs[5][8] # Shows the velocity vector for E=5 D=8 ''' ### Energy table, conveted to velocity table etbl = SwimEnergy.EnergyTable.table().getTable() # Take a default table. logging.debug(etbl) vtbl = SwimEnergy.eV2kms(etbl) logging.debug(vtbl) ### FoV information in SC frame fov = SwimFov.SwimFov.getInstance(coords='SC') fov_arr=[] for ie in range(16): fov_e=[] for id in range(16): view = fov.getDirection(id) view.scale(-vtbl[ie]) # - is convert from 'view direction' to 'velocity' logging.debug(view) fov_e.append(view) fov_arr.append(fov_e) return tuple(fov_arr)
[docs]def velocity16x16lse(t): ''' Returns the velocity vector array in LSE frame for SWIM in km/s. This is the simplest way of getting velocity vector for 16x16 E-D bins for SWIM. The time should be provided as the argument. Format is the one to be supporetd by irfpy.util.utc.convert() method. @return 16x16 array of the veolocity vector. Order of the loop is [E][D]. USAGE: vel_vecs = velocity16x16lse(datetime.datetime(2009, 1, 25, 13, 0, 0)) print vel_vecs Note: Since this method calles irfpy.cy1orb.pvat.getlsevec() method, the retrieved data is cached in the memory. If you use this method frequently, the stored data mush be cleaned manually by calling irfpy.cy1orb.pvat.clear_cahce() method to prevent the excess use of memory. ''' logger=logging.getLogger('velocity16x16lse') logger.setLevel(logging.WARN) sc = velocity16x16sc() fov_arr = [] for ie in range(16): fov_e = [] for id in range(16): scvec = sc[ie][id] lsevec=irfpy.cy1orb.pvat.getlsevec(t, scvec) logger.debug('%s:%s' % (scvec, lsevec)) fov_e.append(lsevec) fov_arr.append(fov_e) return tuple(fov_arr)
import unittest import doctest