Improved algorithm for index 'dry_spell_total_length' with new option…#884
Improved algorithm for index 'dry_spell_total_length' with new option…#884Zeitsperre merged 16 commits intomasterfrom unknown repository
Conversation
…s (operator 'max', possibility to specify start/end dates) and calculation for days near dataset boundaries.
…s (operator 'max', possibility to specify start/end dates) and calculation for days near dataset boundaries.
…s (operator 'max', possibility to specify start/end dates) and calculation for days near dataset boundaries.
|
@aulemahal I updated the algorithm to account for bisextile years. I removed 3 instances of xarray.DataArray casting, which should work better with dask. I also added 2 test cases (see test_indices.py:test_dry_spell). Overall, there are now 6 cases (3 cases x 2 operators). The current (xclim) and proposed algorithms give different results. |
|
@yrouranos Comme je n'ai pas accès en écriture à ta branche, j'ai fait une 3e branche que je veux fusionner dans celle-ci pour ensuite fusionner dans le master. Ma PR est donc ouverte dans ton repo. |
|
@yrouranos J'ai fusionné mes changements et le master! J'ai aussi ajusté la docstring et ajouté une entrée au "history". @huard J'ai ajouté une note pour soulever le problème qui survient aux bords. Je ne pense pas par contre qu'il soit nécessaire de mettre une référence ici? Ça reste un calcul simple? |
|
J'ai 2 commentaires et une suggestion:
|
Ligne 698 : Il n'y pas de données pour -2 et -1, et le drapeau booléen de "période sèche" est attribué au dernier jour de la période, donc 0 et 1 sont NaN.
|
huard
left a comment
There was a problem hiding this comment.
J'ai un peu l'impression que les effets de bords de la méthode sont indésirables, et non un feature.
Il n'y a pas d'indicator associé ?
…anos/xclim into dry-spell-total-length-new-options
…s (operator 'max', possibility to specify start/end dates) and calculation for days near dataset boundaries.
Pull Request Checklist:
number) and pull request (:pull:number) has been added.bumpversion patchhas been called on this branch.zenodo.jsonWhat kind of change does this PR introduce?
sumoperator. The improved algorithm gives the possibility to resample using themaxoperator, which means that a sequence ofwindowdry days can happen if there is a single day with precipitation reaching or exceeding a threshold (tresh).start_dateandend_date. The days comprised in a sequence ofwindowdry days are first identified. A mask is then applied to this result using the provided start and end dates. Resampling at the requested frequency (freq) is finally done. The implication of this change is that it is possible to have fewer thanwindowdays in a year, because some of these days could have been removed by the mask.start_date(ex: "12-01") to be larger thanend_date(ex: "02-28"). In this example, the dry days between December and February are not considered.windowsize that is an even number. The previous version of the algorithm was pushing a sequence of dry days to the right by one day with an evenwindowsize, assigning a wet label to the first day of a dry sequence, and a dry label to the day following the sequence. It can be an issue if one dry day is transferred to the following year (when a dry period overlaps two years). This situation seems to have been caused by the centre-based window, which is asymmetric if it's size is an even number.Does this PR introduce a breaking change?
window / 2days and last(window - 1) / 2days of the input precipitation dataset were assignednanvalue, and thus were assumed to be wet (because they were not dry), which will result in unrealistic indices in certain climates, e.g., West Africa (there is no precipitation between December and February). Ideally, the first and last years of the computed indices should be excluded, but the user may be unaware of this situation, which implies a risk of misusing the function. The combination of a left-based window and a bidirectional scanning (start to end of the input dataset, and the opposite), allows to calculate indices that consider the first and last days, without risk.Other information:
dry_spell_total_lengthalgorithm (indices based on awindow, centre-based or not). A similar solution, or an improved one, could be implemented for other indices.dry_spell_frequency, which should work exactly the same way asdry_spell_total_length.