irfpy.cy1orb.Cy1OrbitNr

Orbit number handling.

Setup:

  1. Prepare the orbit number file. It is named ch1_orbit_number.out_v2. The original file is existing at http://sara.irf.se/archive/raw/orbnum/ch1_orbit_number.out

  2. Setup the ${HOME}/.irfpyrc file. In the section of cy1orb, the prepared file should be specified in the entry , orbnruri.

    [cy1orb]
    orbnruri = file:///path/to/the/file/ch1_orbit_number.out_v2
    

Usage:

  1. Use either of these functions

Sample:

>>> from irfpy.cy1orb import Cy1OrbitNr as cy1onr
>>> t0 = cy1onr.get_first_time()   # The time that the orbit file starts
>>> print(t0)
2008-10-22 01:10:19.081000
>>> t1 = cy1onr.get_last_time()   # The time that the orbit file ends
>>> print(t1)
2009-08-29 10:13:45.081000
>>> orb0 = cy1onr.get_first_orbit_number()   # The start orbit of the orbit file
>>> print(orb0)
0
>>> orb1 = cy1onr.get_last_orbit_number()   # The start orbit of the orbit file
>>> print(orb1)
3475
>>> print(cy1onr.get_start_time(1000))   # Start time of the orbit 1000
2009-01-30 13:29:33.081000
>>> print(cy1onr.get_stop_time(1000))   # Stop time of the orbit 1000
2009-01-30 15:27:39.081000
>>> import datetime
>>> tt = datetime.datetime(2009, 1, 30, 14, 0, 0)
>>> print(cy1onr.get_orbit_number(tt))
1000

Note

In early 2011, we found that the orbit number file had been changed. This may introduce a big confusion. It has been handled transparently, and in case one uses old (v1) file the exception of OldOrbnumFileError is thrown

See Change of orbit number file by project for details.

class irfpy.cy1orb.Cy1OrbitNr.Cy1OrbitNr(rcfile=None)[source]

Bases: object

Orbit number class. Backend.

Class that treats the orbit number. Even though orbit number is not spice-base, the class is considered as a part of spice related class.

The input file is normally provided through the ISSDC public server. The file is saved at ssh://butler.irf.se/home/sara/saradds/archive/incoming/issdc/orbit_no_and_eph/ch1_orbit_number.out.gz. The file should be ‘well behaved’, i.e., the format is strict (14 columns: 13 decimal int + 1 floating point), in addition to the orbit number is sequencial and continuous.

The interface is the same as C++ implementation in https://butler.irf.se/sara-trac/file/ISSDC/spice/module/SaraSpice/Cy1OrbitNr.h

Constructor of Cy1OrbitNr class.

Constructor do nothing. You have to call setFromDefaultUri() or setFromFile() before using.

DEFAULT_URI = None
setFromFile(filename)[source]

Set the orbit information data from the specified file.

setFromUri(uriname)[source]

Set the orbit information data from the specified URI.

setFromDefaultUri()[source]

Set the orbit information data from the URI specified in the .irfpyrc.

getFirstOrbitNr()[source]

Returns the first orbit number

getFirstStarttime()[source]
getLastStoptime()[source]
getLastOrbitNr()[source]

Returns the last orbit number

getStartTime(orbitNr)[source]

Returns the start time of the specified orbit number

getStartDatetime(orbitNr)[source]

Return the start time of the specified orbit number as datetime.datetime.

getStopTime(orbitNr)[source]

Returns the stop time of the specified orbit number

getStopDatetime(orbitNr)[source]

Return the stop time of the specified orbit number as datetime.datetime.

getOrbitNr(t)[source]

Get the orbit number of the specified time.

Parameters

t (datetime.datetime) – Time of inquiry.

irfpy.cy1orb.Cy1OrbitNr.get_first_orbit_number()[source]

Returns the first orbit number, usually, 0

irfpy.cy1orb.Cy1OrbitNr.get_first_time()[source]

Return the start time supported by the orbit number file

Returns

Time of the start of the orbit number file

Return type

datetime.datetime

irfpy.cy1orb.Cy1OrbitNr.get_last_orbit_number()[source]

Returns the first orbit number, usually, 3475

irfpy.cy1orb.Cy1OrbitNr.get_last_time()[source]

Return the time of the orbit number file supported.

Returns

Time of the end of the orbit number file

Return type

datetime.datetime

irfpy.cy1orb.Cy1OrbitNr.get_start_time(orbit_number)[source]

Return the start time of the given orbit number.

Parameters

orbit_number – Orbit number.

Returns

The start time of the given orbit number.

irfpy.cy1orb.Cy1OrbitNr.get_stop_time(orbit_number)[source]

Return the stop time of the given orbit number.

Parameters

orbit_number – Orbit number.

Returns

The stop time of the given orbit number.

irfpy.cy1orb.Cy1OrbitNr.get_orbit_number(t)[source]

Return the orbit number of the given time

Parameters

t (datetime.datetime) – Time

Returns

Orbit number

exception irfpy.cy1orb.Cy1OrbitNr.OldOrbnumFileError(value)[source]

Bases: RuntimeError

Exception raised if v1 version of the orbnum file is loaded.

>>> try:
...     raise OldOrbnumFileError("Old orbnum file loaded.")
...     print("If you reach this line, something wrong.")
... except OldOrbnumFileError as e:
...     print(e)
'Old orbnum file loaded.'