Unidata / pygcdm

BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Coordinate Attribute issue #12

Open rmcsqrd opened 3 years ago

rmcsqrd commented 3 years ago

When ingesting GOES channel 9 data for Puerto Rico, the original data for int fixedgrid_projection does not have a coordinate attribute (view this via ncdump [file] | less.

When running it through awips-ml via pygcdm, fixedgrid_projection:coordinates = "time" gets added.

Need to

rmcsqrd commented 3 years ago

Just some clues from AWIPS ml - using https://github.com/rmcsqrd/awips-ml/tree/ead92b6394414d926ebd87e90b6fc4864ad18ab5.

Choosing a random file (one original file and one thats been processed via TF with _ml extension, we load them using xarray and netCDF4. nc is original file, loaded via netCDF4, ncx is original loaded via xarray, ncml is _ml file loaded via netCDF4 and ncmlx is _ml file loaded via xarray.

Big picture is that the extra attribute doesn't show up in either xarray versions (ncx or ncmlx) and only shows up in the modified version via netCDF4:

# same for xarray
>>> ncx[var]
<xarray.DataArray 'fixedgrid_projection' ()>
array(-2147483647, dtype=int32)
Coordinates:
    time     datetime64[ns] ...
Attributes:
    grid_mapping_name:               geostationary
    latitude_of_projection_origin:   0.0
    longitude_of_projection_origin:  -75.00000000000001
    semi_major:                      6378137.0
    semi_major_axis:                 6378137.0
    semi_minor:                      6356752.31414
    semi_minor_axis:                 6356752.31414
    perspective_point_height:        35786023.0
    sweep_angle_axis:                x
>>> ncmlx[var]
<xarray.DataArray 'fixedgrid_projection' ()>
array(-2147483647, dtype=int32)
Coordinates:
    time     datetime64[ns] ...
Attributes:
    grid_mapping_name:               geostationary
    latitude_of_projection_origin:   0.0
    longitude_of_projection_origin:  -75.00000000000001
    semi_major:                      6378137.0
    semi_major_axis:                 6378137.0
    semi_minor:                      6356752.31414
    semi_minor_axis:                 6356752.31414
    perspective_point_height:        35786023.0
    sweep_angle_axis:                x
# but not for netCDF4
>>> nc.variables[var]
<class 'netCDF4._netCDF4.Variable'>
int32 fixedgrid_projection()
    grid_mapping_name: geostationary
    latitude_of_projection_origin: 0.0
    longitude_of_projection_origin: -75.00000000000001
    semi_major: 6378137.0
    semi_major_axis: 6378137.0
    semi_minor: 6356752.31414
    semi_minor_axis: 6356752.31414
    perspective_point_height: 35786023.0
    sweep_angle_axis: x
unlimited dimensions:
current shape = ()
filling on, default _FillValue of -2147483647 used
>>> ncml.variables[var]
<class 'netCDF4._netCDF4.Variable'>
int32 fixedgrid_projection()
    grid_mapping_name: geostationary
    latitude_of_projection_origin: 0.0
    longitude_of_projection_origin: -75.00000000000001
    semi_major: 6378137.0
    semi_major_axis: 6378137.0
    semi_minor: 6356752.31414
    semi_minor_axis: 6356752.31414
    perspective_point_height: 35786023.0
    sweep_angle_axis: x
    coordinates: time
unlimited dimensions:
current shape = ()
filling on, default _FillValue of -2147483647 used
rmcsqrd commented 3 years ago

Intuition - make sure interface in pygcdm is via xarray variable not dataarray - could be the issue