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

fix: ignore overflow warnings at invalid points #46

Merged
merged 1 commit into from
Jul 8, 2024
Merged
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
27 changes: 18 additions & 9 deletions scripts/fit_surface_tiles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
fit_surface_tiles.py
Written by Tyler Sutterley (06/2024)
Written by Tyler Sutterley (07/2024)

Fits a time-variable surface to altimetry data

Expand Down Expand Up @@ -62,6 +62,7 @@
41(23), 8421--8428, (2014). https://doi.org/10.1002/2014GL061940

UPDATE HISTORY:
Updated 07/2024: ignore overflow errors in ATL06/11 error calculations
Updated 06/2024: renamed GLAH12 quality summary variable to d_qa_sum
Updated 05/2024: switched from individual mask files to a
common raster mask option for non-ice points
Expand Down Expand Up @@ -382,10 +383,12 @@ def fit_surface_tiles(tile_files,
d['data'][c:c+file_length] = data.copy()
d['lon'][c:c+file_length] = lon.copy()
d['lat'][c:c+file_length] = lat.copy()
# combine errors
d['error'][c:c+file_length] = np.sqrt(
mds[gtx][g]['h_li_sigma'][indices]**2 +
mds[gtx][g]['sigma_geo_h'][indices]**2)
# combine errors (ignore overflow at invalid points)
with np.errstate(over='ignore'):
d['error'][c:c+file_length] = np.sqrt(
mds[gtx][g]['h_li_sigma'][indices]**2 +
mds[gtx][g]['sigma_geo_h'][indices]**2
)
# convert timescale to J2000 seconds
d['time'][c:c+file_length] = ts.to_deltatime(
epoch=timescale.time._j2000_epoch,
Expand Down Expand Up @@ -420,10 +423,12 @@ def fit_surface_tiles(tile_files,
ATTRIBUTES=True, KEEP=True)
# invalid value for heights
invalid = attrs[ptx]['h_corr']['_FillValue']
# combine errors
error = np.sqrt(
mds[ptx]['h_corr_sigma'][indices,:]**2 +
mds[ptx]['h_corr_sigma_systematic'][indices,:]**2)
# combine errors (ignore overflow at invalid points)
with np.errstate(over='ignore'):
error = np.sqrt(
mds[ptx]['h_corr_sigma'][indices,:]**2 +
mds[ptx]['h_corr_sigma_systematic'][indices,:]**2
)
# for each cycle
for k, cycle in enumerate(cycle_number):
# convert time to timescale
Expand Down Expand Up @@ -549,6 +554,10 @@ def fit_surface_tiles(tile_files,
if SPL is not None:
d['mask'] &= (SPL.ev(d['x'], d['y']) >= TOLERANCE)

# check if there are any valid points
if not np.any(d['mask']):
raise ValueError('No valid points found for tile')

# log total number of valid points
valid, = np.nonzero(d['mask'])
logging.info(f'Total Valid: {len(valid):d}')
Expand Down