From 7c7868bcb69ecf85a7d58b57866a92a776a8e9cf Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 18:48:20 +0000 Subject: [PATCH 1/7] Clarify docstrings in grid.py, point.py and reformat them to be compatible with pylance --- src/pysolid/grid.py | 40 +++++++++++++------- src/pysolid/point.py | 88 ++++++++++++++++++++++++++++---------------- 2 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index 39d3a2e..72a484c 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -26,20 +26,32 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo input size. This uses the fact that SET varies slowly in space. Comparison w and w/o step_size shows a difference in tide_u with max of 5e-8 m, thus negligible. - Parameters: dt_obj - datetime.datetime object (with precision up to the second) - atr - dict, metadata including the following keys: - LENGTH/WIDTTH - X/Y_FIRST - X/Y_STEP - step_size - float, grid step feeded into the fortran code in meters - to speedup the calculation - display - bool, plot the calculated SET - verbose - bool, print verbose message - Returns: tide_e - 2D np.ndarray, SET in east direction in meters - tide_n - 2D np.ndarray, SET in north direction in meters - tide_u - 2D np.ndarray, SET in up direction in meters - Examples: atr = readfile.read_attribute('geo_velocity.h5') - tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr) + Parameters: + dt_obj : datetime.datetime + The datetime to calculate this grid for, with precision up to the second. + atr : dict + metadata including the following keys: + LENGTH/WIDTH + X/Y_FIRST + X/Y_STEP + step_size : float + grid step size; fed into the fortran code in meters to speedup the + calculation. + display : bool, optional + If True, plot the calculated SET. Defaults to False. + verbose : bool, optional + If True, print verbose messages. Defaults to False. + Returns: + tide_e : 2D np.ndarray of floats + SET in east direction in meters + tide_n : 2D np.ndarray + SET in north direction in meters + tide_u : 2D np.ndarray + SET in up direction in meters + Examples: + atr = readfile.read_attribute('geo_velocity.h5') + + tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr) """ try: from pysolid.solid import solid_grid diff --git a/src/pysolid/point.py b/src/pysolid/point.py index 3a68d9e..7890ee5 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -72,23 +72,39 @@ ################################## Earth tides - point mode ################################## def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, verbose=True): - """Calculate SET in east/north/up direction for the given time period at the given point (lat/lon). - - Parameters: lat/lon - float32, latitude/longitude of the point of interest - dt0/1 - datetime.datetime object, start/end date and time - step_sec - int16, time step in seconds - display - bool, plot the calculated SET - verbose - bool, print verbose message - Returns: dt_out - 1D np.ndarray in dt.datetime objects - tide_e - 1D np.ndarray in float32, SET in east direction in meters - tide_n - 1D np.ndarray in float32, SET in north direction in meters - tide_u - 1D np.ndarray in float32, SET in up direction in meters - Examples: dt0 = dt.datetime(2020,11,1,4,0,0) - dt1 = dt.datetime(2020,12,31,2,0,0) - (dt_out, - tide_e, - tide_n, - tide_u) = calc_solid_earth_tides_point(34.0, -118.0, dt0, dt1) + """ + Calculate SET in east/north/up direction for the given time period at the given + point (lat/lon). + + Parameters: + lat/lon : float + latitude/longitude of the point of interest, in degrees + dt0/1 : datetime.datetime + start/end datetimes + step_sec : int, optional + Time step, in seconds, of the output. Deaults to 60. + display : bool, optional + If True, plot the calculated SET. Defaults to False. + verbose : bool, optional + If True, print verbose messages. Defaults to False. + Returns: + dt_out : 1D np.ndarray of datetime.datetime + The datetimes associated with each index of the following three arrays. + The span of this array will be at least the period between dt0 and dt1. + tide_e : 1D np.ndarray of float32 + SET in east direction, in meters. + tide_n : 1D np.ndarray of float32 + SET in north direction, in meters. + tide_u : 1D np.ndarray of float32 + SET in up direction, in meters. + Example: + dt0 = dt.datetime(2020,11,1,4,0,0) + + dt1 = dt.datetime(2020,12,31,2,0,0) + + ( + dt_out, tide_e, tide_n, tide_u + ) = calc_solid_earth_tides_point(34.0, -118.0, dt0, dt1) """ print('PYSOLID: calculate solid Earth tides in east/north/up direction') @@ -144,20 +160,30 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): - """Calculate solid Earth tides (SET) in east/north/up direction - for one day at the given point (lat/lon). - - Parameters: lat/lon - float32, latitude/longitude of the point of interest - date_str - str, date in YYYYMMDD - step_sec - int16, time step in seconds - Returns: dt_out - 1D np.ndarray in dt.datetime objects - tide_e - 1D np.ndarray in float32, SET in east direction in meters - tide_n - 1D np.ndarray in float32, SET in north direction in meters - tide_u - 1D np.ndarray in float32, SET in up direction in meters - Examples: (dt_out, - tide_e, - tide_n, - tide_u) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219') + """ + Calculate solid Earth tides (SET) in east/north/up direction for one day at the + given point (lat/lon). + + Parameters: + lat/lon : float + Latitude/longitude of the point of interest + date_str : str + Date in YYYYMMDD format. + step_sec : int, optional + Time step, in seconds, of the output. Deaults to 60. + Returns: + dt_out : 1D np.ndarray of datetime.datetime + The datetimes associated with each index of the following three arrays. + tide_e : 1D np.ndarray of float32 + SET in east direction, in meters. + tide_n : 1D np.ndarray of float32 + SET in north direction, in meters. + tide_u : 1D np.ndarray of float32 + SET in up direction, in meters. + Examples: + ( + dt_out, tide_e, tide_n, tide_u + ) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219') """ try: from pysolid.solid import solid_point From 399f728e9ab042550b16b280899b870a6520d6ce Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 18:48:43 +0000 Subject: [PATCH 2/7] small add'l change --- src/pysolid/grid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index 72a484c..8e49aee 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -35,7 +35,7 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo X/Y_FIRST X/Y_STEP step_size : float - grid step size; fed into the fortran code in meters to speedup the + grid step size in meters; fed into the fortran code to speed up the calculation. display : bool, optional If True, plot the calculated SET. Defaults to False. @@ -50,7 +50,7 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo SET in up direction in meters Examples: atr = readfile.read_attribute('geo_velocity.h5') - + tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr) """ try: From 0eef26bedad2878a990b7e42dfa35b10e91f5e47 Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 19:05:47 +0000 Subject: [PATCH 3/7] Fix small docstring issues in calc_solid_earth_tides_grid and calc_solid_earth_tides_point --- src/pysolid/grid.py | 4 +++- src/pysolid/point.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index 8e49aee..0aec2f0 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -51,7 +51,9 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo Examples: atr = readfile.read_attribute('geo_velocity.h5') - tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr) + dt_obj = datetime.datetime(year=2018, month=2, day=19) + + tide_e, tide_n, tide_u = calc_solid_earth_tides_grid(dt_obj, atr) """ try: from pysolid.solid import solid_grid diff --git a/src/pysolid/point.py b/src/pysolid/point.py index 7890ee5..b2eef06 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -82,7 +82,7 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, dt0/1 : datetime.datetime start/end datetimes step_sec : int, optional - Time step, in seconds, of the output. Deaults to 60. + Time step, in seconds, of the output. Defaults to 60. display : bool, optional If True, plot the calculated SET. Defaults to False. verbose : bool, optional @@ -101,7 +101,7 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, dt0 = dt.datetime(2020,11,1,4,0,0) dt1 = dt.datetime(2020,12,31,2,0,0) - + ( dt_out, tide_e, tide_n, tide_u ) = calc_solid_earth_tides_point(34.0, -118.0, dt0, dt1) From 2de5cb8ff0b0007ae9321cf6baa76d62915d1f69 Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 19:16:04 +0000 Subject: [PATCH 4/7] Clarify lat/lon units in calc_solid_earth_tides_point_per_day --- src/pysolid/point.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pysolid/point.py b/src/pysolid/point.py index b2eef06..291dcac 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -78,7 +78,7 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, Parameters: lat/lon : float - latitude/longitude of the point of interest, in degrees + latitude/longitude of the point of interest, in degrees. dt0/1 : datetime.datetime start/end datetimes step_sec : int, optional @@ -166,9 +166,9 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): Parameters: lat/lon : float - Latitude/longitude of the point of interest + Latitude/longitude of the point of interest, in degrees. date_str : str - Date in YYYYMMDD format. + The date to generate solid earth tides for, in YYYYMMDD format. step_sec : int, optional Time step, in seconds, of the output. Deaults to 60. Returns: @@ -180,7 +180,7 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): SET in north direction, in meters. tide_u : 1D np.ndarray of float32 SET in up direction, in meters. - Examples: + Examples: ( dt_out, tide_e, tide_n, tide_u ) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219') From eae9852dba995a4696dd04f4f3c7ba19420b4c52 Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 19:25:14 +0000 Subject: [PATCH 5/7] Further documentation clarifications. --- src/pysolid/grid.py | 2 +- src/pysolid/point.py | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index 0aec2f0..a5c9138 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -40,7 +40,7 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo display : bool, optional If True, plot the calculated SET. Defaults to False. verbose : bool, optional - If True, print verbose messages. Defaults to False. + If True, print verbose messages. Defaults to True. Returns: tide_e : 2D np.ndarray of floats SET in east direction in meters diff --git a/src/pysolid/point.py b/src/pysolid/point.py index 291dcac..7fb79ea 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -73,24 +73,30 @@ ################################## Earth tides - point mode ################################## def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, verbose=True): """ - Calculate SET in east/north/up direction for the given time period at the given - point (lat/lon). + Calculate solid earth tides (SET) in east/north/up direction for the given time + period at the given point. Parameters: - lat/lon : float - latitude/longitude of the point of interest, in degrees. - dt0/1 : datetime.datetime - start/end datetimes + lat : float + Latitude of the point of interest, in degrees. + lon : float + Longitude of the point of interest, in degrees. + dt0 : datetime.datetime + The datetime of the beginning of the SET calculation. + dt1 : datetime.datetime + The datetime of the end of the SET calculation. step_sec : int, optional Time step, in seconds, of the output. Defaults to 60. display : bool, optional If True, plot the calculated SET. Defaults to False. verbose : bool, optional - If True, print verbose messages. Defaults to False. + If True, print verbose messages. Defaults to True. Returns: dt_out : 1D np.ndarray of datetime.datetime The datetimes associated with each index of the following three arrays. The span of this array will be at least the period between dt0 and dt1. + Note that dt_out is clamped to step_sec, so the start and end times may + be slightly different than dt0 and dt1. tide_e : 1D np.ndarray of float32 SET in east direction, in meters. tide_n : 1D np.ndarray of float32 @@ -164,9 +170,11 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): Calculate solid Earth tides (SET) in east/north/up direction for one day at the given point (lat/lon). - Parameters: - lat/lon : float - Latitude/longitude of the point of interest, in degrees. + Parameters: + lat : float + Latitude of the point of interest, in degrees. + lon : float + Longitude of the point of interest, in degrees. date_str : str The date to generate solid earth tides for, in YYYYMMDD format. step_sec : int, optional From a669687399a672504a09125f8765f2f81764a00f Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 19:32:30 +0000 Subject: [PATCH 6/7] Typo fix, specify that step_size is optional in calc_solid_earth_tides_grid --- src/pysolid/grid.py | 4 ++-- src/pysolid/point.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index a5c9138..76c1be9 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -34,9 +34,9 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo LENGTH/WIDTH X/Y_FIRST X/Y_STEP - step_size : float + step_size : float, optional grid step size in meters; fed into the fortran code to speed up the - calculation. + calculation. Defaults to 1e3. display : bool, optional If True, plot the calculated SET. Defaults to False. verbose : bool, optional diff --git a/src/pysolid/point.py b/src/pysolid/point.py index 7fb79ea..acae811 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -178,7 +178,7 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): date_str : str The date to generate solid earth tides for, in YYYYMMDD format. step_sec : int, optional - Time step, in seconds, of the output. Deaults to 60. + Time step, in seconds, of the output. Defaults to 60. Returns: dt_out : 1D np.ndarray of datetime.datetime The datetimes associated with each index of the following three arrays. From 3ffaeaa934d7e343b5f058471b7c912e9889b8e7 Mon Sep 17 00:00:00 2001 From: Tyler Hudson Date: Thu, 5 Mar 2026 21:03:11 +0000 Subject: [PATCH 7/7] Tiny docstring consistency change --- src/pysolid/grid.py | 6 ++++-- src/pysolid/point.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index 76c1be9..676c5c3 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -41,14 +41,16 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo If True, plot the calculated SET. Defaults to False. verbose : bool, optional If True, print verbose messages. Defaults to True. - Returns: + + Returns: tide_e : 2D np.ndarray of floats SET in east direction in meters tide_n : 2D np.ndarray SET in north direction in meters tide_u : 2D np.ndarray SET in up direction in meters - Examples: + + Example: atr = readfile.read_attribute('geo_velocity.h5') dt_obj = datetime.datetime(year=2018, month=2, day=19) diff --git a/src/pysolid/point.py b/src/pysolid/point.py index acae811..546135c 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -91,7 +91,8 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, If True, plot the calculated SET. Defaults to False. verbose : bool, optional If True, print verbose messages. Defaults to True. - Returns: + + Returns: dt_out : 1D np.ndarray of datetime.datetime The datetimes associated with each index of the following three arrays. The span of this array will be at least the period between dt0 and dt1. @@ -103,7 +104,8 @@ def calc_solid_earth_tides_point(lat, lon, dt0, dt1, step_sec=60, display=False, SET in north direction, in meters. tide_u : 1D np.ndarray of float32 SET in up direction, in meters. - Example: + + Example: dt0 = dt.datetime(2020,11,1,4,0,0) dt1 = dt.datetime(2020,12,31,2,0,0) @@ -179,7 +181,8 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): The date to generate solid earth tides for, in YYYYMMDD format. step_sec : int, optional Time step, in seconds, of the output. Defaults to 60. - Returns: + + Returns: dt_out : 1D np.ndarray of datetime.datetime The datetimes associated with each index of the following three arrays. tide_e : 1D np.ndarray of float32 @@ -188,7 +191,8 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): SET in north direction, in meters. tide_u : 1D np.ndarray of float32 SET in up direction, in meters. - Examples: + + Example: ( dt_out, tide_e, tide_n, tide_u ) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219')