>>> >Detelina Ivanova wrote:
>>> > >Hi,
>>> > >
>>> > >I am trying to regrid vector fields from T42 grid to POP gx1v3
>>> grid using
>>> > >the function POPLatLonV,
>>> > >but I am getting error messages about missing rot*.nc file. I do
>>> have the
>>> > >weights (map*.nc files), but not these files which I am guessing
>>> are the
>>> > >rotation angles. Where I can find them?
I have attached a script that does what you need.
The PopLatLonV (as noted before) is set up to go from
the POP model to (say) the atmospheric model grids.
It contains the code to go from atmosphere to POP but
it is not activated.
The script:
[1] does the interpolation: T42 => gx1v3
[2] post rotates the wind vectors to the U grid using
the ANGLE variable
[3] Create a simple netCDF
[4] plots the T42 and gx1v3
Note: I did not know what fields you wanted. I did TAUX and TAUY
Good luck
D
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/popRemap.ncl"
begin
netCDF = True
PLOT = True
if (PLOT) then
res = True ; plot mods desired
res_at_mpFillOn = True
res_at_vcRefMagnitudeF = 0.1 ; define vector ref mag
res_at_vcRefLengthF = 0.045 ; define length of vec ref
res_at_vcGlyphStyle = "CurlyVector" ; turn on curley vectors
res_at_vcMinDistanceF = 0.017 ; thin out vectors
res_at_vcMonoLineArrowColor = False ; create color vectors
res_at_vcRefAnnoOn = False
res_at_gsnSpreadColors = True ; use full colormap
res_at_gsnSpreadColorEnd = -3 ; don't use added gray
res_at_lbLabelBarOn = False ; turn off individual cb's
res_at_gsnDraw = False
res_at_gsnFrame = False
res_at_gsnLeftString = "Surface Stress" ; change left string
plot = new ( 2, "graphic")
resP = True
resP_at_gsnPanelLabelBar = True ; add common colorbar
;resP_at_lbLabelFontHeightF = 0.007 ; make labels smaller
resP_at_vcRefAnnoOn = True
end if
dirr = "/project/cas/shea/POP/" ; mapping dir
filr = "rot_gx1v3.nc" ; rotation angles
fr = addfile (dirr+filr, "r")
ang = fr->ANGLE ; (384,320)
ulat = fr->ULAT ; (384,320)
ulon = fr->ULONG
dir42 = "/project/cas/shea/CCM/UWASH_DATA/" ; T42 dir
fil42 = systemfunc("cd "+dir42+" ; ls 2K*nc")
nfil42 = dimsizes( fil42 )
print(fil42)
; loop over files
do nf=0,nfil42-1
f42 = addfile ( dir42+fil42(nf), "r")
u42 = f42->TAUX ; (time,lat,lon)
v42 = f42->TAUY
s42 = sqrt(u42^2 + v42^2)
printMinMax(s42, True)
; interpolate the T42 components to the gx1v3 grid
u42_gx1v3 = PopLatLon(u42,"T42","gx1v3","bilin","da","020607")
v42_gx1v3 = PopLatLon(v42,"T42","gx1v3","bilin","da","020607")
printVarSummary(u42_gx1v3)
printVarSummary(v42_gx1v3)
if (nf.eq.0) then
rot = conform(u42_gx1v3, ang, (/1,2/) ) ; 2D ==> 3D
end if
; rotate the T42 components on the gx1v3
upop = u42_gx1v3*cos(rot) + v42_gx1v3*sin(rot) ; (time,lat,lon)
vpop = -u42_gx1v3*sin(rot) + v42_gx1v3*cos(rot)
copy_VarMeta( u42_gx1v3, upop)
copy_VarMeta( v42_gx1v3, vpop)
print("=========> "+fil42(nf)+" <==========")
printVarSummary( upop )
printMinMax(upop, True)
printVarSummary( vpop )
printMinMax(vpop, True)
if (netCDF .or. PLOT) then
suffix = get_file_suffix(fil42(nf), 0)
fRoot = suffix_at_fBase
end if
if (netCDF) then
ncName = "gx1v3_"+fRoot+".nc"
system("/bin/rm -f "+ncName) ; remove any pre-existing file
ncdf = addfile(ncName ,"c") ; open output netCDF file
filedimdef(ncdf,"time",-1,True) ; make time unlimited
; output variables directly
ncdf->TAUX = upop
ncdf->TAUY = vpop
;ncdf->ULAT = ulat
;ncdf->ULONG = ulong
end if
if (PLOT) then
wks = gsn_open_wks("x11","popvec_"+fRoot)
gsn_define_colormap(wks,"BlAqGrYeOrReVi200")
i = NhlNewColor(wks,0.7,0.7,0.7) ; add gray
res_at_gsnCenterString = "T42"
plot(0)= gsn_csm_vector_map_ce(wks,u42(0,:,:) ,v42(0,:,:),res)
res_at_gsnCenterString = "gx1v3"
upop_at_lat2d = ulat
upop_at_lon2d = ulon
vpop_at_lat2d = ulat
vpop_at_lon2d = ulon
plot(1)= gsn_csm_vector_map_ce(wks,upop(0,:,:),vpop(0,:,:),res)
resP_at_txString = fil42(nf)
gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot
end if
end do
end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 17 2007 - 14:32:48 MDT
This archive was generated by hypermail 2.2.0 : Mon Aug 20 2007 - 09:30:37 MDT