Looking for Examples of Python Embedding with Xarray #2864
Replies: 4 comments 2 replies
-
Hi @johnlwagner, thanks for your question. I developed this tutorial for Python Embedding which included writing a Python embedding script to use with Can you look at the script there and compare with yours and see if anything stands out? Also please feel free to share your script and command with us, and we will be able to better assist you, and also log files. Without seeing those it's hard to know exactly what might be causing you trouble when trying to use Python embedding with Xarray. Before I reply about the second part of your question, can you please share your |
Beta Was this translation helpful? Give feedback.
-
Thanks Dan. Your link did help and I reworked my python script to match the example more. I believe I have the attributes correct, but there is still an issue with the grid_info. I have a LatLon grid and here is what I have for grid_info:
The error I get is
I have Nlat and Nlon set, so I'm not sure how nx,ny have too many values. My scripts are below. I wasn't able to attach them. test_regrid.sh:
practice_gridded_pyembed.py:
|
Beta Was this translation helpful? Give feedback.
-
It looks like the lat/lon values are indeed integers and not tuples. I set
them both to ints just to be sure.
grid_info['Nlat'] = int(var_data.values[7])
grid_info['Nlon'] = int(var_data.values[8])
I'm still getting the same error:
Traceback (most recent call last):
File
"/apps/ops/para/libs/intel/19.1.3.304/met/11.0.2/share/met/wrappers/write_tmp_dataplane.py",
line 55, in <module>
nx, ny = met_in.met_data.shape
ValueError: too many values to unpack (expected 2)
ERROR :
ERROR : tmp_nc_dataplane() -> command
"/apps/spack/python/3.8.6/intel/19.1.3.304/pjn2nzkjvqgmjw4hmyz43v5x4jbxjzpk/bin/python3
/apps/ops/para/libs/intel/19.1.3.304/met/11.0.2/share/met/wrappers/write_tmp_dataplane.py
/tmp/tmp_met_nc_529407_0 $SCRverif/practice_gridded_pyembed $ncFile
$testDir $proj" failed ... status = 256
ERROR :
Here's what all of my grid_info entries look like:
grid_info= {'type': 'LatLon', 'name': 'accesse', 'lat_ll': -89850000.0,
'lon_ll': 225000.0, 'delta_lat': 450000.0, 'delta_lon': 300000.0, 'Nlat':
800, 'Nlon': 600}
…On Wed, Jan 22, 2025 at 4:19 PM Dan Adriaansen ***@***.***> wrote:
Hi @johnlwagner <https://github.com/johnlwagner> glad to hear the example
helped! I welcome any feedback on how that could be made better if you
found any of it confusing.
Back to your question, I have some questions about this part:
grid_info['lat_ll'] = float(var_data.values[11])
grid_info['lon_ll'] = float(var_data.values[12])
grid_info['delta_lat'] = float(var_data.values[16])
grid_info['delta_lon'] = float(var_data.values[17])
grid_info['Nlat'] = var_data.values[7]
grid_info['Nlon'] = var_data.values[8]
Earlier in your script, it appears var_data for the grid_info is set like
this:
var_data = qpf06['grib2_gds']
My guess here, without having your data file and being able to inspect
what var_data looks like for the variable grib2_gds, is that this:
var_data.values[7]
is returning an object that is not just a single integer value like 800.
Instead, it's returning a tuple or some other type of Python object that
is not a single value. I would recommend inspecting var_data['grib2_gds']
and all of the elements of it you're using to make sure you are providing a
single integer value for grid_info['Nlat'] and grid_info['Nlon'].
Let me know what you find out those items look like, which may help.
—
Reply to this email directly, view it on GitHub
<#2864 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGZ7TYIOXF6W4XVW7JBMO4D2MADM3AVCNFSM6AAAAABVH6Q2YKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJSGE4TCOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
John Wagner
Verification Task Lead
NOAA/National Weather Service
Meteorological Development Laboratory
Digital Forecast Services Division
SSMC2 Room 10106
Silver Spring, MD 20910
(240) 622-9138 <https://mail.google.com/mail/u/0/#m_226873644979562856_>
(Google
Voice)
(301) 427-9471 (office)
(908) 902-4155 (cell/text)
|
Beta Was this translation helpful? Give feedback.
-
Yes, you were right, I did have a 3d array. Now that I have a 2d array, I am seeing different errors. I'm seeing a conflict with python v3.8 and numpy. When testing with python v3.10, there seem to be other python conflicts. I will see if I can fix the python issues on my end and follow up with you. |
Beta Was this translation helpful? Give feedback.
-
Greetings
We are working with python embedding for the first time. Does anyone have a working example of a script using python embedding with xarray that they could share with us? We have been following the examples in Appendix F, but have not gotten a successful test yet. We have looked at some other discussions but haven't found anything that we got to work for us.
We are working on WCOSS and are extracting a single QPF06 grid from a netCDF file that has multiple elements and lead times.
In addition to having issues with python embedding, we may also have an issue with a MET variable. When trying to check a netcdf file with plot_data_plane, we get the following error:
can't open file '/apps/ops/para/libs/intel/19.1.3.304/met/11.1.0-rcl/share/met/wrappers/write_tmp_dataplane.py': [Errno 2] No such file or directory
That file does exist in /apps/ops/para/libs/intel/19.1.3.304/met/11.1.0-rc1/share/met/python/pyembed and in share/met/wrappers for other builds. Testing other versions of MET did not fix this for us. Is there a variable that can be set to change the location of the wrappers directory?
Beta Was this translation helpful? Give feedback.
All reactions