-
Notifications
You must be signed in to change notification settings - Fork 68
Snowfall and rain approximation from Dai 2008 #2208
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
Conversation
Hi @kkkchow, I have a few questions about the You may find my implementation of the snowfall fraction following Dai 2008 in this PR. However, when I computed I used a randomly selected simulation : CanESM5/historical, over a domain including QC, On and part of the maritimes. I only used data for a single winter : 2000-12 to 2001-03 (but the analysis is the same over other winters). I computed different flavours of the new method "Dai", with and without the clipping you described in your comment on the issue. I also tried different values for the clipping. The best fit between my implementation and yours is when I use 4°C (meaning snow fraction is 1 under -4°C and 0 above 4°C). I also computed The next figure shows the total snow fall in mm of SWE over the period. The difference are shown as "CanDCS-M6 minus xclim", so red means my implementation underestimates ![]() This other figure looks at the distribution of this difference with temperature. You are looking at 2D histogram with a log norm on the colors of the difference vs temperature. I added more clipping values so we can see the behaviour. As we can notice, the CanDCS-M6 So with all that the question is: is this discrepancy problematic or does this sound non-significative. To me, an overall 1 mm of prsn error in the full winter sound ok, but still the differences are strange and that lowest error is for a different clipping value than what you said you used. Question also applies to @tlogan2000 ! |
For the record, the issue denoted above was solved. The way the "clipping" was done was different from CanDCS and my first implementation. This has been fixed. "clipping" is now a rescaling of the fraction function. The original tanh function from the paper is not actually bounded by 0 and 1, there's a small snow fraction even at very high temperatures (and vice-versa). The idea from the UVic and CCCS team is to rescale the function to 0 and 1 at a certain |
FTR, I don't hate polymorphism; I don't like when polymorphic variables aren't properly annotated or constrained. Live your best (polymorphic) life.
I think that makes the most sense. Do you see this being used elsewhere in the library? If so, try to make that annotation accessible to multiple modules. |
Cool! I would argue that "xr.DataArray | bool" is simple enough it doesn't require a new type ? Quickly browsing through the other indicators, I didn't find perfect candidate for the new type, but I found these potential ones:
|
The merge conflict is relatively annoying given that the conversion indices have been refactored. Let me know if you want me to take over that task. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@Zeitsperre I think your PR with the conversion refactor forgot to edit references to the submodules in the doc! The last commit adds |
Woops, yes, I did indeed forget. Thanks! |
Pull Request Checklist:
snowfall_approximation
#1752number
) and pull request (:pull:number
) has been addedWhat kind of change does this PR introduce?
landmask
to control which formulation (land or ocean) we use.Does this PR introduce a breaking change?
No. Only new arguments added, no default changed.
Other information:
@Zeitsperre : The
landmask
argument is polymorphic (my favorite, your nemesis (?)), it can either be a DataArray (which is assumed to be of boolean dtype, but no need to check) or a straight boolean. This is not aQuantified
because boolean have no units. Right now, I put the annotation that resolved into the "optional variable"InputType
, which means "bool" is not part of it. Should we create a newInputType
for boolean mask ? It would be similar toQuantified
in that it can be a scalar or a DataArray, but without the units check.@tlogan2000 : I implemented the rain approximation as well. However, in opposition to the 3 other methods already implemented, the Dai rain approximation is not equal to
pr - prsn
because it considers some small fractions of the total precip to be of another phase (denoted "sleet" in the article). Thus, to imitate DonnéesClimatiques, ones need to computeprra
aspr - prsn
instead of usingrain_approximation
. Is this ok ?Tests need to be added, I'll try to base my tests off of DonnéesClimatiques' data. At least it would compare xclim with another implementation, if not an "original" one.