How to regrid/interpolate netCDF data (2.5x2.5 degree) to higher resolution (e.g. 0.25x0.25 degree)?
4 views (last 30 days)
Show older comments
I am trying to use the script below by Hongxiao Jin in her Master thesis to regrid my netCDF NCEP Reanalysis II data to higher resolution at 0.25x0.25 degree. However, there are some errors in the script occurred. I installed mexcdf package to analyze netCDF data. Some errors occurred include: 1) Undefined function 'netcdf' for input arguments of type 'char'; 2) The expression to the left of the equals sign is not a valid target for an assignment in line 6. Thanks for your help.
%Extracting Air relative humidity Example 2004
nc = netcdf('rhum.mon.mean.nc', 'nowrite'); %matlab function
description = nc.description(:); % Global attribute.
variables = var(nc); % Get variable data.
Rhum2004=squeeze(variables{6}(301:312,1,:,:));%variables{6} 360X17X73X144
Rhum2004(find(Rhum2004==32766|Rhum2004==-32767)=nan;
nc = close(nc);
Rhum2004=permute(Rhum2004,[3 1 2]);%144X12X73 0->360
Rhum2004=[Rhum2004(73:144,:,:);Rhum2004(1:72,:,:)];%-180->180
Rhum2004=permute(Rhum2004,[2 3 1]);%12X73X144
Rhum2004=Rhum2004.*0.01+302.65;
[OX,OY]=meshgrid(-180:2.5:177.5,90:-2.5:-90);
[NX,NY]=meshgrid(-179.875:0.25:179.875,89.875:-0.25:-89.875);
RH2004=nan(12,720,1440);
for i=1:12
RH2004(i,:,:) = single(interp2(OX,OY,squeeze(Rhum2004(i,:,:)),NX,NY,'bilinear'));
end
save RH2004 RH2004
3 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!