[ncl-talk] unstagger a C grid (as WRF data)
jmason at eos.ubc.ca
jmason at eos.ubc.ca
Thu Sep 25 13:03:02 MDT 2014
I use this to get access to my U and V on the C grid
uvmet = wrf_user_getvar(in, "uvmet", time) ; destagger and rotate u
an v
u = uvmet(0,:,:,:) ; extract u
v = uvmet(1,:,:,:) ; extract v
> Paolina,
>
> I think you're doing more than you need to. Take another look at the
> function page (linked below). The second argument should be a string
> either "X", "Y", or "Z". Your variables already have this info
> attached to the variables "stagger : Y".
>
> https://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_unstagger.shtml
>
> Therefore I think you can skip straight from the read in line to the
> unstagger line and change the unstagger commands to as below:
>
> u = *wrf_user_unstagger*(U,U at stagger)
>
>
> Good luck,
>
> Alan Brammer
>
>
>
> On Thu, Sep 25, 2014 at 12:12 PM, Paolina Bongioannini Cerlini <
> paolina.cerlini at unipg.it> wrote:
>
>> Hi NCL people,
>>
>> I have this simple script where I am trying to calculate a divergence
>> but I have a staggered C grid. Trying to unstagger the grid ,
>> I cannot define correctly the staggered dimensions, as you may see in
>> the
>> error:
>>
>>
>> -------------------------------------------------------------------------------------------------------------------
>> ;*************************************************
>> ; wind_1.ncl
>> ;*************************************************
>> 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/wrf/WRFUserARW.ncl"
>> ;*************************************************
>> begin
>> ;*************************************************
>> ; open file and read in data: data are on Arakawa C grid
>> ;*************************************************
>> f = addfile("rce-bret-2005.net000000.nc","r")
>> U = f->U(0,0,:,:)
>> V = f->V(0,0,:,:)
>>
>> printVarSummary(U)
>> printVarSummary(V)
>>
>> U!0="y"
>> U!1="x_stag"
>> xstag=ispan(1,195,1)
>> U at x_stag=xstag
>> x_stag=U at x_stag
>> V!0="y_stag"
>> V!1="x"
>> V at y_stag=ispan(1,195,1)
>> y_stag=V at y_stag
>>
>> u = wrf_user_unstagger(U,x_stag)
>> v = wrf_user_unstagger(V,y_stag)
>> printVarSummary(u)
>> printVarSummary(v)
>>
>> ;*************************************************
>> ; calculate divergence: Use Wrap to include meta data
>> ;*************************************************
>> div = uv2dvG_Wrap(u,v) ; u,v ==> divergence
>>
>> ;*************************************************
>> ; calculate divergent wind components
>> ;*************************************************
>> ud = new ( dimsizes(u), typeof(u), u at _FillValue )
>> vd = new ( dimsizes(v), typeof(v), v at _FillValue )
>>
>> dv2uvg(div,ud,vd) ; div ==> divergent wind components
>>
>> copy_VarCoords(u, ud )
>> copy_VarCoords(u, vd )
>> ud at long_name = "Zonal Divergent Wind"
>> ud at units = u at units
>> vd at long_name = "Meridional Divergent Wind"
>> vd at units = v at units
>> ;*************************************************
>> ; plot results
>> ;*************************************************
>> wks = gsn_open_wks("ps","wind") ; open a workstation
>>
>> res = True
>> res at vcRefMagnitudeF = 3. ; make vectors larger
>> res at vcRefLengthF = 0.050 ; reference vector length
>> res at vcGlyphStyle = "CurlyVector" ; turn on curly vectors
>> res at vcMinDistanceF = 0.012 ; thin the vectors
>>
>> res at gsnLeftString = "Divergent Wind"
>> ; plot 1st time step
>> plot= gsn_csm_vector_map_ce(wks,ud(0,:,:),vd(0,:,:),res)
>>
>> end
>>
>> --------------------------------------------------------------------------------------
>> I get this error:
>> Variable: U
>> Type: float
>> Total Size: 151320 bytes
>> 37830 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [y | 194] x [x_stag | 195]
>> Coordinates:
>> x_stag: [-3000..579000]
>> Number Of Attributes: 5
>> Time : 3600
>> standard_name : x_wind
>> long_name : U-velocity
>> units : m s-1
>> stagger : X
>>
>> Variable: V
>> Type: float
>> Total Size: 151320 bytes
>> 37830 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [y_stag | 195] x [x | 194]
>> Coordinates:
>> y_stag: [-3000..579000]
>> Number Of Attributes: 5
>> Time : 3600
>> standard_name : y_wind
>> long_name : V-velocity
>> units : m s-1
>> stagger : Y
>> warning:Argument 1 of the current function or procedure was coerced to
>> the
>> appropriate type and thus will not change if the function or procedure
>> modifies its value
>> fatal:Conditional statements (if and do while) require SCALAR logical
>> values, see all and any functions
>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 536 in
>> file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl
>>
>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 29 in
>> file wind_1.ncl
>>
>>
>> -------------------------------------------------------------------------------------------------------------
>> Thank you.
>>
>> paolina
>> --
>> --
>> Dr. Paolina Bongioannini Cerlini Ph.D.
>> University of Perugia
>> Dip.to Ingegneria
>> CIRIAF -room 8
>> Via G. Duranti, 67
>> 06125 - Perugia
>>
>> Tel.+39 075 585 3576
>> Fax +39 075 585 3697
>> e-mail: paolina.cerlini at unipg.it
>> paolina.cerlini at fisica.unipg.it
>> cell.:+39 3405761980
>> --
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
More information about the ncl-talk
mailing list