jei L
jei L

Reputation: 33

How to filter a catalog by date when importing intake in Python?

I have the following code

import intake
import pandas as pd

# Importing json file
catalog_file = "../my/path/path.json"

#using `intake` to manage the data
cat = intake.open_esm_datastore(catalog_file)

# Furthering filtering the data 
hits = cat.search(variable_id="var", frequency="30minutes")

#Loading the data
dataset_dict = hits.to_dataset_dict(cdf_kwargs={"chunks": {"time": 1}})

now, I've got an error when using .to_dataset_dict. The error basically says that it cannot find the first *.nc file:

OSError: 
            Failed to open netCDF/HDF dataset.

            *** Arguments passed to xarray.open_dataset() ***:

            - filename_or_obj: /work/bm1235/k203123/experiments/ngc2009/run_20200204T000000-20200218T235920/ngc2009_atm_2d_30min_inst_20200208T000000Z.nc
            - kwargs: {'chunks': {'time': 1}}

            *** fsspec options used ***:

            - root: /work/bm1235/k203123/experiments/ngc2009/run_20200204T000000-20200218T235920/ngc2009_atm_2d_30min_inst_20200208T000000Z.nc
            - protocol: None

            ********************************************

The data is complete from the 9.02.2020 (September 9th, 2020) onwards. The error comes from a *.nc file with data for day 08.02.2020 (August 2nd, 2020).

I am not an expert in intake an I was just wondering if there is a way to filter/select the data from 9.02.2020 until 1.03.2022.

Upvotes: 0

Views: 90

Answers (0)

Related Questions