Skip to content

Best way to implement lazy backend for data format with multiple files? #5860

Answered by arbennett
arbennett asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, after a quick side chat with @jhamman this was a trivial fix. All I had to do was expose self.read_parflow_file so that you can use xr.open_dataset with the actual files that contain the data. Then, when using the metadata file to read the full dataset I change:

def read_variable(self, variable_name):
    time_slice_files = self.output_metadata[variable_name]['file-series']
    # Some other metadata wrangling
    return xr.concat([self.read_parflow_file(f) for f in time_slice_files])

to

def read_variable(self, variable_name):
    time_slice_files = self.output_metadata[variable_name]['file-series']
    # Some other metadata wrangling
    return xr.open_mfdataset(time_slice_files, c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by arbennett
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant