irfpy.vexpvat.vexspice

VEX spice related module

Tutorial is available at Tutorial to setup SPICE for VEX.

Following the tutorial, users have to download the kernels and .irfpyrc file should have following two entries to specify the location of the kernel.

[vexpvat]
spiceroot = /Volumes/scidata/data/venus/spice/kernels/

To use the vexspice module, user has to initialized via init() function.

>>> init()

Then use get_position() function to retrieve the position of Venus Express.

>>> print(get_position(datetime.datetime(2008, 12, 5, 13, 0, 0)))
[ -5700.13781279  19446.89874591 -41646.92614695]

Note

Since March 2017, ESA looks to provide MK file, which contains the meta data of SPICE. The current version just ignores this file.

For the future development, the MK file will be used.

irfpy.vexpvat.vexspice.isdb()[source]

Return whether the SPICE kernels are located in the correct location specified in .irfpyrc.

class irfpy.vexpvat.vexspice.VexSpiceFactory[source]

Bases: object

showstatus()[source]
get_filename_list(level='full', dataonly=True)[source]
Parameters
  • level

  • dataonly

Returns

get_full(dataonly=True)[source]

Get the kernel file name list

Parameters

dataonly

Returns

The file name list of the SPICE kernels

furnsheach(fname)[source]
furnsh()[source]

Furnsh the kernels.

irfpy.vexpvat.vexspice.isinitialized()[source]
irfpy.vexpvat.vexspice.init(update=True)[source]

Initialize the VEX spice kernels

Parameters

update – Not used anymore.

irfpy.vexpvat.vexspice.init_noatt(update=True)[source]

Furnsh default kernels from the irfpyrc’s mk file

Parameters

update – Update the mk file, but not for attitude file.

Warning

This function is now the same as init().

irfpy.vexpvat.vexspice.furnsh(kernel_file)[source]

Furnsh additional kernel file

irfpy.vexpvat.vexspice.updatemk(noatt=False, mkfile=None)[source]

Update the mk file.

Walk throught the path under spiceroot, create mk file.

Excluding *.txt

>>> updatemk()
irfpy.vexpvat.vexspice.get_position(t, target='VEX', origin='VENUS', frame='VSO', correction='LT+S')[source]

Get the position. By default, VEX in VSO.

>>> init()
>>> pos = get_position(datetime.datetime(2006, 12, 2, 15, 30))
>>> print('%.2f %.2f %.2f' % (pos[0], pos[1], pos[2]))  # may change slightly
-985.40 -2387.85 -68309.44
irfpy.vexpvat.vexspice.get_velocity(t, target='VEX', origin='VENUS', frame='VSO', correction='LT+S')[source]

Get the velocity. By default, VEX in VSO.

>>> init()
>>> vel = get_velocity(datetime.datetime(2006, 12, 2, 15, 30))
>>> print('%.2f %.2f %.2f' % (vel[0], vel[1], vel[2]))  # may change slightly
0.85 0.26 -0.70
irfpy.vexpvat.vexspice.get_positions(tlist, target='VEX', origin='Venus', frame='VSO', correction='LT+S')[source]

Get the time series of the position.

Parameters

tlist – Iterable of datetime.datetime object.

Returns

(N, 3) array of the position vector.

>>> init()
>>> tlist = [datetime.datetime(2012, 1, 1, 12), datetime.datetime(2012, 1, 1, 13)]
>>> positions = get_positions(tlist)
>>> print(positions.shape)
(2, 3)
>>> print("{p[0]:.2f} {p[1]:.2f} {p[2]:.2f}".format(p=positions[0, :]))
-7673.50 26101.15 -37544.75
>>> print("{p[0]:.2f} {p[1]:.2f} {p[2]:.2f}".format(p=positions[1, :]))
-7858.35 25955.30 -45445.77
irfpy.vexpvat.vexspice.get_velocities(tlist, target='VEX', origin='Venus', frame='VSO', correction='LT+S')[source]

Get the time series of the velocity.

Parameters

tlist – Iterable of datetime.datetime object.

Returns

(N, 3) array of the position vector.

>>> init()
>>> tlist = [datetime.datetime(2012, 1, 1, 12), datetime.datetime(2012, 1, 1, 13)]
>>> velocities = get_velocities(tlist)
>>> print(velocities.shape)
(2, 3)
>>> print("{p[0]:.2f} {p[1]:.2f} {p[2]:.2f}".format(p=velocities[0, :]))
-0.09 0.09 -2.40
>>> print("{p[0]:.2f} {p[1]:.2f} {p[2]:.2f}".format(p=velocities[1, :]))
-0.02 -0.16 -2.00
irfpy.vexpvat.vexspice.get_posvel(t, target='VEX', origin='VENUS', correction='LT+S', frame='VSO')[source]
irfpy.vexpvat.vexspice.get_scannerangle(t)[source]

Return the scanner angle in degrees.

irfpy.vexpvat.vexspice.get_lonlatalt(t, target='VEX', body='VENUS', frame='IAU_VENUS', re=6052, f=0)[source]

codeauthor:: Moa Persson

Parameters
  • t – input specific time in datetime format

  • target – target body of which longitude we seek, standard is Venus Express

  • body – body of which longitude we look at

  • frame – has to be body fixed, standard is IAU Venus

  • re – radius of body, standard Venus radius 6052 km

  • f – Flattening coefficient, \((re-rp) / re\) where \(rp\) is the polar radius of the spheroid, and the units of \(rp\) match those of \(re\). Standard for Venus: zero oblateness.

Returns

longitude, latitude and altitude of target. longitude and latitude as radians. altitude as the point above reference spheloid.

>>> init()
>>> t = datetime.datetime(2006, 12, 2, 15, 30)
>>> lon, lat, alt = get_lonlatalt(t)
>>> print('%.2f %.2f %.2f' % (lon, lat, alt))
1.56 -1.56 62306.26
irfpy.vexpvat.vexspice.get_lonlat(*args, **kwds)[source]

Alias to get_lonlatalt().

irfpy.vexpvat.vexspice.get_lst(t, lon, bodyID=299)[source]

codeauthor:: Moa Persson

Parameters
  • t – input specific time in datetime format

  • lon – input longitude on the surface

  • bodyID – spice ID of body, standard 299 is Venus

Returns

local solar time float and string

>>> init()
>>> t = datetime.datetime(2006, 12, 2, 15, 30)
>>> lon, lat, alt = get_lonlat(t)
>>> lst_frac, time = get_lst(t, lon)
>>> print('%.2f' % (lst_frac), time)  # may change slightly
10.84 10:50:17
irfpy.vexpvat.vexspice.get_sza(t, origin='Venus', target='VEX')[source]

codeauthor:: Moa Persson

Parameters
  • t – input specific time in datetime format

  • origin – origin of the coordinate system vector

  • target – target of the coordinate system vector

Returns

solar zenith angle (sza) of the target in the frame of the origin body at the specified t

>>> init()
>>> sza = get_sza(datetime.datetime(2006, 12, 2, 15, 30))
>>> print('%.2f' % (sza))
90.83
irfpy.vexpvat.vexspice.convert_matrix(t, fromframe='VEX_SPACECRAFT', toframe='VSO')[source]

Return conversion matrix as a numpy array.

Parameters

tdatatime.datetime object specifying time.

Returns

Numpy array of the conversion matrix. numpy.pxform is used.

Conversion between IMA frame and SC frame is

>>> from irfpy.vexpvat import vexspice
>>> vexspice.init()
>>> import datetime
>>> t = datetime.datetime.now()   # This is just a placeholder, as they are fixed each other.
>>> matx = convert_matrix(t, fromframe='VEX_ASPERA4_IMA', toframe='VEX_SPACECRAFT')
>>> from irfpy.util.with_context import printoptions
>>> with printoptions(suppress=True, precision=3): print(matx)
[[-0.  1. -0.]
 [ 1.  0.  0.]
 [ 0. -0. -1.]]