Convert gives unexpected results with python embedding in Grid-Stat #2214
-
Hi: I'm reading data into Grid-Stat using python embedding and then performing a units conversion using convert. In this case, I'm not performing the conversion in the python embedding script because the script is used to read other fields that do not need to be converted. However, I am getting some unexpected results in Grid-Stat that are inconsistent with the results from plot_data_plane. I've attached 2 images below. These show the output from plot_data_plane using python embedding. The first is the original data, and the second is with the units converted, using the commands listed. The results are as expected. plot_data_plane PYTHON_NUMPY testMaxcth_units.ps 'name="read_extrap_byte_netcdf.py /data1/work/aspire/mdvNc/radar/CTH/20210917/050000.mdv.cf.nc MaxCTH kFT obs"; convert(x) = x*0.0032808399;' However, the next 2 images show the output from Grid-Stat. These are the plots done on the netCDF output file from Grid-Stat. In this case, the data is put on a coarser and smaller grid, so some differences are unexpected. The first image is without using convert in Grid-Stat, and the data is consistent with the first plot above. However, the second shows the output from Grid-Stat with convert. In this case, the data values are orders of magnitude smaller. It almost looks like the conversion is happening twice, which I know was an issue previously discussed (convert being performed twice with regridding). This is MET version 11.0.1. Is there a specific setting that's needed in METplus to ensure the conversion is not performed twice? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hi @CPKalb. Do you have |
Beta Was this translation helpful? Give feedback.
-
Tina, it looks to like that conversion operation is being applied twice. Checking the max value from the colorbar of the Grid-Stat output... And this same issue was noted in discussion #2033 and addressed in issue dtcenter/MET#2437. This doesn't provide a complete answer to your question, but is just to say that this isn't the first time it's come up. We'll need to look very closely at the context in which your conversion function is defined. What version of MET are you using? 11.0.0 or 11.0.2 which would include the bugfix for issue dtcenter/MET#2437. |
Beta Was this translation helpful? Give feedback.
Good news, I found the bug in
src/libcode/vx_data2d_python/data2d_python.cc
.MET runs the python script once and stores the result in a DataPlane object. Future calls to retrieve data from that python script just serve up the data it reads the first time. The bug is that the conversion and censoring logic are being applied to that stored version. And Grid-Stat calls that python script twice, once to get the grid definition and once to get the data. So the conversion function was being applied to that stored version 2 times.
The fix is to leave the data read from the python script as-is. Apply the conversion and censoring logic to a copy of the DataPlane object rather than modifying it in …