[ncl-talk] Error with gsn_csm_pres_hgt

Rick Brownrigg brownrig at ucar.edu
Wed Jul 13 09:40:18 MDT 2016


Hi,

I don't know for certain, but I suspect that although you've given names to
the dimensions of your variable TKtimeAvg, there are likely no
coordinate-variables in your file by that name.  The printVarSummary shows
no coordinates associated with the variable.   Your input file appears to
be a WRF file, and for example, the latitude coordinates in a WRF file are
typically named XLAT (and are two/three dimensional).  I don't know offhand
what would correspond to "lev".

Hopefully that helps some...
Rick


On Tue, Jul 12, 2016 at 11:42 PM, Shreta Ghimire <shreta.g at gmail.com> wrote:

> Hello,
>
> I am fairly new to NCL. I am using ncl version 6.1.2. I am trying to
> create a Press/Hgt vs Lat plot using gsn_csm_pres_hgt and it's throwing me
> the following error
>
> *(0)     gsn_csm_pres_hgt: Fatal: The first dimension of the input data
> must*
> *(0)     have a coordinate variable called 'lev.'*
> *(0)     Cannot create plot.*
> *fatal:Illegal right-hand side type for assignment*
> *fatal:["Execute.c":8128]:Execute: Error occurred at or near line 118 in
> file check_Verticle.ncl*
>
> I have checked the earlier talk on the similar error "
> http://www.ncl.ucar.edu/Support/talk_archives/2009/1887.html "
> I tried to fix the error but still the code is producng the same error.
>
> Here is the code that i have used.
>
> *; ***************************************
> *; Load Packages*
> *; ***************************************
> *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/wrf/WRFUserARW.ncl"*
> *load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"*
>
> *; ***************************************
> *; Read File*
> *; ***************************************
>
> *a = addfile("wrfout_d01.nc <http://wrfout_d01.nc>", "r")*
>
> *; ***************************************
> *; Read Variable*
> *; ***************************************
>
> *theta = a->T*
> *perturbP = a->P*
> *baseStateP = a->PB*
>
> *; ***************************************
> *; Calculations*
> *; ***************************************
> *P1 = perturbP + baseStateP*
> *theta = theta + 300*
>
> *TK = wrf_tk(P1,theta)*
>
> *; ***************************************
> *; Rename Dimensions of Variable*
> *; ***************************************
> *TK!0 = "time"*
> *TK!1 = "lev"*
> *TK!2 = "lat"*
> *TK!3 = "lon"*
>
> *; ***************************************
> *; reorder the dimensions *
> *; compute average based on dimensions*
> *; ***************************************
>
> *TKreorder = TK(lev|:,lat|:,lon|:,time|:)                ;
> (lev,lat,lon,time)*
>
> *TKtime = dim_avg_Wrap(TKreorder) ; (lev,lat,lon)*
>
> *TKtimeAvg = dim_avg_Wrap(TKtime_reorder)   ; (lev,lat)*
>
> *printVarSummary(TKtimeAvg)*
>
> *; ***************************************
> *; Creat Plot*
> *; ***************************************
> *wks = gsn_open_wks("png", "PressVsLat_TK")*
> *gsn_define_colormap(wks,"NCV_bright")*
>
> *res = True*
> *res at cnFillOn = True*
> *res at lbLabelAutoStride = True*
>
> *plot = gsn_csm_pres_hgt(wks,TKtimeAvg(lev|:,lat|:),res)*
> ; ==================================================
>
> printVarSummary(TKtimeAvg) gives the following output, which shows the
> first dimension of the variable to be "lev"
>
>          Variable: TKtimeAvg
>          Type: float
>          Total Size: 32000 bytes
>                          8000 values
>          Number of Dimensions: 2
>          Dimensions and sizes:   [lev | 40] x [lat | 200]
>          Coordinates:
>          Number Of Attributes: 3
>              units :       K
>              description : Temperature
>              average_op_ncl :      dim_avg over dimension(s): lon
>
>
>
>
> Regards,
> Shreta Ghimire
>
>
> _______________________________________________
> 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/20160713/e6b6e756/attachment.html 


More information about the ncl-talk mailing list