input4mips_validation.database#
| Sub-package | Description |
|---|---|
| creation | Creation of database entries |
| database | Data model of our input4MIPs database |
| raw | Raw database definition |
input4mips_validation.database
#
Definition of everything database-related
Input4MIPsDatabaseEntryFile
#
Bases: Input4MIPsDatabaseEntryFileRaw
Data model for a file entry in the input4MIPs database
Source code in src/input4mips_validation/database/database.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
from_file(file, cvs, xr_variable_processor=XRVariableHelper(), frequency_metadata_keys=FrequencyMetadataKeys(), time_dimension='time')
classmethod
#
Initialise based on a file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Path
|
File from which to extract data to create the database entry |
required |
cvs
|
Input4MIPsCVs
|
Controlled vocabularies that were used when writing the file |
required |
xr_variable_processor
|
XRVariableProcessorLike
|
Helper to use for processing the variables in xarray objects. |
XRVariableHelper()
|
frequency_metadata_keys
|
FrequencyMetadataKeys
|
Metadata definitions for frequency information |
FrequencyMetadataKeys()
|
time_dimension
|
str
|
Time dimension of |
'time'
|
Returns:
| Type | Description |
|---|---|
Input4MIPsDatabaseEntryFile
|
Initialised database entry |
Source code in src/input4mips_validation/database/database.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
dump_database_file_entries(entries, db_dir)
#
Load a database of file entries from a database directory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
Collection[Input4MIPsDatabaseEntryFile]
|
Entries to dump to the database |
required |
db_dir
|
Path
|
Directory in which the file entries are being kept |
required |
Raises:
| Type | Description |
|---|---|
FileExistsError
|
An entry would be dumped to a file which already exists. This indicates that there is already an entry for that file in the database. This has to be resolved before dumping the data to the database. |
Source code in src/input4mips_validation/database/database.py
load_database_file_entries(db_dir, glob_input='*.json')
#
Load a database of file entries from a database directory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_dir
|
Path
|
Directory in which the file entries are being kept |
required |
glob_input
|
str
|
Input to |
'*.json'
|
Returns:
| Type | Description |
|---|---|
tuple[Input4MIPsDatabaseEntryFile, ...]
|
Loaded database of file entries |
Source code in src/input4mips_validation/database/database.py
update_database_file_entries(entries, db_dir)
#
Update file entries in a database directory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
Collection[Input4MIPsDatabaseEntryFile]
|
Entries to update in the database |
required |
db_dir
|
Path
|
Directory in which the file entries are being kept |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
An entry would be a new entry, not an updated one. This has to be resolved before dumping the data to the database. |