Skip to content

Option to reduce the number of server requests #60

@Paul-Rutten-MPS

Description

@Paul-Rutten-MPS

for each dateset query we make, xarray.open_dataset() sends multiple requests to the server:

  • 4 meta data requests (to the .dds, .das, .dds, and .dods endpoints respectively)
  • 1 request per parameter we want data for.

Given that some datasets contain over 20 parameters, this can result in a lot of requests to get some data.

It is possible to reduce this to 2 request, by filling in the OPeNDAP Dataset Access Form programmatically and converting the resulting data to an xarray Dataset.

The example below returns an xarray.Dataset with dimensions: (y: 2, x: 2, time: 1, height: 6) and variables (latitude, longitude, wind_speed, wind_direction)

import xarray as xr
from pydap.client import open_dods_url

dd = open_dods_url('https://thredds.met.no/thredds/dodsC/nora3_subset_atmos/wind_hourly/arome3kmwind_1hr_202312.nc.dods?latitude[0:1][0:1],longitude[0:1][0:1],x[0:1],y[0:1],wind_speed[0:1:0][0:1:5][0:1][0:1],wind_direction[0:1:0][0:1:5][0:1][0:1]')

ds = xr.open_dataset(xr.backends.PydapDataStore(dd))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions