diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL03.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL03.rst index 98effb1..1616390 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL03.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL03.rst @@ -5,7 +5,7 @@ compute_tides_ICESat2_ATL03.py - Calculates tidal elevations for correcting ICESat-2 photon height data - Calculated at ATL03 segment level using reference photon geolocation and time - Segment level corrections can be applied to the individual photon events (PEs) -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL06.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL06.rst index a227ed4..f598cb3 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL06.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL06.rst @@ -3,7 +3,7 @@ compute_tides_ICESat2_ATL06.py ============================== - Calculates tidal elevations for correcting ICESat-2 land ice elevation data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL07.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL07.rst index 802cefa..0693552 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL07.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL07.rst @@ -3,7 +3,7 @@ compute_tides_ICESat2_ATL07.py ============================== - Calculates tidal elevations for correcting ICESat-2 sea ice height data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL10.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL10.rst index 668a928..16578fc 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL10.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL10.rst @@ -3,7 +3,7 @@ compute_tides_ICESat2_ATL10.py ============================== - Calculates tidal elevations for correcting ICESat-2 sea ice freeboard data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL11.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL11.rst index 33f7322..c64c48f 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL11.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL11.rst @@ -4,7 +4,7 @@ compute_tides_ICESat2_ATL11.py - Calculates tidal elevations for correcting ICESat-2 annual land ice height data - Calculates tidal elevations for both along-track and across-track locations -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL12.rst b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL12.rst index caaa8c3..016fa8f 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat2_ATL12.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat2_ATL12.rst @@ -3,7 +3,7 @@ compute_tides_ICESat2_ATL12.py ============================== - Calculates tidal elevations for correcting ICESat-2 ocean surface height data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Glgobal Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_ICESat_GLA12.rst b/doc/source/api_reference/tides/compute_tides_ICESat_GLA12.rst index c7108e4..71118d0 100644 --- a/doc/source/api_reference/tides/compute_tides_ICESat_GLA12.rst +++ b/doc/source/api_reference/tides/compute_tides_ICESat_GLA12.rst @@ -3,7 +3,7 @@ compute_tides_ICESat_GLA12.py ============================= - Calculates tidal elevations for correcting ICESat/GLAS L2 GLA12 Antarctic and Greenland Ice Sheet elevation data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/doc/source/api_reference/tides/compute_tides_icebridge_data.rst b/doc/source/api_reference/tides/compute_tides_icebridge_data.rst index f935c5e..9f59d54 100644 --- a/doc/source/api_reference/tides/compute_tides_icebridge_data.rst +++ b/doc/source/api_reference/tides/compute_tides_icebridge_data.rst @@ -3,7 +3,7 @@ compute_tides_icebridge_data.py =============================== - Calculates tidal elevations for correcting Operation IceBridge elevation data -- Can use OTIS format tidal solutions provided by Ohio State University and ESR +- Can use OTIS format tidal solutions provided by Oregon State University and ESR - Can use Global Tide Model (GOT) solutions provided by Richard Ray at GSFC - Can use Finite Element Solution (FES) models provided by AVISO diff --git a/tides/compute_tides_ICESat2_ATL03.py b/tides/compute_tides_ICESat2_ATL03.py index 7dde003..7f0da1f 100644 --- a/tides/compute_tides_ICESat2_ATL03.py +++ b/tides/compute_tides_ICESat2_ATL03.py @@ -6,7 +6,7 @@ Calculated at ATL03 segment level using reference photon geolocation and time Segment level corrections can be applied to the individual photon events (PEs) -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -68,6 +68,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -221,25 +225,26 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(bounding_lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS, + grid=corrections, crop=CROP, bounds=BOUNDS, apply_flexure=APPLY_FLEXURE) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -291,25 +296,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, epoch=timescale.time._atlas_sdp_epoch, standard='GPS') # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(lon, lat, constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(lon, lat, constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(lon, lat, constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(lon, lat, constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -325,11 +330,11 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, tide = np.ma.empty((n_seg),fill_value=fv) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_ICESat2_ATL06.py b/tides/compute_tides_ICESat2_ATL06.py index c11dfc3..54bb04b 100644 --- a/tides/compute_tides_ICESat2_ATL06.py +++ b/tides/compute_tides_ICESat2_ATL06.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting ICESat-2 land ice elevation data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -63,6 +63,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -211,25 +215,26 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS, + grid=corrections, crop=CROP, bounds=BOUNDS, apply_flexure=APPLY_FLEXURE) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -274,25 +279,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, epoch=timescale.time._atlas_sdp_epoch, standard='GPS') # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(val['longitude'], val['latitude'], constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(val['longitude'], val['latitude'], constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -308,11 +313,11 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, tide = np.ma.empty((n_seg),fill_value=fv) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_ICESat2_ATL07.py b/tides/compute_tides_ICESat2_ATL07.py index 4f35802..9d8bda0 100644 --- a/tides/compute_tides_ICESat2_ATL07.py +++ b/tides/compute_tides_ICESat2_ATL07.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting ICESat-2 sea ice height data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -61,6 +61,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -204,24 +208,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS) + grid=corrections, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -264,25 +269,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, epoch=timescale.time._atlas_sdp_epoch, standard='GPS') # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(val['longitude'], val['latitude'], constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(val['longitude'], val['latitude'], constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -298,11 +303,11 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, tide = np.ma.empty((n_seg)) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_ICESat2_ATL10.py b/tides/compute_tides_ICESat2_ATL10.py index c44a584..2670888 100644 --- a/tides/compute_tides_ICESat2_ATL10.py +++ b/tides/compute_tides_ICESat2_ATL10.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting ICESat-2 sea ice height data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -61,6 +61,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -207,24 +211,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS) + grid=corrections, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -289,25 +294,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, epoch=timescale.time._atlas_sdp_epoch, standard='GPS') # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(val['longitude'], val['latitude'], constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(val['longitude'], val['latitude'], constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -323,11 +328,11 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, tide = np.ma.empty((n_seg)) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_ICESat2_ATL11.py b/tides/compute_tides_ICESat2_ATL11.py index 08d8621..e02468d 100644 --- a/tides/compute_tides_ICESat2_ATL11.py +++ b/tides/compute_tides_ICESat2_ATL11.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting ICESat-2 annual land ice height data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -64,6 +64,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 06/2024: added option to not run with crossover measurements Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations @@ -208,25 +212,26 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(bounding_lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS, + grid=corrections, crop=CROP, bounds=BOUNDS, apply_flexure=APPLY_FLEXURE) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -314,25 +319,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, nt = len(ts) # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(longitude[track], latitude[track], constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros_like(ts.tt_ut1) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(longitude[track], latitude[track], constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros_like(ts.tt_ut1) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(longitude[track], latitude[track], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(longitude[track], latitude[track], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -354,13 +359,13 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, # predict tidal elevations and infer minor corrections tide[track].data[valid,cycle] = pyTMD.predict.drift( ts.tide[valid,cycle], hc[valid,:], c, - deltat=deltat[valid,cycle], corrections=model.format) + deltat=deltat[valid,cycle], corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor( ts.tide[valid,cycle], hc[valid,:], c, deltat=deltat[valid,cycle], - corrections=model.format) + corrections=corrections) tide[track].data[valid,cycle] += minor.data[:] elif (track == 'XT'): # find valid time and spatial points @@ -369,13 +374,13 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, # predict tidal elevations and infer minor corrections tide[track].data[valid] = pyTMD.predict.drift( ts.tide[valid], hc[valid,:], c, - deltat=deltat[valid], corrections=model.format) + deltat=deltat[valid], corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor( ts.tide[valid], hc[valid,:], c, deltat=deltat[valid], - corrections=model.format) + corrections=corrections) tide[track].data[valid] += minor.data[:] # replace masked and nan values with fill value diff --git a/tides/compute_tides_ICESat2_ATL12.py b/tides/compute_tides_ICESat2_ATL12.py index 9a53379..e749e76 100644 --- a/tides/compute_tides_ICESat2_ATL12.py +++ b/tides/compute_tides_ICESat2_ATL12.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting ICESat-2 ocean surface height data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -61,6 +61,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -205,24 +209,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, BOUNDS[3] = np.maximum(BOUNDS[3], np.max(lat)) # read tidal constants - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): constituents = pyTMD.io.OTIS.read_constants(model.grid_file, model.model_file, model.projection, type=model.type, - grid=model.format, crop=CROP, bounds=BOUNDS) + grid=corrections, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): constituents = pyTMD.io.ATLAS.read_constants(model.grid_file, model.model_file, type=model.type, compressed=model.compressed, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): constituents = pyTMD.io.GOT.read_constants(model.model_file, - compressed=model.compressed, crop=CROP, bounds=BOUNDS) + compressed=model.compressed, grid=grid, crop=CROP, bounds=BOUNDS) # available model constituents c = constituents.fields - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): constituents = pyTMD.io.FES.read_constants(model.model_file, type=model.type, version=model.version, compressed=model.compressed, crop=CROP, bounds=BOUNDS) @@ -265,25 +270,25 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, epoch=timescale.time._atlas_sdp_epoch, standard='GPS') # interpolate tidal constants to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D = pyTMD.io.OTIS.interpolate_constants(val['longitude'], val['latitude'], constituents, model.projection, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D = pyTMD.io.ATLAS.interpolate_constants(val['longitude'], val['latitude'], constituents, type=model.type, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # use delta time at 2000.0 to match TMD outputs deltat = np.zeros((n_seg)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph = pyTMD.io.GOT.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.interpolate_constants(val['longitude'], val['latitude'], constituents, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale) @@ -299,11 +304,11 @@ def compute_tides_ICESat2(tide_dir, INPUT_FILE, tide = np.ma.empty((n_seg)) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_ICESat_GLA12.py b/tides/compute_tides_ICESat_GLA12.py index b362b49..d3a4a14 100755 --- a/tides/compute_tides_ICESat_GLA12.py +++ b/tides/compute_tides_ICESat_GLA12.py @@ -5,7 +5,7 @@ Calculates tidal elevations for correcting ICESat/GLAS L2 GLA12 Antarctic and Greenland Ice Sheet elevation data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -67,6 +67,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -236,25 +240,27 @@ def compute_tides_ICESat(tide_dir, INPUT_FILE, epoch=timescale.time._j2000_epoch, standard='UTC') # read tidal constants and interpolate to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D,c = pyTMD.io.OTIS.extract_constants(lon_40HZ, lat_40HZ, model.grid_file, model.model_file, model.projection, - type=model.type, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, - cutoff=CUTOFF, grid=model.format, apply_flexure=APPLY_FLEXURE) + type=model.type, grid=corrections, crop=CROP, method=METHOD, + extrapolate=EXTRAPOLATE, cutoff=CUTOFF, apply_flexure=APPLY_FLEXURE) deltat = np.zeros((n_40HZ)) - elif (model.format == 'netcdf'): + elif model.format in ('ATLAS-netcdf',): amp,ph,D,c = pyTMD.io.ATLAS.extract_constants(lon_40HZ, lat_40HZ, model.grid_file, model.model_file, type=model.type, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale, compressed=model.compressed) deltat = np.zeros((n_40HZ)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph,c = pyTMD.io.GOT.extract_constants(lon_40HZ, lat_40HZ, - model.model_file, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, - cutoff=CUTOFF, scale=model.scale, compressed=model.compressed) + model.model_file, crop=CROP, crop=CROP, method=METHOD, + extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale, + compressed=model.compressed) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.extract_constants(lon_40HZ, lat_40HZ, model.model_file, type=model.type, version=model.version, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, @@ -273,11 +279,11 @@ def compute_tides_ICESat(tide_dir, INPUT_FILE, tide = np.ma.empty((n_40HZ),fill_value=fv) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace masked and nan values with fill value invalid, = np.nonzero(np.isnan(tide.data) | tide.mask) diff --git a/tides/compute_tides_icebridge_data.py b/tides/compute_tides_icebridge_data.py index e10d72d..123014a 100644 --- a/tides/compute_tides_icebridge_data.py +++ b/tides/compute_tides_icebridge_data.py @@ -4,7 +4,7 @@ Written by Tyler Sutterley (07/2024) Calculates tidal elevations for correcting Operation IceBridge elevation data -Uses OTIS format tidal solutions provided by Ohio State University and ESR +Uses OTIS format tidal solutions provided by Oregon State University and ESR http://volkov.oce.orst.edu/tides/region.html https://www.esr.org/research/polar-tide-models/list-of-polar-tide-models/ ftp://ftp.esr.org/pub/datasets/tmd/ @@ -71,6 +71,10 @@ UPDATE HISTORY: Updated 07/2024: added option to crop to the domain of the input data added option to use JSON format definition files + renamed format for ATLAS to ATLAS-compact + renamed format for netcdf to ATLAS-netcdf + renamed format for FES to FES-netcdf and added FES-ascii + renamed format for GOT to GOT-ascii and added GOT-netcdf Updated 05/2024: use wrapper to importlib for optional dependencies Updated 04/2024: use timescale for temporal operations Updated 01/2024: made the inferrence of minor constituents an option @@ -258,11 +262,12 @@ def compute_tides_icebridge_data(tide_dir, arg, TIDE_MODEL, epoch=timescale.time._j2000_epoch, standard='UTC') # read tidal constants and interpolate to grid points - if model.format in ('OTIS','ATLAS','TMD3'): + corrections, _, grid = model.format.partition('-') + if model.format in ('OTIS','ATLAS-compact','TMD3'): amp,ph,D,c = pyTMD.io.OTIS.extract_constants(dinput['lon'], dinput['lat'], model.grid_file, model.model_file, model.projection, - type=model.type, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, - cutoff=CUTOFF, grid=model.format, apply_flexure=APPLY_FLEXURE) + type=model.type, grid=corrections, crop=CROP, method=METHOD, + extrapolate=EXTRAPOLATE, cutoff=CUTOFF, apply_flexure=APPLY_FLEXURE) deltat = np.zeros((file_lines)) elif model.format in ('netcdf'): amp,ph,D,c = pyTMD.io.ATLAS.extract_constants(dinput['lon'], dinput['lat'], @@ -270,13 +275,14 @@ def compute_tides_icebridge_data(tide_dir, arg, TIDE_MODEL, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale, compressed=model.compressed) deltat = np.zeros((file_lines)) - elif (model.format == 'GOT'): + elif model.format in ('GOT-ascii','GOT-netcdf'): amp,ph,c = pyTMD.io.GOT.extract_constants(dinput['lon'], dinput['lat'], - model.model_file, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, - cutoff=CUTOFF, scale=model.scale, compressed=model.compressed) + model.model_file, grid=grid, crop=CROP, method=METHOD, + extrapolate=EXTRAPOLATE, cutoff=CUTOFF, scale=model.scale, + compressed=model.compressed) # delta time (TT - UT1) deltat = ts.tt_ut1 - elif (model.format == 'FES'): + elif model.format in ('FES-ascii','FES-netcdf'): amp,ph = pyTMD.io.FES.extract_constants(dinput['lon'], dinput['lat'], model.model_file, type=model.type, version=model.version, crop=CROP, method=METHOD, extrapolate=EXTRAPOLATE, cutoff=CUTOFF, @@ -318,11 +324,11 @@ def compute_tides_icebridge_data(tide_dir, arg, TIDE_MODEL, tide = np.ma.empty((file_lines),fill_value=fill_value) tide.mask = np.any(hc.mask,axis=1) tide.data[:] = pyTMD.predict.drift(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) # calculate values for minor constituents by inferrence if INFER_MINOR: minor = pyTMD.predict.infer_minor(ts.tide, hc, c, - deltat=deltat, corrections=model.format) + deltat=deltat, corrections=corrections) tide.data[:] += minor.data[:] # replace invalid values with fill value tide.data[tide.mask] = tide.fill_value