-
Notifications
You must be signed in to change notification settings - Fork 12
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
15 remapping of one input variable to multiple new ones #21
15 remapping of one input variable to multiple new ones #21
Conversation
…essors. add tests for the remapper.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #21 +/- ##
========================================
Coverage 99.82% 99.83%
========================================
Files 21 22 +1
Lines 1158 1213 +55
========================================
+ Hits 1156 1211 +55
Misses 2 2 ☔ View full report in Codecov by Sentry. |
Hi Sara! @sahahner |
In my opinion, mapping n variables to n variables should be done by another preprocessor, as this conversion can be done in-place to save memory. The new preprocessor considers starting from only one variable. Together with @da-ewanp we are talking about extending it to n-to-m mappings in a follow-up PR. |
Hi Sara, thank you for this PR. I wonder if it also works for forcings. We would highly appreciate that. Our case is the directional forcing variable Could your implementation also be used derive As a final remark, I had a brief look at your code and noted that you have an |
Thank you Marek for the feedback.
The forcing variables are actually included in the training to enable the rollout.
If I can include the feature in this PR, this should also work for datetime variables. |
I left this argument, as we call all preprocessors in a loop and the Do you @MeraX have a recommendation on how to solve this? I would be happy to incorporate some solution for that. |
Hi Sara, thank you for your quick reply. I think that a non-functional argument confuses the users or at least me. If you want to execute processors that support import inspect
for preprocessor in preprocessors:
if "in_place" in inspect.getargspec(func):
preprocessor(x, in_place=True)
else:
x = preprocessor(x) Of course, one could find a better way to identify capabilities of preprocessors other than inspecting their signature. Or perhaps, it could help to simply rename that argument. If I understand the code correctly, |
…ing variables at the end
Hi @MeraX, I implemented the remapping of forcing variables. This should work on the datetime variables as well since at the place, where the preprocessors are applied, they are treated as any other variable. Please give it a try! Thank you for the proposals for handling the in_place input. We are still deciding on how to handle these cases. |
… indices and remapper
…. structure and additional assert in index collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes. LGTM
* feat: remapper and change to data indices when mapping one variable to several * tests: update imputer and normalizer tests * feat: include remapper as a preprocessor. update init for all preprocessors. add tests for the remapper. * tests: update tests for index collection * documentation and changelog * feat: enable remapper for forcing variables * tests: include remapping forcing variable and do not test with remapping variables at the end * comment and warning about using in_place=True in remapper as this is not possible * comments: incorporate changes/documentation requested by jesper * change order of function inputs preprocessors, documentation for data indices and remapper * style: dict in config files for defining the variables to be remapped. structure and additional assert in index collection. * args in preprocessors
Remapping of one prognostic input variable to multiple new ones using a preprocessor.
A postprocessor maps the multiple variables back to the original one.
Solves issue #15
Implemented options: map a variable x in degrees ( in the range [0, 360] ) to cos(x) and sin(x).
Preprocessor:
The model should handle the remapped variables, and the training loss must be calculated on the remapped set of variables. The validation loss should be calculated on the original variable, which will also be output in inference. Therefore, this remapping should be implemented as a preprocessor that allows the remapping of one variable to several new ones.
Data Indices:
The preprocessors are the first layers of the model, so the input variables are the same.
After the preprocessors, the set of variables has changed. Therefore, this information needs to be included in the data indices.
The changes to the data indices need to be incorporated into anemoi-training, which is why the pytests in anemoi-training/develop fail. The changes to anemoi-training are incorporated by the following PR: ecmwf/anemoi-training#17. When this branch is checked out, all tests pass.
📚 Documentation preview 📚: https://anemoi-models--21.org.readthedocs.build/en/21/