input4mips_validation.io#
input4mips_validation.io
#
Input/output of data to/from disk
generate_creation_timestamp()
#
Generate creation timestamp, formatted as needed for input4MIPs files
Returns:
| Type | Description |
|---|---|
str
|
Creation timestamp |
Source code in src/input4mips_validation/io.py
prepare_out_path_and_cubes(ds, out_path, cvs, xr_variable_processor=XRVariableHelper(), frequency_metadata_keys=FrequencyMetadataKeys(), bounds_info=BoundsInfo())
#
Prepare a path and iris.cube.Cube's for writing to disk
A note for users of this function. We convert the dataset to a list of iris.cube.Cube with ncdata.iris_xarray.cubes_from_xarray because iris adds CF-conventions upon writing, which is needed for input4MIPs data. This works smoothly in our experience, but the conversion can be tricky to debug. If you are having issues, this may be the reason.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to write to disk. May contain one or more variables. |
required |
out_path
|
Path
|
Path in which to write the dataset |
required |
cvs
|
Input4MIPsCVs
|
CVs to use to validate the dataset before writing |
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()
|
bounds_info
|
BoundsInfo
|
Metadata definitions for bounds handling |
BoundsInfo()
|
Returns:
| Type | Description |
|---|---|
CubeList
|
iris.cube.Cube's which can be written to disk. |
Source code in src/input4mips_validation/io.py
write_ds_to_disk(ds, out_path, cvs, **kwargs)
#
Write a dataset to disk
This function is just a thin wrapper around input4mips_validation.io.prepare_out_path_and_cubes and iris.save. For details, see these functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to write to disk. May contain one or more variables. |
required |
out_path
|
Path
|
Path in which to write the dataset |
required |
cvs
|
Input4MIPsCVs
|
CVs to use to validate the dataset before writing |
required |
**kwargs
|
Any
|
Passed through to iris.save |
{}
|
Returns:
| Type | Description |
|---|---|
Path
|
Path in which the dataset was written |