xBOUT icon indicating copy to clipboard operation
xBOUT copied to clipboard

Normalisations

Open TomNicholas opened this issue 6 years ago • 4 comments

Once BOUT enforces that normalisations should be saved in the attrs of each variable, then xBOUT can automatically read them and (optionally) apply them to get back to physical units.

Should read through the CF conventions to see if there is a standard for this which we should follow.

TomNicholas avatar Dec 08 '18 16:12 TomNicholas

I'm not sure we can promise that normalisations will always be saved but just that we can provide a mechanism for users to save normalisations should they wish to. Would this still work ok with xBOUT (i.e. it would try to get the normalisations but carry on anyway if they're not available)?

d7919 avatar Dec 08 '18 16:12 d7919

That's fine, just have something like:

from warnings import warn

if normalisation is 'physical' :
    for var in ds:
         if 'norm' in ds[var].attrs:
              ds[var] = ds[var] * ds[var].attrs['norm']
         else:
             warn(f"No normalisation found for {var}") 

There should probably be an optional argument to open_boutdataset() to choose if you don't want to apply the normalisations at all (my normalisation).

TomNicholas avatar Dec 10 '18 10:12 TomNicholas

While it might be nice to do it in BOUT++, it is not required.

We could provide a mechanism for model specific callbacks to added, that checks if the simulation looks like the model, and if so provides normalisation. I think storm has .e.g a [storm] section, hermes-2 has a [hermes] section in BOUT.inp etc. That could be used for normalisation.

Does it make sense to have that part of xbout?

dschwoerer avatar Sep 26 '22 12:09 dschwoerer

The way we've gone with STORM is to have a STORM-specific subclass of xBOUT (called xSTORM) that adds model-specific stuff like normalisations. I think that's working out pretty well - it seems sensible to maintain model-specific stuff separately and keep xBOUT generic for any BOUT++ code.

johnomotani avatar Sep 26 '22 18:09 johnomotani