[ncl-talk] confusion with reading attributes

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Nov 21 20:01:33 MST 2019


Mark, I should have caught this before.  There are unnecessary elements in
your read statement.  A simpler version would be better:

lats = obsfile->$"latitude at MetaData"$

The whole-array subscript (:) is not needed unless you have a specific
reason to trap a latitude variable that has more than one dimension.


On Thu, Nov 21, 2019 at 7:40 PM M P <mzp3769 at gmail.com> wrote:

> Thanks very much that solved this problem but another one occurred related
> to scatter-plotting that I will follow-up
> in a separate thread,
> Mark
>
> On Thu, Nov 21, 2019 at 4:37 PM Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Mark has a netcdf file with an "at sign" embedded in a variable name.
>> This is quite odd, but it is legal netcdf.
>>
>> This needs special quoting in NCL, because the "at sign" is an active NCL
>> operator.  Special quoting is needed.  This should work:
>>
>>  lats = ndtooned (obsfile->$"latitude at MetaData"$(:))
>>
>>
>> On Thu, Nov 21, 2019 at 4:27 PM Rick Brownrigg via ncl-talk <
>> ncl-talk at ucar.edu> wrote:
>>
>>> I for one don't understand this line:
>>>
>>>   float latitude at MetaData(nlocs) ;
>>>
>>> Could you perhaps open the file and provide the output from
>>> "printVarSummary(obsfile)" ??
>>>
>>> Rick
>>>
>>>
>>> On Thu, Nov 21, 2019 at 4:02 PM M P via ncl-talk <ncl-talk at ucar.edu>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a file in the following format
>>>> netcdf aod_viirs_obs_2018041500_f {
>>>> dimensions:
>>>>         nvars = 1 ;
>>>>         nlocs = UNLIMITED ; // (27545 currently)
>>>> variables:
>>>>          ....
>>>>         float latitude at MetaData(nlocs) ;
>>>>
>>>> with  latitude at MetaData just being a variable name
>>>>
>>>> That is falsely being read as an attribute with a code
>>>>
>>>>  obsfile   = addfile("./indata/aod_viirs_obs_2018041500_s.nc4","r")
>>>>    ; lons, lats, AOD
>>>>  lats  =   ndtooned(obsfile->latitude at MetaData(:))    ; Pull off lat
>>>>
>>>> and warning/error
>>>>
>>>> warning:["NclAdvancedFile.c":5317]:AdvancedFileReadVarAtt: (MetaData)
>>>> is not an attribute of (latitude)
>>>>
>>>> How to correct it so that the variable latitude at MetaData is read
>>>> properly?
>>>>
>>>> Thanks,
>>>>
>>>> Mark
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191121/d668f217/attachment.html>


More information about the ncl-talk mailing list