Skip to content

All dimmensions become coordinates? #722

@wilhelmsen

Description

@wilhelmsen

I have a netcdf file that looks like this (ncdump):

netcdf filevYpcG2 {
dimensions:
    coor1 = 2 ;
    dim1 = 2 ;
variables:
    int coor1(coor1) ;
        coor1:_FillValue = 999999 ;
    int var1(coor1) ;
        var1:_FillValue = 999999 ;
    int var2(dim1) ;
        var2:units = "unit1" ;
        var2:_FillValue = 999999 ;
        var2:attr_name = "variable1" ;

// global attributes:
        :metadata1 = "metadata1" ;
data:

 coor1 = 1, 2 ;

 var1 = 1, 2 ;

 var2 = 3, 4 ;
}

When opening it in xray (xarray) I therefore expect dim1 to be a dimension and coor1 to be a coordinate, because coor1 is also a variable, coor1(coor1)? But when opening the dataset in xray, I get the following:

In [1]: import xray;

In [2]: filename = "/tmp/filevYpcG2"

In [3]: x = xray.open_dataset(filename)

In [4]: x
Out[4]: 
<xray.Dataset>
Dimensions:  (coor1: 2, dim1: 2)
Coordinates:
  * coor1    (coor1) float64 1.0 2.0
  * dim1     (dim1) int64 0 1
Data variables:
    var1     (coor1) float64 1.0 2.0
    var2     (dim1) float64 3.0 4.0
Attributes:
    metadata1: metadata1


In [5]: x.coords
Out[5]: 
Coordinates:
  * coor1    (coor1) float64 1.0 2.0
  * dim1     (dim1) int64 0 1

In [6]: x.dims
Out[6]: Frozen(SortedKeysDict({u'coor1': 2, u'dim1': 2}))

In [7]: x.data_vars
Out[7]: 
Data variables:
    var1     (coor1) float64 1.0 2.0
    var2     (dim1) float64 3.0 4.0

That is, both coor1 and dim1 becomes coordinate variables. I expected only coor1 to become a coordinate variable, and not dim1.

Am I wrohg, or is it meant to be like this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions