Re: .ABL format

From: Jatin Kala <jatin.kala.jk_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 06 2013 - 13:53:46 MST

Hi,
Looks like the matlab function is just reading a binary big endian file. NCL's fbindirread function should be able to do the same i think, worth trying perhaps:
http://www.ncl.ucar.edu/Applications/r-binary.shtml

Sent from my iPhone

On 07/11/2013, at 7:26 AM, Michael Notaro <mnotaro@wisc.edu> wrote:

> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 6 13:54:03 2013

This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:34 MST