Skip to content
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

Derive #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Derive #16

wants to merge 3 commits into from

Conversation

leosaffin
Copy link
Collaborator

I've added the layout to do automatic calculation of a variable by name from a dataset with CF standard names (mirroring what I was trying to do here EUREC4A-UK/twin-otter#14). Currently I've used the existing JOANNE dataset for the tests and calculated an imaginary variable. I'm not sure whether you want to merge this pull request now or keep it open for adding extra variables in since at the moment it does nothing useful

@leifdenby
Copy link
Collaborator

It's great! I also love that you called the variable you came up with thingness, hahahaha.

You say in the code you are checking for CF standard names, is that right? I can't see where that lookup is happening. And what happens for variables which don't have a standard name? I'll using the CF standard names, but maybe we need to add so that we can have our own in addition?

@leosaffin
Copy link
Collaborator Author

Lines 24-38 in interface.py. (Not sure how to add the lines directly in here)

For JOANNE the variables have the CF standard names in their attributes so I create a dictionary mapping CF standard names to variables names.

That will be called every time the function doesn't just directly extract the variable so it's probably excessive when it gets very recursive. Ideally I would determine the calculation path and then perform the calculations but that requires a bit more thought.

@leifdenby
Copy link
Collaborator

Ah, I see. So does that mean that the actual variable in a dataset could have any name, but people just have to make sure the standard_name attribute is correct? And in the functions we should just use things by there "standard_name"?

I thought the code was checking that a CF valid standard name was being used.

@leosaffin
Copy link
Collaborator Author

Yes that's right. There's no actual checking for CF compliance. It just makes it easier to keep a consistent variable naming for function arguments.

In the functions you shouldn't worry about the name of the variable as this function covers extracting by name and renaming the output. So a general function should be "f(x, y) -> z" and you can name the variables however you like if that makes sense.

For a dataset without CF standard names I would just add translation table (dictionary) to the module. This is what I did for the twinotter.

@leosaffin
Copy link
Collaborator Author

I just realised there's no unit checking in this though as that was implicit due to using metpy functions previously

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants