Skip to content

isimip_utils.protocol

Functions to fetch information from machine-actionable ISIMIP protocols.

fetch_definitions(path, protocol_locations=PROTOCOL_LOCATIONS)

Fetch definitions from ISIMIP protocol locations.

Parameters:

Name Type Description Default
path str | Path

Path to search for definitions.

required
protocol_locations str | list[str]

List of protocol locations to search (default: https://protocol.isimip.org).

PROTOCOL_LOCATIONS

Returns:

Type Description
dict[str, Any]

Dictionary of definitions with specifiers as keys.

Raises:

Type Description
NotFound

If no definitions are found for the given path.

fetch_pattern(path, protocol_locations=PROTOCOL_LOCATIONS)

Fetch pattern definitions from ISIMIP protocol locations.

Parameters:

Name Type Description Default
path str | Path

Path to search for patterns.

required
protocol_locations str | list[str]

List of protocol locations to search (default: https://protocol.isimip.org).

PROTOCOL_LOCATIONS

Returns:

Type Description
dict[str, Any]

Dictionary containing compiled regex patterns for 'path', 'file', 'dataset',

dict[str, Any]

and lists of 'suffix', 'specifiers', and 'specifiers_map'.

Raises:

Type Description
NotFound

If no pattern is found for the given path.

fetch_schema(path, protocol_locations=PROTOCOL_LOCATIONS)

Fetch schema from ISIMIP protocol locations.

Parameters:

Name Type Description Default
path str | Path

Path to search for schema.

required
protocol_locations str | list[str]

List of protocol locations to search (default: https://protocol.isimip.org).

PROTOCOL_LOCATIONS

Returns:

Type Description
Any

Schema JSON object.

Raises:

Type Description
NotFound

If no schema is found for the given path.

fetch_tree(path, protocol_locations=PROTOCOL_LOCATIONS)

Fetch tree structure from ISIMIP protocol locations.

Parameters:

Name Type Description Default
path str | Path

Path to search for tree structure.

required
protocol_locations str | list[str]

List of protocol locations to search (default: https://protocol.isimip.org).

PROTOCOL_LOCATIONS

Returns:

Type Description
Any

Tree JSON object.

Raises:

Type Description
NotFound

If no tree is found for the given path.

find_json(protocol_location, sub_location, path)

Find JSON files in protocol locations by traversing path components.

Parameters:

Name Type Description Default
protocol_location str

Base protocol location URL or path.

required
sub_location str

Subdirectory within protocol location (e.g., 'definitions', 'pattern').

required
path str | Path

Path to search for JSON files.

required

Returns:

Type Description
None

The JSON response from the first matching path.