python-cdo - cdo sellonlatbox (Abort): Unsupported grid type!
Added by Hande Buyukarslan almost 4 years ago
Hi,
I'm trying to use sellonlatbox and remapbil functions for wrf outputs in python by using python-cdo=1.5.4=pyhd8ed1ab_0.
I also tried to make it in cdo 1.9.9 but i still have the same return:
Warning (cdf_set_var): Inconsistent variable definition for XLAT!
Warning (cdf_set_var): Inconsistent variable definition for XLONG!
Warning (cdf_set_var): Inconsistent variable definition for XLAT_U!
Warning (cdf_set_var): Inconsistent variable definition for XLONG_U!
Warning (cdf_set_var): Inconsistent variable definition for XLAT_V!
Warning (cdf_set_var): Inconsistent variable definition for XLONG_V!
Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable Times!
Warning (cdfInqContents): Coordinates variable XTIME can't be assigned!
....
Warning (cdf_read_coordinates): Time varying grids unsupported, using grid at time step 1!
cdo sellonlatbox: Unsupported grid type: generic
cdo sellonlatbox (Abort): Latitudinal dimension is too small!
Code that i tried to run is in the below:
#converting projected coordinates to lat/lons
#transformer = Transformer.from_crs(4326,3857, always_xy=True)
transformer = Transformer.from_crs(4326,3857, always_xy=True)
transform_out = Transformer.from_crs(3857,4326, always_xy=True)
wrf_loc_name_d3 = "wrfout_d03_2021-03-07_18:00:00.nc"
#for cdo sellonlatbox
distance = 50000 #[m]
def location_defining(ikey,ilat,ilon,idistance):
cdo = Cdo()
points = [(ilon,ilat)]
for pt in transformer.itransform(points):
x,y = pt[0],pt[1]
area_in = [(x - idistance, y - idistance)]
area_out= [(x + idistance, y + idistance)]
for bounds_in in transform_out.itransform(area_in):
lon_,lat_ = bounds_in[0], bounds_in[1]
for bounds_out in transform_out.itransform(area_out):
lon, lat = bounds_out[0], bounds_out[1]
lonlatbox = str(lon_) + "," + str(lon) + "," + str(lat_) + "," + str(lat)
remap = "lon=" + str(ilon) + "_lat=" + str(ilat)
cdo.sellonlatbox(lonlatbox,
input="OUTPUT/WRF/" + wrf_loc_name_d3,
output="OUTPUT/WRF/wrf_sellonlat_" + ikey + ".nc")
cdo.remapbil(remap,
input="OUTPUT/WRF/" + wrf_loc_name_d3,
output="OUTPUT/WRF/wrf_remapbil_" + ikey + ".nc")
location_defining(location_input_data["key"],location_input_data["lat"],location_input_data["lon"],distance)
any suggestion would be appreciated to interpolate this nc file
thanks in advance
Replies (1)
RE: python-cdo - cdo sellonlatbox (Abort): Unsupported grid type! - Added by Brendan DeTracey almost 4 years ago
From the first paragraph of the CDO manual.
The NetCDF attributes should follow the GDT, COARDS or CF Conventions.Try: https://www.google.com/search?q=wrf+output+to+cf+metadata and https://www.ncl.ucar.edu/Applications/wrfnetcdf.shtml
Looks like WRF?