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

Standardize metadata between pyramid generation methods #118

Closed
maxrjones opened this issue Mar 26, 2024 · 0 comments · Fixed by #119
Closed

Standardize metadata between pyramid generation methods #118

maxrjones opened this issue Mar 26, 2024 · 0 comments · Fixed by #119

Comments

@maxrjones
Copy link
Contributor

There are some differences between the metadata produced by pyramid_reproject, pyramid_coarsen, and pyramid_regrid. It would be good to align the metadata between these functions and check for agreement with the current ndpyramid metadata schema. For example, pyramid_coarsen adds local variables to the recorded kwargs, whereas pyramid_coarsen and pyramid_reproject do not. pyramid_coarsen also lacks the multiscales.datasets.pixels_per_tile attribute.

pyramid_coarsen

import xarray as xr
import rioxarray
from ndpyramid import pyramid_coarsen, pyramid_reproject, pyramid_regrid

# load a sample xarray.Dataset
ds = xr.tutorial.load_dataset('air_temperature')
# make a coarsened pyramid
coarsened = pyramid_coarsen(ds, factors=[16, 8, 4, 3, 2, 1], dims=['lat', 'lon'], boundary='trim')
coarsened.attrs
{'multiscales': [{'datasets': [{'path': '0'},
    {'path': '1'},
    {'path': '2'},
    {'path': '3'},
    {'path': '4'},
    {'path': '5'}],
   'type': 'reduce',
   'metadata': {'method': 'pyramid_coarsen',
    'version': '0.1.0.post32+g56e0d0d.d20240319',
    'args': [],
    'kwargs': {'factors': [16, 8, 4, 3, 2, 1],
     'dims': ['lat', 'lon'],
     'kwargs': {'boundary': 'trim', 'lat': 1, 'lon': 1}}}}]}

pyramid_reproject

# make a reprojected (EPSG:3857) pyramid
ds = ds.rio.write_crs('EPSG:4326')
reprojected = pyramid_reproject(ds, levels=2)
reprojected.attrs
{'multiscales': [{'datasets': [{'path': '0',
     'pixels_per_tile': 128,
     'crs': 'EPSG:3857'},
    {'path': '1', 'pixels_per_tile': 128, 'crs': 'EPSG:3857'}],
   'type': 'reduce',
   'metadata': {'method': 'pyramid_reproject',
    'version': '0.1.0.post32+g56e0d0d.d20240319',
    'args': [],
    'kwargs': {'levels': 2, 'pixels_per_tile': 128}}}],
 'title': 'multiscale data pyramid',
 'version': '0.1.0.post32+g56e0d0d.d20240319'}

pyramid_regrid

regridded = pyramid_regrid(ds, levels=2)
regridded.attrs
{'multiscales': [{'datasets': [{'path': '0',
     'pixels_per_tile': 128,
     'crs': 'EPSG:3857'},
    {'path': '1', 'pixels_per_tile': 128, 'crs': 'EPSG:3857'}],
   'type': 'reduce',
   'metadata': {'method': 'pyramid_regrid',
    'version': '0.1.0.post32+g56e0d0d.d20240319',
    'args': [],
    'kwargs': {'projection': 'web-mercator',
     'levels': 2,
     'method': 'bilinear',
     'regridder_kws': {'periodic': True},
     'regridder_apply_kws': None,
     'other_chunks': None,
     'pixels_per_tile': 128}}}],
 'title': 'multiscale data pyramid',
 'version': '0.1.0.post32+g56e0d0d.d20240319'}
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

Successfully merging a pull request may close this issue.

1 participant