Python Embedding for plot_data_plane and MTD #2691
-
Hi, now that the issue with the python version is solved (see discussion), I'm finally trying to apply MTD on my data. However, I encountered two issues with the Python embedding script that I created to use the data with MET: 1) plotting data with plot_data_plane: Below is an example with temperature data. On the left is the plot generated with The embedding script I used for 2) use mtd on the data:
The embedding script is called I start MTD with the following command: I've tried to look into what's causing the errors, but I haven't been able to find the reason. I experimented with different values for 'true_lat_south_pole' and 'true_lon_south_pole', and 'aux_rotation', but it didn't change temperature field. Thanks in advance for your help! I really appreciate your time and support in helping me resolve these issues! Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi Annabell, And thank you for your questions (and providing the necessary input for testing). I'll reply to each of your questions in turn. 1) plotting data with plot_data_plane: This flip is caused by how MET's Python Embedding reads in data. Unlike some data input systems where gridded data is read from the lower leftmost point to the upper rightmost point, MET's Python embedding will read in a gridded field from the upper leftmost point to the lower rightmost point. This can result in data being flipped from north to south, in a manner you saw in your plot-data-plane call. To correct for this, add the following line to your script, after the data field is copied into
This will flip the north-south orientation and produce the results you are expecting. 2) use mtd on the data: This error was caused by your usage of the
When defining the grid that As you may have seen in the MET User's Guide section for Grid Specification Strings, you need to use the
after declaring the "rotlatlon" projection. As an example of how to properly use the
A user might fill in the required information using the following values:
As the documentation indicates,
Please let us know if you have any further issues with this verification process, or if any of the above information isn't clear. |
Beta Was this translation helpful? Give feedback.
-
That's a good question, and the answer is yes! As long as the input netCDF file follows Climate and Forecast (CF) conventions, it should be usable by METplus without the need for Python Embedding. For more information on those conventions, please see the MET User's Guide. To check if the file was netCDF-CF compliant, I first ran your embedding_MTD.py script, along with the sample file hourly_data_00.nc with Plot-Data-Plane. It's always a good idea to check a new file or Python Embedding setup with Plot-Data-Plane, as the resulting image and processing is quicker to the point if there are any errors/issues. The command I used below was a success:
I then reran Plot-Data-Plane, but this time I directly passed in the sample file hourly_data_00.nc. This command failed:
The error was proceeded by a warning; I've printed both of those here:
As you can see, the input file is NOT CF-compliant (aka not ready). To do so, some corrections would need to be made to the latitude and longitude variables. Take a look at this valid unit strings table and you'll notice that in order for MET to interpret a variable as the longitude, for example, it will need to have a unit of "degrees_east", "degree_east", or any of the listed acceptable units. As those issues are fixed, you may find additional attributes that need to be adjusted to bring the file into CF-compliance. For the purposes of troubleshooting, I went ahead and continued to use your embedding_MTD.py script and the config_test configuration file in a MODE-TD call. I was met with the same error you found:
After some internal discussion, it seems like this error originates from MTD's use of a code function that only provides support for lat/lon, lambert conformal, and polar stereographic projections. So if you provide MTD input data in any other gridded projection, even if those projections are supported by other MET tools, during the output writing step MET will error out. As a result, I've created this issue documenting the bug and what we need to do to patch this. We hope to make this bugfix available in the upcoming METplus coordinated 6.0 release, as well as a MET 11.1 bugfix. In the meantime, you should be able to sidestep this issue by first calling the Regrid-Data-Plane tool to change the projection from rotated lat/lon to one of the 3 supported projections, then calling MTD for verification. Of course, this does introduce regridding distortions so please be aware of that potential. |
Beta Was this translation helpful? Give feedback.
That's a good question, and the answer is yes! As long as the input netCDF file follows Climate and Forecast (CF) conventions, it should be usable by METplus without the need for Python Embedding. For more information on those conventions, please see the MET User's Guide.
To check if the file was netCDF-CF compliant, I first ran your embedding_MTD.py script, along with the sample file hourly_data_00.nc with Plot-Data-Plane. It's always a good idea to check a new file or Python Embedding setup with Plot-Data-Plane, as the resulting image and processing is quicker to the point if there ar…