Skip to content

Commit 69f841b

Browse files
committed
refactor: change 1 liner default EPSG to 4326 (#379)
* ci: bump version of upload artifact to v4
1 parent 1217432 commit 69f841b

File tree

11 files changed

+302
-164
lines changed

11 files changed

+302
-164
lines changed

.github/workflows/python-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
verbose: true
9393
- name: Archive code coverage results
9494
if: steps.secrets.outputs.accessible == 'true'
95-
uses: actions/upload-artifact@v3
95+
uses: actions/upload-artifact@v4
9696
with:
9797
name: code-coverage-report
9898
path: ./coverage.xml

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Contributing
115115
############
116116

117117
This project contains work and contributions from the `scientific community <./CONTRIBUTORS.rst>`_.
118-
If you would like to contribute to the project, please have a look at the `open issues <https://github.com/tsutterley/pyTMD/issues>`_ and the project `code of conduct <./CODE_OF_CONDUCT.rst>`_.
118+
If you would like to contribute to the project, please have a look at the `open issues <https://github.com/tsutterley/pyTMD/issues>`_ and `discussions board <https://github.com/tsutterley/pyTMD/discussions>`_.
119119

120120
Credits
121121
#######

pyTMD/compute.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def tide_elevations(
220220
CROP: bool = False,
221221
BOUNDS: list | np.ndarray | None = None,
222222
BUFFER: int | float | None = None,
223-
EPSG: str | int = 3031,
223+
EPSG: str | int = 4326,
224224
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
225225
TYPE: str | None = 'drift',
226226
TIME: str = 'UTC',
@@ -261,7 +261,7 @@ def tide_elevations(
261261
Boundaries for cropping tide model data
262262
BUFFER: int, float or NoneType, default None
263263
Buffer distance for cropping tide model data
264-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
264+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
265265
Input coordinate system
266266
EPOCH: tuple, default (2000,1,1,0,0,0)
267267
Time period for calculating delta times
@@ -448,7 +448,7 @@ def tide_currents(
448448
CROP: bool = False,
449449
BOUNDS: list | np.ndarray | None = None,
450450
BUFFER: int | float | None = None,
451-
EPSG: str | int = 3031,
451+
EPSG: str | int = 4326,
452452
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
453453
TYPE: str | None = 'drift',
454454
TIME: str = 'UTC',
@@ -487,7 +487,7 @@ def tide_currents(
487487
Boundaries for cropping tide model data
488488
BUFFER: int, float or NoneType, default None
489489
Buffer distance for cropping tide model data
490-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
490+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
491491
Input coordinate system
492492
EPOCH: tuple, default (2000,1,1,0,0,0)
493493
Time period for calculating delta times
@@ -667,7 +667,7 @@ def tide_masks(x: np.ndarray, y: np.ndarray,
667667
MODEL: str | None = None,
668668
GZIP: bool = False,
669669
DEFINITION_FILE: str | pathlib.Path | None = None,
670-
EPSG: str | int = 3031,
670+
EPSG: str | int = 4326,
671671
METHOD: str = 'spline'
672672
):
673673
"""
@@ -687,7 +687,7 @@ def tide_masks(x: np.ndarray, y: np.ndarray,
687687
Tide model files are gzip compressed
688688
DEFINITION_FILE: str or NoneType, default None
689689
Tide model definition file for use
690-
EPSG: str or int, default: 3031 (Polar Stereographic South, WGS84)
690+
EPSG: str or int, default: 4326 (WGS84 Latitude and Longitude)
691691
Input coordinate system
692692
METHOD: str, default 'spline'
693693
interpolation method
@@ -795,7 +795,7 @@ def tide_masks(x: np.ndarray, y: np.ndarray,
795795
# PURPOSE: compute long-period equilibrium tidal elevations
796796
def LPET_elevations(
797797
x: np.ndarray, y: np.ndarray, delta_time: np.ndarray,
798-
EPSG: str | int = 3031,
798+
EPSG: str | int = 4326,
799799
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
800800
TYPE: str | None = 'drift',
801801
TIME: str = 'UTC',
@@ -812,7 +812,7 @@ def LPET_elevations(
812812
y-coordinates in projection EPSG
813813
delta_time: np.ndarray
814814
seconds since EPOCH or datetime array
815-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
815+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
816816
Input coordinate system
817817
EPOCH: tuple, default (2000,1,1,0,0,0)
818818
Time period for calculating delta times
@@ -900,7 +900,7 @@ def LPET_elevations(
900900
# following IERS Convention (2010) guidelines
901901
def LPT_displacements(
902902
x: np.ndarray, y: np.ndarray, delta_time: np.ndarray,
903-
EPSG: str | int = 3031,
903+
EPSG: str | int = 4326,
904904
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
905905
TYPE: str | None = 'drift',
906906
TIME: str = 'UTC',
@@ -921,7 +921,7 @@ def LPT_displacements(
921921
y-coordinates in projection EPSG
922922
delta_time: np.ndarray
923923
seconds since EPOCH or datetime array
924-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
924+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
925925
Input coordinate system
926926
EPOCH: tuple, default (2000,1,1,0,0,0)
927927
Time period for calculating delta times
@@ -1100,7 +1100,7 @@ def LPT_displacements(
11001100
# following IERS Convention (2010) guidelines
11011101
def OPT_displacements(
11021102
x: np.ndarray, y: np.ndarray, delta_time: np.ndarray,
1103-
EPSG: str | int = 3031,
1103+
EPSG: str | int = 4326,
11041104
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
11051105
TYPE: str | None = 'drift',
11061106
TIME: str = 'UTC',
@@ -1122,7 +1122,7 @@ def OPT_displacements(
11221122
y-coordinates in projection EPSG
11231123
delta_time: np.ndarray
11241124
seconds since EPOCH or datetime array
1125-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
1125+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
11261126
Input coordinate system
11271127
EPOCH: tuple, default (2000,1,1,0,0,0)
11281128
Time period for calculating delta times
@@ -1328,7 +1328,7 @@ def OPT_displacements(
13281328
# PURPOSE: compute solid earth tidal elevations
13291329
def SET_displacements(
13301330
x: np.ndarray, y: np.ndarray, delta_time: np.ndarray,
1331-
EPSG: str | int = 3031,
1331+
EPSG: str | int = 4326,
13321332
EPOCH: list | tuple = (2000, 1, 1, 0, 0, 0),
13331333
TYPE: str | None = 'drift',
13341334
TIME: str = 'UTC',
@@ -1349,7 +1349,7 @@ def SET_displacements(
13491349
y-coordinates in projection EPSG
13501350
delta_time: np.ndarray
13511351
seconds since EPOCH or datetime array
1352-
EPSG: int, default: 3031 (Polar Stereographic South, WGS84)
1352+
EPSG: int, default: 4326 (WGS84 Latitude and Longitude)
13531353
Input coordinate system
13541354
EPOCH: tuple, default (2000,1,1,0,0,0)
13551355
Time period for calculating delta times

pyTMD/predict.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def map(t: float | np.ndarray,
108108
corrections: str = 'OTIS'
109109
):
110110
"""
111-
Predict tides at a single time using harmonic constants :cite:p:`Egbert:2002ge`
111+
Predict tides at a single time using harmonic
112+
constants :cite:p:`Egbert:2002ge`
112113
113114
Parameters
114115
----------
@@ -280,8 +281,9 @@ def infer_minor(
280281
):
281282
"""
282283
Infer the tidal values for minor constituents using their
283-
relation with major constituents :cite:p:`Doodson:1941td` :cite:p:`Schureman:1958ty`
284-
:cite:p:`Foreman:1989dt` :cite:p:`Egbert:2002ge`
284+
relation with major constituents :cite:p:`Doodson:1941td`
285+
:cite:p:`Schureman:1958ty` :cite:p:`Foreman:1989dt`
286+
:cite:p:`Egbert:2002ge`
285287
286288
Parameters
287289
----------
@@ -621,7 +623,8 @@ def _infer_diurnal(
621623
Infer the tidal values for diurnal minor constituents
622624
using their relation with major constituents taking into
623625
account resonance due to free core nutation
624-
:cite:p:`Munk:1966go` :cite:p:`Ray:2017jx` :cite:p:`Wahr:1981if` :cite:p:`Cartwright:1973em`
626+
:cite:p:`Munk:1966go` :cite:p:`Ray:2017jx` :cite:p:`Wahr:1981if`
627+
:cite:p:`Cartwright:1973em`
625628
626629
Parameters
627630
----------
@@ -1259,7 +1262,8 @@ def solid_earth_tide(
12591262
):
12601263
"""
12611264
Compute the solid Earth tides due to the gravitational attraction of
1262-
the moon and sun :cite:p:`Mathews:1991kv` :cite:p:`Mathews:1997js` :cite:p:`Ries:1992ip` :cite:p:`Wahr:1981ea`
1265+
the moon and sun :cite:p:`Mathews:1991kv` :cite:p:`Mathews:1997js`
1266+
:cite:p:`Ries:1992ip` :cite:p:`Wahr:1981ea`
12631267
12641268
Parameters
12651269
----------

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ omit = [
101101
[tool.coverage.report]
102102
show_missing = true
103103
precision = 2
104+
105+
[tool.ruff]
106+
line-length = 80

test/test_arguments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,8 @@ def test_parse_tables():
853853
CTE = pyTMD.arguments._parse_tide_potential_table(table)
854854
for i, line in enumerate(CTE):
855855
# convert Doodson number to Cartwright numbers
856-
tau, s, h, p, n, pp = pyTMD.arguments._from_doodson_number(line['DO'])
856+
DO = line['DO']
857+
tau, s, h, p, n, pp = pyTMD.arguments._from_doodson_number(DO)
857858
assert tau == line['tau'], line
858859
assert s == line['s'], line
859860
assert h == line['h'], line

test/test_atlas_read.py

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@
5353

5454
# PURPOSE: Download TPXO8 ATLAS compact constituents from AWS S3 bucket
5555
# @pytest.fixture(scope="module", autouse=True)
56-
def download_TPXO8(aws_access_key_id,aws_secret_access_key,aws_region_name):
56+
def download_TPXO8(
57+
aws_access_key_id,
58+
aws_secret_access_key,
59+
aws_region_name
60+
):
5761
# get aws session object
5862
session = boto3.Session(
5963
aws_access_key_id=aws_access_key_id,
@@ -67,8 +71,11 @@ def download_TPXO8(aws_access_key_id,aws_secret_access_key,aws_region_name):
6771
model_directory = filepath.joinpath('tpxo8_atlas')
6872
# recursively create model directory
6973
model_directory.mkdir(parents=True, exist_ok=True)
74+
model_files = ['grid_tpxo8atlas_30_v1',
75+
'hf.tpxo8_atlas_30_v1',
76+
'uv.tpxo8_atlas_30_v1']
7077
# retrieve each model file from s3
71-
for f in ['grid_tpxo8atlas_30_v1','hf.tpxo8_atlas_30_v1','uv.tpxo8_atlas_30_v1']:
78+
for f in model_files:
7279
# retrieve constituent file
7380
obj = bucket.Object(key=posixpath.join('tpxo8_atlas',f))
7481
response = obj.get()
@@ -83,7 +90,11 @@ def download_TPXO8(aws_access_key_id,aws_secret_access_key,aws_region_name):
8390

8491
# PURPOSE: Download TPXO9 ATLAS V2 netCDF constituents from AWS S3 bucket
8592
@pytest.fixture(scope="module", autouse=True)
86-
def download_TPXO9_v2(aws_access_key_id,aws_secret_access_key,aws_region_name):
93+
def download_TPXO9_v2(
94+
aws_access_key_id,
95+
aws_secret_access_key,
96+
aws_region_name
97+
):
8798
# get aws session object
8899
session = boto3.Session(
89100
aws_access_key_id=aws_access_key_id,
@@ -94,13 +105,14 @@ def download_TPXO9_v2(aws_access_key_id,aws_secret_access_key,aws_region_name):
94105
bucket = s3.Bucket('pytmd')
95106

96107
# model parameters for TPXO9-atlas-v2
97-
model = pyTMD.io.model(filepath,format='ATLAS-netcdf',compressed=True,
98-
verify=False).elevation('TPXO9-atlas-v2-nc')
108+
model = pyTMD.io.model(filepath,compressed=True,verify=False
109+
).elevation('TPXO9-atlas-v2-nc')
99110
# recursively create model directory
100111
model_directory = model.model_file[0].parent
101112
model_directory.mkdir(parents=True, exist_ok=True)
102113
# retrieve grid file from s3
103-
obj = bucket.Object(key=posixpath.join('TPXO9_atlas_v2',model.grid_file.name))
114+
key = posixpath.join('TPXO9_atlas_v2',model.grid_file.name)
115+
obj = bucket.Object(key=key)
104116
response = obj.get()
105117
# save grid data
106118
with model.grid_file.open(mode='wb') as destination:
@@ -109,7 +121,8 @@ def download_TPXO9_v2(aws_access_key_id,aws_secret_access_key,aws_region_name):
109121
# retrieve each model file from s3
110122
for model_file in model.model_file:
111123
# retrieve constituent file
112-
obj = bucket.Object(key=posixpath.join('TPXO9_atlas_v2',model_file.name))
124+
key = posixpath.join('TPXO9_atlas_v2',model_file.name)
125+
obj = bucket.Object(key=key)
113126
response = obj.get()
114127
# save constituent data
115128
with model_file.open(mode='wb') as destination:
@@ -131,8 +144,12 @@ def test_read_TPXO9_v2(METHOD, EXTRAPOLATE, CROP):
131144
# model grid file
132145
grid_file = model_directory.joinpath('grid_tpxo9_atlas_30_v2.nc.gz')
133146
# constituent files included in test
134-
model_files = ['h_m2_tpxo9_atlas_30_v2.nc.gz','h_s2_tpxo9_atlas_30_v2.nc.gz',
135-
'h_k1_tpxo9_atlas_30_v2.nc.gz','h_o1_tpxo9_atlas_30_v2.nc.gz']
147+
model_files = [
148+
'h_m2_tpxo9_atlas_30_v2.nc.gz',
149+
'h_s2_tpxo9_atlas_30_v2.nc.gz',
150+
'h_k1_tpxo9_atlas_30_v2.nc.gz',
151+
'h_o1_tpxo9_atlas_30_v2.nc.gz'
152+
]
136153
model_file = [model_directory.joinpath(m) for m in model_files]
137154
constituents = ['m2','s2','k1','o1']
138155
TYPE = 'z'
@@ -176,8 +193,12 @@ def test_compare_TPXO9_v2(METHOD):
176193
# model grid file
177194
grid_file = model_directory.joinpath('grid_tpxo9_atlas_30_v2.nc.gz')
178195
# constituent files included in test
179-
model_files = ['h_m2_tpxo9_atlas_30_v2.nc.gz','h_s2_tpxo9_atlas_30_v2.nc.gz',
180-
'h_k1_tpxo9_atlas_30_v2.nc.gz','h_o1_tpxo9_atlas_30_v2.nc.gz']
196+
model_files = [
197+
'h_m2_tpxo9_atlas_30_v2.nc.gz',
198+
'h_s2_tpxo9_atlas_30_v2.nc.gz',
199+
'h_k1_tpxo9_atlas_30_v2.nc.gz',
200+
'h_o1_tpxo9_atlas_30_v2.nc.gz'
201+
]
181202
model_file = [model_directory.joinpath(m) for m in model_files]
182203
TYPE = 'z'
183204
SCALE = 1.0
@@ -316,8 +337,12 @@ def test_verify_TPXO9_v2(METHOD, EXTRAPOLATE, CROP):
316337
# model grid file
317338
grid_file = model_directory.joinpath('grid_tpxo9_atlas_30_v2.nc.gz')
318339
# constituent files included in test
319-
model_files = ['h_m2_tpxo9_atlas_30_v2.nc.gz','h_s2_tpxo9_atlas_30_v2.nc.gz',
320-
'h_k1_tpxo9_atlas_30_v2.nc.gz','h_o1_tpxo9_atlas_30_v2.nc.gz']
340+
model_files = [
341+
'h_m2_tpxo9_atlas_30_v2.nc.gz',
342+
'h_s2_tpxo9_atlas_30_v2.nc.gz',
343+
'h_k1_tpxo9_atlas_30_v2.nc.gz',
344+
'h_o1_tpxo9_atlas_30_v2.nc.gz'
345+
]
321346
model_file = [model_directory.joinpath(m) for m in model_files]
322347
constituents = ['m2','s2','k1','o1']
323348
model_format = 'ATLAS-netcdf'
@@ -413,7 +438,8 @@ def test_definition_file(MODEL):
413438
model = pyTMD.io.model(filepath,compressed=True).elevation(MODEL)
414439
# create model definition file
415440
fid = io.StringIO()
416-
attrs = ['name','format','grid_file','model_file','compressed','type','scale']
441+
attrs = ['name','format','grid_file','model_file',
442+
'compressed','type','scale']
417443
d = model.to_dict(fields=attrs, serialize=True)
418444
json.dump(d, fid)
419445
fid.seek(0)

test/test_coordinates.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
@pytest.mark.parametrize("MODEL", models)
2020
# PURPOSE: verify forward and backwards coordinate conversions
2121
def test_coordinates(MODEL):
22-
startlat = {'Gr1km-v2':60,'CATS2008':-60,'AOTIM-5-2018':60,'TPXO9-atlas-v5':90}
23-
endlat = {'Gr1km-v2':70,'CATS2008':-70,'AOTIM-5-2018':70,'TPXO9-atlas-v5':-90}
24-
is_geographic = {'Gr1km-v2':False,'CATS2008':False,
25-
'AOTIM-5-2018':False,'TPXO9-atlas-v5':True}
22+
startlat = {'Gr1km-v2':60, 'CATS2008':-60,
23+
'AOTIM-5-2018':60,'TPXO9-atlas-v5':90}
24+
endlat = {'Gr1km-v2':70, 'CATS2008':-70,
25+
'AOTIM-5-2018':70,'TPXO9-atlas-v5':-90}
26+
is_geographic = {'Gr1km-v2':False, 'CATS2008':False,
27+
'AOTIM-5-2018':False, 'TPXO9-atlas-v5':True}
2628
i1 = np.arange(-180,180+1,1)
2729
i2 = np.linspace(startlat[MODEL],endlat[MODEL],len(i1))
2830
# convert latitude and longitude to and from projection

0 commit comments

Comments
 (0)