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

Custom Python processors #18

Merged
merged 4 commits into from
Mar 11, 2021
Merged

Custom Python processors #18

merged 4 commits into from
Mar 11, 2021

Conversation

forman
Copy link
Member

@forman forman commented Mar 10, 2021

You can now provide your Python code for customization of the datasets read and written. (#16)

  • input/custom_preprocessor: "module:function" is called on each input after optional variable selection.
  • process/custom_processor: "module:function" is called after optional renaming and before optional rechunking.

Both "function"s are expected to receive an xarray.Dataset object as only argument and return the same or modified xarray.Dataset object.

Note: to let Python import "module" that is not a user package, you can extend the PYTHONPATH environment variable before calling nc2zarr:

export PYTHONPATH=${PYTHONPATH}:path/to/my/modules
nc2zarr ...

This PR has is already used for producing the CCI GHG CO2 Zarr dataset and seems to work as expected.

@forman forman requested review from TonioF and pont-us March 10, 2021 14:56
@forman forman self-assigned this Mar 10, 2021
@TonioF TonioF merged commit 22d4dcf into main Mar 11, 2021
This was referenced Mar 11, 2021
@forman forman deleted the forman-16-custom_processors branch March 12, 2021 10:37
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 this pull request may close these issues.

3 participants