Got a problem in cdtgrid function.
Afficher commentaires plus anciens
Could run the following code upto weights_target but got a error in cdtgrid(). line.
%creating a meshgrid for cdtarea (make sure you create (lat,lon))
[lat_source, lon_source] = meshgrid(lat, lon);
weights = cdtarea(lat_source, lon_source, 'Method', 'mean');
weights_target = cdtarea(lat_target, lon_target, 'Method', 'mean');
% Call the regrid function to interpolate the data to the target grid
tas_regrid = cdtgrid().regrid(tas, 'X', 'Y', lon_edges_target, lat_edges_target, 'Weights', weights, 'WeightsTarget', weights_target);
% Save the regridded data to a new netCDF file
new_ncfile = 'temperature_data_regrid.nc';
cdfwrite(new_ncfile, 'tas', 'Data', tas_regrid, 'Lon', lon_edges_target(1:end-1), 'Lat', lat_edges_target(1:end-1));
Got an error of :
Error using cdtgrid
Not enough output arguments. I am trying to regrid the data from another dimension to 2.5 by 2.5 with this code. Is the process right? I was also stuck in a previous line. Thanks to Chad Greene for your help.
1 commentaire
Mandip
le 27 Fév 2023
Réponses (1)
Amal Raj
le 15 Mar 2023
Hi
I believe there is a problem with the arguments of 'cdtgrid'. Try replacing it with the code below.
tas_regrid = cdtgrid().regrid(tas, 'X', lon_source, 'Y', lat_source, 'Lon', lon_edges_target, 'Lat', lat_edges_target, 'Weights', weights, 'WeightsTarget', weights_target);
Catégories
En savoir plus sur NetCDF dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!