Define Grid dictionary for WRFout for Python Embedding #1225
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi Scott, I see you have a question about python embedding of gridded data in the MET tools. I see that you'd like to derive wind speed from the U and V components from your NetCDF wrfout file. But prior to jumping into that, you're testing 2m temperature... which is an excellent idea! First, you're doing exactly what I think you should be doing... testing your python embedding script using MET's plot_data_plane utility. By running that tool you can confirm that MET is placing your data at the right spot on the earth and orienting it correctly... which it currently is not doing. Second, I want to call your attention to this related GitHub development issue: Third, getting to the actual issue at hand. While python embedding of gridded data enables the MET tools to read a wider variety of inputs, it has some downsides. When reading data from GRIB files, the MET libraries check the metadata to figure out the order in which the data is packed... top to bottom, left to right, or the reverse of either. Those flags determine the order in which the data is retrieved. In the case of python embedding, no such parsing options exist. The user serves up a 2D array of data, and MET processes it exactly as it receives it. The responsibility falls to the user to confirm that the data is oriented correctly. And that's why running plot_data_plane first is ALWAYS a good idea. Fortunately, the fix for this is very easy. You just need to add a well-placed "-1" in the python script you're running to reverse the order of one of the dimensions. Take a look at this example script: The -1 in this line reverses the order of the data:
Note that the ".copy()" function is also needed so that the "met_data" variable is a complete copy of the data in memory. And that's what MET's C++ library code needs to read this data from memory. Please give that a try. If you get stuck, please attach a sample data file and python embedding script to this issue as a tarred-zipped file and I can look more closely at it. |
Beta Was this translation helpful? Give feedback.
Hi Scott, I see you have a question about python embedding of gridded data in the MET tools. I see that you'd like to derive wind speed from the U and V components from your NetCDF wrfout file. But prior to jumping into that, you're testing 2m temperature... which is an excellent idea!
First, you're doing exactly what I think you should be doing... testing your python embedding script using MET's plot_data_plane utility. By running that tool you can confirm that MET is placing your data at the right spot on the earth and orienting it correctly... which it currently is not doing.
Second, I want to call your attention to this related GitHub development issue:
dtcenter/MET#1518
When processi…