climate_ref.datasets.esmvaltool_reference
#
Adapter for ESMValTool reference (observational/reanalysis) datasets.
ESMValTool reference data is not CMOR/obs4MIPs compliant, so metadata cannot be read
from global attributes the way :mod:climate_ref.datasets.obs4mips does. Instead it is
parsed from the ESMValCore DRS path and filename templates by
:mod:climate_ref_core.esmvaltool_reference, which describes the layouts.
ESMValToolReferenceDatasetAdapter
#
Bases: DatasetAdapter
Adapter for ESMValTool reference datasets.
See the module docstring for the layout conventions this adapter understands.
Source code in packages/climate-ref/src/climate_ref/datasets/esmvaltool_reference.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
find_local_datasets(file_or_directory, skip=None)
#
Generate a data catalog from the specified file or directory.
Each dataset may contain multiple files (rows). The unique dataset identifier is
the instance_id slug in :attr:slug_column.
Files selected by skip are left out of the catalog.
Source code in packages/climate-ref/src/climate_ref/datasets/esmvaltool_reference.py
iter_local_datasets(file_or_directory, chunk_size=10000, skip=None)
#
Stream the data catalog in chunks to bound peak memory.
Discovery walks the tree once, but parsing and DataFrame construction
happen chunk_size files at a time.
Chunks flush at directory boundaries so files belonging to the same dataset stay together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_or_directory
|
Path
|
Root of the archive (or a single file) to ingest. |
required |
chunk_size
|
int
|
Soft target for the number of files per chunk. |
10000
|
skip
|
SkipFunction | None
|
Selects files to leave out of the catalog, such as files already in the database. |
None
|
Yields:
| Type | Description |
|---|---|
DataFrame
|
Catalog DataFrames, each containing metadata for one chunk of files. Empty chunks are skipped. |
Source code in packages/climate-ref/src/climate_ref/datasets/esmvaltool_reference.py
parse_esmvaltool_reference(file, **kwargs)
#
Parse a single ESMValTool reference file into a metadata record.
Metadata comes from the path rather than the file contents, because the data is not CMOR compliant.