> I am a new user of NCL.
Welcome ...
> I try to read many x-y dimension binary files named with date,
> then write them into nc format, I have three questions.
> First question, I try read one file, and write out one vairable.
> I use Grads to visialize the plot , the error message is following:
> Scanning self-describing file: rain.nc
> SDF file has no discernable X coordinate.
[1]
This is a Grads error. Perhaps there is an error in the ddf file.
A description that might help is:
http://www.cgd.ucar.edu/~asphilli/ddfhelp.html
[2] Are you sure your data is of type "byte" ?
That is unusual for binary data. Usually, it is
of type float or double or integer. Data packed
in "byte" usually have a 'scale_factor' and/or
'add_offset' to get it into float or double.
> The following is my ncl file:
[3] **Untested** modifications of your code. I speculate
the "byte" should be "float"
[4] fout = addfile ("./rain.nc","c")
^ not "w"
_______________________________________________
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"
procedure createNcVariable (x:numeric, longName:string, units:string \
,lat[*]:numeric, lon[*]:numeric)
; procedure to add meta data
begin
xmsg = -9999.0
x!0 ="lat"
x!1 ="lon"
x&lat = lat ; assign coordinate values and units
x&lon = lon
x@long_name = longName
x@units = units
x@_FillValue = xmsg
x@missing_value = xmsg
; set values to _FillValue
x1d = ndtooned( x )
imsg = ind( x1d.ge.251 .and. x1d.le.255)
x1d(imsg) = xmsg
x = onedtond ( x1d, dimsizes(x) )
end
begin
nlat = 720
mlon = 1440
file_in = "/disk/ide41/yzhang/AMSR_E/amsre_20040601v4_d3d"
SST = fbindirread (file_in,0, (/nlat,mlon/),"byte")
????
WSPD = fbindirread (file_in,1, (/nlat,mlon/),"byte")
VAPOR = fbindirread (file_in,2, (/nlat,mlon/),"byte")
CLOUD = fbindirread (file_in,3, (/nlat,mlon/),"byte")
RAIN = fbindirread (file_in,4, (/nlat,mlon/),"byte")
;==========================================
; Create lon and lat coordinates variables; contributed.ncl
;==========================================
lat = latGlobeFo (nlat, "lat", "latitude", "degrees_north")
lon = lonGlobeFo (mlon, "lon", "longitude", "degrees_east")
; lat = fspan (-89.875,89.875,nlat)
; lon = fspan (0.125,359.875,mlon)
printVarSummary (lat)
printVarSummary (lon)
;creat output variables with proper dimensions
createNcVariable (SST , "sea surface temperature*0.15-3.0" \
, "deg C", lat, lon)
createNcVariable (WSPD , "wind speed", "???", lat, lon)
createNcVariable (VAPOR, "atmospheric water vapor*0.3" \
, "mm", lat, lon)
createNcVariable (CLOUD, "cloud liquid water*0.01" \
, "mm", lat, lon)
createNcVariable (RAIN , "rain rate*0.01", "mm/hr", lat, lon)
printVarSummary (SST)
;=======================
; draw variable
;=======================
wks=gsn_open_wks("x11","example")
gsn_define_colormap (wks, "gui_default")
res = True
res@gsnMaximize = True ; only affect ps or pdf (otherwise, ignored)
res@cnFillOn = True ; turn on color
res@gsnSpreadColors = True ; use entire color map
plot=gsn_csm_contour_map_ce(wks,SST,res)
fout = addfile ("./rain.nc","c")
fout@source_file = file_in
fout@creation_date = systemfunc("date")
fout ->SST = SST
end
____________________________________________________
> second question, I try to read many binary files which named with
> date such as amsre_20040601v4_d3d, how can I do?
; read the names of multiple files
file_in = systemfunc (" ls/disk/ide41/yzhang/AMSR_E/amsre_*_d3d")
print(file_in)
nfils = dimsizes(file_in) ; number of files
You can loop over files
do nf=0,nfils-1
:
end do
FYI: consider
fil = "/disk/ide41/yzhang/AMSR_E/amsre_20040601v4_d3d"
filc = stringtochar ( fil )
year = stringtointeger( chartostring( filc(32:35) )
month= stringtointeger( chartostring( filc(36:37) )
day = stringtointeger( chartostring( filc(38:39) )
> Third question, the value of missing data is from 251 to 255,
> I try to change 255 to -9999.9 and change 251, 252, 253, 254
> as missing data with same value, May I use ncl to do this?
yes, of course. see createNcVariable
Could anyone help me?
Thanks and regards!
Li Tao
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Tue Jan 18 2005 - 07:18:59 MST