How to write a grads executable file?

1 次查看(过去 30 天)
Here is my MATLAB code for saving a variable in .grd format, so that i can able to plot in grads with the help of control file. this is my long program. The line in where I have commented as 'DOUBT 1' is my doubt. P.S.: Dont go through the program, otherwise you will confuse in understanding the steps. My main doubt is in writing the gridded file.
clc
clear
lon=ncread('2010110512-Jal-9km-bogus-r60km.nc','lon');
lat=ncread('2010110512-Jal-9km-bogus-r60km.nc','lat') ;
ntime=ncread('2010110512-Jal-9km-bogus-r60km.nc','time');
u=ncread('2010110512-Jal-9km-bogus-r60km.nc','u');
time=length(ntime)
one_degree=round(1/(lat(2)-lat(1)));
coc=[9.5,87];
no_of_radius=15;
h=waitbar(0,'Please wait...');
for k =1:25 %for time step 25
waitbar(k/25)
u1=u(:,:,:,k);
if k==1
for i=1:13
i
u2=u1(:,:,i);
if i==1
[lat2,lon2]=cyclonic_modified1(coc(1),coc(2),no_of_radius);
for i=1:no_of_radius
U(:,i)=interp2(lon,lat,u2,lon2(:,i),lat2(:,i));
end
else
[lat2(:,:,i),lon2(:,:,i)]=cyclonic_modified1(coc(1),coc(2),no_of_radius);
for j=1:no_of_radius
U(:,j,i)=interp2(lon,lat,u2,lon2(:,i),lat2(:,i));
end
end
end
else
for i=1:13
u2=u1(:,:,i);
if i==1
[lat2,lon2]=cyclonic_modified1(coc(1),coc(2),no_of_radius);
for i=1:no_of_radius
U2(:,i)=interp2(lon,lat,u2,lon2(:,i),lat2(:,i));
end
else
[lat2(:,:,i),lon2(:,:,i)]=cyclonic_modified1(coc(1),coc(2),no_of_radius);
for j=1:no_of_radius
U2(:,j,i)=interp2(lon,lat,u2,lon2(:,i),lat2(:,i));
end
end
end
U(:,:,:,k)=U2; % -------------------------------------------------------------------------------DOUBT 1
end
[~,I1]=min(abs(lat-coc(1)));
[~,I2]=min(abs(lon-coc(2)));
lat_range=[I1-round(one_degree/2):I1+round(one_degree/2)];
lat_range(lat_range<=0)=1;
lon_range=[I2-round(one_degree/2):I2+round(one_degree/2)];
lon_range(lon_range<=0)=1;
lat1=lat(lat_range);
lon1=lon(lon_range);
rain1=u(lon_range,lat_range);
[r,c]=minmat(rain1);
r=lat1(r);
c=lon1(c);
coc=[r,c];
end
fpo=fopen('jal_cyclone1.grd','wb');
fwrite(fpo,U,'float32');
fclose(fpo);
Every time my loops runs, it store U as 360*15*13*k where k starts from 1 to 25 After my loops ends, U has dimension 360*15*13*25 360*15 is the for the circular plot. 360 is degree and 15 is the circular radius. 13 is number of levels and 25 is number of time steps. How to write in a grid file so that it can be execute in grads.
P.S. If I save only 360*15 separately in a file, then i can able to plot in grads (The picture I have attached). But how to save as levels and different time steps. I can make a grads control file but there is an error in writing the grid file.

回答(1 个)

Walter Roberson
Walter Roberson 2017-9-9

类别

Help CenterFile Exchange 中查找有关 Electromechanical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by