Ouranosinc / miranda

A modern Python utility library for climate data collection and management
Apache License 2.0
18 stars 2 forks source link

Snow units in ERA5/-Land variables #106

Closed Zeitsperre closed 1 year ago

Zeitsperre commented 1 year ago

I've run into some confusion in the units-handling for the converted snow variables (snd, snr, snw). I want to be certain that the conversions are being performed properly.

ERA5 and ERA5-Prelimary-Back-Extension

ERA5-Land

There are currently no fucntions for calculating snd given snr and snw. This should be added. The relevant literature for all snow variables can be found here: https://www.ecmwf.int/sites/default/files/elibrary/2016/17117-part-iv-physical-processes.pdf#section.H.4

aulemahal commented 1 year ago

When you say "this should be added", are you thinking about xclim or miranda?

Some code exists in the MELCC parser I believe. Also, there I used snow_density as the variable name (since there are no CMIP6 standard), but I do like snr, its shorter and not conflicting with CMIP6. We could change the MELCC parser to be coherent.

As for the swe <-> snw transformations, the most recent xclim adds a few functionalities for that. At least, a convert_units_to(swe, snw) should work out-of-the-box if the correct standard name if set on the input.

Zeitsperre commented 1 year ago

This is good to know! I'm thinking that this conversion could be added here, but based on existing functions (xclim is a dependency in miranda).

Are the existing mapping for ERA5 to CF-like units correct for swe and snw? How can we be sure to make use of snr when converting them?

Having a consistent variable code for snow density is a good idea. snr does the job.

aulemahal commented 1 year ago

I think your mappings are correct: ERA's sd is in fact swe (lwe_thickness_of_surface_snow_amount [m]) and transformation to CMIP6-compliant snw is done multiplying by 1000 kg/m³.

I'd convert them to snw before computing snd, because it then simply becomes : snd = snw / snr.

Zeitsperre commented 1 year ago

Fixed with #1271