irfpy.asperacommon.wind

WIND module

WIND is earth L1 point spacecraft measuring the solar wind parameters.

Supporse WIND observed the solar wind velocity (vx0, vy0, vz0) in the GSE frame at t=t0. You may convert the vector in any frame via spice, to be (vx, vy, vz).

Todo

Detailed explanation of conversion to Mars should be done.

If the WIND is at (x0, y0, z0) at t0 in IAU_SUN and Mars, for example, at t0 (X0, Y0, Z0). The reason of using IAU_SUN is that the best angular separation is addressed to the Sun rotation. Assume the polar coordinates (r:distance, ph:longitude, th:latitude) and then the WIND position (r0, ph0, th0) at t0 and the Mars position (R0, Ph0, Th0) at t0. The solar wind velocity vector to be (vx0, vy0, vz0) in IAU_SUN at t0.

Note

For all the calculation, SPICE correction should be none. No light time correction is suitable.

(To be written)

Data file generation

Download all the needed dataset.

for yr in {2004..2013}; do wget -nc -np -r ftp://space.mit.edu/pub/plasma/wind/kp_files/$yr; done
ln -s space.mit.edu/pub/plasma/wind/kp_files/ raw

Then, start calculating the data.

for yr in {2004..2013}; do cd raw/$yr; python -c 'from irfpy.asperacommon import wind; wind.run()'; cd ../..; done

You may find .mars file in the directories.

The directory should be pointed by [asperacommon] windatmarsbase entry in .irfpyrc

Todo

MAG data propagation in a coherent way.

Todo

Extend this module to Venus in coherent way. It is found not very simple… Also, extension to other planets may be useful for future. In this sense, you may outdate this module, and put the module to another project or sub-package.

irfpy.asperacommon.wind.vec2rtp(vec)[source]

Return r, theta(latitude) and phi in radians

irfpy.asperacommon.wind.rtp2vec(r, t, p)[source]
irfpy.asperacommon.wind.showvec(vec, fp=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]
irfpy.asperacommon.wind.approach(x_ref, x_tar, v_sw, w_lon=2.666253e-06, logfile=None)[source]

To calculate the WIND observation toward Mars.

Suppose the solar wind velocity vector vsw=(vx, vy, vz) measured at x_ref, the radial and the longitudal propagations will make the solar wind velocity vector near to the target postion, x_tar. Not exactly matches, becuse x_tar will be changed.

This function will return the tuple, stating (t_diff, x_ref_new), where t_diff is the propagation time and x_ref_new is the new position of the reference point (closest to x_tar at t=0).

The coordinate system should be IAU_SUN. This is because the longitudal propagation we assume the Sun rotation.

>>> if not ms.isdb():    # Check if SPICE is initialized
...     print("SPICE is not loaded. Check if MEX/SPICE module is enabled")  
... else:
...     xr = [4, 1, 2]
...     xt = [-1, 5, 1]
...     vsw = [1, 1, 0.1]
...     t, xr2, vsw = approach(xr, xt, vsw)
...     print('%.3f' % t)
541313.542
...     print '%.3f %.3f %.3f' % tuple(xr2)
-0.936 4.681 2.052

If the y location is behind, minus will be returned.

>>> if not ms.isdb():    # Check if SPICE is initialized
...     print("SPICE is not loaded. Check if MEX/SPICE module is enabled")  
... else:
...     xr = [4, 1, 2]
...     xt = [-1, -5, 1]
...     vsw = [1, -1, 0.1]
...     t, xr2, vsw = approach(xr, xt, vsw)
...     print('%.3f' % t)
-682286.883
...     print '%.3f %.3f %.3f' % tuple(xr2)
-0.934 -4.671 2.076
irfpy.asperacommon.wind.wind2mars(t0, wind_gse, v_sw_gse, tlimsec=1, logfile=None)[source]

WIND observation converted to the Mars position.

Use of WIND, not ACE, as abberation is included for ACE.

>>> if not ms.isdb():    # Check if SPICE is initialized
...     print("SPICE is not loaded. Check if MEX/SPICE module is enabled")  
... else:
...     t0 = datetime.datetime(2009, 3, 1, 12, 0, 0)
...     wind = [1257103.8, -102048., -127687.56]
...     vsw = [-437.6, -0.5192, -6.457]
...     tm, xm, distrate = wind2mars(t0, wind, vsw)
...     print(tm.strftime('%FT%T'))
2009-03-14T13:40:32
...     print '{:.5e} {:.5e} {:.5e}'.format(xm[0], xm[1], xm[2])
4.33638e+06 2.78700e+06 -4.21764e+07
irfpy.asperacommon.wind.wind2mars_fromfile(filename, outfile)[source]
irfpy.asperacommon.wind.run()[source]
class irfpy.asperacommon.wind.Wind[source]

Bases: object

WIND data base.

Now, the WIND data is mass-prepared by run() function, and the *.mars files should be placed under the directory specified by [asperacommon]-windatmarsbase.

From the directory below, the data is stored into a sqlite database. The database name is {winddatamarsbase}/wind.db

filetabledefinition = 'FileTable\n           (Filename TEXT,\n            DataDate TEXT,\n            DataVersion INTEGER,\n            DataParseDate TEXT,\n            FileCreationDate TEXT)'
datatabledefinition = 'SwParamTable\n           (Filename TEXT,\n            Time TEXT,\n            TimeMars TEXT,\n            ErrorMars REAL,\n            Velocity REAL,\n            Density REAL,\n            Temperature REAL)'