Data Structures

PyTPM wraps many of the C structures in TPM as Python classes, using Cython extension types or cdef classes.

Note that these are only useful in the context of their usage in PyTPM. Defining these structures make it easy to call the various TPM C functions from within Python. They are neither complete nor should be used in general handling of dates, times and vectors.

Classes for representing angles

There are two classes for storing angles. DMS for degrees, arc-minutes and arc-seconds, and HMS for hours, minutes and seconds. Objects of these classes can be initialized by passing scalar value of the angle in any of the three formats for representing angles: radians, hours, and degrees.

class pytpm.tpm.DMS

Angle in degrees, arc-minutes and arc-seconds.

A class to represent angle in degrees, arc-minutes and arc-seconds. It can be initialized using angle in other units and can be converted into other units. It can be initialized with angle in radians, r, angle in hours, h, and also using degrees, arc-minutes and arc-seconds of the angle, dd, mm and ss, respectively. If r is given then its value is used, and others are ignored. If h is present, then it is preferred over dd, mm and ss. All of dd, mm and ss are used, if they are present.

Warning

In this class, the negative sign is used for each part of the angle separately. This is different from the usual case in sexagesimal notation where the sign applies to the whole angle. Also, after calling the normalize method the sign gets assigned to the degrees part. Hence this class is not recommended for use outside PyTPM.

Parameters :

r : float, optional

Angle in radians

h : float, optional

Angle in hours.

dd : float, int, optional

Angle in degrees, or the degrees part.

mm : float, int, optional

Angle in arc-minutes or the arc-minutes part of angle.

ss : float, int, optional

Angle in arc-seconds or the arc-seconds part of angle.

Attributes

dd Degrees.
mm Minutes of arc.
ss Seconds of arc.
dd

Degrees.

mm

Minutes of arc.

normalize()

Normalize components.

Normalizes the arc-minutes and arc-seconds of the angle into the proper range. Note that after normalize the sign of the angle applies to the degrees part alone, and not to the whole angle.

Don’t use this class outside of PyTPM.

Examples

>>> from pytpm import tpm
>>> dms = tpm.DMS(dd=-1.23)
>>> dms.dd, dms.mm, dms.ss
(-1.23, 0.0, 0.0)
>>> print dms
-01D 13' 47.999"
>>> dms.normalize()
>>> dms.dd, dms.mm, dms.ss
(-2.0, 46.0, 12.00000000000017)

Note that in the above case if we were to do dms.dd=-1.0, dms.mm=13 and dms.ss=48, we would get different results.

>>> dms.dd = -1
>>> dms.mm = 46.0
>>> dms.ss = 12.0
>>> print dms
--> print(dms)
-00D 13' 48.000"
ss

Seconds of arc.

to_degrees()

Return angle in decimal degrees.

Angle in degrees, arc-minutes and arc-seconds is converted into decimal degrees.

Returns :

dd : float

Angle in degrees.

to_hms()

Convert to an HMS object.

Returns a tpm.HMS class containing the angle in this instance converted into hours, minutes and seconds.

Returns :

hms : tpm.HMS

A tpm.HMS object.

to_hours()

Return angle in decimal hours.

Angle in degrees, arc-minutes and arc-seconds is converted into hours.

Returns :

hh : float

Angle in hours.

to_radians()

Return angle in radians.

Angle in degrees, arc-minutes and arc-seconds is converted into radians.

Returns :

r : float

Angle in radians.

class pytpm.tpm.HMS

Angle (or time) in hours, minutes and seconds.

This can be initialized using angles in radians, r, degrees dd, and directly providing hours, hh, minutes mm and seconds ss. The keyword used in initialization is the first keyword in the following order of precedence: r, dd and then zero or more of hh, mm and ss.

Parameters :

r : float, optional

Angle in radians

dd : float, optional

Angle in degrees.

hh : float, int, optional

Angle in hours, or the hours part.

mm : float, int, optional

Angle in minutes or the minutes part of angle.

ss : float, int, optional

Angle in seconds or the seconds part of angle.

Attributes

hh Hours.
mm Minutes.
ss Seconds.
hh

Hours.

mm

Minutes.

normalize()

Normalize components.

Normalizes the angle so that hours and minutes part are integer valued and the fractional part gets assigned to seconds. Similar to the case of DMS, the negative sign gets assigned to the hours part.

Examples

>>> from pytpm import tpm
>>> h = tpm.HMS()
>>> h.hh = 12.34
>>> h.mm = 1.3
>>> h.ss = 61.4
>>> h
{'mm': 1.3, 'ss': 61.399999999999999, 'hh': 12.34}
>>> h.normalize()
>>> h
{'mm': 22.0, 'ss': 43.400000000001455, 'hh': 12.0}
>>> h.hh = -12.34
>>> h
{'mm': 22.0, 'ss': 43.400000000001455, 'hh': -12.34}
>>> h.normalize()
>>> h
{'mm': 2.0, 'ss': 19.400000000001967, 'hh': -12.0}
ss

Seconds.

to_degrees()

Convert HMS into decimal degrees.

Angle in hours, minutes and seconds is converted into degrees.

Returns :

d : float

Angle in degrees.

to_dms()

Convert to a DMS object.

Returns a tpm.DMS class containing the angle/time in this instance converted into degrees, arc-minutes, and arc-seconds.

Returns :

dms : tpm.DMS

A tpm.DMS object.

to_hours()

Convert time into hours.

Angle in hours, minutes and seconds is converted into hours.

Returns :

h : float

Angle in hours.

to_radians()

Convert HMS into radians.

Angle in hours, minutes and seconds is converted into radians.

Returns :

r : float

Angle in radians.

Classes for storing time and date-time

The class YMD can be used to store a Gregorian calendar date and time, where as the class JD can be used to store a Julian date. As noted before the HMS structure can be used to store time in hours, minutes and seconds.

class pytpm.tpm.YMD

Class for representing data-time.

Date and time is represented using (year, month, day, hours, minutes and seconds) in the Gregorian calendar. This can be initialized in several ways. If j is present then other are ignored. If j is not present then preference is given to year, and jdd in that order. If none of these are present then zero or more of the remaining arguments are used.

Parameters :

j : float, optional

Julian date. The calendar date-time will be calculated from this.

year : float, optional

Year with fractional part.

ydd : 2-element tuple of floats, optional

Year and day of the year. Year is in the Gregorian calendar.

y : int, optional

Year.

m : int, optional

Month.

dd : float, optional

Day, which can have a fractional part.

hh : float, optional

Hour of the day.

mm : float, optional

Minute.

ss : float, optional

Second.

Attributes

y Year as an integer.
m Month as an integer.
dd Day as a float.
hh Hours as a float.
mm Minutes as a float.
ss Seconds as a float.
dd

Day as a float.

doy()

Day of the year corresponding to the date-time.

Returns :

doy : float

Day of the year.

Examples

>>> tpm.YMD(y=2000,m=1,dd=1,hh=12.0).doy()
1.5
>>> tpm.YMD(y=2000,m=1,dd=1,hh=12.5).doy()
1.5208333334885538
hh

Hours as a float.

m

Month as an integer.

mm

Minutes as a float.

normalize()

Normalize YMD.

The components y, m, dd, hh, mm and ss are normalized into their proper ranges.

Examples

>>> ymd = tpm.YMD(y=2010,m=3,dd=12.5,hh=12.25)
>>> ymd
{'mm': 0.0, 'dd': 12.5, 'm': 3, 'ss': 0.0, 'hh': 12.25, 'y': 2010}
>>> ymd.normalize()
>>> ymd
{'mm': 14.0, 'dd': 13.0, 'm': 3, 'ss': 59.999986588954926, 'hh': 0.0, 'y': 2010}
raw_str()

A string representation in the ‘raw’ format.

Returns :

s : str

A “raw” representation of the Calendar date-time.

Examples

>>> tpm.YMD(y=2000,m=1,dd=1,hh=12.0).raw_str()
'2000 1 1 12 0 0'
>>> tpm.YMD(y=2000,m=6,dd=1.34,hh=12.0,mm=12.678).raw_str()
'2000 6 1.34 12 12.678 0'

Printing or converting to str gives a nicely formatted string representation.

>>> ymd = tpm.YMD(y=2000,m=1,dd=1,hh=12.0)
>>> print ymd
--> print(ymd)
Sat Jan  1 12:00:00.000 2000
>>> str(ymd)
'Sat Jan  1 12:00:00.000 2000'
ss

Seconds as a float.

to_j()

Convert YMD into scalar Julian date.

Returns :

jd : float

The Julian date corresponding to the Calendar date-time.

Examples

>>> tpm.YMD(y=2000,m=1,dd=1,hh=12.0).to_j()
2451545.0
to_jd()

Convert into a tpm.JD object.

Returns :

jd : tpm.JD

Contains Julian date corresponding to the Calendar date.

Examples

>>> j = tpm.YMD(y=2000,m=1,dd=1,hh=12.0).to_jd()
>>> j
{'mm': 0.0, 'ss': 0.0, 'dd': 2451545.0, 'hh': 0.0}
to_year()

Convert date-time into a year number.

Returns :

year : float

Year number, i.e., year + (day / num. days).

Examples

>>> tpm.YMD(y=2000,m=1,dd=1).to_year()
2000.0027322404371
>>> 2000+(1/366.0)
2000.0027322404371
>>> tpm.YMD(y=2000,m=1,dd=1,hh=12.0).to_year()
2000.0040983606557
>>> 2000+(1/366.0+12/(24.0*366.0))
2000.0040983606557
y

Year as an integer.

class pytpm.tpm.JD

Class for Julian dates, with hours, minutes and seconds.

This class represents a Julian date using a day part and hours, minutes and seconds. This can be initialized using several parameters. If multiple keyword arguments are given then one that gets used is based on this order: j, year and then zero or more of dd, hh, mm and ss.

Parameters :

j : float, optional

Scalar Julian date.

year : float, optional.

Date-time as a year number. This is just (integer_year + day / num_of_days.)

dd : float, optional

Scalar Julian date or scalar Julian day number.

hh : float, optional

Hour of the day.

mm : float, optional

Minute.

ss : float, optional

Second.

Attributes

dd Day as a float.
hh Hours.
mm Minutes.
ss Seconds.
dd

Day as a float.

hh

Hours.

mm

Minutes.

normalize()

Normalize the JD structure.

Normalize the components into their proper ranges and carry the fractional part of the date into seconds.

Examples

>>> j = tpm.JD(j=2451545.1234467)
>>> j
{'mm': 0.0, 'ss': 0.0, 'dd': 2451545.1234467002, 'hh': 0.0}
>>> j.normalize()
>>> j
{'mm': 57.0, 'ss': 45.794894099235535, 'dd': 2451545.0, 'hh': 2.0}
ss

Seconds.

to_j()

Convert JD to a scalar Julian date.

Returns :

j : float

The scalar Julian date.

Examples

>>> jd = tpm.JD(dd=2451545.0, hh=12.0)
>>> jd.to_j()
2451545.5
to_year()

Convert JD into year (Gregorian calendar).

Returns :

y : float

Year with fractional part. This is just (integer_year + day/num_of_days).

Examples

>>> jd = tpm.JD(dd=2451545.0, hh=12.0)
>>> jd.to_year()
2000.0054644808743
>>> 2000+(2/366.0)
2000.0054644808743
to_ymd()

Convert to YMD (Gregorian calendar).

Returns :

ymd : tpm.YMD

The Julian date is converted into Gregorian calendar date and returned as a tpm.YMD object.

Examples

>>> jd = tpm.JD(dd=2451545.0, hh=12.0)
>>> ymd = jd.to_ymd()
>>> ymd
{'mm': 0.0, 'dd': 1.5, 'm': 1, 'ss': 0.0, 'hh': 12.0, 'y': 2000}

Classes for representing vectors

TPM stores and manipulates positions of objects using full length vectors. All calculations are carried out using Cartesian vectors with units of AU for length and AU/day for velocities. In addition to vectors with three components TPM uses, “6-vectors” that store the three position components and the three velocity components. TPM uses spherical vectors while handling user input coordinates, for example positions and proper motions from catalog. Here the units are radians and radians/day.

In PyTPM, these data structures are provided as Python classes; Cython extension types. These are not meant to provide a complete implementation of vectors, but only have those features needed for their use in PyTPM. Just like the classes for angles and dates described above, they should only be used within the context of PyTPM.

There are four vector classes: V3CP, V3SP, V6C and V6S. For the general use of PyTPM, only V6C and V6S are required.

Classes V3CP and V3SP are used for representing a position vector in Cartesian and spherical coordinates, respectively. Both of these are derived from the class V3, which by itself is not very useful.

The class V6C is used for representing a Cartesian 6-vector, and the class V6S is used for representing a spherical 6-vector. Both of these are derived from the class V6, which by itself is not very useful.

There is no class for representing a velocity vector on its own, since I didn’t find any need for it. In fact, the V3CP and V3SP are also not needed, but I have them implemented anyway.

V3CP and V3SP

class pytpm.tpm.V3CP

A V3 Cartesian position vector.

Parameters :

x : float

X coordinate.

y : float

Y coordinate.

z : float

Z coordinate.

Attributes

x X coordinate.
y Y coordinate.
z Z coordinate.
c2s()

Convert Cartesian position vector into spherical vector.

Returns :

v3 : tpm.V3SP

The position in spherical coordinates.

cross()

Return the cross product of two V3CP vectors.

Returns :

x : tpm.V3CP

Cross product of this vector with the given vector.

dot()

Return the dot product of two V3CP vectors.

Returns :

d : float

Dot product of the given vector with this vector.

mod()

Return modulus (length) of the V3CP vector.

Returns :

x : float

Length of the vector.

unit()

Return unit V3CP vector.

Returns :

x : tpm.V3CP

Unit vector in the direction of this vector.

x

X coordinate.

y

Y coordinate.

z

Z coordinate.

class pytpm.tpm.V3SP

A V3 spherical position vector.

Parameters :

r : float

Radial coordinate.

alpha : float

Longitudinal angle in radians.

delta : float

Latitudinal angle in radians.

Notes

The following attributes are also present:

nalpha : alpha normalized to [0, 2π). ndelta : delta normalized to [-π/2, π/2].

Attributes

r Radial coordinate.
alpha Longitudinal coordinate.
delta Latitudinal coordinate.
alpha

Longitudinal coordinate.

cross()

Return the cross product of two V3SP vectors.

Cross product is calculated after converting to Cartesian coordinates.

Returns :

v : tpm.V3SP

Spherical vector.

delta

Latitudinal coordinate.

dot()

Return the dot product of two V3SP vectors.

Dot product is calculated after converting to Cartesian coordinates.

Returns :

d : float

Dot product.

mod()

Return magnitude of radial component R.

Returns :

m : float

Length of the radial component.

nalpha

alpha normalized to [0, 2π).

ndelta

delta normalized to [-π/2, π/2].

r

Radial coordinate.

s2c()

Convert spherical position vector into Cartesian vector.

Returns :

v : tpm.V3CP

Spherical vector converted into Cartesian.

As mentioned above, these are used for representing a position vector in Cartesian and spherical coordinates respectively.

An instance of the V3CP class has the attributes x, y and z which stores the three components. The V3SP class stores the components in r, alpha and delta; alpha is the RA like angle and delta is the DE like angle. It also has attributes nalpha and ndelta that store the angles alpha and delta respectively, scaled to [0 - 2π] and [-π/2 - π/2], respectively.

The values for these components can be supplied at creation time, and can be modified later on.

>>> v3cp = tpm.V3CP(x=1.0)
>>> v3cp.x, v3cp.y, v3cp.z
    (1.0, 0.0, 0.0)
>>> v3cp.y=1
>>> v3cp.x, v3cp.y, v3cp.z
    (1.0, 1.0, 0.0)
>>> v3sp = tpm.V3SP(r=10.0)
>>> v3sp.r, v3sp.alpha, v3sp.delta
    (10.0, 0.0, 0.0)
>>> v3sp.delta = 2.3
>>> v3sp.r, v3sp.alpha, v3sp.delta
    (10.0, 0.0, 2.2999999999999998)

Both these types can be can be converted into a string representation by passing it to str() or unicode(). These will be converted into strings if they are used with the print statement.

>>> print v3sp
--> print(v3sp)
 1.000000000000000e+01  0.000000000000000e+00  2.300000000000000e+00
>>> print v3cp
--> print(v3cp)
 1.000000000000000e+00  1.000000000000000e+00  0.000000000000000e+00

Two V3CP vectors can be added together, subtracted from each other. The method unit() returns the unit vector, where as mod() returns the length of the vector. The method cross() returns the cross product between two V3CP vectors, and the method dot returns the dot product between two V3CP vectors. A V3CP method can also be multiplied with a scalar; all components will get multiplied with the scalar and a new V3CP vector will be returned.

>>> v3cp = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v3cp1 = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v = v3cp + v3cp1
>>> v.x, v.y, v.z
    (2.0, 2.0, 2.0)
>>> v = v3cp - v3cp1
>>> v.x, v.y, v.z
    (0.0, 0.0, 0.0)
>>> v3cp = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v3cp.mod()
    1.7320508075688772
>>> v = v3cp.unit()
>>> v.x, v.y, v.z
    (0.57735026918962584, 0.57735026918962584, 0.57735026918962584)
>>> v3cp = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v3cp1 = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v = v3cp.cross(v3cp1)
>>> v.x, v.y, v.z
    (0.0, 0.0, 0.0)
>>> v3cp.dot(v3cp1)
    3.0
>>> v = v3cp * 3
>>> v.x, v.y, v.z
    (3.0, 3.0, 3.0)

The method c2s() will convert the Cartesian components into spherical and return the results as a V3SP object.

>>> v3cp = tpm.V3CP(x=1.0,y=1.0,z=1.0)
>>> v3sp = v3cp.c2s()
>>> v3sp.r, v3sp.alpha, v3sp.delta
    (1.7320508075688772, 0.78539816339744828, 0.61547970867038726)

A V3SP object, has most of methods as a V3CP object. Most operations are done by first converting into Cartesian and then converting the result back into spherical. It has the s2c() method that will convert the vector into Cartesian coordinates and returns the results as a V3CP object.

V6C

class pytpm.tpm.V6C

Class for Cartesian V6 vector.

Parameters :

x : float

X coordinate.

y : float

Y coordinate.

z : float

Z coordinate.

xdot : float

Rate of change of x.

ydot : float

Rate of change of y.

zdot : float

Rate of change of z.

Attributes

x X coordinate.
y Y coordinate.
z Z coordinate.
xdot Rate of change of X coordinate.
ydot Rate of change of Y coordinate.
zdot Rate of change of Z coordinate.
c2s()

Cartesian to spherical conversion.

Returns :

v : tpm.V6S

The spherical equivalent of this vector.

cross()

Cross product of the position components.

The velocity component of the resulting V6 vector is set to 0.

Returns :

v : tpm.V6C

A V6C vector with position component set to the cross product of the position component of this vector and the given vector. The velocity component is set ot 0.

dot()

Dot product of the position components.

Returns :

x : float

The dot product of the position component of this vector with that of the given vector.

mod()

Return modulus of position component of V6C vector.

Returns :

x : float

The length of the position component.

pos

The position component.

scale()

Return V6C with components scaled by the given factor.

Returns :

v : tpm.V6C

A vector with components set to those in this vector multiplied by the given x.

unit()

Return V6C with unit position and scaled velocity components.

The velocity component is scaled by inverse of length of the position component.

Returns :

v : tpm.V6C

A V6C vector.

v62v3()

Convert V6C into V3CP by addding space motion.

The positon component is increment by the product of space motion and given number of days, dt.

Returns :

v : tpm.V6CP

The position vector at the end of time dt.

x

X coordinate.

xdot

Rate of change of X coordinate.

y

Y coordinate.

ydot

Rate of change of Y coordinate.

z

Z coordinate.

zdot

Rate of change of Z coordinate.

This class is used for representing a Cartesian 6-vector and has 6 important attributes: x, y, z, xdot, ydot and zdot. Each of these stand for the position and velocity components. These can be assigned values at creation time by passing keyword arguments. Their values can be modified after creation.

>>> v6c = tpm.V6C(x=1.0)
>>> v6c.x
    1.0
>>> v6c.y
    0.0
>>> v6c.z=100.0
>>> v6c.ydot=-10.94
>>> v6c.x, v6c.y, v6c.z, v6c.xdot, v6c.ydot, v6c.zdot
    (1.0, 0.0, 100.0, 0.0, -10.94, 0.0)

We can add and subtract two V6C vectors: the corresponding coordinate components are added and subtracted.

>>> v6c1 = tpm.V6C(x=10,y=9,z=8,xdot=-1.0,ydot=3.0,zdot=-12.345)
>>> v6c2 = tpm.V6C(x=10,y=7,z=3,xdot=-6.0,ydot=-3.0,zdot=1)
>>> v6c = v6c1 + v6c2
>>> v6c.x, v6c.y, v6c.z, v6c.xdot, v6c.ydot, v6c.zdot
    (20.0, 16.0, 11.0, -7.0, 0.0, -11.345000000000001)
>>> v6c = v6c1 - v6c2
>>> v6c.x, v6c.y, v6c.z, v6c.xdot, v6c.ydot, v6c.zdot
    (0.0, 2.0, 5.0, 5.0, 6.0, -13.345000000000001)

The length of the position component in a V6C vector can be calculated using the mod() method.

>>> v6c = tpm.V6C(x=3.0,y=3.0,z=3.0)
>>> v6c.mod()
    5.196152422706632
>>> v6c.mod()**2
    27.0

The method unit() will return another V6C vector, containing the unit vector of the position component and with the velocity components scaled with reciprocal of length of the position component.

>>> v6c = tpm.V6C(x=3.0,y=3.0,z=3.0,xdot=1.0,ydot=1.0,zdot=1.0)
>>> v6cu = v6c.unit()
>>> v6cu.x, v6cu.y, v6cu.z, v6cu.xdot, v6cu.ydot, v6cu.zdot
(0.57735026918962573,
 0.57735026918962573,
 0.57735026918962573,
 0.19245008972987526,
 0.19245008972987526,
 0.19245008972987526)
>>> 1.0/v6c.mod()
    0.19245008972987526
>>> 3.0/v6c.mod()
    0.57735026918962573

The method scale() will multiply all components with the given number and return a new V6C vector with the components set to the results.

>>> v6c = tpm.V6C(x=3.0,y=3.0,z=3.0,xdot=1.0,ydot=1.0,zdot=1.0)
>>> v6c = v6c.scale(10.0)
>>> v6c.x, v6c.y, v6c.z, v6c.xdot, v6c.ydot, v6c.zdot
    (30.0, 30.0, 30.0, 10.0, 10.0, 10.0)

The method v62v3(), multiply the velocity components with the given scalar, adds them to the corresponding position component and returns the result as a V3CP vector. That is, it applies space motion to the given V6C position component.

>>> v6c = tpm.V6C(x=3.0,y=3.0,z=3.0,xdot=1.0,ydot=1.0,zdot=1.0)
>>> v3cp = v6c.v62v3(2.0)
>>> v3cp.x, v3cp.y, v3cp.z
    (5.0, 5.0, 5.0)

The methods dot() and cross() perform scalar and vector product between the two vectors. In the latter case, the velocity components of the resulting vector is set to 0.0

>>> v6c1 = tpm.V6C(x=10,y=9,z=8,xdot=-1.0,ydot=3.0,zdot=-12.345)
>>> v6c2 = tpm.V6C(x=10,y=7,z=3,xdot=-6.0,ydot=-3.0,zdot=1)
>>> v6c1.dot(v6c2)
    187.0
>>> v6c = v6c1.cross(v6c2)
>>> v6c.x, v6c.y, v6c.z, v6c.xdot, v6c.ydot, v6c.zdot
    (-29.0, 50.0, -20.0, 0.0, 0.0, 0.0)

The method c2s() converts the 6-vector into spherical coordinates and returns the result as a V6S vector. This is the method that will be used often, while using the PyTPM library. All calculations in PyTPM are done in Cartesian coordinates but the final result is most often needed in spherical coordinates, for example RA and DE.

>>> v6c = tpm.V6C(x=1.0,y=1.0,z=1.0,xdot=1,ydot=1,zdot=1.0)
>>> v6s = v6c.c2s()
>>> v6s.r, v6s.alpha, v6s.delta, v6s.rdot, v6s.alphadot, v6s.deltadot
(1.7320508075688772,
 0.78539816339744828,
 0.61547970867038726,
 1.7320508075688774,
 0.0,
 -8.739772475095232e-18)

V6S

class pytpm.tpm.V6S

Class for spherical V6 vector.

Parameters :

r : float

Radial coordinate.

alpha : float

Longitudinal angle.

delta : float

Latitudinal angle.

rdot : float

Rate of change in r.

alphadot : float

Rate of change in alpha.

deltadot : float

Rate of change in delta.

Notes

The following attributes are also present:

nalpha : alpha normalized to [0, 2π). ndelta : delta normalized to [-π/2, π/2].

Attributes

r R coordinate.
alpha ALPHA coordinate.
delta DELTA coordinate.
rdot Rate of change of R coordinate.
alphadot Rate of change of ALPHA coordinate.
deltadot Rate of change of DELTA coordinate.
alpha

ALPHA coordinate.

alphadot

Rate of change of ALPHA coordinate.

delta

DELTA coordinate.

deltadot

Rate of change of DELTA coordinate.

nalpha

alpha normalized to [0, 2π).

ndelta

delta normalized to [-π/2, π/2].

r

R coordinate.

rdot

Rate of change of R coordinate.

s2c()

Spherical to Cartesian.

Returns :

v : tpm.V6C

The Cartesian equivalent of this vector.

The V6S class holds a 6-vector in spherical coordinates. The components are stored in the attributes r, alpha, delta, rdot, alphadot, and deltadot. Here alpha is the RA like angle and delta is the DE like angle. These properties can be set at creation time and can be modified later on. The angles are in radians.

>>> v6s = tpm.V6S(r=1e9,alpha=2.3, delta=3.5)
>>> v6s.r, v6s.alpha, v6s.delta, v6s.rdot, v6s.alphadot, v6s.deltadot
    (1000000000.0, 2.2999999999999998, 3.5, 0.0, 0.0, 0.0)
>>> v6s.r = 1.0
>>> v6s.r, v6s.alpha, v6s.delta, v6s.rdot, v6s.alphadot, v6s.deltadot
    (1.0, 2.2999999999999998, 3.5, 0.0, 0.0, 0.0)

The attributes nalpha and ndelta gives normalized values of alpha and delta respectively. The first gives a value between 0 and 2π, while the latter gives a value between -π/2 and π/2.

>>> tpm.M_PI
    3.1415926535897931
>>> v6s.alpha = tpm.M_PI*3
>>> v6s.nalpha
    3.1415926535897931
>>> v6s.delta = -tpm.M_PI
>>> v6s.ndelta
    0.0

Since a V6S vector is only used for converting catalog data into Cartesian coordinates, and vice-versa, this vector has only one method: s2c. The method converts the vector into Cartesian coordinates and returns a V6C vector.

>>> tpm.M_PI
    3.1415926535897931
>>> v6s = tpm.V6S(r=1.0,alpha=tpm.M_PI/4.0,delta=tpm.M_PI/3.0)
>>> v6c = v6s.s2c()
>>> v6c.x, v6c.y, v6c.z
    (0.35355339059327384, 0.35355339059327379, 0.8660254037844386)
>>> v6c.xdot, v6c.ydot, v6c.zdot
    (0.0, 0.0, 0.0)

TSTATE

class pytpm.tpm.TSTATE

Class corresponding to TPM TSTATE structure.

The class stores all 30 quantities needed to define a state in TPM. These quantities are accessible as attributes of an object. The 12 independent attributes are read-write and the 18 dependent attributes are read-only.

Parameters :

utc : float

The “current time” as a Julian date (UTC).

delta_at : float

TAI - UTC in seconds.

delta_ut : float

UT1 - UTC in seconds.

lon : float

Longitude of an observer in radians. Eastern longitudes are positive.

lat : float

Latitude of an observer in radians. Northern latitide are positive.

alt : float

Altitude of an observer in meters.

xpole : float

Polar motion in radians.

ypole : float

Polar motion in radians.

T : float

Temperature in Kelvins.

P : float

Pressure in milli-bars.

H : float

Ambient humidity [0-1].

wavelength : float

Wavelength of observation in microns.

Attributes

utc UTC as JD. Defines NOW, i.e., current time.
delta_at DELTA_AT = TAI - UTC (s)
delta_ut DELTA_UT = UT1 - UTC (s)
lon East longitude in radians.
lat Latitude in radians.
alt Altitude above geoid in meters.
xpole Polar motion in radians.
ypole Polar motion in radians.
T Ambient temperature in Kelvins.
P Ambient pressure in millibars.
H Ambient humidity (0-1).
wavelength Observing wavelength in microns.
tai International Atomic Time.
tdt Terrestrial Dynamic Time (Terrestrial Time).
tdb Barycentric Dynamic Time.
obliquity Obliquity of the Ecliptic.
nut_lon Nutation in longitude.
nut_obl Nutation in obliquity.
nm Nutation matrix for NOW.
pm Precession matrix from J2000 to NOW.
ut1 Universal time.
gmst Greewich Mean Sidereal Time.
gast Greewich Apparent Sidereal Time.
last Local Apparent Sidereal Time.
eb Barycentric Earth state vector.
eh Heliocentric Earth state vector.
obs_m Geocentric Earth-fixed mean state vector.
obs_t Geocentric Earth-fixed true state vector.
obs_s Geocentric space-fixed true state vector.
refa Refraction coefficient.
refb Refraction coefficient.
H

Ambient humidity (0-1).

P

Ambient pressure in millibars.

T

Ambient temperature in Kelvins.

alt

Altitude above geoid in meters.

delta_at

DELTA_AT = TAI - UTC (s)

delta_ut

DELTA_UT = UT1 - UTC (s)

eb

Barycentric Earth state vector.

eh

Heliocentric Earth state vector.

gast

Greewich Apparent Sidereal Time.

gmst

Greewich Mean Sidereal Time.

last

Local Apparent Sidereal Time.

lat

Latitude in radians.

lon

East longitude in radians.

nm

Nutation matrix for NOW.

nut_lon

Nutation in longitude.

nut_obl

Nutation in obliquity.

obliquity

Obliquity of the Ecliptic.

obs_m

Geocentric Earth-fixed mean state vector.

obs_s

Geocentric space-fixed true state vector.

obs_t

Geocentric Earth-fixed true state vector.

pm

Precession matrix from J2000 to NOW.

refa

Refraction coefficient.

refb

Refraction coefficient.

tai

International Atomic Time.

tdb

Barycentric Dynamic Time.

tdt

Terrestrial Dynamic Time (Terrestrial Time).

ut1

Universal time.

utc

UTC as JD. Defines NOW, i.e., current time.

wavelength

Observing wavelength in microns.

xpole

Polar motion in radians.

ypole

Polar motion in radians.

A TSTATE object is used to store the “state data” in PyTPM. This is equivalent to the TPM_TSTATE structure in TPM. The reason I implemented this class was so that I can call the tpm_data() and tpm() functions from within Python. This object does not have any useful methods, but only has attributes corresponding to the 32 parameters that define a state. Of these the independent parameters are read-write, where as the dependent parameters are read only. The latter can be calculated, as in TPM, by passing the object to tpm_data() along with the type of calculation.

PVEC

class pytpm.tpm.PVEC

Class for holding N_TPM_STATES element array of V6 vectors.

This is a list like object with valid indexes from 0 to 21. Each index represents the state having the same number. Each index location stores a V6C vector corresponding to that state.

TPM needs an array of V6 structures, where it will store the initial, intermediate and final results, while performing coordinate transformations. In PyTPM, I have decided to implement a class that can be treated as an array of V6CP object. This is much more flexible and robust than dealing with a simple list of V6CP objects. This object can be passed, along with other information, to tpm() when performing coordinate transformations.

An index location corresponds to the appropriate TPM state. For example, the index location 6, i.e., pvec[6], corresponds to the state TPM_S06, and pvec[4] corresponds to TPM_S04.

So while performing FK5 epoch and equinox J2000 to Galactic conversion, we would insert our input V6CP vector at index location 6 and retrieve the result from index location 4.

A full example is shown here.