geodezyx.conv package
Submodules
geodezyx.conv.conv_angle module
Created on Thu Aug 13 15:11:12 2020
@author: psakic
This sub-module of geodezyx.conv deals with angle conversion.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_angle.angle2equivalent_earth_parallel(angle_in, latitude_in, angtype='deg', earth_radius=6371008.8)
Quick and simple function which gives the equivalent distance on a Earth parallel circle of an angle
Useful to determine metric varaitions in longitude (but the latitude is also necessary to determine
the radius of the parallel)
angle can be : “deg”, “rad”, “mas”
- geodezyx.conv.conv_angle.angle2equivalent_earth_radius(angle_in, angtype='deg', earth_radius=6371008.8)
Quick and simple function which gives the equivalent distance on a spherical Earth great circle of an angle
Useful to determine metric varations in latitude
angle can be : “deg”, “rad”, “mas”
- geodezyx.conv.conv_angle.angle_from_3_pts(p1, p2, p3)
Gives angle between 3 points p3 is the vertex (sommet)
References
http://www.les-mathematiques.net/phorum/read.php?8,596072,596231
- geodezyx.conv.conv_angle.angle_interpolation_quick(A, B, w)
Determine the interpolation between angle A & B by conversion to the cartesian space the parameter w € [0,1] define the interpoled angle C(w) where C(w=0) = A & C(w=1) = B
References
https://stackoverflow.com/questions/2708476/rotation-interpolation
- geodezyx.conv.conv_angle.anglesfromvects(xa, ya, xb, yb, angtype='deg')
Determines the angle between the points A(xa,ya) and B(xb,yb)
angle can be : “deg”, “rad”
- geodezyx.conv.conv_angle.arcsec2deg(arcsec_in)
Angle conversion
Convert : Arcsecond => Degrees
NB : Not really useful, should be avoided
- geodezyx.conv.conv_angle.cartesian2polar(x, y)
Coordinates conversion
cartesian => polar conversion
- Parameters:
x (numpy.array of float) – cartesian coordinates
y (numpy.array of float) – cartesian coordinates
- Returns:
r , theta – polar coordinates (radius / angle in radians)
- Return type:
float
- geodezyx.conv.conv_angle.deg2arcsec(deg_in)
Angle conversion
Convert : Degrees => Arcsecond
NB : Not really useful, should be avoided
- geodezyx.conv.conv_angle.deg_dec2dms(deg_in, only_dm=False)
- geodezyx.conv.conv_angle.degdec2dms(deg_in, only_dm=False)
Angle conversion
Convert : Decimal Degree => Degree Minute Seconds
- Parameters:
deg_in (float or iterable of floats) – Decimal degrees
- Returns:
deg , minu , sec – 3 arrays for Degrees, Minutes, Seconds
- Return type:
numpy.array of float
- geodezyx.conv.conv_angle.dms2dec(dms_str, onlyDM=False)
- geodezyx.conv.conv_angle.dms2dec_num(deg, minn=0, sec=0)
- geodezyx.conv.conv_angle.dms2degdec_num(deg, minn=0, sec=0)
Angle conversion
Convert : Degree Minute Second float Angle => decimal Degree float Angle
- Parameters:
sec (deg & minn &) – degres, minutes and seconds of the input Angle
- Returns:
dd_float – Decimal degree Angle
- Return type:
float
- geodezyx.conv.conv_angle.dms2degdec_str(dms_str, onlyDM=False)
Angle conversion
Convert : Degree Minute Second string Angle => decimal Degree float Angle
can manage only DM angle in input
NB : Too Complicated …. must be simplified
- Parameters:
dms_str (str) – string of DMS angle e.g. “2°20’35.09”E”
onlyDM (bool) – True if the string is only a Degree Minute Angle e.g. “40°52.0931’N” “28°31.4136’E”
- Returns:
dd_float – Decimal degree Angle
- Return type:
float
- geodezyx.conv.conv_angle.polar2cartesian(r, theta, ang='deg')
Coordinates conversion
polar => cartesian conversion
- Parameters:
r (float or iterable of floats) – polar coordinates
theta (float or iterable of floats) – polar coordinates
ang (string) – ‘deg’ (degrees) or ‘rad’ (radian)
- Returns:
x , y – cartesian coordinates
- Return type:
numpy.array of float
geodezyx.conv.conv_coords module
Created on Thu Aug 13 15:11:12 2020
@author: psakic
This sub-module of geodezyx.conv deals with coordinate conversion.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_coords.ECEF2ECI(xyz, utc_times)
Convert ECEF (Earth Centered Earth Fixed) positions to ECI (Earth Centered Inertial) positions
- Parameters:
xyz (numpy.array of floats) – XYZ are cartesian positions in ECEF. Should have shape (N,3)
utc_times (numpy.array of floats) – UTC_times are UTC timestamps, as datetime objects. Sould have shape (N)
- Returns:
eci – Earth Centered Inertial coordinates. will have shape (N,3)
- Return type:
numpy.array of floats
Note
Requires pyorbital module
[X] [C -S 0][X] [Y] = [S C 0][Y] [Z]eci [0 0 1][Z]ecf
C and S are cos() and sin() of gmst (Greenwich Meridian Sideral Time)
References
http://ccar.colorado.edu/ASEN5070/handouts/coordsys.doc Inspired from satellite-js (https://github.com/shashwatak/satellite-js)
- geodezyx.conv.conv_coords.ECI2ECEF(xyz, utc_times)
Convert ECI (Earth Centered Inertial) positions to ECEF (Earth Centered Earth Fixed) positions
- Parameters:
xyz (numpy.array of floats) – XYZ are cartesian positions in Earth Centered Inertial. Should have shape (N,3)
utc_times (numpy.array of floats) – UTC_times are UTC timestamps, as datetime objects. Sould have shape (N)
- Returns:
ecef – Earth Centered Earth Fixed coordinates. will have shape (N,3)
- Return type:
numpy.array of floats
Note
Requires pyorbital module
[X] ([C -S 0])[X] [Y] = inv([S C 0])[Y] [Z]ecef ([0 0 1])[Z]eci
- Empirically:
[X] [ C S 0][X] [Y] = [-S C 0][Y] [Z]ecef [ 0 0 1][Z]eci
C and S are cos() and sin() of gmst (Greenwich Meridian Sideral Time)
References
http://ccar.colorado.edu/ASEN5070/handouts/coordsys.doc Inspired from satellite-js (https://github.com/shashwatak/satellite-js)
Note
Quick mode of the reverse fct, can be improved
- geodezyx.conv.conv_coords.ECI2RTN(P, V, C)
legacy wrapper of ECI2RTN_or_RPY
- geodezyx.conv.conv_coords.ECI2RTN_or_RPY(P, V, C, out_rpy=False, rpy_theo_mode=False)
convert ECI coordinates in RTN (RIC) or RPY (Roll Pitch Yaw)
- Parameters:
P (numpy.array) – 3D vector, position of the ref object in ECI frame
V (numpy.array) – 3D vector, velocity of the ref object in ECI frame
C (numpy.array) – 3D Vector, coordinates in ECF frame that will be transformed
out_rpy (bool) – if True output in RPY frame, RTN instead
rpy_theo_mode (bool) – use the theoretical matrix composition, but wrong ans. empirically, only for debug !!
- Returns:
Cout
- Return type:
conversion of P in RTN or RPY ref. frame
References
“Coordinate Systems”, ASEN 3200 1/24/06 George H. Born
- geodezyx.conv.conv_coords.ENU2XYZ(E, N, U, x0, y0, z0, velocity_mode=False)
Coordinates conversion
ENU Topocentic => XYZ ECEF Geocentric
- Parameters:
E (numpy.array of floats) – cartesian coordinates E,N,U in meters
N (numpy.array of floats) – cartesian coordinates E,N,U in meters
U (numpy.array of floats) – cartesian coordinates E,N,U in meters
x0 (floats or numpy.array of floats) – coordinate of the topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as E,N,U) a different x0,y0,z0 will be applied for each E,N,U element
y0 (floats or numpy.array of floats) – coordinate of the topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as E,N,U) a different x0,y0,z0 will be applied for each E,N,U element
z0 (floats or numpy.array of floats) – coordinate of the topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as E,N,U) a different x0,y0,z0 will be applied for each E,N,U element
velocity_mode (bool) – For the Velocity mode, coordinates of the topocentric origin point are NOT added at the end of the conversion Default is False
- Returns:
X,Y,Z – ECEF X,Y,Z Component (m)
- Return type:
numpy.array of floats
References
https://gssc.esa.int/navipedia/index.php/Transformations_between_ECEF_and_ENU_coordinates
- geodezyx.conv.conv_coords.ENU2XYZ_legacy(E, N, U, Xref, Yref, Zref)
KEPT FOR LEGACY REASONS, use ENU2XYZ
diffère de ENU2XYZ pour d’obscure raisons, à investiguer !!! est laissé pour des scripts de conversion de GINS (170119)
this fct compute the dXYZ and not the final XYZ
- geodezyx.conv.conv_coords.ENU2XYZ_vector(ENU, xyz_ref)
- geodezyx.conv.conv_coords.GEO2XYZ(phi, llambda, he, angle='deg', a=6378137.0, e2=0.00669438003)
Coordinates conversion
FLH Geographic => XYZ ECEF Cartesian
- Parameters:
phi (numpy.array of floats) – latitude (deg/rad), longitude (deg/rad), height (m)
llambda (numpy.array of floats) – latitude (deg/rad), longitude (deg/rad), height (m)
he (numpy.array of floats) – latitude (deg/rad), longitude (deg/rad), height (m)
angle (string) – describe the angle input type : ‘deg’ or ‘rad’
a (floats) – ellipsoid parameters (WGS84 per default)
e2 (floats) – ellipsoid parameters (WGS84 per default)
- Returns:
X,Y,Z – cartesian coordinates X,Y,Z in meters
- Return type:
numpy.array of floats
References
Based on PYACS of J.-M. Nocquet
- geodezyx.conv.conv_coords.GEO2XYZ_vector(FLH, angle='deg', a=6378137.0, e2=0.00669438003)
- geodezyx.conv.conv_coords.XYZ2ENU(dX, dY, dZ, lat0, lon0)
Coordinates conversion
XYZ ECEF Geocentric => ENU Topocentic
use XYZ2ENU_2 in priority
(XYZ2ENU is a core function for XYZ2ENU_2)
dXYZ = XYZrover - XYZref
- Parameters:
dX (floats or numpy.array of floats) – cartesian coordinates difference between the considered point(s) and the reference point
dY (floats or numpy.array of floats) – cartesian coordinates difference between the considered point(s) and the reference point
dZ (floats or numpy.array of floats) – cartesian coordinates difference between the considered point(s) and the reference point
lat0 (floats or numpy.array of floats) – if they are iterable arrays (of the same size as dX,dY,dZ) a different x0,y0,z0 will be applied for each dX,dY,dZ element
lon0 (floats or numpy.array of floats) – if they are iterable arrays (of the same size as dX,dY,dZ) a different x0,y0,z0 will be applied for each dX,dY,dZ element
- Returns:
E,N,U – East North Up Component (m) w.r.t. x0,y0,z0
- Return type:
numpy.array of floats
References
https://gssc.esa.int/navipedia/index.php/Transformations_between_ECEF_and_ENU_coordinates
Note
This recursive fuction should be improved
- geodezyx.conv.conv_coords.XYZ2ENU_2(X, Y, Z, x0, y0, z0)
Coordinates conversion
XYZ ECEF Geocentric => ENU Topocentic
- Parameters:
X (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
Y (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
Z (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
x0 (floats or numpy.array of floats) – coordinate of the wished topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as X,Y,Z) a different x0,y0,z0 will be applied for each X,Y,Z element
y0 (floats or numpy.array of floats) – coordinate of the wished topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as X,Y,Z) a different x0,y0,z0 will be applied for each X,Y,Z element
z0 (floats or numpy.array of floats) – coordinate of the wished topocentric origin point in the geocentric frame if they are iterable arrays (of the same size as X,Y,Z) a different x0,y0,z0 will be applied for each X,Y,Z element
- Returns:
E,N,U – East North Up Component (m) w.r.t. x0,y0,z0
- Return type:
numpy.array of floats
References
https://gssc.esa.int/navipedia/index.php/Transformations_between_ECEF_and_ENU_coordinates
- geodezyx.conv.conv_coords.XYZ2ENU_around_fix_pos(X, Y, Z)
Computes the mean of the X,Y,Z and return the topocentric ENU position around its mean position
- Parameters:
X (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
Y (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
Z (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
- Returns:
E,N,U (numpy.array of floats) – East North Up Component (m) w.r.t. the mean position
x0 , y0 , z0 (floats) – coordinates of the mean position in the geocentic frame
- geodezyx.conv.conv_coords.XYZ2ENU_vector(XYZ, xyz0)
- geodezyx.conv.conv_coords.XYZ2GEO(x, y, z, outdeg=True, A=6378137.0, E2=0.00669438003)
Coordinates conversion
XYZ ECEF Cartesian => FLH Geographic
- Parameters:
x (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
y (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
z (numpy.array of floats) – cartesian coordinates X,Y,Z in meters
outdeg (bool) – if True, degrees output for the angle, else radian
A (floats) – ellipsoid parameters (WGS84 per default)
E2 (floats) – ellipsoid parameters (WGS84 per default)
- Returns:
latitude, longitude, height – latitude (deg/rad), longitude (deg/rad), height (m)
- Return type:
numpy.array of floats
References
Based on PYACS of J.-M. Nocquet
- geodezyx.conv.conv_coords.XYZ2GEO_vector(XYZ, outdeg=True, A=6378137.0, E2=0.00669438003)
- geodezyx.conv.conv_coords.normal_vector(phi, llambda, angle='deg', normalized=True)
Compute the Ellipsoid “Normale”
References
Bosser (2012), Géométrie de l’Ellipsoïde, p27
- geodezyx.conv.conv_coords.sENU2sFLH(F, L, H, sE, sN, sU, ang='deg', A=6378137.0, E2=0.00669438003)
Convert standard deviation Cartesian Topocentric ENU => Geographic FLH
Warning
Inputs values are assumed as uncorrelated, which is not accurate Must be improved
References
Linear Algebra, Geodesy, and GPS p332
- geodezyx.conv.conv_coords.sFLH2sENU(F, L, H, sF, sL, sH, ang='deg')
Convert standard deviation Geographic FLH => Cartesian Topocentric ENU
Warning
Inputs values are assumed as uncorrelated, which is not accurate Must be improved
References
Linear Algebra, Geodesy, and GPS p332
- geodezyx.conv.conv_coords.sFLH2sXYZ(F, L, H, sF, sL, sH, ang='deg')
Convert standard deviation Geographic FLH => Cartesian ECEF XYZ
Warning
Inputs values are assumed as uncorrelated, which is not accurate Must be improved
References
Linear Algebra, Geodesy, and GPS p332
- geodezyx.conv.conv_coords.sXYZ2sENU(X, Y, Z, sX, sY, sZ, sXY=0, sYZ=0, sXZ=0)
Convert standard deviation Cartesian ECEF XYZ => Cartesian Topocentric ENU
Warning
Inputs values are assumed as uncorrelated, which is not accurate Must be improved
References
Linear Algebra, Geodesy, and GPS p332
- geodezyx.conv.conv_coords.vector_separator(ABC)
Split a Nx3 Array/DataFrame in three separated 1-component vectors To simplify the usage of the conversion functions (which take single component vectors as input)
- Parameters:
ABC (Array or DataFrame) – Nx3 XYZ, ENU… array.
- Returns:
A (Array) – 1st component.
B (Array) – 2nd component.
C (Array) – 3rd component.
- geodezyx.conv.conv_coords.wnorm(phi, a=6378137.0, e2=0.00669438003)
Compute the Ellipsoid “Grande Normale”
References
ALG0021 in NTG_71 (IGN Lambert Projection Tech document) Based on PYACS of J.-M. Nocquet
geodezyx.conv.conv_geometric module
Created on Thu Aug 13 15:11:12 2020
@author: psakicki
This sub-module of geodezyx.conv deals with low-level geometric operation.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_geometric.barycenter(points_list_in)
Determines the barycenter of a list of points
- geodezyx.conv.conv_geometric.dist(A, B)
Cartesian distance between 2 points A & B
- Parameters:
A (numpy.array of float) – 3D-points
B (numpy.array of float) – 3D-points
- Returns:
D – distance between A & B
- Return type:
float
- geodezyx.conv.conv_geometric.dist_diff(A, B)
First derivative of cartesian distance between 2 points A & B
- Parameters:
A (numpy.array of float) – “points”, can be 2D or 3D vectors (list, np.array …)
B (numpy.array of float) – “points”, can be 2D or 3D vectors (list, np.array …)
- Returns:
diffA (numpy.array of float) – [ dD/dxa , dD/dya , dD/dza ]
diffB (numpy.array of float) – [ dD/dxb , dD/dyb , dD/dzb ] = -diffA
- geodezyx.conv.conv_geometric.equilateral_triangle(side)
Gives coordinates of an equilateral triangle of a given side
- geodezyx.conv.conv_geometric.line_maker(x1, y1, x2, y2, nbpts=10000)
Determine points of a line easily
- Parameters:
x1 (float) – Coordinates of the start point
y1 (float) – Coordinates of the start point
x2 (float) – Coordinates of the end point
y2 (float) – Coordinates of the end point
- Returns:
X,Y – points of the line
- Return type:
numpy.array of float
- geodezyx.conv.conv_geometric.orthogonal_projection(Xa, Xb, Xv)
Project a point A on a line defined with a vector V and a point B
- Parameters:
Xa (list/numpy.array of float) – Coordinates of A point, we want to project
Xb (list/numpy.array of float) – Coordinates of B point, the origin point of the vector
Xv (list/numpy.array of float) – Coordinates of the line direction vector
- Returns:
Xh (numpy.array of float) – Coordinates of H point, projection of A
D (float) – Distance between A and H
- geodezyx.conv.conv_geometric.pythagore(a, b, c=0)
Computes Pythagore’s formula
- geodezyx.conv.conv_geometric.relative_orientation(x1, y1, x2, y2, trigo_orient=True)
Return the angle between a point 1 and a point 2 (reference vector : to the right)
- geodezyx.conv.conv_geometric.vincenty_full(point1, point2, miles=False, full=True, azimuth_in_deg=True)
Vincenty’s formula (inverse method) to calculate the distance (in kilometers or miles) between two points on the surface of a spheroid. Gives also the Azimuth between 2 points
- Parameters:
point1 (iterable of float) – coordinates of the points
point2 (iterable of float) – coordinates of the points
miles (bool) – kilometers if True
full (bool) – Description param3
azimuth_in_deg (bool) – azimut in Rad if False
- Returns:
s (float) – Distance betwwen the 2 points
fwdAz,revAz (float) – Forward and Reverse Azimuth between the 2 points
References
https://github.com/maurycyp/vincenty/blob/master/vincenty/
Examples
>>> vincenty((0.0, 0.0), (0.0, 0.0)) # coincident points 0.0 >>> vincenty((0.0, 0.0), (0.0, 1.0)) 111.319491 >>> vincenty((0.0, 0.0), (1.0, 0.0)) 110.574389 >>> vincenty((0.0, 0.0), (0.5, 179.5)) # slow convergence 19936.288579 >>> vincenty((0.0, 0.0), (0.5, 179.7)) # failure to converge >>> boston = (42.3541165, -71.0693514) >>> newyork = (40.7791472, -73.9680804) >>> vincenty(boston, newyork) 298.396057 >>> vincenty(boston, newyork, miles=True) 185.414657
geodezyx.conv.conv_interpolators module
Created on Tue Aug 24 13:58:51 2021
@author: psakicki
- class geodezyx.conv.conv_interpolators.Slerp_time(times, rotations, extrapolate=True)
Bases:
Slerp
Slerp interpolation (for quaterinons) with datetime as inputs
This class inherites from scipy.spatial.transform.Slerp and can take as input datetime as X
Sakic 2020-01
- class geodezyx.conv.conv_interpolators.interp1d_time(x, y, kind='linear', axis=-1, copy=True, bounds_error=None, fill_value=nan, assume_sorted=False)
Bases:
interp1d
Interpolation with datetime as inputs
This class inherites from scipy.interpolate.interp1d and can take as input datetime as X
Pierre Sakic 2020-01
- dtype
geodezyx.conv.conv_proj_lambert module
Created on Thu Aug 13 15:11:12 2020
@author: psakic
This sub-module of geodezyx.conv deals with Lambert/Conform Conic projections.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_proj_lambert.lambert_projection(long, lat, n, c, e, lc, Xs, Ys)
ALG0003 in NTG_71 (IGN Lambert Projection Tech document)
- geodezyx.conv.conv_proj_lambert.lambert_projection_CC_frontend(long, lat, NZ=93)
Project WGS84/ITRF Latitude/Longitude to Lambert Conique Conforme
- Parameters:
long (float) – WGS84/ITRF Longitude/Latitude
lat (float) – WGS84/ITRF Longitude/Latitude
NZ (int) – Lambert93, NZ = 0 or = 93
- Returns:
X,Y (float) – Projected coordinates
Source
——
https (//fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert)
https (//geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/notice/NTG_71.pdf)
https (//geodesie.ign.fr/contenu/fichiers/documentation/rgf93/Lambert-93.pdf)
- geodezyx.conv.conv_proj_lambert.lambert_secante_parameter(a, e, l0, phi0, phi1, phi2, X0, Y0)
ALG0054 in NTG_71 (IGN Lambert Projection Tech document)
- geodezyx.conv.conv_proj_lambert.latitude_isometric(phi, e)
ALG0001 in NTG_71 (IGN Lambert Projection Tech document)
geodezyx.conv.conv_proj_utm module
Created on Wed Jan 25 20:37:05 2023
@author: psakic
This sub-module of geodezyx.conv deals with UTM projections.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_proj_utm.utm_coef(e=None, m=0)
- Projection coefficients
returns a vector of 5 coefficients based on the input parameters
- Parameters:
e (TYPE, optional) – first ellipsoid excentricity. The default is None.
m (int, optional) –
- Describes the expected coefficients.
M = 0 for transverse mercator M = 1 for transverse mercator reverse coefficients M = 2 for merdian arc
The default is 0.
- Returns:
c – Coefficient Matrix.
- Return type:
numpy array
- geodezyx.conv.conv_proj_utm.utm_geo2xy(lat, lon, ellips='wgs84', zone=None)
Latitude/Longitude to Universal Transverse Mercator(UTM) coordinates precise (mm-level) conversion. converts coordinates Latitude/Longitude (in degrees) to UTM X and Y (in meters). Default ellipsoid is WGS84.
- Parameters:
lat (float or numpy array) – Latitude (in degrees).
lon (float or numpy array) – Longitude (in degrees).
ellips (str or 2-tuple, optional) –
uses specific ellipsoid for conversion. ellipsoid can be one of the following strings
’wgs84’: World Geodetic System 1984 (default) ‘nad27’: North American ellips 1927 ‘clk66’: Clarke 1866 ‘nad83’: North American ellips 1983 ‘grs80’: Geodetic Reference System 1980 ‘int24’: International 1924 / Hayford 1909
OR can be a 2-element tuple [A,F] where A is semimajor axis (in meters) F is flattening of the user-defined ellipsoid. The default is “wgs84”.
zone (int, optional) – forces the UTM ZONE (scalar integer or same size as LAT and LON) instead of automatic set. The default is None.
- Returns:
x,y (float or numpy array) – UTM X and Y coordinates (in meters).
f (float or numpy array) – returns also the computed UTM ZONE (negative value for southern hemisphere points).
Notes
It does not perform cross-ellips conversion. Precision is near a millimeter.
This function implements the IGN algorithm. This one is more accurate than pyproj or utm python lib because it implements more coefficients.
Source
Adapted from WebObs source code, François Beauducel et al. https://github.com/IPGP/webobs/blob/master/CODE/matlab/ll2utm.m
I.G.N., Projection cartographique Mercator Transverse: Algorithmes,
Notes Techniques NT/G 76, janvier 1995. https://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/notice/NTG_76.pdf
geodezyx.conv.conv_rinex module
Created on Thu Aug 13 15:11:12 2020
@author: psakicki
This sub-module of geodezyx.conv deals with rinex name handeling conversion.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_rinex.interval_from_rinex_name(rnx_name_inp)
from a RINEX file name (long name) determines the nominal data interval
- Parameters:
rnx_name_inp (str) – long RINEX filename.
- Returns:
interval_ok – nominal data interval in seconds.
- Return type:
int
- geodezyx.conv.conv_rinex.period_from_rinex_name(rnx_name_inp)
from a RINEX file name (long naming) determines the nominal file period
- Parameters:
rnx_name_inp (str) – long RINEX filename.
- Returns:
interval_ok – nominal data interval in seconds.
- Return type:
int
- geodezyx.conv.conv_rinex.rinex_regex(compressed=None, compiled=False)
Return a regex corresponding to a RINEX name (v2 - short convention)
- Parameters:
compressed (bool or None) – return a the regex for a compressed rinex if None, does not matter (return both compressed or not)
- compiledbool
return a Python regex object already compliled
- Returns:
out – a regex
- Return type:
string or python’s regex
- geodezyx.conv.conv_rinex.rinex_regex_long_name(compressed=None, compiled=False)
Return a regex corresponding to a RINEX name (v3/4 - long convention)
- Parameters:
compressed (bool or None) – return a the regex for a compressed rinex if None, does not matter (return both compressed or not)
- compiledbool
return a Python regex object already compliled
- Returns:
out – a regex
- Return type:
string or python’s regex
- geodezyx.conv.conv_rinex.rinex_regex_long_name_brdc(compressed=None, compiled=False)
Return a regex corresponding to a BROADCAST RINEX name (v3/4 - new convention)
- Parameters:
compressed (bool or None) – return a the regex for a compressed rinex if None, does not matter (return both compressed or not)
- compiledbool
return a Python regex object already compliled
- Returns:
out – a regex
- Return type:
string or python’s regex
- geodezyx.conv.conv_rinex.rinex_regex_long_name_gfz_godc(compressed=None, compiled=False)
Return a regex corresponding to a RINEX name (new convention) from the GFZ’s GODC archive (both OBS and NAV types)
- Parameters:
compressed (bool or None) – return a the regex for a compressed rinex if None, does not matter (return both compressed or not)
- compiledbool
return a Python regex object already compliled
- Returns:
out – a regex
- Return type:
string or python’s regex
- geodezyx.conv.conv_rinex.rinex_regex_search_tester(str_in, short_name=True, long_name=True, brdc_long_name=False, gfz_godc_name=False, compressed=None)
Frontend function for a RINEX regex search/match
- Parameters:
str_in (str) – input string. If it is a path, will extract its basename.
short_name (bool, optional) – check if the pattern matches a short name RINEX. The default is True.
long_name (bool, optional) – check if the pattern matches a long name RINEX. The default is True.
brdc_long_name (bool, optional) – check if the pattern matches a brdc long name RINEX. The default is False.
gfz_godc_name (bool, optional) – check if the pattern matches a GFZ’s GODC (GNSS Operational Data Center) internal long name RINEX. The default is False.
compressed (bool or None) – return a the regex for a compressed rinex if None, does not matter (return both compressed or not)
- Returns:
match result.
- Return type:
None or re object
- geodezyx.conv.conv_rinex.rinex_regex_tester()
Returns two list of string to test the efficiency of the RINEX regexs.
true_positive_rnxs is a list of strings describing actual RINEX filenames. They must be matched
false_positive_rnxs is a list of strings describing other filenames. But which have been matched at one moment because of too weak regexs They must NOT be matched
geodezyx.conv.conv_rotation_matrices module
Created on Thu Aug 13 15:11:12 2020
@author: psakicki
This sub-module of geodezyx.conv deals with rotation, implemented with matrices.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_rotation_matrices.C_2D(theta, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_cep2itrs(xpole, ypole)
xpole and ypole are given in mas, miliarcsecond
References
Hofmann-Wellenhof,et al. 2008 - GNSS - p21 Xu - 2007 - GPS - p17 Xu - Orbits - p15
- geodezyx.conv.conv_rotation_matrices.C_ecef2enu(phi, llambda, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_ecef2ned(phi, llambda, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_eci2rtn(P, V)
gives the transformation matrix between ECI ref. frame and RTN (aka RIC or RSW)
- Parameters:
P (numpy.array) – 3D vector, position of the object in ECI frame
V (numpy.array) – 3D vector, velocity of the object in ECI frame
- Returns:
C_eci2rtn – transformation matrix
- Return type:
numpy.array
References
“Coordinate Systems”, ASEN 3200 1/24/06 George H. Born https://www.colorado.edu/ASEN/asen3200/handouts/Coordinate%20System.pdf
- geodezyx.conv.conv_rotation_matrices.C_enu2ecef(phi, llambda, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_enu2ned()
- geodezyx.conv.conv_rotation_matrices.C_euler(phi, theta, psi)
Gives the matrix of an Euler rotation
References
- geodezyx.conv.conv_rotation_matrices.C_ned2ecef(phi, llambda, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_ned2enu()
- geodezyx.conv.conv_rotation_matrices.C_rpy2enu(roll, pitch, yaw, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_rpy2enu2(roll, pitch, yaw, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.C_rtn2rpy()
- geodezyx.conv.conv_rotation_matrices.C_x(theta)
Gives the rotation matrix along the X-axis
Manage iterable (list, array) as input
[1,0, 0] [0,C,-S] [0,S, C]
References
https://fr.wikipedia.org/wiki/Matrice_de_rotation#En_dimension_trois
- geodezyx.conv.conv_rotation_matrices.C_y(theta)
Gives the rotation matrix around the Y-axis
Manage iterable (list, array) as input
[ C,0,S] [ 0,1,0] [-S,0,C]
References
https://fr.wikipedia.org/wiki/Matrice_de_rotation#En_dimension_trois
- geodezyx.conv.conv_rotation_matrices.C_z(theta)
Gives the rotation matrix around the Z-axis
[C,-S,0] [S, C,0] [0, 0,1]
References
https://fr.wikipedia.org/wiki/Matrice_de_rotation#En_dimension_trois
- geodezyx.conv.conv_rotation_matrices.add_offset(Direction, Delta, Point=None, out_delta_enu=False)
Un mode adhoc a du être implémenté dans la fonction élémentaire vector_RPY pour que ça puisse marcher correctement, reste à comprendre pourquoi …
out_delta_enu est prioritaire sur les autres modes de sortie et renvoie le delta
par défaut on a le delta + le vecteur Direction et si Point est précisé : Point + Direction
- geodezyx.conv.conv_rotation_matrices.rot_quelconq(theta, Vx, Vy, Vz, angtype='deg')
- geodezyx.conv.conv_rotation_matrices.vector_RPY(V, out_deg=True, ad_hoc_mode=False)
Donne le “Roll Pitch Yaw” pour un Point/Vecteur (les coordonnées spheriques plus exactement, le roll sera tjrs nul)
le ad_hoc_mode est la pour corriger un bug que je n’explique pas pour l’utilisation de ads_offset (cette methode a été trouvé par les scripts ENURPY2 et ENURPY3)
geodezyx.conv.conv_time module
Created on Thu Aug 13 15:11:12 2020
@author: psakic
This sub-module of geodezyx.conv deals with time conversion.
it can be imported directly with: from geodezyx import conv
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.conv.conv_time.MJD2dt(mjd_in, seconds=None, round_to='1s')
Time representation conversion
Modified Julian Day => Python’s Datetime
- Parameters:
mjd_in (float/int or list/numpy.array of float/int.) – Modified Julian Day. Can handle several float/int in an iterable.
seconds (float/int or list/numpy.array of float/int.) – Handle a number
round_to (str or None) – round the output datetime see round_dt function for details
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
Note
Modified Julian Day starts at 0h Nov 17, 1858 (JD − 2400000.5)
- geodezyx.conv.conv_time.convert_partial_year(number)
DISCONTINUED use year_decimal2dt instead (which is the same)
- geodezyx.conv.conv_time.date2dt(date_in)
Time Python type conversion
Python’s Date => Python’s Datetime
- Parameters:
date_in (date or list/numpy.array of date.) – Date(s). Can handle several dates in an iterable.
- Returns:
L – Time as Datetime(s)
- Return type:
Datetime or list of Datetime
- geodezyx.conv.conv_time.date_string_2_dt(strin)
Time representation conversion
String => Python’s Datetime
Wrapper of dateutil.parser.parse
The input string should looks like a timestamp
- Parameters:
strin (string or list/numpy.array of strings.) – string(s). Can handle several datetimes in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.date_to_jd(year, month, day)
- geodezyx.conv.conv_time.datestr_gins_filename_2_dt(datestrin)
Time representation conversion
GINS filename time format => Python’s Datetime
GINS filename time format : ‘YYMMDD_HHMMSS’
It is the time format used in the listing names
- Parameters:
datestrin (string or list/numpy.array of string.) – GINS filename time format string(s). Can handle several string in an iterable.
- Returns:
dtout – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.datestr_sinex_2_dt(datestrin)
Time representation conversion
SINEX time format => Python’s Datetime
SINEX time format : ‘YY:DDD:SSSSS’ or ‘YYYY:DDD:SSSSS’
- Parameters:
datestrin (string or list/numpy.array of string.) – SINEX time format string(s). Can handle several string in an iterable.
- Returns:
dtout – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.datetime64_numpy2dt(npdt64_in)
Time Python type conversion
Numpy’s datetime64 => Python’s Datetime
This function is depreciated !!!!!
use numpy_dt2dt instead !!!!!
- Parameters:
npdt64_in (datetime64 or list/numpy.array of datetime64.) – Numpy’s datetime64(s). Can handle several datetimes in an iterable.
- Returns:
L (Datetime or list of Datetime) – Time as Datetime(s)
Source
——
https (//stackoverflow.com/questions/13703720/converting-between-datetime-timestamp-and-datetime64)
- geodezyx.conv.conv_time.datetime_improved(*args)
- geodezyx.conv.conv_time.doy2dt(year, days, hours=0, minutes=0, seconds=0)
Time representation conversion
Day of Year Time => Python’s datetime
- Parameters:
year (float or list/numpy.array of floats.) – year, days of year
days (float or list/numpy.array of floats.) – year, days of year
hours (float or list/numpy.array of floats, optional) – hours, minutes, seconds
minutes (float or list/numpy.array of floats, optional) – hours, minutes, seconds
seconds (float or list/numpy.array of floats, optional) – hours, minutes, seconds
- Returns:
L – Datetime(s)
- Return type:
datetime or list/numpy.array of datetime.
- geodezyx.conv.conv_time.dt2MJD(dtin)
Time representation conversion
Python’s Datetime => Modified Julian Day
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L – Modified Julian Day(s)
- Return type:
float or list of floats
Note
Modified Julian Day starts at 0h Nov 17, 1858 (JD − 2400000.5)
- geodezyx.conv.conv_time.dt2date(dt_in)
Time Python type conversion
Python’s Datetime => Python’s Date
- Parameters:
dt_in (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L – Time as Datetime(s)
- Return type:
Datetime or list of Datetime
- geodezyx.conv.conv_time.dt2doy(dtin, outputtype=<class 'str'>)
- geodezyx.conv.conv_time.dt2doy_year(dtin, outputtype=<class 'str'>)
Time representation conversion
Python’s datetime => Day of Year, Year
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
doy , year – Day of Year and Year Is a list of tuple if the input is an iterable
- Return type:
tuple of int
- geodezyx.conv.conv_time.dt2epoch_rnx3(dt_in, epoch_flag=0, nsats=0, rec_clk_offset=0)
Time representation conversion
Python’s Datetime => RINEX3/4 epoch representation e.g. > 2022 11 29 17 15 25.0000000 0 0 0.000000000000
- Parameters:
dt_in (datetime or list of datetime.) – Datetime(s).
epoch_flag (int, optional) –
- Epoch flag:
0 : OK 1 : power failure between previous and current epoch >1 : Special event (see RINEX documentation).
The default is 0.
nsats (int, optional) – Number of satellites observed in current epoch. The default is 0.
rec_clk_offset (float, optional) – Receiver clock offset correction (seconds). The default is 0.
- Returns:
epoch_out – output RINEX3/4 epoch representation.
- Return type:
str or list of str
- geodezyx.conv.conv_time.dt2fracday(dtin)
Time representation conversion
Python’s datetime => Fraction of the day
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
fraction_day – Fractional of the day Is a list of int if the input is an iterable
- Return type:
float
- geodezyx.conv.conv_time.dt2gpstime(dtin, dayinweek=True, inp_ref='utc', outputtype=<class 'int'>)
Time scale conversion
Python’s datetime (UTC,TAI or GPS time scale) => GPS time
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
inp_ref (str) – “utc” : apply the 19 sec & leap second correction at the epoch “gps” : no correction applied “tai” : apply -19 sec correction
dayinweek (bool) –
if True : returns GPS week, day in GPS week
if False : returns GPS week, sec in GPS week
- Returns:
GPS_week, GPS_day/GPS_sec – GPS week or GPS day/GPS sec
Is a list of tuple if the input is an iterable
- Return type:
tuple of int
- geodezyx.conv.conv_time.dt2gpsweek_decimal(dtin, return_middle_of_day=True)
Time representation conversion
Python’s datetime => GPS week
Return the GPS week in a decimal mode
(Easier for plots)
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
return_middle_of_day (bool) – if False, return the decimal part of the week at the begining of the day
- Returns:
GPS_week_decimal – decimal GPS week
Is a list of float if the input is an iterable
- Return type:
float
- geodezyx.conv.conv_time.dt2jjulCNES(dtin, onlydays=True)
Time representation & scale conversion
Python’s Datetime => Julian Day CNES
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
only_days (bool) – if False, return also the seconds in the day
- Returns:
L – Julian Day CNES, [seconds in the Day]
- Return type:
int or list of int.
Note
Julian Day CNES starts at 0h Jan 1, 1950 (JD − 2433282.5)
https://www.aviso.altimetry.fr/fr/donnees/outils/jours-calendaires-ou-jours-juliens.html
- geodezyx.conv.conv_time.dt2list(dtin, return_useful_values=True)
Time representation conversion
Python’s Datetime => Years, Months, Days, Hours, Minutes, Seconds
- Parameters:
dtin (datetime) – Datetime
return_useful_values (bool) – if True, returns only Years, Months, Days
- Returns:
L – Years, Months, Days, [Hours, Minutes, Seconds]
- Return type:
list of int
- geodezyx.conv.conv_time.dt2posix(dtin, out_array=False)
Time representation conversion
Python’s Datetime => POSIX Time
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
out_array (bool) – if iterable as input, force the output as a Numpy array
- Returns:
L – POSIX Time(s)
- Return type:
float or list/numpy.array of floats
- geodezyx.conv.conv_time.dt2secinday(dtin)
Time representation conversion
Python’s datetime => Seconds in days
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
secinday – Seconds in the day Is a list of int if the input is an iterable
- Return type:
int
- geodezyx.conv.conv_time.dt2sp3_timestamp(dtin, start_with_star=True)
Time representation conversion
Python’s Datetime => SP3 Timestamp e.g.
2000 5 28 0 0 0.00000000
- geodezyx.conv.conv_time.dt2str(dtin, str_format='%Y-%m-%d %H:%M:%S')
Time representation conversion
Python’s Datetime => String
Just a wrapper of strftime
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L (string or list of strings) – Time as string(s)
Source
——
https (//stackoverflow.com/questions/7999935/python-datetime-to-string-without-microsecond-component)
http (//www.jacksay.com/tutoriaux/bash-shell/bashshell-utilisation-commande-date.html)
- geodezyx.conv.conv_time.dt2tuple(dtin)
- geodezyx.conv.conv_time.dt2year_decimal(dtin)
Time representation conversion
Python’s Datetime => Decimal Year
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L – Decimal Year(s)
- Return type:
float or list/numpy.array of floats
- geodezyx.conv.conv_time.dt2ymdhms(dtin, with_microsec=True)
Time representation conversion
Python’s Datetime => Lists of Years, Months, Days, Hours, Minutes, Seconds
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Python DateTime
with_microsec (bool) – if False : rounding the microsecs to the nearest sec
- Return type:
tuple with year , month , day , hour , minute , second , microsecond
- geodezyx.conv.conv_time.dt_2_sinex_datestr(dtin, short_yy=True, year_sep=':')
Time representation conversion
Python’s Datetime => SINEX time format
- Parameters:
dtin (datetime) –
- Returns:
dtout (str) – Date in SINEX format
year_sep (str) – year separator, usually :, but can also be empty
- geodezyx.conv.conv_time.dt_2_sp3_datestr(dtin)
Time representation conversion
Python’s Datetime => SP3 time format
- Parameters:
dtin (datetime) –
- Returns:
dtout – Date in SP3 format
- Return type:
str
- geodezyx.conv.conv_time.dt_ceil(dtin)
Round a datetime object to the begining of the day
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime you want to round, default now. Can handle several datetimes in an iterable.
- Returns:
dtout – Rounded Datetime
- Return type:
datetime or list/numpy.array of datetime
- geodezyx.conv.conv_time.dt_gpstime2dt_tai(dtgpsin, out_array=False)
Time scale conversion
Datetime in GPS Time Scale => Datetime in TAI Time Scale
Correct d the 19sec difference between GPS Time and TAI
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s) in GPS Time Scale. Can handle several datetimes in an iterable.
out_array (bool) – if iterable as input, force the output as a Numpy array
- Returns:
L – Datetime(s) in TAI Time Scale
- Return type:
datetime or list/numpy.array of datetime.
- geodezyx.conv.conv_time.dt_gpstime2dt_utc(dtgpsin, out_array=False)
Time scale conversion
Datetime in GPS Time Scale => Datetime in UTC Time Scale
Correct both the Leap second and the 19sec difference between GPS Time and UTC
- Parameters:
dtin (datetime or list/numpy.array of datetime.) – Datetime(s) in GPS Time Scale. Can handle several datetimes in an iterable.
out_array (bool) – if iterable as input, force the output as a Numpy array
- Returns:
L – Datetime(s) in UTC Time Scale
- Return type:
datetime or list/numpy.array of datetime.
- geodezyx.conv.conv_time.dt_improved(*args)
- geodezyx.conv.conv_time.dt_in_local_timezone2posix(dtin)
- geodezyx.conv.conv_time.dt_range(start_dt, end_dt, day_step=1, sec_step=0)
Range of datetime between a start and end (included)
- Parameters:
start_dt (datetime) – Datetimes
end_dt (datetime) – Datetimes
- Returns:
out_range – range of dates
- Return type:
list of datetime
- geodezyx.conv.conv_time.dt_round(dtin=None, roundTo=60)
Round a datetime object to any time laps in seconds
This function is depreciated !!! Use round_dt instead !!!
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime you want to round, default now. Can handle several datetimes in an iterable.
roundTo (int) – Closest number of seconds to round to, default 1 minute.
- Returns:
dtout – Rounded Datetime
- Return type:
datetime or list/numpy.array of datetime
- geodezyx.conv.conv_time.dt_tai2dt_tt(dtin)
Time scale conversion
Python’s datetime in TAI => Python’s datetime in Terrestrial Time (TT)
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L (list of datetime) – converted DateTimes
Source
——
https (//en.wikipedia.org/wiki/Terrestrial_Time)
Note
Realization of the TT by the BIPM (restimation and correction by dozen of µsec) https://www.bipm.org/en/bipm-services/timescales/time-ftp/ttbipm.html
- geodezyx.conv.conv_time.dt_tai2dt_utc(dtin)
Time scale conversion
Python’s datetime in TAI => Python’s datetime in UTC
(Wrapper to correct the leap second)
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L – converted DateTimes
- Return type:
list of datetime
Note
TAI is (currently) ahead of UTC
- geodezyx.conv.conv_time.dt_utc2dt_tai(dtin)
Time scale conversion
Python’s datetime in UTC => Python’s datetime in TAI
(Wrapper to correct the leap second)
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
- Returns:
L – converted DateTimes
- Return type:
list of datetime
Note
TAI is (currently) ahead of UTC
- geodezyx.conv.conv_time.dt_utc2dt_ut1(dtin, dUT1)
Time scale conversion
Python’s datetime in UTC => Python’s datetime in UT1
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
dUT1 (float) – UT1-UTC in seconds.
- Returns:
L – converted DateTimes
- Return type:
list of datetime
- geodezyx.conv.conv_time.dt_utc2dt_ut1_smart(dtin, DF_EOP_in, use_interp1d_obj=True, EOP_interpolator=None)
Time scale conversion
Python’s datetime in UTC => Python’s datetime in UT1 using an EOP DataFrame provided by files_rw.read_eop_C04
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime(s). Can handle several datetimes in an iterable.
DF_EOP_in (DataFrame) – EOP DataFrame for the UT1-UTC provided by files_rw.read_eop_C04
use_interp1d_obj (TYPE, optional) – Use an interp1d_time Interpolator object for the EOP determination at the right epoch. Faster in recursive mode when dtin is a list/array The default is True.
EOP_interpolator (interp1d_time object, optional) – The interp1d_time Interpolator object for the EOP determination Will be determined automatically inside the function The default is None.
- Returns:
DESCRIPTION.
- Return type:
TYPE
- geodezyx.conv.conv_time.epo_epos_converter(inp, inp_type='mjd', out_type='yyyy', verbose=False)
Frontend for the GFZ EPOS epo converter
- Parameters:
inp (string or int) – the input day, like 58773 2019290 20754 …
inp_type (str) – An output format managed by epo command : wwwwd,yyddd,yyyyddd,yyyymmdd
out_type (str) – An output format managed by epo command : mjd,yyyy,yy,ddd,mon,dmon,hour,min,sec,wwww,wd
- Returns:
year – Year as integer. Years preceding 1 A.D. should be 0 or negative. The year before 1 A.D. is 0, 10 B.C. is year -9.
- Return type:
int
- geodezyx.conv.conv_time.find_leapsecond(dtin, get_leapsec_lis=[(datetime.datetime(1972, 7, 1, 0, 0), 1), (datetime.datetime(1973, 1, 1, 0, 0), 2), (datetime.datetime(1974, 1, 1, 0, 0), 3), (datetime.datetime(1975, 1, 1, 0, 0), 4), (datetime.datetime(1976, 1, 1, 0, 0), 5), (datetime.datetime(1977, 1, 1, 0, 0), 6), (datetime.datetime(1978, 1, 1, 0, 0), 7), (datetime.datetime(1979, 1, 1, 0, 0), 8), (datetime.datetime(1980, 1, 1, 0, 0), 9), (datetime.datetime(1981, 7, 1, 0, 0), 10), (datetime.datetime(1982, 7, 1, 0, 0), 11), (datetime.datetime(1983, 7, 1, 0, 0), 12), (datetime.datetime(1985, 7, 1, 0, 0), 13), (datetime.datetime(1988, 1, 1, 0, 0), 14), (datetime.datetime(1990, 1, 1, 0, 0), 15), (datetime.datetime(1991, 1, 1, 0, 0), 16), (datetime.datetime(1992, 7, 1, 0, 0), 17), (datetime.datetime(1993, 7, 1, 0, 0), 18), (datetime.datetime(1994, 7, 1, 0, 0), 19), (datetime.datetime(1996, 1, 1, 0, 0), 20), (datetime.datetime(1997, 7, 1, 0, 0), 21), (datetime.datetime(1999, 1, 1, 0, 0), 22), (datetime.datetime(2006, 1, 1, 0, 0), 23), (datetime.datetime(2009, 1, 1, 0, 0), 24), (datetime.datetime(2012, 7, 1, 0, 0), 25), (datetime.datetime(2015, 7, 1, 0, 0), 26), (datetime.datetime(2017, 1, 1, 0, 0), 27)], apply_initial_delta=True)
Find the TAI-UTC leap second for a given datetime
- Parameters:
dtin (datetime) – Epoch for which the leap second is researched
get_leapsec_lis (list, optional) – A list of leap second, provided by get_leapsecond_frontend() automatically determined if given list is empty
apply_initial_delta (bool, optional) – See note below
- Returns:
leapsec_out – The leap second for the given epoch
- Return type:
int
Note
Universal Time (UT1) and International Atomic Time (TAI) were defined as equal in 1958. When UTC was introduced in 1972, UT1 had shifted by around 10 seconds in relation to TAI. We therefore chose an initial offset of 10 seconds between UTC and TAI.
In 1972, the leap-second system was introduced so that the broadcast UTC seconds could be made exactly equal to the standard SI second, while still maintaining the UTC time of day and changes of UTC date synchronized with those of UT1 (the solar time standard that superseded GMT).[11] By then, the UTC clock was already 10 seconds behind TAI, which had been synchronized with UT1 in 1958, but had been counting true SI seconds since then. After 1972, both clocks have been ticking in SI seconds, so the difference between their readouts at any time is 10 seconds plus the total number of leap seconds that have been applied to UTC (37 seconds as of January 2017).
- geodezyx.conv.conv_time.get_leapsecond_frontend()
INTERNAL_FUNCTION
Nota : Universal Time (UT1) and International Atomic Time (TAI) were defined as equal in 1958. When UTC was introduced in 1972, UT1 had shifted by around 10 seconds in relation to TAI. We therefore chose an initial offset of 10 seconds between UTC and TAI.
the initial 10sec are added in find_leapsecond
- geodezyx.conv.conv_time.gpstime2dt(gpsweek, gpsdow_or_seconds, dow_input=True, output_time_scale='utc')
Time scale & representation conversion
GPS Time => Python’s datetime
- Parameters:
gpsweek (int) – year, days of year
gpsdow_or_seconds (int) – Day of Week OR Seconds in Weeks
dow_input (bool) – select if Day of Week (True) OR Seconds in Weeks (False)
output_time_scale (str) – gives the wished time scale : “utc”, “tai”, “gps”
- Returns:
L – DateTime
- Return type:
datetime or list/numpy.array of datetime.
Note
Only reliable at the day level for the moment
the leapsecond is found only after a first calc without leapsecond it can be some side effects when the input time is close to a leap second jump
https://gist.github.com/jeremiahajohnson/eca97484db88bcf6b124
- geodezyx.conv.conv_time.gpstime2utc_bad(gpsweek, gpssecs, utc_offset)
DISCONTINUED FUNCTION, TOO UNSTABLE (171017) use gpstime2dt instead
[year,month,day,hour,minute,sec] = gpstime2utc(gpsweek,gpssecs,utc_offset) Converts GPS week and seconds into UTC time, Python version, March 2009
- geodezyx.conv.conv_time.gpsweek_decimal2dt(gpsweekdec_in, output_time_scale='utc')
Time representation conversion
Decimal GPS Week => Python’s datetime
- Parameters:
gpsweekdec_in (float or list/numpy.array of float) – GPS week in decimal form.
output_time_scale (str) – gives the wished time scale : “utc”, “tai”, “gps”
- Returns:
L – converted DateTimes
- Return type:
list of datetime
- geodezyx.conv.conv_time.hr_to_Day(hr, minu, sec)
Convert Julian Day to date.
- Parameters:
jd (float) – Julian Day
- Returns:
year (int) – Year as integer. Years preceding 1 A.D. should be 0 or negative. The year before 1 A.D. is 0, 10 B.C. is year -9.
month (int) – Month as integer, Jan = 1, Feb. = 2, etc.
day (float) – Day, may contain fractional part.
Examples
Convert Julian Day 2446113.75 to year, month, and day.
>>> jd_to_date(2446113.75) (1985, 2, 17.25)
- geodezyx.conv.conv_time.jd_to_date(jd)
Convert Julian Day to date.
- Parameters:
jd (float) – Julian Day
- Returns:
year (int) – Year as integer. Years preceding 1 A.D. should be 0 or negative. The year before 1 A.D. is 0, 10 B.C. is year -9.
month (int) – Month as integer, Jan = 1, Feb. = 2, etc.
day (float) – Day, may contain fractional part.
Examples
Convert Julian Day 2446113.75 to year, month, and day.
>>> jd_to_date(2446113.75) (1985, 2, 17.25)
- geodezyx.conv.conv_time.jd_to_mjd(jd)
Convert Julian Day to Modified Julian Day
- Parameters:
jd (float) – Julian Day
- Returns:
mjd – Modified Julian Day
- Return type:
float
- geodezyx.conv.conv_time.jjulCNES2dt(jjulin)
Time representation & scale conversion
Julian Day CNES => Python’s Datetime
- Parameters:
jjulin (float/int or list/numpy.array of float/int.) – Julian Day CNES. Can handle several float/int in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
Note
Julian Day CNES starts at 0h Jan 1, 1950 (JD − 2433282.5)
https://www.aviso.altimetry.fr/fr/donnees/outils/jours-calendaires-ou-jours-juliens.html
- geodezyx.conv.conv_time.matlab_time2dt(matlab_datenum)
Time representation conversion
MATLAB Time => Datetime
- Parameters:
matlab_datenum (float or list/numpy.array of float) – MATLAB time(s). Can handle several time floats in a list.
- Returns:
python_datetime – Converted Datetime(s)
- Return type:
datetime or list/numpy.array of datetime
- geodezyx.conv.conv_time.mjd_to_jd(mjd)
Convert Modified Julian Day to Julian Day.
- Parameters:
mjd (float) – Modified Julian Day
- Returns:
jd – Julian Day
- Return type:
float
- geodezyx.conv.conv_time.numpy_datetime2dt(npdtin)
Time representation conversion
Numpy Datetime => Datetime
This function is depreciated !!! Use numpy_dt2dt instead !!!
- Parameters:
npdtin (np.datetime64 or list/numpy.array of np.datetime64) – Numpy Datetime. Can handle several time in a list.
- Returns:
python_datetime (datetime or list/numpy.array of datetime) – Converted Datetime(s)
Source
——
https (//stackoverflow.com/questions/29753060/how-to-convert-numpy-datetime64-into-datetime/29755657)
- geodezyx.conv.conv_time.numpy_dt2dt(numpy_dt_in)
Time representation conversion
Numpy datetime64 object => Python’s Datetime
- Parameters:
numpy_dt_in (numpy datetime64 object) – numpy datetime64 object
- Returns:
dt (datetime or list/numpy.array of datetime) – Converted Datetime(s) If the input is a Pandas Series, the output is forced as an array
Source
——
https (//gist.github.com/blaylockbk/1677b446bc741ee2db3e943ab7e4cabd)
- geodezyx.conv.conv_time.pandas_timestamp2dt(timestamp_in)
Time Python type conversion
Pandas’s Timestamp => Python’s Datetime
- Parameters:
timestamp_in (Timestamp or list/numpy.array of Timestamp.) – Pandas’s Timestamp(s). Can handle several datetimes in an iterable.
- Returns:
L – Time as Datetime(s)
- Return type:
Datetime or list of Datetime
- geodezyx.conv.conv_time.posix2dt(posixin, out_array=False)
Time representation conversion
POSIX Time => Python’s Datetime
- Parameters:
posixin (float or list/numpy.array of floats.) – POSIX Time. Can handle several time in a list.
out_array (bool) – if iterable as input, force the output as a Numpy array
- Returns:
L – Converted Datetime(s)
- Return type:
datetime or list/numpy.array of datetime.
- geodezyx.conv.conv_time.posix2dt_in_local_timezone(posixin)
- geodezyx.conv.conv_time.rinexname2dt(rinexpath)
Time representation conversion
RINEX Name (short or long naming convention) => Python’s Datetime
Extract the date in a RINEX name
- Parameters:
rinexpath (string) – RINEX path. The RINEX basename will be extracted automatically.
- Returns:
dt – Datetime
- Return type:
datetime
- geodezyx.conv.conv_time.roundTime(*args)
Wrapper of dt_round for legacy reasons
This function is depreciated !!! Use round_dt instead !!!
- geodezyx.conv.conv_time.round_dt(dtin, round_to, python_dt_out=True, mode='round')
Round a datetime object to any time laps in seconds
- Parameters:
dtin (datetime or list/numpy.array of datetime) – Datetime you want to round Can handle several datetimes in an iterable.
round_to (str) –
The way to round the datetime.
It follows the Pandas’ Series conventions, e.g.:
one-day rounding: ‘1D’
one-minute rounding: ‘1min’
one-second rounding: ‘1s’
Full list is in the Note’s link
python_dt_out (bool, optional) – If True, it returns the date as a legacy Python’s DateTime. If False, it returns a Pandas Timestamp. The default is True.
mode (str) – define the way you want to round the values: ‘round’ (i.e. the nearest), ‘floor’, ‘ceil’ The default if ‘round’
- Returns:
dtout – Rounded Datetime
- Return type:
datetime or list/numpy.array of datetime
- geodezyx.conv.conv_time.sp3name2dt(sp3path)
Time representation conversion
Orbit SP3 Name (legacy/new naming convention) => Python’s Datetime
Extract the date in a Orbit SP3 name
- Parameters:
sp3path (string) – Orbit SP3 path. The basename will be extracted automatically.
- Returns:
dt – Datetime
- Return type:
datetime
- geodezyx.conv.conv_time.sp3name_leg_2dt(sp3path)
Time representation conversion
Orbit SP3 Name (old/legacy naming convention) => Python’s Datetime
Extract the date in a Orbit SP3 name
- Parameters:
sp3path (string) – Orbit SP3 path. The basename will be extracted automatically.
- Returns:
dt – Datetime
- Return type:
datetime
- geodezyx.conv.conv_time.sp3name_v3_2dt(sp3path)
Time representation conversion
Orbit SP3 Name (new naming convention) => Python’s Datetime
Extract the date in a Orbit SP3 name
- Parameters:
sp3path (string) – Orbit SP3 path. The basename will be extracted automatically.
- Returns:
dt – Datetime
- Return type:
datetime
- geodezyx.conv.conv_time.statname_dt2rinexname(statname, datein, rnxtype='d.Z', session_a_instead_of_daily_session=False)
Time representation conversion
Python’s Datetime (and station name) => RINEX name
Create a RINEX name from a station name and date
- Parameters:
statname (string) – name of the station if is more than 4 characters long (typically for 9-chars. names), only the 4 first characters will be used
datein (datetime) – date of the wished RINEX name
rnxtype (string) – extension of the RINEX (“d.Z”,”.o”) …
session_a_instead_of_daily_session (bool) – if True, gives an hourly session name (a,b,c …) instead of a daily session (0)
- Returns:
rinexname – The name of the RINEX
- Return type:
string
- geodezyx.conv.conv_time.statname_dt2rinexname_long(statname, datein, country='XXX', data_source='R', file_period='00U', data_freq='00U', data_type='MO', format_compression='crx.gz', preset_type=None)
Time representation conversion
Python’s Datetime (and station name) => RINEX long name convention
Create a RINEX name from a station name, date and ancillary parameters
- Parameters:
statname (string) – name of the station can be a 4 or 9 char.
datein (datetime) – date of the wished RINEX name
country (string) – optional. the 3char. country code if given, will replace the one in an input 9-char statname default value is “XXX”
data_source (str, optional) – Data Source. R – From Receiver, data using vendor or other software S – From data Stream (RTCM or other) U – Unknown The default is “R”.
file_period (str, optional) – File Period 15M–15 Minutes 01H–1 Hour 01D–1 Day 01Y–1 Year 00U-Unspecified The default is “00U”.
data_freq (str, optional) – data frequency. XXC – 100 Hertz XXZ – Hertz, XXS – Seconds, XXM – Minutes, XXH – Hours, XXD – Days XXU – Unspecified The default is “00U”.
data_type (str, optional) –
Two characters represent the data type: GO - GPS Obs. RO - GLONASS Obs. EO - Galileo Obs. JO - QZSS Obs. CO - BDS Obs. IO – NavIC/IRNSS Obs. SO - SBAS Obs. MO - Mixed Obs. GN - Nav. GPS RN - GLONASS Nav. EN - Galileo Nav. JN - QZSS Nav. CN - BDS Nav. IN – NavIC/IRNSS Nav. SN - SBAS Nav. MN – Mixed Nav. (All GNSS Constellations) MM-Meteorological Observation
The default is “MO”.
format_compression (string) – extension of the RINEX (“rnx”,”crz”,”crz.gz”) … The default is ‘crz.gz’.
preset_type (str, optional) – takes “daily” or “hourly” values. set the most common data_freq and file_period for an hourly or daily session. The default is None.
- Returns:
out_rnx_name – The name of the RINEX.
- Return type:
str
- geodezyx.conv.conv_time.str_date2dt(strin)
Time representation conversion
String => Python’s Datetime
Wrapper of dateutil.parser.parse
The input string should looks like a timestamp
- Parameters:
strin (string or list/numpy.array of strings.) – string(s). Can handle several datetimes in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.strdate2dt(strin)
Time representation conversion
String => Python’s Datetime
Wrapper of dateutil.parser.parse
The input string should looks like a timestamp
- Parameters:
strin (string or list/numpy.array of strings.) – string(s). Can handle several datetimes in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.string_date2dt(strin)
Time representation conversion
String => Python’s Datetime
Wrapper of dateutil.parser.parse
The input string should looks like a timestamp
- Parameters:
strin (string or list/numpy.array of strings.) – string(s). Can handle several datetimes in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.tgipsy2dt(tin)
Time representation conversion
GIPSY Time => Datetime
- Parameters:
tin (float or list/numpy.array of float) – GIPSY time(s). Can handle several time float in a list.
- Returns:
dtout – Converted Datetime(s)
- Return type:
datetime or list/numpy.array of datetime
Note
GIPSY time is not the ‘real’ J2000 but only counted starting from 1st January 2000 at Noon
- geodezyx.conv.conv_time.toYearFraction(date_in)
DISCONTINUED use dt2year_decimal instead (does the same)
- geodezyx.conv.conv_time.trimble_file2dt(trmfile_in)
Time representation conversion
Trimble raw data file => Python’s Datetime
Trimble file exemple : CASG202101070000A.T02
- Parameters:
trmfile_in (string or list/numpy.array of string.) – Trimble raw data file as string. Can handle several string in an iterable. Will extract the basename of a path.
- Returns:
dtout – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.tup_or_lis2dt(lisin)
Time representation conversion
Date-looking strings => Python’s datetime
- Parameters:
lisin (iterable (tuple/list/numpy.array) of string.) – list of Date-looking strings like : [“2018”,”12”,”31”,”12”,”30”,”00”]
- Returns:
L – converted DateTimes
- Return type:
list of datetime
- geodezyx.conv.conv_time.utc2gpstime(year, month, day, hour, min, sec)
Convert UTC Time to GPS Time
- Parameters:
year (int) – input UTC time.
month (int) – input UTC time.
day (int) – input UTC time.
hour (int) – input UTC time.
min (int) – input UTC time.
sec (int) – input UTC time.
- Returns:
Converted epoch in GPS time, i.e. GPS Week and GPS seconds in week.
- Return type:
gpsweek,gpssecs
- geodezyx.conv.conv_time.utc2gpstime_bad(year, month, day, hour, min, sec)
- geodezyx.conv.conv_time.year_decimal2dt(yearin)
Time representation conversion
Decimal Year => Python’s Datetime
- Parameters:
yearin (float or list/numpy.array of floats.) – Decimal year(s). Can handle several floats in an iterable.
- Returns:
L – Datetime(s)
- Return type:
datetime or list of datetime.
- geodezyx.conv.conv_time.ymdhms2dt(y=0, mo=0, d=0, h=0, mi=0, s=0, ms=0)
Improved time representation conversion to Datetime
can manage list, array, or floats as input can manage NaN too (return POSIX 0 epoch if NaN)
- Parameters:
y (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
mo (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
d (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
h (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
mi (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
s (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
ms (float or list/numpy.array of floats.) – year , month… . Can handle several times in lists.
- Returns:
Converted Datetime(s)
- Return type:
Datetime
- geodezyx.conv.conv_time.ymdhms_vectors2dt(yrlis, mlis, dlis, hlis, minlis, slis)
Time representation conversion
Lists of Years, Months, Days, Hours, Minutes, Seconds => Python’s Datetime
- Parameters:
yrlis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
mlis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
dlis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
hlis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
minlis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
slis (float or list/numpy.array of floats.) – Lists of Years, Months, Days, Hours, Minutes, Seconds
- Returns:
L – Datetime(s)
- Return type:
datetime or list/numpy.array of datetime.