0

I have prepared a catalog.yml with this content:

metadata:
  description: Sample catalog
    information.
  version: 1
plugins:
  source:
    - module: intake_xarray
sources:
  this_source:
    args:
      storage_options:
        client_kwargs:
          endpoint_url: https://mys3
          verify: false
        key: mykey
        secret: mysecret
      urlpath: s3://thispath/{{ date.strftime('%Y/%m/%Y%m%d') }}.nc
      chunks: {}
      xarray_kwargs:
        engine: h5netcdf
    description: CREATE sample
    driver: netcdf
    metadata: {}
    parameters:
      date:
        default: '2025-01-01T00:00:00'
        description: Date and hour of data.
        min: '2020-01-01T00:00:00'
        type: datetime

then I tried to open the dataset in this way:

from datetime import datetime
import intake

cat = intake.open_catalog('catalog.yml')
ds = cat.this_source(date=datetime(2024, 1, 1)).read()

My problem is that the output data is related to default date value (2025-01-01) whatever value I pass to the reader.

Indeed, it seems that the input parameter value is not used by the reader. I verified the same approach/syntax with an Intake csv source and it works perfectly.

Does someone know how to fix this issue?

Thank you

2
  • This is more like a bug report than a question for SO - would you like to move it to the intake issues tracker? Commented Jul 4 at 13:47
  • @mdurant I've opened the issue: github.com/intake/intake-xarray/issues/150. Thank you Commented Jul 11 at 15:19

1 Answer 1

1

There is an oversight in the implementation of intake-xarray for intake2. The following is a workaround you can use, and we will see if we can correct this probablem.

ds = cat._entries["this_source"](date=datetime(2024, 1, 1)).read()

Note that you could also use intake.readers.readers.XArrayDatasetReader and version 2 catalogs to do this, if you wanted re-write what you have and not have to use this workaround.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks @mdurant. I tried to follow your suggestion tu use intake.readers.readers.XArrayDatasetReader and version 2 but I didn't find the way to do this, neither an example. I've just found this example where mainly reader_from_call is used to create a catalog entry but I couldn't replicate that on xarray.open_dataset since it doesn't accept storage_options argument. Do you have some example/suggestion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.