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 various issues and tune some filtering parameters #78

Merged
merged 5 commits into from
Mar 31, 2022
Merged
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
4 changes: 1 addition & 3 deletions ragmac_xdem/dem_postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,7 @@ def fname_func(pair_id):
pair_id = pair_ids[count]
print(f"\nProcessing pair {pair_id}")

dems_list = groups[count]
dem_dates = utils.get_dems_date(dems_list)

time_stamps = np.array(matplotlib.dates.date2num(dem_dates))
# time_stamps = np.array([utils.date_time_to_decyear(i) for i in dem_dates])

Expand Down Expand Up @@ -842,7 +840,7 @@ def fname_func(pair_id):
min_date = np.percentile(ds.time, 2)
max_date = np.percentile(ds.time, 98)
time_delta_max = int((max_date - min_date).astype('timedelta64[D]') / np.timedelta64(1, 'D'))
time_delta_min = int(time_delta_max * 0.1)
time_delta_min = min(4*365, int(time_delta_max * 0.5))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! :)

print("Min 2 percentile date:",np.datetime_as_string(min_date, unit='D'))
print("Max 98 percentile date:",np.datetime_as_string(max_date, unit='D'))
print("Time delta between dates:",time_delta_max, 'days')
Expand Down
4 changes: 2 additions & 2 deletions ragmac_xdem/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def main(case: dict, mode: str, run_name: str, sat_type: str = "ASTER", nproc: i
selection_opts = {"mode": "subperiod", "dt": 365}
downsampling = 1
merge_opts = {"mode": "TimeSeries3"}
elif mode == "TimeSeries4":
elif mode == "TimeSeries_full":
selection_opts = {"mode": "subperiod", "dt": 10958} #~30 years
downsampling = 1
merge_opts = {"mode": "TimeSeries3"}
else:
raise ValueError("`mode` must be either of 'DEMdiff_autoselect', 'DEMdiff_median', 'TimeSeries', 'TimeSeries2' or 'TimeSeries3'")
raise ValueError("`mode` must be either of 'DEMdiff_autoselect', 'DEMdiff_median', 'TimeSeries', 'TimeSeries2', 'TimeSeries3' or TimeSeries_full")

# Get run parameters
run = runs[run_name]
Expand Down
12 changes: 10 additions & 2 deletions ragmac_xdem/mass_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,21 @@ def fill_ddem_local_hypso(ddem, ref_dem, roi_mask, roi_outlines, filtering=True)
`interp_residuals` the difference between input and interpolated ddem,
`frac_obs` the fraction of observation for each feature in roi_outlines
"""
# Filter large outliers - as in Dussaillant et al. 2019 (DOI: 10.1038/s41561-019-0432-5)
if filtering:
slope = xdem.terrain.slope(ref_dem)
ddem_filt = ddem.copy()
ddem_filt.data.mask[slope.data > 45] = True
else:
ddem_filt = ddem

# Calculate mean elevation change within elevation bins
# TODO: filter pixels within each bins that are outliers
ddem_bins = xdem.volume.hypsometric_binning(ddem.data[roi_mask], ref_dem.data[roi_mask])
ddem_bins = xdem.volume.hypsometric_binning(ddem_filt.data[roi_mask], ref_dem.data[roi_mask], bins=100)

# Filter outliers in bins
if filtering:
ddem_bins_filtered = ddem_bins_filtering(ddem_bins, verbose=True)
ddem_bins_filtered = ddem_bins_filtering(ddem_bins, verbose=True, nmad_fact=-1)
else:
ddem_bins_filtered = ddem_bins.copy()

Expand Down
2 changes: 1 addition & 1 deletion scripts/main_experiment1.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
if args.mode is not None:
all_modes = [args.mode]

if args.qc or args.mode == "TimeSeries3":
if args.qc or args.mode == "TimeSeries3" or args.mode == "TimeSeries_full":
# Launch dask cluster for computation on larger than memory arrays.
client = io.dask_start_cluster(args.nproc)

Expand Down
2 changes: 1 addition & 1 deletion scripts/main_experiment2.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if args.run is not None:
all_runs = [args.run]

if args.qc or args.mode == "TimeSeries3":
if args.qc or args.mode == "TimeSeries3" or args.mode == "TimeSeries_full":
# Launch dask cluster for computation on larger than memory arrays.
client = io.dask_start_cluster(args.nproc)

Expand Down