Conversation
|
It's great! I also love that you called the variable you came up with 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? |
|
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. |
|
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 I thought the code was checking that a CF valid standard name was being used. |
|
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. |
|
I just realised there's no unit checking in this though as that was implicit due to using metpy functions previously |
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