Hi Marco,
Thanks so much for the input.
I've been trying to understand the data structure you use in your variables. Here's what I think each part means in the context of my data:
1. The "np.arange(6).reshape(2, 3)" is the reshaped vertcross output data. In my case, if the output data's shape was (161,2) then I would do np.arange(322).reshape(u_zonal_cross)
2. The ("latlon", ["lat/lon1", "lat/lon2"]) are the two lat/lon points generated from vertcross. In my case, this would be u_zonal_cross[0,:] with a length of 2 in this example.
3, The "lev", [10, 20, 30] are the vertical coordinates generated from vertcross. In my case, this would be u_zonal_cross.shape[:,0] with a length of 161.
Can you correct me if I'm wrong? When I run the following code
u_zonal_cross = vertcross(u_wind_ms, p_hpa, levels = np.arange(1000, 199.9, -5.), start_point = CoordPair(lat = i, lon = j), end_point = CoordPair(lat = k, lon = l), latlon = True, wrfin = ncfile, meta = True)
cross_5 = xr.DataArray(np.arange(805).reshape(u_zonal_cross.T), [("latlon", u_zonal_cross[0,:]), ("lev", u_zonal_cross[:,0])])
I get the warning UserWarning: 'latlon' is set to True, but 'field3d' is not of type xarray.DataArray and contains no coordinate information warnings.warn("'latlon' is set to True, but 'field3d' is "
and the program stops with the error
Traceback (most recent call last):
File "wrf_crosssec.py", line 136, in <module>
cross_5 = xr.DataArray(np.arange(805).reshape(u_zonal_cross.T), [("latlon", u_zonal_cross[0,:]), ("lev", u_zonal_cross[:,0])])
TypeError: 'DataArray' object cannot be interpreted as an integer
Let me know if you need anything else from me.
Thank you,
Michael