Skip to content

Store processed data in Pooch cache #68

Answered by leouieda
mdtanker asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mdtanker thanks for asking! This is where you'd want to make a custom processor. The processor allows you to insert custom code between the file download and the return of the path.

For example, this code downloads one of our sample grids, converts the units to m/s², saves the converted grid, and returns the path to it instead:

from pathlib import Path


def custom_processor(fname, action, pooch):
    "Load the data, calculate something, save it back."
    fname = Path(fname)
    # Rename the file to ***-processed.nc
    fname_processed = fname.with_stem(fname.stem + "-processed")
    # Only recalculate if making a new download or the processed file doesn't exist yet
    if action in ("…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@mdtanker
Comment options

@leouieda
Comment options

@mdtanker
Comment options

@leouieda
Comment options

@mdtanker
Comment options

Answer selected by mdtanker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants