I have a solution.
If I run this NCL script, it loops through a full set of .abl files
and one by one calls matlab to convert them to netcdf.
Michael
NCL script loop.ncl
-------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin
prefix=(/"jana","janb","feba","febb","mara","marb","apra","aprb","maya","mayb","juna","junb",\
"jula","julb","auga","augb","sepa","sepb","octa","octb","nova","novb","deca","decb"/)
name="AVHRRBUVI01.2000jula"
quote=str_get_dq()
do iy=0,29
do ip=0,23
print(ip+" "+iy)
name="AVHRRBUVI01."+(1982+iy)+prefix(ip)+""
comm="matlab -nodesktop -nosplash -r "+quote+"name='"+name+"';loop"+quote
system(comm)
end do
end do
end
Matlab script loop.m
---------------------------
name_abl=[name,'.abl'];
name_nc=[name,'.nc'];
fid=fopen(name_abl,'r');
lai=fread(fid,[2160,4320],'uint8',0,'ieee-be');
lai=lai.*0.1;
lait=lai';
veg=lait(1:1:4320,2160:-1:1);
lon=1:4320;
lat=1:2160;
ncid = netcdf.create(name_nc,'nc_write');
dimid(1) = netcdf.defDim(ncid,'latitude',2160);
dimid(2) = netcdf.defDim(ncid,'longitude',4320);
varid(1) = netcdf.defVar(ncid,'latitude','double',dimid(1));
varid(2) = netcdf.defVar(ncid,'longitude','double',dimid(2));
varid(3) = netcdf.defVar(ncid,'lai','double',dimid(2:-1:1));
netcdf.endDef(ncid);
netcdf.putVar(ncid,varid(1),lat);
netcdf.putVar(ncid,varid(2),lon);
netcdf.putVar(ncid,varid(3),veg);
netcdf.close(ncid);
quit
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 6 13:27:47 2013
This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:33 MST