[ncl-talk] Doubt about interpolation from hybrid sigma level coordinate to height of 10m
leilane.passos at inpe.br
leilane.passos at inpe.br
Mon May 15 13:09:15 MDT 2017
Hi,
I need to interpolate the wind results from CCSM4(CAM) in
hybrid sigma level coordinate to height of 10 m. Then, I tried to use
the function wrf_user_intrp3d with the u, v and the geopotential height
(Z3), but the interpolated field has undefined values and I don't know
the reason. I have the following questions:
1) I think that I should
find the interpolated values in the entire domain. But why did I find
undefined values in certain areas like Andes Chain?
2) If I use the
command vinth2p to interpolate from hybrid to pressure coordinates, what
is a similar function that I could use to convert from pressure to
height of 10 m?
; -------------- LOAD FUNCTIONS AND PROCEDURES
----------------
load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl"
load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl"
load
"/usr/share/ncarg/nclscripts/csm/contributed.ncl"
load
"/usr/share/ncarg/nclscripts/csm/shea_util.ncl"
load
"/usr/share/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load
"/usr/share/ncarg/nclscripts/acentos.ncl"
; -------------- BEGINING OF
NCL SCRIPT ----------------
begin
outfile =
"test_U10mV10m.1985.20thC.nc"
if (isfilepresent(outfile)) then
system("rm -rf "+outfile) ;-- make sure that file does not exist
end
if
;-- open data file
in_u =
addfile("224331.U.1985.20thC.U.nc","r")
in_v =
addfile("224331.V.1985.20thC.V.nc","r")
in_z =
addfile("239928.Z3.1985.20thC.Z3.nc","r")
;-- get variable t and its
dimensions and dimension sizes
u = in_u->U ;(time, lev, lat, lon) ;--
get variable u
v = in_v->V ;(time, lev, lat, lon) ;-- get variable v
z
= in_z->Z3 ;(time, lev, lat, lon) ;-- get variable u
time = in_u->time
;-- get dimension time
lev = in_u->lev ;-- get dimension lev
lat =
in_u->lat ;-- get dimension lat
lon = in_u->lon ;-- get dimension lon
ntim = dimsizes(time) ;-- get dimension sizes of time
nlev =
dimsizes(lev) ;-- get dimension sizes of lev
nlat = dimsizes(lat) ;--
get dimension sizes of lat
nlon = dimsizes(lon) ;-- get dimension sizes
of lon
;-- Interpolate u and v to 10m:
;u10m = u ;-- copy variable
and its dimensions and attributes
u10m =
wrf_user_intrp3d(u,z,"h",10.0,0.,False) ;-- interpolate u
u10m at units =
"m/s" ;-- define new units
;v10m = v ;-- copy variable and its
dimensions and attributes
v10m =
wrf_user_intrp3d(v,z,"h",10.0,0.,False) ;-- interpolate v
v10m at units =
"m/s" ;-- define new units
;print(u10m)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;-- create new netCDF file
fout = addfile(outfile,"c")
;-- begin
output file settings
setfileoption(fout,"DefineMode",True) ;--
explicitly declare file definition mode
;-- create global attributes
of the file
fAtt = True ;-- assign file attributes
fAtt at title = "NCL
Efficient Approach to netCDF Creation"
fAtt at source_file = "CCSM4.nc"
fAtt at Conventions = "CF"
fAtt at creation_date = systemfunc ("date")
fAtt at history = "NCL script: ex_netcdf_2.ncl"
fAtt at comment = "Convert
variable t: Kelvin to Celsius"
fileattdef(fout,fAtt) ;-- copy file
attributes
;-- predefine the coordinate variables and their
dimensionality
dimNames = (/"time", "lat", "lon"/)
dimSizes = (/ -1 ,
nlat, nlon /)
dimUnlim = (/ True , False, False/)
filedimdef(fout,dimNames,dimSizes,dimUnlim)
;-- predefine the the
dimensionality of the variables to be written out
filevardef(fout,
"time" ,typeof(time),getvardims(time))
filevardef(fout, "lat"
,typeof(lat), getvardims(lat))
filevardef(fout, "lon" ,typeof(lon),
getvardims(lon))
filevardef(fout, "u10m" ,typeof(u10m),
getvardims(u10m))
filevardef(fout, "v10m" ,typeof(v10m),
getvardims(v10m))
;-- copy attributes associated with each variable to
the file
filevarattdef(fout,"time" ,time) ;-- copy time attributes
filevarattdef(fout,"lat" ,lat) ;-- copy lat attributes
filevarattdef(fout,"lon" ,lon) ;-- copy lon attributes
filevarattdef(fout,"u10m" ,u10m) ;-- copy u10m attributes
filevarattdef(fout,"v10m" ,v10m) ;-- copy v10m attributes
;--
explicitly exit file definition mode (not required)
setfileoption(fout,"DefineMode",False)
;-- output only the data values
since the dimensionality and such have been predefined.
;-- The "(/",
"/)" syntax tells NCL to only output the data values to the predefined
;-- locations on the file.
fout->time = (/time/) ;-- write time to new
netCDF file
fout->lat = (/lat/) ;-- write lat to new netCDF file
fout->lon = (/lon/) ;-- write lon to new netCDF file
fout->u10m =
(/u10m/) ;-- write variable to new netCDF file
fout->v10m = (/v10m/)
;-- write variable to new netCDF file
end
Best regards,
Leilane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/840fac50/attachment.html
More information about the ncl-talk
mailing list