Skip to content

Commit ec695e0

Browse files
committed
Added time dependant transformation function (DOESNT WORK YET)
1 parent 4693bd1 commit ec695e0

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

geodepy/transform.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
from math import radians
1616
import numpy as np
1717
from geodepy.constants import (Transformation, TransformationSD,
18-
atrf2014_to_gda2020, gda94_to_gda2020)
18+
atrf2014_to_gda2020, gda94_to_gda2020,
19+
itrf2014_to_gda2020, itrf2014_to_itrf2005)
1920
from geodepy.statistics import vcv_local2cart, vcv_cart2local
2021
from geodepy.convert import (hp2dec, geo2grid,
2122
grid2geo, xyz2llh, llh2xyz)
2223
from geodepy.ntv2reader import NTv2Grid, interpolate_ntv2
24+
from dateutil.relativedelta import relativedelta
2325

2426

2527
def conform7(x, y, z, trans, vcv=None):
@@ -147,6 +149,65 @@ def conform14(x, y, z, to_epoch, trans, vcv=None):
147149
xtrans, ytrans, ztrans, trans_vcv = conform7(x, y, z, timetrans, vcv=vcv)
148150
return xtrans, ytrans, ztrans, trans_vcv
149151

152+
def time_dep_transformation_aus(x, y, z, from_epoch, to_epoch, trans, plate_motion=itrf2014_to_gda2020, vcv=None):
153+
"""
154+
Preforms time dependant transformations using a Helmert 14 Conformal Transformation and a plate motion model.
155+
Performs a Helmert 14 Parameter Conformal Transformation using Cartesian point co-ordinates
156+
and a predefined transformation object. The transformation parameters are projected from
157+
the transformation objects reference epoch to a specified epoch.
158+
159+
:param x: Cartesian X (m)
160+
:param y: Cartesian Y (m)
161+
:param z: Cartesian Z (m)
162+
:param from_epoch: Epoch co-ordinate transformation is from (datetime.date Object)
163+
:param to_epoch: Epoch co-ordinate transformation is to (datetime.date Object)
164+
:param trans: Transformation Object
165+
:param plat_motion: Plate motion model for transformation (defaults to australian plate motion)
166+
:param vcv: Optional 3*3 numpy array in Cartesian units to propagate tf uncertainty
167+
:return: Cartesian X, Y, Z co-ordinates and vcv matrix transformed using Transformation parameters at desired epoch
168+
"""
169+
if type(trans) != Transformation:
170+
raise ValueError("trans must be a Transformation Object")
171+
if type(to_epoch) != datetime.date:
172+
raise ValueError("to_epoch must be a datetime.date Object")
173+
if type(from_epoch) != datetime.date:
174+
raise ValueError("from_epoch must be a datetime.date Object")
175+
if type(plate_motion) != Transformation:
176+
raise ValueError("plate_motion must be a Transformation Object")
177+
178+
179+
if from_epoch == trans.ref_epoch:
180+
181+
print("The from Epoch was correct!")
182+
# Calculate 7 Parameters from 14 Parameter Transformation Object
183+
timetrans = trans + to_epoch
184+
185+
# Perform Transformation
186+
xtrans, ytrans, ztrans, trans_vcv = conform7(x, y, z, timetrans, vcv=vcv)
187+
return xtrans, ytrans, ztrans, trans_vcv
188+
else:
189+
# Step 1: Transform coordinates to ref_epoch
190+
# Find time difference
191+
timediff = relativedelta(from_epoch, trans.ref_epoch)
192+
#timediff = trans.ref_epoch - from_epoch
193+
plate_to_epoch = plate_motion.ref_epoch + timediff
194+
print(f"Step 1 epoch: {timediff}")
195+
# Complete conform14 with plate motion
196+
x, y, z, vcv = conform14(x, y, z, plate_to_epoch, plate_motion, vcv)
197+
198+
# Step 2: Complete transformation
199+
x, y, z, vcv = conform7(x, y, z, trans, vcv)
200+
201+
# Step 3: Transform coordinates to to_epoch
202+
# Find time difference
203+
timediff = relativedelta(to_epoch, trans.ref_epoch) #+ datetime.timedelta(days=1)
204+
print(f"Step 2 diff: {timediff}")
205+
plate_to_epoch = plate_motion.ref_epoch + timediff
206+
207+
# Complete conform14 with plate motion
208+
return conform14(x, y, z, plate_to_epoch, plate_motion, vcv)
209+
210+
print(time_dep_transformation(-4052042.7920922847, 4212825.645301947, -2545098.301585565, datetime.date(2000, 1, 1), datetime.date(2020, 1 ,1), itrf2014_to_itrf2005))
150211

151212
def transform_mga94_to_mga2020(zone, east, north, ell_ht=False, vcv=None):
152213
"""

0 commit comments

Comments
 (0)