[ncl-talk] List subscripting used on non-list variable, can't continue

Barry Lynn barry.h.lynn at gmail.com
Wed Aug 7 06:01:40 MDT 2019


Hi:

I am not sure which variable is being printed in error, but you are trying
to subscript (add indices) to a variable that doesn't have them.  Try to
solve your problem by finding the variable.  You can printVarSummary to see
the dimensions of each.

Barry

On Wed, Aug 7, 2019 at 2:40 PM Borja Sas González via ncl-talk <
ncl-talk at ucar.edu> wrote:

> I am trying to write a csv to represent several variables. To make it
> easy, copy the example from the NCL page (write_csv_5.ncl) that represents
> the temperature at 2 m.
>
> The only changes I made in the script are the output file of the WRF that
> you are going to read and the map points that I want.
>
> When executing it, the following error is printed:
>
> fatal:List subscripting used on non-list variable, can't continue
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 51 in
> file csv.ncl
>
> The script is:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
>
>   a =
> addfile("/home/bsas/wrf_wind/WRF/test/em_real/wrfout_d03_2019-08-07_00:00:
> 00.nc","r")
>
>   times = wrf_user_list_times(a) ; "2019-08-01_12:00:00", etc
>   tk2   = wrf_user_getvar(a,"T2",-1) ; T2 in Kelvin
>
>   times  = wrf_user_list_times(a)
>   ntimes = dimsizes(times)
>   print("ntimes = " + ntimes)
>
> ;---Calculate i,j locations of data closest to set of lat/lon points
>   lats = (/28.290147,28.379555/)
>   lons = (/-16.377643,-16.585276/)
>   nlatlon = dimsizes(lats)
>   loc = wrf_user_ll_to_xy(a, lons, lats, True)   ; 2 x nlatnlon
>
> ;  loc = wrf_user_ll_to_ij(a, lons, lats, True)   ; 2 x nlatnlon
> ;  loc = loc - 1                                  ; wrf_user_ll_to_ij
> returns 1-based indexes
>
> ;---Set up CSV file and header information for the file
>   csv_filename = "wrf_2m_temperature.csv"
>   system("rm -f " + csv_filename)                ; Remove file in case it
> exists.
>   fields = (/"TIME", "LAT", "LON", "TEMPERATURE (degC)"/)
>
> ;---Create a header line for CSV file
>   dq     = str_get_dq()
>   fields = dq + fields + dq                      ; Pre/append quotes to
> field names
>   header = [/str_join(fields,",")/]              ; Header is field names
> separated
>                                                  ; by commas.
> ;
> ; Format to use for writing each variable to CSV file.
> ; If you don't want spaces in CSV file, use the following
> ; format string:
> ;     format = "%s,%g,%g,%g"
> ;
> format = "%s,%6.2f,%7.2f,%6.2f"
>
> ;
> ; Loop through each time step and desired list of lat/lon values,
> ; and write a single line of data to CSV file.
> ;
>   write_table(csv_filename, "w", header, "%s")   ; Write header to CSV
> file.
>   do it = 0,ntimes-1
>     do nl = 0,nlatlon-1
>       nln   = loc(0,nl)
>       nlt   = loc(1,nl)
>       lat1  = a[0]->XLAT(0,nlt,nln)    ; nearest grid point
>       lon1  = a[0]->XLONG(0,nlt,nln)
>       alist = [/times(it),lat1,lon1,tk2(it,nlt,nln)/]   ; Store data to be
> written in a list.
>       write_table(csv_filename, "a", alist, format)     ; Write list to
> CSV file.
>     end do
>   end do
> end
> --
> Borja Sas González
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk



-- 
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190807/7e61a994/attachment.html>


More information about the ncl-talk mailing list