def trace(self, x, y, z, rlim=10., r0=1., dir=-1, maxloop=1000): # returns the last x,y,z and arrays xx,yy,zz along trace # x,y,z have to be scalar # we need to call recalc since common block is shared between instances # of geopack_2008 and T89,T96,T01,T04 self.ps = geopack.recalc(self.dt_seconds) parmod = self.iopt # geopack.trace(xi,yi,zi,dir,rlim=10,r0=1,parmod=2,exname='t89',inname='igrf',maxloop=1000) if self.use_igrf: return geopack.trace(x, y, z, dir, rlim, r0, parmod, 't89', 'igrf', maxloop=maxloop) else: return geopack.trace(x, y, z, dir, rlim, r0, parmod, 't89', 'dip', maxloop=maxloop)
def trace(self, x, y, z, rlim=10., r0=1., dir=-1, maxloop=1000): # returns the last x,y,z and arrays xx,yy,zz along trace if self.use_igrf: return geopack.trace(x, y, z, dir, rlim, r0, self.parmod, 't04', 'igrf', maxloop=maxloop) else: return geopack.trace(x, y, z, dir, rlim, r0, self.parmod, 't01', 'dip', maxloop=maxloop)
def test_to_known_values(self): """geopack should give known result with known input""" # test recalc, which returns dipole tilt angle in rad. self.assertEqual(self.test['recalc'], geopack.recalc(self.test['ut'], *self.test['v_gse'])) # test sun, which returns 5 angles in rad. self.assertEqual(self.test['sun'], geopack.sun(self.test['ut'])) # test internal models. self.assertTrue( approx_eq(self.test['igrf'], geopack.igrf_gsm(*self.test['r_gsm']))) self.assertTrue( approx_eq(self.test['dip'], geopack.dip(*self.test['r_gsm']))) self.assertTrue( approx_eq(self.test['igrf_gsw'], geopack.igrf_gsw(*self.test['r_gsw']), 1e-3)) self.assertTrue( approx_eq(self.test['dip_gsw'], geopack.dip_gsw(*self.test['r_gsw']), 1e-3)) # test external models. self.assertTrue( approx_eq(self.test['t89'], t89.t89(*self.test['par1']))) self.assertTrue( approx_eq(self.test['t96'], t96.t96(*self.test['par2']))) self.assertTrue( approx_eq(self.test['t01'], t01.t01(*self.test['par2']))) self.assertTrue( approx_eq(self.test['t04'], t04.t04(*self.test['par2']))) # test coord transform, which returns B in nT. self.assertTrue( approx_eq(self.test['r_mag'], geopack.geomag(*self.test['r_geo'], 1))) self.assertTrue( approx_eq(self.test['r_geo'], geopack.geomag(*self.test['r_mag'], -1))) self.assertTrue( approx_eq(self.test['r_geo'], geopack.geigeo(*self.test['r_gei'], 1))) self.assertTrue( approx_eq(self.test['r_gei'], geopack.geigeo(*self.test['r_geo'], -1))) self.assertTrue( approx_eq(self.test['r_sm'], geopack.magsm(*self.test['r_mag'], 1))) self.assertTrue( approx_eq(self.test['r_mag'], geopack.magsm(*self.test['r_sm'], -1))) self.assertTrue( approx_eq(self.test['r_gse'], geopack.gsmgse(*self.test['r_gsm'], 1))) self.assertTrue( approx_eq(self.test['r_gsm'], geopack.gsmgse(*self.test['r_gse'], -1))) self.assertTrue( approx_eq(self.test['r_gsm'], geopack.smgsm(*self.test['r_sm'], 1))) self.assertTrue( approx_eq(self.test['r_sm'], geopack.smgsm(*self.test['r_gsm'], -1))) self.assertTrue( approx_eq(self.test['r_gsm'], geopack.geogsm(*self.test['r_geo'], 1))) self.assertTrue( approx_eq(self.test['r_geo'], geopack.geogsm(*self.test['r_gsm'], -1))) self.assertTrue( approx_eq(self.test['r_gsw'], geopack.gswgsm(*self.test['r_gsm'], -1))) self.assertTrue( approx_eq(self.test['r_gsm'], geopack.gswgsm(*self.test['r_gsw'], 1))) self.assertTrue( approx_eq(self.test['geo'], geopack.geodgeo(*self.test['geod'], 1), 1e-3)) self.assertTrue( approx_eq(self.test['geod2'], geopack.geodgeo(*self.test['geo2'], -1), 1e-3)) # test trace. self.assertTrue( approx_eq( self.test['trace_t89_igrf'], geopack.trace(*self.test['r_gsm'], *self.test['trace_setting'], self.test['par1'][0], 't89', 'igrf'))) self.assertTrue( approx_eq( self.test['trace_t96_igrf'], geopack.trace(*self.test['r_gsm'], *self.test['trace_setting'], self.test['par2'][0], 't96', 'igrf'))) self.assertTrue( approx_eq( self.test['trace_t01_igrf'], geopack.trace(*self.test['r_gsm'], *self.test['trace_setting'], self.test['par2'][0], 't01', 'igrf'))) self.assertTrue( approx_eq( self.test['trace_t04_igrf'], geopack.trace(*self.test['r_gsm'], *self.test['trace_setting'], self.test['par2'][0], 't04', 'igrf'))) # test magnetopaus model. self.assertTrue( approx_eq( self.test['mgnp_t96'], geopack.t96_mgnp(*self.test['mgnp_t96_par'], *self.test['r_gsm']))) self.assertTrue( approx_eq( self.test['mgnp_shu'], geopack.shuetal_mgnp(*self.test['mgnp_shu_par'], *self.test['r_gsm'])))
For T04 par: A model paramter. It is a 10-element array, whose elements are (1-10) | par | 1 | 2 | 3-4 | 5-10 | | Var | Pdyn | Dst | ByIMF,BzIMF | W1 to W6 | where Pdyn is the solar wind dynamic pressure in nPa; Dst is the Dst index in nT; ByImf,BzImf are the y and z components of the IMF (interplanetary magnetif field) in GSM; W1,W2,...,W6 are six indices defined in Tsyganenko (2005). """ # From date and time t1 = dt.datetime(2001, 1, 2, 3, 4, 5) # year month day hour min sec t0 = dt.datetime(1970, 1, 1) # start of epoch ut = (t1 - t0).total_seconds() ps = geopack.recalc(ut) x0gsm = 6.3 y0gsm = 5.3 z0gsm = -2.9 dir = 1 rlim = 1.1 r0 = 1 par = 2 exname = 't04' inname = 'igrf' out = geopack.trace(x0gsm, y0gsm, z0gsm, dir) #, par, exname)#, inname) pdb.set_trace()