Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add keep_encoding to global options #5336

Closed
snowman2 opened this issue May 18, 2021 · 5 comments
Closed

ENH: Add keep_encoding to global options #5336

snowman2 opened this issue May 18, 2021 · 5 comments

Comments

@snowman2
Copy link
Contributor

Is your feature request related to a problem? Please describe.
https://corteva.github.io/rioxarray/stable/getting_started/manage_information_loss.html

Original data:

rds.green.attrs, rds.green.encoding
({'nodata': 0, 'units': ('DN', 'DN')},
 {'dtype': 'float64',
  'grid_mapping': 'spatial_ref',
  'scale_factor': 1.0,
  'add_offset': 0.0,
  '_FillValue': nan,
  'source': 'netcdf:../../test/test_data/input/PLANET_SCOPE_3D.nc:green'})
with xarray.set_options(keep_attrs=True):
    new_ds = rds.green + rds.green
new_ds.attrs, new_ds.encoding
{'nodata': 0, 'units': ('DN', 'DN')}, {}

Describe the solution you'd like

with xarray.set_options(keep_attrs=True, keep_encoding=True):
    new_ds = rds.green + rds.green
new_ds.attrs, new_ds.encoding
({'nodata': 0, 'units': ('DN', 'DN')},
 {'dtype': 'float64',
  'grid_mapping': 'spatial_ref',
  'scale_factor': 1.0,
  'add_offset': 0.0,
  '_FillValue': nan,
  'source': 'netcdf:../../test/test_data/input/PLANET_SCOPE_3D.nc:green'})
@jhamman
Copy link
Member

jhamman commented Mar 27, 2023

This seems like a reasonable thing to do. We can likely reuse a lot of the machinery from keep_attrs to make this happen. @snowman2 - is this something you would be up to work on?

@snowman2
Copy link
Contributor Author

I am not certain about my availability at the moment. If I get free time, I would be happy to do so. However, if someone else gets started on it first, that would be great as well.

@dcherian
Copy link
Contributor

I think we were leaning towards removing encoding in #5082

@max-sixty
Copy link
Collaborator

Now we have .reset_encoding, does that supplant this?

I'd generally lean away from global options — increases the cardinality of the library, similar code will act differently based on context, etc.

@dcherian
Copy link
Contributor

Yes we are deleting encoding eventually so I'll close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants