# [ncl-talk] Problem in calculating CAPE

Guido Cioni guidocioni at gmail.com
Wed Mar 14 08:22:34 MDT 2018

```Did you read the documentation?

https://www.ncl.ucar.edu/Document/Functions/Built-in/conform_dims.shtml <https://www.ncl.ucar.edu/Document/Functions/Built-in/conform_dims.shtml> especially  Example 4

ndim
An array of dimension indexes to indicate which dimension sizes indicated by dims match the dimensions in r. Dimension numbering starts at the left and must be increasing. The leftmost dimension index is 0, the next dimension index is 1, and so on. If r is a scalar, then ndim can have the special value of -1 (see below).

You indicated ndim =0, that is lat if the variables are dimensioned as you are saying  (lat, lon, lev, time). Instead you are defining pressure as an height variable as far as I understand from your assignment

>     p = (/ 10.000000, 20.000000, 30.000000, 50.000000, 70.000000,
> 100.000000  \
>           , 150.000000, 200.000000, 250.000000, 300.000000, 400.000000,
> 500.000000  \
>           , 600.000000, 700.000000, 850.000000, 925.000000, 950.000000,
> 1000.000000 /)

So you should do p = conform_dims (dimsizes(q),p,2).

> On 14. Mar 2018, at 12:20, vivek at ncmrwf.gov.in wrote:
>
> Hello Sir,
> I have a model data(nc format). I am trying to calculate CAPE as below.
>
> ;CAPE and CIN in ncl:
>     f = addfile("./cape.nc" , "r")
>     p = (/ 10.000000, 20.000000, 30.000000, 50.000000, 70.000000,
> 100.000000  \
>           , 150.000000, 200.000000, 250.000000, 300.000000, 400.000000,
> 500.000000  \
>           , 600.000000, 700.000000, 850.000000, 925.000000, 950.000000,
> 1000.000000 /)
>     t = f->temp
>     q = f->q
>     z = f->ht_1
> ;    p = conform_dims (dimsizes(q),p,0)
>     zsfc = f->ht ; (lat,lon)
>     psfc = f->p_1         ; (lat,lon) or (time,lat,lon)
>     cinfo = wrf_cape_3d(p, t, q, z, zsfc, psfc, False) ; cinfo(2,...)
> ;    cape3d = wrf_user_getvar(f,"cape_3d",-1)
>
> I am getting following error.
>
> fatal:conform_dims: the dimensions sizes of the second argument do not
> match those indicated by the third argument
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 9 in file
> cape.ncl
>
> fatal:wrf_cape_3d: The p, t, q, and z arrays must all have the same number
> of dimensions
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 12 in
> file cape.ncl
>
>
>
> What I could understand from the error is  the dimension of 'p' is not
> matching with dimension of q(or t; lat, lon, lev, time).
>
> Kindly suggest that How to match the dimension of p with that of q/t
>
> Thnking You,
>
> Vivek
>
>
>
>
>
>
> --
> Yours Sincerely
> ----------------
> Vivek Singh
> (Scientist-'C')
> NCMRWF,A-50, Sector-62,
> Ministry of Earth Sciences
> NOIDA.U.P. 201309
> Mobile:09821123574,07042321724
> Institute Website: www.ncmrwf.gov.in
> Alternate email: vivek.sgh1 at gmail.com
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Guido Cioni
http://guidocioni.altervista <http://guidocioni.altervista/>.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180314/6f563dfc/attachment.html>
```

More information about the ncl-talk mailing list