NCAR / geocat-comp

GeoCAT-comp provides implementations of computational functions for operating on geosciences data. Many of these functions originated in NCL and were translated into Python.
https://geocat-comp.readthedocs.io
Apache License 2.0
129 stars 56 forks source link

NCL stdatmus_z2tdp[💡]: #631

Open ABF-EC opened 4 months ago

ABF-EC commented 4 months ago

Describe the functionality you are requesting, linking any relevant usage or previous implementations in the python ecosystem or otherwise.

Hi, I am wondering how to acces the stdatmus_z2tdp function from NCL in python. Is this fonction available in your package? Do you know other package that could be loaded in pythin via conda that include NCL functions stdatmus_z2tdp? Thanks and have nice day!

Is this a request for functionality that was previously in NCL?

Yes

Additional context

https://www.ncl.ucar.edu/Document/Functions/Built-in/stdatmus_z2tdp.shtml

kafitzgerald commented 4 months ago

Thanks for the question!

We don't have this implemented here in geocat-comp, but metpy has several functions for standard atmosphere calculations. I've also seen some smaller packages out there with the functionality implemented (e.g. ussa1976). We can certainly take a look at what metpy has and what might be missing on our end, but if there's anything in particular that would be useful that'd be great to hear.

Also, we're currently working on a new resource (with an NCL index and Python content) that would be great to house this type of information. I'll see if we can prioritize getting an entry for this added and share that here once we have one. Any feedback would be greatly appreciated.

ABF-EC commented 4 months ago

That would be great!

I will have a look at what is available in MetPy and will let you know if I find what I need.

Thank a lot and have a nice day!

ABF-EC commented 4 months ago

Hi Katelyn,

I have looked into the MetPy library https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.height_to_pressure_std.html#metpy.calc.height_to_pressure_std There are a few major issues with the height_to_pressure_std function from MetPy. They are using the ICAO standard atmosphere from 1976 and not the current one from 1993. The constants used in the formula equation are not the same as the ICAO standard atmosphere definition from 1993, The last issue is that the equation that they are using is valid only for the troposphere. They are not consider other atmospheric layer (tropopause, etc.).

Do you know if the NCL equations for the stdatmus_z2tdp would contain the same faults?

What are the constant and equations used in stdatmus_z2tdp? Are they the same as the one I mentioned here https://github.com/Unidata/MetPy/issues/3561 ?

Thanks a lot! Anna-Belle

kafitzgerald commented 4 months ago

I believe NCL uses the 1976 U.S. Standard Atmosphere as a reference, but has a more robust implementation than MetPy. You can see the code here: https://github.com/NCAR/ncl/blob/develop/ni/src/lib/nfpfort/stndAtmUS76_dp.f

I also noticed this Python package https://github.com/airinnova/ambiance which seems to implement the newer standard, but haven't had a chance to look it over too deeply.

ABF-EC commented 4 months ago

Hi Katelyn,

Thanks a lot for sharing the code.

I have look into the NCL code and even though the equation's names say US std atm 1976, when I look at the constant definition I see that they are the same as the std atm definition from 1993. So, I believe that it was adjusted to fit the most recent standard atmosphere version.

I was able to use the Python package ambiance. It is working well to transfer the height to pressure for a standard atmosphere.

Thanks again for your support I truly appreciate it! Anna-Belle