Skip to content

Commit 6ab4e9d

Browse files
Taking care of time-steps in the middle of the hour (#79)
* Taking care of time-steps in the middle of the hour In cases, the middle hour time-step was printed as HH:29:599999 so it cause issues with time shift, as 29 != 30 (30 was the assumption previosuly). Furthermore, the last time step of subsetting is assumed to be HH:45:00 so as to no miss time-steps where the value is set to HH:30:00001 (slightly past HH:30:00). Reported-by: Mohamed Elshamy <[email protected]> Signed-off-by: Kasra Keshavarz <[email protected]> * time-stamp correction removed per user's request --------- Signed-off-by: Kasra Keshavarz <[email protected]>
1 parent ee79769 commit 6ab4e9d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

var/repos/builtin/recipes/ouranos-mrcc5-cmip6/mrcc5-cmip6.sh

+13-9
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ range=$(seq $startYear $interval $endYear)
236236

237237
# date formats
238238
subsetStartFormat="%Y-%m-%dT%H:00:00"
239-
subsetEndFormat="%Y-%m-%dT%H:30:00"
239+
subsetEndFormat="%Y-%m-%dT%H:45:00"
240240

241241
# empty arrays
242242
startDateArray=()
@@ -263,7 +263,7 @@ for iter in $range; do
263263
endValueYear="$(date --date "${endValueSub}" +"%Y")"
264264
# double-check end-date
265265
if [[ "$endValueYear" -gt 2100 ]]; then
266-
endValue="2100-12-31T23:30:00" # irregular last date for dataset files
266+
endValue="2100-12-31T23:45:00" # irregular last date for dataset files
267267
fi
268268

269269
# fill up arrays
@@ -351,13 +351,17 @@ for modelMember in "${modelArr[@]}"; do
351351
done # until ncks
352352

353353
# statement for ncap2
354-
minute="$(date --date "$(ncks --dt_fmt=1 --cal -v time -C --jsn "${src}" | jq -r ".variables.time.data[0]")" +"%M")"
355-
356-
if [[ "$minute" == "30" ]]; then
357-
ncap2Statement="where(lon>0) lon=lon-360; time=time-1.0/48.0" # shift for half an hour (1/48th of a day)
358-
else
359-
ncap2Statement="where(lon>0) lon=lon-360;" # no shift required
360-
fi
354+
# some scenarios and variable have time-stamps at the middle of
355+
# the hours, rather than the top. The following lines can take
356+
# care of these hiccups.
357+
# minute="$(date --date "$(ncks --dt_fmt=1 --cal -v time -C --jsn "${src}" | jq -r ".variables.time.data[0]")" +"%M")"
358+
359+
# if [[ "$minute" == "30" ]] ||
360+
# [[ "$minute" == "29" ]]; then
361+
# ncap2Statement="where(lon>0) lon=lon-360; time=time-1.0/48.0" # shift for half an hour (1/48th of a day)
362+
# else
363+
# ncap2Statement="where(lon>0) lon=lon-360;" # no shift required
364+
# fi
361365

362366
# change lon values so the extents are from ~-180 to 0
363367
# this is solely for easymore compatibility

0 commit comments

Comments
 (0)