I would appreciate * guidance regarding translation of IDL routines to R, generally * assistance translating two IDL routines to R, specifically
Why I ask: I'm slowly learning how to do atmospheric modeling. One language that has been been popular in this space is IDL http://en.wikipedia.org/wiki/IDL_(programming_language) which unfortunately is proprietary (not to mention butt-ugly, IMHO :-) There is an emerging FOSS implementation, GDL http://en.wikipedia.org/wiki/GNU_Data_Language but I can't presently install GDL on either my own workstation or the cluster on which I do my "real work." And, unfortunately, I need to generate some datasets for which instructions are provided only in IDL (see listings following my .sig). However I have R in both work environments, and love it. So if there are any experts in IDL-to-R porting out there, I'd appreciate your assistance. TIA, Tom Roche <tom_ro...@pobox.com>---2 IDL routines follow to EOF--- from ftp://gfed3:dailyandhou...@zea.ess.uci.edu/GFEDv3.1/Readme.pdf ;++++++++++++++++++++ idl code to generate daily emissions +++++++++ nlon=720 ; number of grid points by longitude nlat=360 ; number of grid points by latitude gfedmly=fltarr(nlon,nlat) ; array containing monthly emissions gfeddly=fltarr(nlon,nlat) ; array containing daily emissions ; You must read monthly emissions to generate daily fluxes. ; For example, if you want daily emissions for January 21st, 2004, ; you need read monthly data in January 2004 first: file0_in='GFED3.1_200401_C.txt' file0_in=strcompress(file0_in, /REMOVE_ALL) gfedmly = read_ascii( file0_in ) gfedmly = gfedmly.field001 ; reverse the direction of latitude with monthly emissions ; to combine with daily fire fractions. for j=1, nlat/2 do begin tmp = gfedmly[*,j-1] gfedmly[*,j-1] = gfedmly[*,nlat-j] gfedmly[*,nlat-j] = tmp endfor undefine, tmp ; Then, you can read daily fire fractions from the netcdf file. file1_in = string('fraction_emissions_20040121.nc') file1_in=strcompress(file1_in, /REMOVE_ALL) fid=NCDF_OPEN(file1_in) varid=NCDF_VARID(fid,'Fraction_of_Emissions') NCDF_VARGET, fid, varid, DATA NCDF_CLOSE, fid gfeddly=gfedmly*DATA ;++++++++++++++++++++ the end for daily emissions ++++++++++++++++++ ;++++++++++++++++++++ idl code to generate 3-hourly emissions ++++++ nlon=720 ; number of grid points by longitude nlat=360 ; number of grid points by latitude nhor=8 ; numbers of 3-hourly intervals each day gfeddly=fltarr(nlon,nlat) ; array containing daily emissions gfed3hly=fltarr(nlon,nlat,nhor) ; array containing 3-hourly emissions file_in = string('fraction_emissions_200401.nc') file_in=strcompress(file_in, /REMOVE_ALL) fid=NCDF_OPEN(file_in) varid=NCDF_VARID(fid,'Fraction_of_Emissions') NCDF_VARGET, fid, varid, DATA NCDF_CLOSE, fid for nh=0,nhor-1 do begin gfed3hly[*,*,nh]=gfeddly*DATA[*,*,nh] endfor ;++++++++++++++++++++ the end for 3-hourly emissions +++++++++++++++ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.