[ncl-talk] hyi2hyo: rightmost dimension of ps and xi must be the same

Dennis Shea shea at ucar.edu
Tue Oct 31 14:17:19 MDT 2017


I think the refrain 'look at your data' applies here.

===
There are several* dimension related *issues with your data.

[A] Variable

*xi*
*xi:  *[time | *12*] x [lev | 31] x *[lon | 192] x [lat | 96]*

Note the two rightmost 'spatial' dimensions: names and sizes

[B] Variable psfc

*psfc*: [time | *1*] x *[lat | 96] x [lon | 192]*

----------------------

spatial dimensions:
xi has order (...,lon,lat)     ==> (...,192,96)
psfc gas order (...,lat,lon)   ==> (...,96,192)

temporal dimension size
xi has time=12, psfc=1

-----------------------

You could expand psfc 12 size 12 but I am not sure that is wht you want to
do.

[C]

P0 must have a units attribute

[D]

Did you want to remove the zonal means or the time mena???

++++++++++++++++++++++++++++++++++++++++++++

  f    = addfile("ham_oxi_aps_T63L31.nc","r")
  hyai = f->hyam          ; input A(k)
  hybi = f->hybm          ; input B(k)
  xi   = f->OX_VMR_avrg   ; variable to be interpolated
  printVarSummary(xi)     ; (time,lev,lon,lat);  (0,1,2,3)
  print("---")

  xi  := xi(time|:,lev|:,lat|:,lon|:)  ; (time,lev,lat,lon); REORDER
  printVarSummary(xi)     ; (time,lev,lat,lon);  (0,1,2,3)
  print("---")

  xi   = dim_rmvmean_Wrap(xi)        ; *remove zonal means*
 ;xi   = dim_rmvmean_n_Wrap(xi, 0)   *; remove time mean*
  printVarSummary(xi)          ; rmvmean_op_NCL:  dim_rmvmean over
dimension(s): lon
  print("---")

  fP   = addfile("surf_pres_new_exp_echam_exp.nc","r")
  psfc = fP->aps          ; surface pressure (Pa)
  printVarSummary(psfc)   ; (time,lat,lon)
  print("---")

  PSFC = conform( xi(:,0,:,:), psfc(0,:,:), (/1,2/) )
  copy_VarMeta(psfc(0,:,:), PSFC(0,:,:))
  printVarSummary(PSFC)

  sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945,
0.11654, 0.14916, \
         0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529,
0.60135, 0.66482,    \
         0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459,
0.97418, 0.99000,    \
         1.00000/)

  hybo = sigma            ; *your* B(k) [ sigma levels ]
  nsig = dimsizes(hybo)
  hyao = new(nsig,typeof(hybo))
  hyao = 0.0             ; set output A(k) to 0.0

  p0   = 101325           ; reference pressure (Pa)
  p0 at units = "Pa"

  xo   = hyi2hyo_Wrap(p0,hyai,hybi,PSFC,xi,hyao,hybo,0) ; contributed.ncl
  printVarSummary(xo)



On Tue, Oct 31, 2017 at 11:01 AM, Jayant <jayantkp2979 at gmail.com> wrote:

> Dear,
>
> I am following the steps given in thread (https://www.ncl.ucar.edu/Supp
> ort/talk_archives/2006/0001.html) to convert a file from hybrid level to
> sigma levels. I paste below my script and the outputs. I am not able to
> understand where I am going wrong. Please advice. Also, let me know if I
> need to send my netcdf files as well.
> Thanks in advance,
> Jayant
>
>   f=addfile("ham_oxi_aps_T63L31.nc","r")
>   hyai = f->hyam         ; input A(k)
>   hybi = f->hybm         ; input B(k)
>   xi   = f->OX_VMR_avrg        ; (0,:,:,:)     ; variable to be
> interpolated
>   dims = getvardims(xi)
>   xin  = dim_rmvmean_Wrap(xi($dims(0)$|:,$dims(1)$|:,$dims(3)$|:,$dim
> s(2)$|:))
>   printVarSummary(xin)
>   p0   = 101325            ; reference pressure (Pa)
>
>   fP   = addfile("surf_pres_new_exp_echam_exp.nc","r")
>   psfc = fP->aps            ; surface pressure (Pa)
>   printVarSummary(psfc)
>   ; dims = getvardims(psfc)
>   ; psfcr = dim_rmvmean_Wrap(psfc($dims(0)$|:,$dims(2)$|:,$dims(1)$|:))
>   ; psfc2d = psfcr(0,:,:)
>
>   sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945,
> 0.11654, 0.14916, \
>          0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529,
> 0.60135, 0.66482,    \
>          0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459,
> 0.97418, 0.99000,    \
>          1.00000/)
>
>   hybo = sigma            ; *your* B(k) [ sigma levels ]
>   nsig = dimsizes(hybo)
>   hyao = new(nsig,typeof(hybo))
>   hyao = 0.0             ; set output A(k) to 0.0
>
>   ; xo = hyi2hyo_Wrap(p0,hyai,hybi,psfcr,xi,hyao,hybo,0) ;
> contributed.ncl
>   xo = hyi2hyo_Wrap(p0,hyai,hybi,psfc,xin,hyao,hybo,0) ; contributed.ncl
>   printVarSummary(xo)
>
> On running, I am getting the following error:
>
> Variable: xin
> Type: float
> Total Size: 27426816 bytes
>             6856704 values
> Number of Dimensions: 4
> Dimensions and sizes:    [time | 12] x [lev | 31] x [lat | 96] x [lon |
> 192]
> Coordinates:
>             time: [   0..  11]
>             lev: [ 1..31]
>             lat: [88.5721685140073..-88.5721685140073]
>             lon: [   0..358.125]
> Number Of Attributes: 5
>   rmvmean_op_NCL :    dim_rmvmean over dimension(s): lon
>   long_name :    Deviation from mean
>   grid_type :    gaussian
>   units :    VMR
>   _FillValue :    9.96921e+36
>
> Variable: psfc
> Type: float
> Total Size: 73728 bytes
>             18432 values
> Number of Dimensions: 3
> Dimensions and sizes:    [time | 1] x [lat | 96] x [lon | 192]
> Coordinates:
>             time: [30.99166666666667..30.99166666666667]
>             lat: [88.57216851400727..-88.57216851400727]
>             lon: [   0..358.125]
> Number Of Attributes: 5
>   grid_type :    gaussian
>   table :    128
>   code :    134
>   units :    Pa
>   long_name :    surface pressure
> fatal:hyi2hyo: The rightmost dimensions of 'ps' and 'xi' must be the same
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 9139 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171031/b0766e3e/attachment.html>


More information about the ncl-talk mailing list