Add ability to derive variables and add selected derived forcings#34
Add ability to derive variables and add selected derived forcings#34ealerskans merged 100 commits intomllam:mainfrom
Conversation
- Update the configuration file so that we list the dependencies and the method used to calculate the derived variable instead of having a flag to say that the variables should be derived. This approach is temporary and might be revised soon. - Add a new class in mllam_data_prep/config.py for derived variables to distinguish them from non-derived variables. - Updates to mllam_data_prep/ops/loading.py to distinguish between derived and non-derived variables. - Move all functions related to forcing derivations to a new and renamed function (mllam_data_prep/ops/forcings.py).
…eck the attributes of the derived variable data-array
|
Hi @ealerskans, just sneaking in a question about this. Me and @sadamov are eager to add on derived forcing inputs to some experiments. I see that there is still discussion ongoing above about the code structure and tests, but is all the actual functionality in place here? I.e. could we check out this branch and use it in the meantime to create the forcings we need? |
|
I have tried to update the PR now based on all the great suggestions and feedback I have gotten. What I think is missing now are
With respect to tests, I think that the following would be nice to test, but I am not sure how to do it:
@mafdmi do you perhaps have any good ideas on 1) if it would be good to test them, and 2) how to do it? Is the functionality to wrap in Then there is also the task of adding other derived fields, such as creating a land-sea mask or a boundary mask (https://github.com/mllam/neural-lam/blob/feature_calculate_forcings/create_forcings.py). But I guess these can be added in another PR. |
Hi @joeloskarsson and @sadamov If you are only interested in adding the datetime forcings (hour of day and day of year) and top-of-the-atmosphere radiation), then you should be able to use this branch as it is now. I believe that I at one point also tested training neural-lam on a small test dataset which included derived variables as well. However no guarantees ;) |
Yes, I think we can test them. For |
If you have time it would be really helpful if you could give it a go. Then I can try and learn from that :) |
I've opened ealerskans#1 with tests added:) |
…plit up test_derived_variable.py into test_physical_field.py and test_time_components.py. Removed redundant test from test_main.py
Tests for _check_and_get_required_attributes and _get_derived_variabl…
|
@leifdenby I have implemented what we talked about in 0ecfcca. |
mfroelund
left a comment
There was a problem hiding this comment.
Looks great!! Only minor suggestions/fixes
This is brilliant, worked like a charm for my Swiss dataset! Thank you 🙏 |
README.md
Outdated
|
|
||
| config_path = "example.danra.yaml" | ||
| config = mdp.Config.from_yaml_file(config_path) | ||
| config = mdp.Config.load_config(config_path) |
There was a problem hiding this comment.
I think this example in the README still needs changing back :)
Implements the ability to derive fields from the input datasets, as discussed in Deriving forcings #29.
At the moment, I have only added the possibility to derive the following forcings:
time of year (cyclically encoded)But additional variables, such as boundary and land-sea masks, should be added. But I think that is for another PR.