access_nri_intake.experiment.main#
Functions#
|
Specify a builder and an experiment directory in order to build and/or open |
|
Try to find an ESM datastore in the experiment directory, with the same name |
|
Provides the user information about how to add a datastore to the access-nri-intake |
Module Contents#
- access_nri_intake.experiment.main.use_datastore(experiment_dir, builder=None, catalog_dir=None, builder_kwargs=None, open_ds=True, datastore_name='experiment_datastore', description=None)#
Specify a builder and an experiment directory in order to build and/or open an esm-datastore in place for that experiment. Valid and up to date datastores will not be overwritten.
Further configuration can be done by passing additional keyword arguments
- Parameters:
- builderBuilder
The builder object that will be used to build the datastore.
- experiment_dirPath | str
The directory containing the experiment. If a string is passed, it will be converted to a Path object.
- catalog_dirPath | str, optional
The directory containing/to write the catalog to, if it differs from the experiment directory. If None, the catalog will be written to the experiment directory. If a string is passed, it will be converted to a Path object.
- open_dsbool
Whether to open the datastore after building it. Typically set to false when called from a console script.
- builder_kwargsdict, optional
Any additional keyword arguments to pass to the builder if needed - for example, AccessEsm15Builder additionally takes an ensemble argument
- datastore_namestr, optional
The name of the datastore to be written. Defaults to ‘experiment_datastore’. Datastores are written as catalog_dir / datastore_name.json.
- descriptionstr, optional
A description of the datastore. If None, a default description will be used.
- Returns:
- esm_datastore | None
The datastore object, if it was requested to be opened. Otherwise, None.
- Raises:
- TBC
- access_nri_intake.experiment.main.find_esm_datastore(experiment_dir, datastore_name)#
Try to find an ESM datastore in the experiment directory, with the same name as the one we intend to build. If not, return a dummy DatastoreInfo object.
To find an ESM datastore, we use the heuristic that an esm_datastore comprises a json file and a csv.gz (or.csv) file with the same name. To find these, we are first going to search experiment_dir and all its subdirectories for a json file, and then look for a file in the same directory where ‘.csv’ is a member of the file objects suffixes property.
- Parameters:
- experiment_dirPath
The directory containing the experiment.
- datastore_namestr
The name of the datastore to be found.
- Returns:
- DatastoreInfo
A DatastoreInfo object containing the json and csv files if found, or a null DatastoreInfo object if not found.
- access_nri_intake.experiment.main.scaffold_catalog_entry(interactive)#
Provides the user information about how to add a datastore to the access-nri-intake catalog. If interactive is set to True, the user will be prompted to confirm that they are ready to continue with each step - else, all steps will be printed at once.
- Parameters:
- interactivebool
Whether to provide interactive help or not.