@@ -23,7 +23,9 @@ def lon_to_180(lon):
2323 Normalize longitude to between -180 and 180
2424
2525 :param lon: Longitude
26+ :type lon: float
2627 :return: Longitude between -180 to 180
28+ :rtype: float
2729 """
2830 return ((lon + 180.0 ) % 360.0 ) - 180.0
2931
@@ -33,7 +35,9 @@ def circular_mean_lon(lons_deg):
3335 Circular mean longitude in degrees, returned in [-180,180).
3436
3537 :param lons_deg: Longitdue in degrees
38+ :type lons_deg: list of floats
3639 :return: Returns the mean longitude
40+ :rtype: float
3741 """
3842 angles = [math .radians (l ) for l in lons_deg ]
3943 sx = sum (math .cos (a ) for a in angles )
@@ -47,8 +51,11 @@ def unwrap_lons_to_reference(coords, ref_lon):
4751 This avoids seam jumps when projecting.
4852
4953 :param coords: Array with lat and lon
50- :param ref_lon: Mean Lonitude
51- :return: Unwrapped Lonitude
54+ :type coords: list of tuples
55+ :param ref_lon: Mean Longitude
56+ :type ref_lon: float
57+ :return: Unwrapped Longitude
58+ :rtype: list of tuples
5259 """
5360 out = []
5461 for lon , lat in coords :
@@ -65,7 +72,9 @@ def read_morvel_plate_file(path):
6572 Read MORVEL file and place into dictionary
6673
6774 :param path: Path to morvel plate file
75+ :type path: str
6876 :return: Dictionary of plates with their boundaries
77+ :rtype: dict
6978 """
7079 plates = {}
7180 current_plate = None
@@ -131,7 +140,9 @@ def build_plate_index(dig_path):
131140 }
132141
133142 :param dig_path: Path to morvel plate file
143+ :type dig_path: str
134144 :return: Dictionary of plates
145+ :rtype: dict
135146 """
136147 plates = read_morvel_plate_file (dig_path )
137148 index = {}
@@ -204,9 +215,13 @@ def plate_from_ll(lat, lon, plate_index):
204215 Find plate for geographic lat/lon (degrees).
205216
206217 :param lat: Latitude of point
218+ :type lat: float
207219 :param lon: Longitude of point
220+ :type lon: float
208221 :param plate_index: Dictionary of plates
222+ :type plate_index: dict
209223 :return: Plate ID
224+ :rtype: Array of strings or None
210225 """
211226 lon = lon_to_180 (lon )
212227
@@ -235,10 +250,15 @@ def plate_from_xyz(x, y, z, plate_index):
235250 Converts XYZ to LLH and runs plate_from_ll to find plate
236251
237252 :param x: Cartesian X (m)
253+ :type x: float
238254 :param y: Cartesian Y (m)
255+ :type y: float
239256 :param z: Cartesian Z (m)
257+ :type z: float
240258 :param plate_index: Dictionary of plates
259+ :type plate_index: dict
241260 :return: plate ID
261+ :rtype: Array of strings or None
242262 """
243263 lat , lon , h = geodepy .convert .xyz2llh (x , y , z )
244264 return plate_from_ll (lat , lon , plate_index )
@@ -265,7 +285,9 @@ def load_poles(path):
265285 where rot is deg/Ma anti-clockwise.
266286
267287 :param path: Path to plate motion file
288+ :type path: str
268289 :return: Array of PlatePole objects containing each plate
290+ :rtype: list of PlatePole
269291 """
270292 path = Path (path )
271293 poles = []
@@ -308,9 +330,13 @@ def euler_to_drx_dry_drz(lat_deg, lon_deg, rot_deg_ma):
308330 Convert Euler pole (lat, lon, rot deg/Ma) to GeodePy rotation rates d_rx,d_ry,d_rz in arcsec/yr.
309331
310332 :param lat_deg: Euler pole Latitude in degrees
333+ :type lat_deg: float
311334 :param lon_deg: Euler pole Longitude in degrees
335+ :type lon_deg: float
312336 :param rot_deg_ma: Euler pole rotation in deg/Ma
337+ :type rot_deg_ma: float
313338 :return: Rotation paramters in rx, ry, rz
339+ :rtype: tuple of floats (d_rx, d_ry, d_rz)
314340 """
315341 phi = math .radians (lat_deg )
316342 lam = math .radians (lon_deg )
@@ -331,9 +357,13 @@ def sd_drot_from_rms_and_pole(rms_mm_yr, lat_deg, lon_deg, radius_m=6378137.0):
331357 Assumes uncertainty is magnitude-only along pole direction.
332358
333359 :param rms_mm_yr: RMS of pole in mm/yr
360+ :type rms_mm_yr: float
334361 :param lat_deg: Euler pole Latitude in degrees
362+ :type lat_deg: float
335363 :param lon_deg: Euler pole Longitude in degrees
364+ :type lon_deg: float
336365 :return: RMS values for rotation paramters
366+ :rtype: tuple of floats (sd_d_rx, sd_d_ry, sd_d_rz)
337367 """
338368 # RMS speed -> m/yr
339369 sigma_v = rms_mm_yr / 1000.0
@@ -373,10 +403,15 @@ def plate_transformation(
373403 d_rx/d_ry/d_rz = Euler pole converted to arcsec/yr
374404
375405 :param plate_code: Plate code eg "AU"
406+ :type plate_code: str
376407 :param poles_file: Path to plate motion file
408+ :type poles_file: str
377409 :param ref_epoch: Reference epoch of transformation
410+ :type ref_epoch: datetime.date
378411 :param from_datum: Source datum for transformation
412+ :type from_datum: str
379413 :param to_datum: Destination datum for transformation
414+ :type to_datum: str
380415 :return: Geodepy.constants.Transformation Object
381416 """
382417 poles = load_poles (poles_file )
@@ -419,18 +454,32 @@ def plate_transformation(
419454
420455def universal_plate_motion_transformation (x ,y , z ,
421456 from_epoch , to_epoch , vcv = None ,
422- plate_file = "MORVEL56_plates.dig" ,
423- poles_file = "NNR-MORVEL56_poles.txt" ,
457+ plate_file = "other_files/ MORVEL56_plates.dig" ,
458+ poles_file = "other_files/ NNR-MORVEL56_poles.txt" ,
424459 ref_epoch = date (2020 , 1 , 1 )):
425460 """
426461 Given ECEF XYZ coordinates, find the plate, find the plate motion and transform point.
427462
428463 :param x: Cartesian X (m)
464+ :type x: float
429465 :param y: Cartesian Y (m)
466+ :type y: float
430467 :param z: Cartesian Z (m)
468+ :type z: float
431469 :param from_epoch: Source epoch for plate motion
470+ :type from_epoch: datetime.date
432471 :param to_epoch: Destination epoch for plate motion
433- :param vcv:
472+ :type to_epoch: datetime.date
473+ :param vcv: Optional 3*3 numpy array in Cartesian units to propagate tf uncertainty
474+ :type vcv: numpy.ndarray
475+ :param plate_file: Path to morvel plate file
476+ :type plate_file: str
477+ :param poles_file: Path to plate motion file
478+ :type poles_file: str
479+ :param ref_epoch: Reference epoch of transformation
480+ :type ref_epoch: datetime.date
481+ :return: Transformed XYZ and VCV
482+ :rtype: tuple (xtrans, ytrans, ztrans, vcv)
434483 """
435484
436485 # Create Index of plates
@@ -450,75 +499,3 @@ def universal_plate_motion_transformation(x ,y, z,
450499 xtrans , ytrans , ztrans , vcv = geodepy .transform .plate_motion_transformation (x , y , z , from_epoch , to_epoch , transformation , vcv )
451500
452501 return xtrans , ytrans , ztrans , vcv
453-
454- """
455- x, y, z = -4130636.759, 2894953.142, -3890530.249
456- sigma = 0.003
457- vcv_xyz = np.diag([sigma**2, sigma**2, sigma**2])
458-
459- x, y, z, vcv = universal_plate_motion_transformation(x, y, z, date(2020,1,1), date(2025,1,1), vcv=vcv_xyz)
460- print(x, y, z)
461-
462-
463- x, y, z, vcv = geodepy.transform.plate_motion_transformation(x, y, z, date(2020,1,1), date(2025, 1, 1), geodepy.constants.itrf2014_to_gda2020, vcv=vcv_xyz)
464- print(x, y, z)
465- sigmas_out = np.sqrt(np.diag(vcv))
466- print(sigmas_out)
467- """
468- """
469- x, y, z = -4130636.759, 2894953.142, -3890530.249
470-
471- eez = build_plate_index("EEZ_australia_approx.dig")
472-
473- x, y, z = -4130636.759, 2894953.142, -3890530.249
474- plate_id = plate_from_xyz(x, y, z, eez)
475- print(f"ID: {plate_id} (Should be MA)")
476-
477- lon, lat = 170.48, -27.31
478- plate_id = plate_from_ll(lat, lon, eez)
479- print(f"ID: {plate_id} (Should be MA)")
480-
481- lon, lat = 161.28, -36.12
482- plate_id = plate_from_ll(lat, lon, eez)
483- print(f"ID: {plate_id} (Should be MA)")
484-
485- lon, lat = 133.71, -23.33
486- plate_id = plate_from_ll(lat, lon, eez)
487- print(f"ID: {plate_id} (Should be MA)")
488-
489- lon, lat = 109.73, -33.88
490- plate_id = plate_from_ll(lat, lon, eez)
491- print(f"ID: {plate_id} (Should be MA)")
492-
493- lon, lat = 116.65, -14.18
494- plate_id = plate_from_ll(lat, lon, eez)
495- print(f"ID: {plate_id} (Should be MA)")
496-
497- lon, lat = 159.71, -59.28
498- plate_id = plate_from_ll(lat, lon, eez)
499- print(f"ID: {plate_id} (Should be MQ)")
500-
501- lon, lat = 107.35, -12.09
502- plate_id = plate_from_ll(lat, lon, eez)
503- print(f"ID: {plate_id} (Should be CH)")
504-
505- lon, lat = 95.7, -10.5
506- plate_id = plate_from_ll(lat, lon, eez)
507- print(f"ID: {plate_id} (Should be CO)")
508-
509- lon, lat = 170.63, -43.66
510- plate_id = plate_from_ll(lat, lon, eez)
511- print(f"ID: {plate_id} (Should be None)")
512-
513- lon, lat = 156.6, -37.39
514- plate_id = plate_from_ll(lat, lon, eez)
515- print(f"ID: {plate_id} (Should be None)")
516-
517- lon, lat = 108.59, -29.73
518- plate_id = plate_from_ll(lat, lon, eez)
519- print(f"ID: {plate_id} (Should be None)")
520-
521- lon, lat = -97.1, 38.8
522- plate_id = plate_from_ll(lat, lon, eez)
523- print(f"ID: {plate_id} (Should be None)")
524- """
0 commit comments