[ncl-talk] error reading netcdf4 file

Dennis Shea shea at ucar.edu
Wed Nov 30 07:59:15 MST 2016


Maybe:

   var = "/p100.128"        ;
   a->$var$




On Wed, Nov 30, 2016 at 7:24 AM, Marston Johnston <shejo284 at gmail.com>
wrote:

> Hi Karin,
>
>
>
> I have tried that and it did not work. I forgot to write that I tested
> that iteration as well.
>
>
>
> fatal:syntax error: line 15 in file process_t511.ncl before or near .128
>
>   g = a->p100.128
>
> ----------------^
>
>
>
> fatal:Syntax Error in block, block not executed
>
> fatal:error at line 17 in file process_t511.ncl
>
>
>
> I’m going to try using cdo to rename the variable to remove the “.” And
> test again.
>
> But the link should be updated to remove this example where the variable
> name contains a “.”.
>
>
>
> /M
>
>
>
> *From: *<ncl-talk-bounces at ucar.edu> on behalf of Karin Meier-Fleischer <
> meier-fleischer at dkrz.de>
> *Date: *Wednesday, 30 November 2016 at 15:18
> *To: *Marston Johnston <marston.johnston at gu.se>
> *Cc: *"ncl-talk [ncl-talk]" <ncl-talk at ucar.edu>
> *Subject: *Re: [ncl-talk] error reading netcdf4 file
>
>
>
> Hi Marston,
>
>
>
> the variable name in your netCDF file is p100.128 and not /p100.128. NCLs
> error message is exactly telling you what is wrong in line 18.
>
> Because the test script you send is not the script producing the error I
> guess that the line
>
>
>
>     g = short2flt(a->/p100.128)
>
>
>
> is the problem. Change it to
>
>
>
>     g = short2flt(a->p100.128)
>
>
>
> Bye,
>
> Karin
>
>
>
> Am 30.11.2016 um 14:59 schrieb Marston Johnston <marston.johnston at gu.se>:
>
>
>
> Hi,
>
>
>
> I writing a small script to read a netcdf4 file that was created by
> grib_api (version 1.17.0). But despite following the examples given here:
> http://www.ncl.ucar.edu/Applications/netcdf4.shtml. At first I thought
> the “.” in the variable name was causing the problem but in the examples
> given in the link above, such a file naming type was given. I’ve tried
> using $”/p100.128”$, treating it as a group: a=>/p100.128, but to no avail.
>
>
>
> I can upload the file for testing.
>
>
>
> ****************** script *********************
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
>
>   idir="/home/ "
>
>   fil="ICMGGglxc+2007var100.nc"
>
>   setfileoption("nc", "FileStructure", "Advanced")
>
>   setfileoption("nc", "Format",  "NetCDF4")
>
>   a = addfile(idir+fil,"r")
>
>   printVarSummary(a)
>
>   vNames = getfilevarnames (a)
>
>   print(vNames)
>
>   g = short2flt(a->/p100.128)
>
>   printVarInfo(g,"g")
>
> end
>
> *****************  results  ********************
>
> [nclcodes]$ ncdump -k /home/ICMGGglxc+2007var100.nc
>
> netCDF-4
>
> [nclcodes]$
>
> ncdump -g /p100.128 /home/ICMGGglxc+2007var100.nc
>
> ncdump: /p100.128: No such group
>
>
>
> [nclcodes]$ ncdump -h /home/ICMGGglxc+2007var100.nc
>
> netcdf ICMGGglxc+2007var100 {
>
> dimensions:
>
>                 longitude = 1024 ;
>
>                 latitude = 512 ;
>
>                 level = 11 ;
>
>                 time = UNLIMITED ; // (2920 currently)
>
> variables:
>
>                 float longitude(longitude) ;
>
>                                 longitude:standard_name = "longitude" ;
>
>                                 longitude:long_name = "longitude" ;
>
>                                 longitude:units = "degrees_east" ;
>
>                                 longitude:axis = "X" ;
>
>                 float latitude(latitude) ;
>
>                                 latitude:standard_name = "latitude" ;
>
>                                 latitude:long_name = "latitude" ;
>
>                                 latitude:units = "degrees_north" ;
>
>                                 latitude:axis = "Y" ;
>
>                 double level(level) ;
>
>                                 level:long_name = "model_level_number" ;
>
>                                 level:axis = "Z" ;
>
>                 double time(time) ;
>
>                                 time:standard_name = "time" ;
>
>                                 time:long_name = "time" ;
>
>                                 time:units = "hours since 1900-1-1
> 00:00:00" ;
>
>                                 time:calendar = "standard" ;
>
>                                 time:axis = "T" ;
>
>                 short p100.128(time, level, latitude, longitude) ;
>
>                                 p100.128:long_name = "Experimental
> product" ;
>
>                                 p100.128:units = "~" ;
>
>                                 p100.128:grid_type = "gaussian" ;
>
>                                 p100.128:add_offset = 2826.8713701289 ;
>
>                                 p100.128:scale_factor =
> 0.0914882578243023 ;
>
>                                 p100.128:_FillValue = -32767s ;
>
>                                 p100.128:missing_value = -32767s ;
>
>
>
> // global attributes:
>
>                                 :CDI = "Climate Data Interface version
> 1.7.0 (http://mpimet.mpg.de/cdi)" ;
>
>                                 :history = "Mon Nov 28 23:20:13 2016: cdo
> -O -v mergetime ICMGGglxc+200701_var100.nc ICMGGglxc+200702_var100.nc
> ICMGGglxc+200703_var100.nc ICMGGglxc+200704_var100.nc ICMGGglxc+
> 200705_var100.nc ICMGGglxc+200706_var100.nc ICMGGglxc+200707_var100.nc
> ICMGGglxc+200708_var100.nc ICMGGglxc+200709_var100.nc ICMGGglxc+
> 200710_var100.nc ICMGGglxc+200711_var100.nc ICMGGglxc+200712_var100.nc
> ICMGGglxc+2007var100.nc\n2016-11-28 22:01:41 GMT by
> grib_to_netcdf-1.17.0: grib_to_netcdf -k 3 -o ICMGGglxc+200712_var100.nc
> ICMGGglxc+200712_var100.grb" ;
>
>                                 :Conventions = "CF-1.6" ;
>
>                                 :CDO = "Climate Data Operators version
> 1.7.0 (http://mpimet.mpg.de/cdo)" ;
>
> }
>
> [nclcodes]$
>
>
>
> [nclcodes]$ ncl process_t511.ncl
>
> Copyright (C) 1995-2015 - All Rights Reserved
>
> University Corporation for Atmospheric Research
>
> NCAR Command Language Version 6.3.0
>
> The use of this software is governed by a License Agreement.
>
> See http://www.ncl.ucar.edu/ for more details.
>
>
>
> Variable: a
>
> Type: file
>
> File path                :               /home/ICMGGglxc+2007var100.nc
>
>
>
> Number of global attributes            :               4
>
> Number of dimensions      :               4
>
> Number of chunk_dimensions         :               1
>
> Number of variables          :               5
>
>
>
> Variable: vNames
>
> Type: string
>
> Total Size: 40 bytes
>
>             5 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes:        [5]
>
> Coordinates:
>
> (0)           /longitude
>
> (1)           /latitude
>
> (2)           /level
>
> (3)           /time
>
> (4)           /p100.128
>
> fatal:["Execute.c":132]:variable (/p100.128) is not in file
> (/home/ICMGGglxc+2007var100.nc)
>
> fatal:["Execute.c":6316]:variable (/p100.128) is not in file (a)
>
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 18 in
> file process_t511.ncl
>
>
>
> Cheers,
>
> /M
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
>
> _______________________________________________ ncl-talk mailing list
> ncl-talk at ucar.edu List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> 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/20161130/f7114dfe/attachment.html 


More information about the ncl-talk mailing list