Skip to content

Commit b7b4d5c

Browse files
authored
Merge pull request #82 from adehecq/amaury
Fix several small isues
2 parents 08eef22 + 0b62809 commit b7b4d5c

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

ragmac_xdem/data_tree.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ aster_path = "DEM*tif"
4444
validation_dates = ["2000-02-01", "2012-10-01", "2019-10-01"]
4545

4646
["RU_FJL"]
47-
ref_dem_path = "RU_FJL_Copernicus_REF_DEM.tif"
47+
ref_dem_path = "RU_FJL_Copernicus_REF_DEM_30m.tif"
4848
rgi_path = "09_rgi60_rua_wgs83_utm40n.shp"
4949
selected_path = "09_rgi60_rua_wgs83_utm40n_fjl_selection.shp"
5050
tdx_path = "*dem_mcf.tif"

ragmac_xdem/utils.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ def dems_selection(
284284
raise ValueError(f"Mode {mode} not recognized")
285285

286286

287+
def median_date(dates):
288+
"""
289+
Returns the median date from a list of datetime objects. The output is rounded to the nearest day.
290+
"""
291+
med_ordinal = np.median([date.toordinal() for date in dates])
292+
return datetime.fromordinal(int(med_ordinal))
293+
294+
287295
def get_start_end_dates(groups, merge_mode, validation_dates):
288296
"""
289297
Returns the first and last dates of the DEM subgroup used for each subperiod, depending on the merging method set.
@@ -300,8 +308,8 @@ def get_start_end_dates(groups, merge_mode, validation_dates):
300308
for count, pair in enumerate(pair_indexes):
301309
k1, k2 = pair
302310
pair_id = pair_ids[count]
303-
start_date[pair_id] = np.min(get_dems_date(groups[k1]))
304-
end_date[pair_id] = np.max(get_dems_date(groups[k2]))
311+
start_date[pair_id] = median_date(get_dems_date(groups[k1]))
312+
end_date[pair_id] = median_date(get_dems_date(groups[k2]))
305313

306314
elif (merge_mode == "TimeSeries") or (merge_mode == "TimeSeries2") or (merge_mode == "TimeSeries3"):
307315

scripts/archive_results.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ rm -f $outfile # To avoid appending to existing file
2828
for exp in experiment_1 experiment_2
2929
do
3030

31-
for dir in $exp/*/*
31+
for dir in $exp/*/results*
3232
do
3333
cmd="tar --append --file=$outfile $dir"
3434
echo $cmd; `$cmd`

scripts/download_data.sh

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ echo -e "\n*** Unzipping archives ***\n"
2121
for f in `ls $TARGET_DIR/experiment_*/*/*zip`; do echo -e "\n$f"; unzip -n $f -d `dirname $f`; done
2222

2323
echo -e "\n*** Downloading finished ***\n"
24+
25+
# Force REF DEM for RU_FJL case to be sampled at exactly 30 m - the difference with original is less than 1e-10.
26+
echo -e "Resampling REF_DEM for case RU_FJL"
27+
gdalwarp -tr 30 30 data/raw/experiment_2/RU_FJL/RU_FJL_Copernicus_REF_DEM.tif data/raw/experiment_2/RU_FJL/RU_FJL_Copernicus_REF_DEM_30m.tif -r bilinear

0 commit comments

Comments
 (0)