Skip to content

Accessing variables with symbols in the name #251

@dpabon

Description

@dpabon

I have a Netcdf where the names of several variables contain-

if I do:

pfts_test.GRASS-MAN

Of course, this fails:

ERROR: ArgumentError: GRASS not found in Dataset
Stacktrace:
 [1] getindex(x::Dataset, i::Symbol)
   @ YAXArrays.Datasets /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrays/au5n4/src/DatasetAPI/Datasets.jl:121
 [2] getproperty(x::Dataset, k::Symbol)
   @ YAXArrays.Datasets /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrays/au5n4/src/DatasetAPI/Datasets.jl:118
 [3] top-level scope

if I do:

pfts_test."GRASS-MAN".properties

It fails:

ERROR: MethodError: no method matching getproperty(::Dataset, ::String)
Closest candidates are:
  getproperty(::DataFrames.DataFrameColumns, ::AbstractString) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/DataFrames/LteEl/src/abstractdataframe/iteration.jl:210
  getproperty(::DataFrameRow, ::AbstractString) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/DataFrames/LteEl/src/dataframerow/dataframerow.jl:303
  getproperty(::DataFrames.GroupKey, ::AbstractString) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/DataFrames/LteEl/src/groupeddataframe/groupeddataframe.jl:690
  ...

if I do:

get_var_attrs(pfts_test, "GRASS-MAN")

it fails:

ERROR: MethodError: no method matching get_var_attrs(::Dataset, ::String)
Closest candidates are:
  get_var_attrs(::YAXArrayBase.ZarrDataset, ::Any) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrayBase/R6Frw/src/datasets/zarr.jl:11
  get_var_attrs(::YAXArrayBase.NetCDFDataset, ::Any) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrayBase/R6Frw/src/datasets/netcdf.jl:52
  get_var_attrs(::YAXArrayBase.GDALDataset, ::Any) at /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrayBase/R6Frw/src/datasets/archgdal.jl:94

Is there some way around, or is this a bug?

I greatly appreciate your help.
Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions