Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add crop option to tide prediction #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ATL1415/ATL11_to_ATL15.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from ATL1415.make_mask_from_vector import make_mask_from_vector
from ATL1415.SMB_corr_from_grid import SMB_corr_from_grid
import pyTMD
import scipy.optimize

def get_SRS_info(hemisphere):
if hemisphere==1:
Expand Down Expand Up @@ -239,6 +238,7 @@ def apply_tides(D, xy0, W,
tide_adjustment=False,
tide_adjustment_file=None,
tide_adjustment_format='h5',
crop=True,
extrapolate=True,
cutoff=200,
EPSG=None,
Expand All @@ -262,6 +262,7 @@ def apply_tides(D, xy0, W,
tide_adjustment: adjust amplitudes of tide model amplitudes to account for ice flexure
tide_adjustment_file: File for adjusting tide and dac values for ice shelf flexure
tide_adjustment_format: file format of the scaling factor grid
crop: Crop tide model data to (buffered) bounds of input
extrapolate: extrapolate outside tide model bounds with nearest-neighbors
cutoff: extrapolation cutoff in kilometers

Expand Down Expand Up @@ -289,11 +290,11 @@ def apply_tides(D, xy0, W,
# extrapolate tide estimate beyond model bounds
# extrapolation cutoff is in kilometers
if np.any(is_els.ravel()):
D.tide_ocean = pyTMD.compute_tide_corrections(
D.x, D.y, D.delta_time,
DIRECTORY=tide_directory, MODEL=tide_model,
EPOCH=(2018,1,1,0,0,0), TYPE='drift', TIME='utc',
EPSG=EPSG, EXTRAPOLATE=extrapolate, CUTOFF=cutoff)
D.tide_ocean = pyTMD.compute.tide_elevations(
D.x, D.y, D.delta_time, DIRECTORY=tide_directory,
MODEL=tide_model, CROP=crop, EPSG=EPSG,
EPOCH=(2018,1,1,0,0,0), TYPE='drift', TIME='GPS',
EXTRAPOLATE=extrapolate, CUTOFF=cutoff)
# use a flexure mask to adjust estimated tidal values
if np.any(is_els.ravel()) and tide_adjustment:
print(f"\t\t{tide_adjustment_file}") if verbose else None
Expand Down
5 changes: 4 additions & 1 deletion scripts/_usgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def _usgs(**kwargs):
cmap = colors.LinearSegmentedColormap('usgs', _usgs_data, **kwargs)
cmap.set_over('w')
# register color map to be recognizable by cm.get_cmap()
cm.register_cmap(name='usgs', cmap=cmap)
try:
cm.register_cmap(name='usgs', cmap=cmap)
except:
pass
# return the colormap
return cmap