How to Expand Point Data to Match Spatial Grid and Fill Grid Cells in CDO
Added by thanu roh 13 days ago
I have two NetCDF files:
spatial_data.nc: This file contains gridded spatial data with multiple time steps (e.g., a variable var_spatial).
point_data.nc: This file contains a single-point regional average value for the same no of time steps (e.g., a variable var_point).
I want to expand the point data (point_data.nc) to match the spatial extent and grid structure of spatial_data.nc, and then fill each grid cell with the corresponding value from point_data.nc for every time step.
So the output should be
A new file (expanded_point_data.nc) with:
The same grid structure as spatial_data.nc.
All grid cells in each time step filled with the corresponding regional average value from point_data.nc.
Replies (1)
RE: How to Expand Point Data to Match Spatial Grid and Fill Grid Cells in CDO - Added by Karin Meier-Fleischer 13 days ago
I guess you are looking at the enlarge operator that enlarges data to a given larger data file grid.
For example, the point_data.nc file contains data of the variable tas at the location lon=7.5 and lat=51.0:
cdo -enlarge,spatial_data.nc -chname,tas,tas_avg point_data.nc enlarged.nc cdo -setctomiss,-999.9 \ -expr,'tas_avg=(((clon(tas_avg)>=7.0 && clon(tas_avg)<=8.0) && (clat(tas_avg)>=50. && clat(tas_avg)<=52.)) ? tas_avg : -999.9)' \ enlarged.nc \ enlarged_point_data.nc