<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body>
<p>Hi,</p>
<p>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:</p>
<p>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?</p>
<p>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?</p>
<p> </p>
<p>; -------------- LOAD FUNCTIONS AND PROCEDURES ----------------<br /><br /> load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl"<br /> load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl"<br /> load "/usr/share/ncarg/nclscripts/csm/contributed.ncl"<br /> load "/usr/share/ncarg/nclscripts/csm/shea_util.ncl"<br /> load "/usr/share/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br /> load "/usr/share/ncarg/nclscripts/acentos.ncl"<br /><br /> ; -------------- BEGINING OF NCL SCRIPT ----------------<br /><br /> begin<br /><br /> outfile = "test_U10mV10m.1985.20thC.nc"<br /><br /> if (isfilepresent(outfile)) then<br /> system("rm -rf "+outfile) ;-- make sure that file does not exist<br /> end if<br /><br /> ;-- open data file<br /><br /> in_u = addfile("224331.U.1985.20thC.U.nc","r")<br /> in_v = addfile("224331.V.1985.20thC.V.nc","r")<br /> in_z = addfile("239928.Z3.1985.20thC.Z3.nc","r")<br /><br /> ;-- get variable t and its dimensions and dimension sizes<br /><br /> u = in_u->U ;(time, lev, lat, lon) ;-- get variable u<br /> v = in_v->V ;(time, lev, lat, lon) ;-- get variable v<br /> z = in_z->Z3 ;(time, lev, lat, lon) ;-- get variable u<br /><br /> time = in_u->time ;-- get dimension time<br /> lev = in_u->lev ;-- get dimension lev<br /> lat = in_u->lat ;-- get dimension lat<br /> lon = in_u->lon ;-- get dimension lon<br /><br /> ntim = dimsizes(time) ;-- get dimension sizes of time<br /> nlev = dimsizes(lev) ;-- get dimension sizes of lev<br /> nlat = dimsizes(lat) ;-- get dimension sizes of lat<br /> nlon = dimsizes(lon) ;-- get dimension sizes of lon<br /><br /> ;-- Interpolate u and v to 10m:<br /> ;u10m = u ;-- copy variable and its dimensions and attributes<br /> u10m = wrf_user_intrp3d(u,z,"h",10.0,0.,False) ;-- interpolate u<br /> u10m@units = "m/s" ;-- define new units<br /> ;v10m = v ;-- copy variable and its dimensions and attributes<br /> v10m = wrf_user_intrp3d(v,z,"h",10.0,0.,False) ;-- interpolate v<br /> v10m@units = "m/s" ;-- define new units<br /> ;print(u10m)<br /><br /> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br /> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br /> ;-- create new netCDF file<br /> fout = addfile(outfile,"c")<br /><br /> ;-- begin output file settings<br /> setfileoption(fout,"DefineMode",True) ;-- explicitly declare file definition mode<br /><br /> ;-- create global attributes of the file<br /> fAtt = True ;-- assign file attributes<br /> fAtt@title = "NCL Efficient Approach to netCDF Creation"<br /> fAtt@source_file = "CCSM4.nc"<br /> fAtt@Conventions = "CF"<br /> fAtt@creation_date = systemfunc ("date")<br /> fAtt@history = "NCL script: ex_netcdf_2.ncl"<br /> fAtt@comment = "Convert variable t: Kelvin to Celsius"<br /> fileattdef(fout,fAtt) ;-- copy file attributes<br /><br /> ;-- predefine the coordinate variables and their dimensionality<br /> dimNames = (/"time", "lat", "lon"/)<br /> dimSizes = (/ -1 , nlat, nlon /)<br /> dimUnlim = (/ True , False, False/)<br /> filedimdef(fout,dimNames,dimSizes,dimUnlim)<br /><br /> ;-- predefine the the dimensionality of the variables to be written out<br /> filevardef(fout, "time" ,typeof(time),getvardims(time))<br /> filevardef(fout, "lat" ,typeof(lat), getvardims(lat))<br /> filevardef(fout, "lon" ,typeof(lon), getvardims(lon))<br /> filevardef(fout, "u10m" ,typeof(u10m), getvardims(u10m))<br /> filevardef(fout, "v10m" ,typeof(v10m), getvardims(v10m))<br /><br /> ;-- copy attributes associated with each variable to the file<br /> filevarattdef(fout,"time" ,time) ;-- copy time attributes<br /> filevarattdef(fout,"lat" ,lat) ;-- copy lat attributes<br /> filevarattdef(fout,"lon" ,lon) ;-- copy lon attributes<br /> filevarattdef(fout,"u10m" ,u10m) ;-- copy u10m attributes<br /> filevarattdef(fout,"v10m" ,v10m) ;-- copy v10m attributes<br /><br /> ;-- explicitly exit file definition mode (not required)<br /> setfileoption(fout,"DefineMode",False)<br /><br /> ;-- output only the data values since the dimensionality and such have been predefined.<br /> ;-- The "(/", "/)" syntax tells NCL to only output the data values to the predefined<br /> ;-- locations on the file.<br /> fout->time = (/time/) ;-- write time to new netCDF file<br /><br /> fout->lat = (/lat/) ;-- write lat to new netCDF file<br /> fout->lon = (/lon/) ;-- write lon to new netCDF file<br /> fout->u10m = (/u10m/) ;-- write variable to new netCDF file<br /> fout->v10m = (/v10m/) ;-- write variable to new netCDF file<br /><br />end<br /><br /></p>
<p> </p>
<p> </p>
<p>Best regards,</p>
<p>Leilane</p>
<div> </div>
</body></html>