|
15 | 15 | from math import radians |
16 | 16 | import numpy as np |
17 | 17 | 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) |
19 | 20 | from geodepy.statistics import vcv_local2cart, vcv_cart2local |
20 | 21 | from geodepy.convert import (hp2dec, geo2grid, |
21 | 22 | grid2geo, xyz2llh, llh2xyz) |
22 | 23 | from geodepy.ntv2reader import NTv2Grid, interpolate_ntv2 |
| 24 | +from dateutil.relativedelta import relativedelta |
23 | 25 |
|
24 | 26 |
|
25 | 27 | def conform7(x, y, z, trans, vcv=None): |
@@ -147,6 +149,65 @@ def conform14(x, y, z, to_epoch, trans, vcv=None): |
147 | 149 | xtrans, ytrans, ztrans, trans_vcv = conform7(x, y, z, timetrans, vcv=vcv) |
148 | 150 | return xtrans, ytrans, ztrans, trans_vcv |
149 | 151 |
|
| 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)) |
150 | 211 |
|
151 | 212 | def transform_mga94_to_mga2020(zone, east, north, ell_ht=False, vcv=None): |
152 | 213 | """ |
|
0 commit comments