Skip to content

Commit

Permalink
fix: added encoding for reading leap seconds ascii files (#116)
Browse files Browse the repository at this point in the history
* fix: added encoding for reading leap seconds ascii files

feat: try a windows build

* no windows build (missing octave)
  • Loading branch information
tsutterley authored Oct 27, 2022
1 parent 19372ae commit 4933f72
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/source/getting_started/Getting-Started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Some regional tide models are projected in a different coordinate system.
For these cases, ``pyTMD`` will `convert from latitude and longitude to the model coordinate system <https://github.com/tsutterley/pyTMD/blob/main/pyTMD/convert_ll_xy.py>`_.

OTIS models may be projected into a separate coordinate system. The available OTIS projections within ``pyTMD`` are

- ``'4326'`` (global latitude and longitude)
- ``'3031'`` (Antarctic Polar Stereographic in kilometers)
- ``'3413'`` (NSIDC Sea Ice Polar Stereographic North in kilometers)
Expand Down
3 changes: 2 additions & 1 deletion doc/source/getting_started/Resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Software
- `TMD Matlab Toolbox Repository <https://github.com/EarthAndSpaceResearch/TMD_Matlab_Toolbox_v2.5>`_
- `Antarctic Tide Gauge (AntTG) Database Tools <https://github.com/EarthAndSpaceResearch/AntTG_Database_Tools>`_
- `OSU Tidal Prediction Software (OTPS) <https://www.tpxo.net/otps>`_
- `FES (Finite Element Solution) tide model software <https://bitbucket.org/cnes_aviso/fes/src/master/>`_
- `FES (Finite Element Solution) tide model software <https://github.com/CNES/aviso-fes>`_
- `Tidal Correction Software for NASA Polar Altimetry Missions <https://github.com/tsutterley/Grounding-Zones>`_
7 changes: 4 additions & 3 deletions pyTMD/time.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
time.py
Written by Tyler Sutterley (08/2022)
Written by Tyler Sutterley (10/2022)
Utilities for calculating time operations
PYTHON DEPENDENCIES:
Expand All @@ -16,6 +16,7 @@
utilities.py: download and management utilities for syncing files
UPDATE HISTORY:
Updated 10/2022: added encoding for reading leap seconds ascii files
Updated 08/2022: output variables to unit conversion to seconds
and the number of days per month for both leap and standard years
Updated 05/2022: changed keyword arguments to camel case
Expand Down Expand Up @@ -555,7 +556,7 @@ def get_leap_seconds(truncate=True):
"""
leap_secs = pyTMD.utilities.get_data_path(['data','leap-seconds.list'])
# find line with file expiration as delta time
with open(leap_secs,'r') as fid:
with open(leap_secs, mode='r', encoding='utf8') as fid:
secs, = [re.findall(r'\d+',i).pop() for i in fid.read().splitlines()
if re.match(r'^(?=#@)',i)]
# check that leap seconds file is still valid
Expand Down Expand Up @@ -973,7 +974,7 @@ def read_iers_bulletin_a(fileID):
# TAI time is ahead of GPS by 19 seconds
TAI_GPS = 19.0
# calculate calendar dates from Modified Julian days
Y,M,D,h,m,s = convert_julian(MJD[:valid]+2400000.5,FORMAT='tuple')
Y,M,D,h,m,s = convert_julian(MJD[:valid]+2400000.5, format='tuple')
# calculate GPS Time (seconds since 1980-01-06T00:00:00)
# by converting the Modified Julian days (days since 1858-11-17T00:00:00)
GPS_Time = convert_delta_time(MJD[:valid]*8.64e4, epoch1=(1858,11,17,0,0,0),
Expand Down
15 changes: 10 additions & 5 deletions test/test_download_and_read.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
u"""
test_download_and_read.py (09/2021)
test_download_and_read.py (10/2022)
Tests that CATS2008 data can be downloaded from the US Antarctic Program (USAP)
Tests that AOTIM-5-2018 data can be downloaded from the NSF ArcticData server
Tests the read program to verify that constituents are being extracted
Expand All @@ -19,6 +19,7 @@
https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
UPDATE HISTORY:
Updated 10/2022: added encoding for reading ascii files
Updated 09/2021: added test for model definition files
Updated 07/2021: download CATS2008 and AntTG from S3 to bypass USAP captcha
Updated 05/2021: added test for check point program
Expand Down Expand Up @@ -238,7 +239,8 @@ def test_compare_CATS2008(self):
TYPE = 'z'

# open Antarctic Tide Gauge (AntTG) database
with open(os.path.join(filepath,'AntTG_ocean_height_v1.txt'),'r') as f:
AntTG = 'AntTG_ocean_height_v1.txt'
with open(os.path.join(filepath,AntTG),mode='r',encoding='utf8') as f:
file_contents = f.read().splitlines()
# counts the number of lines in the header
count = 0
Expand Down Expand Up @@ -333,7 +335,8 @@ def test_verify_CATS2008(self, parameters):
EPSG = 'CATS2008'

# open Antarctic Tide Gauge (AntTG) database
with open(os.path.join(filepath,'AntTG_ocean_height_v1.txt'),'r') as f:
AntTG = 'AntTG_ocean_height_v1.txt'
with open(os.path.join(filepath,AntTG),mode='r',encoding='utf8') as f:
file_contents = f.read().splitlines()
# counts the number of lines in the header
count = 0
Expand Down Expand Up @@ -444,7 +447,8 @@ def test_tidal_ellipse(self):
EPSG = 'CATS2008'

# open Antarctic Tide Gauge (AntTG) database
with open(os.path.join(filepath,'AntTG_ocean_height_v1.txt'),'r') as f:
AntTG = 'AntTG_ocean_height_v1.txt'
with open(os.path.join(filepath,AntTG),mode='r',encoding='utf8') as f:
file_contents = f.read().splitlines()
# counts the number of lines in the header
count = 0
Expand Down Expand Up @@ -654,7 +658,8 @@ def test_verify_AOTIM5_2018(self, parameters):
EPSG = 'PSNorth'

# open Arctic Tidal Current Atlas list of records
with open(os.path.join(filepath,'List_of_records.txt'),'r') as f:
ATLAS = 'List_of_records.txt'
with open(os.path.join(filepath,ATLAS),mode='r',encoding='utf8') as f:
file_contents = f.read().splitlines()
# skip 2 header rows
count = 2
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1

0 comments on commit 4933f72

Please sign in to comment.