libera_utils.io.netcdf.write_libera_data_product#
- libera_utils.io.netcdf.write_libera_data_product(data_product_definition: str | CloudPath | Path | LiberaDataProductDefinition, data: dict[str, ndarray[Any, dtype[_ScalarType_co]]] | Dataset, output_path: str | CloudPath | Path, time_variable: str, dynamic_product_attributes: dict[str, Any] | None = None, strict: bool = True, add_archive_path_prefix: bool = False) LiberaDataProductFilename#
Write a Libera data product NetCDF4 file that conforms to data product definition requirements
Steps:
(Numpy array input only) Create a product Dataset from the input arrays and optional dynamic attributes, using the product definition to determine the expected structure and metadata.
Bring the Dataset into conformance with the product definition, fixing any issues that can be automatically fixed and issuing warnings for any issues that cannot be automatically fixed.
Check the final conformance of the Dataset against the product definition, raising an exception if any issues are found in strict mode.
Generate the data product filename using the product definition and the specified time variable.
Write the Dataset to a NetCDF4 file at the specified output path with the generated filename, using the configured NetCDF engine.
- Parameters:
data_product_definition (str | PathType | LiberaDataProductDefinition) – Path to the data product definition against which to verify conformance
data (dict[str, NDarray] | xr.Dataset) – Data mapping variable names to numpy data arrays or a fully formed L1A xarray Dataset.
output_path (str | PathType) – Base path (directory or S3 prefix) at which to write the product file
time_variable (str) – Name of variable that indicates time. This is used to generate the start and end time for the filename.
dynamic_product_attributes (dict[str, Any] | None) – Optional dictionary of additional global attributes to add to the data product file. Must conform to the data product definition.
strict (bool) – Default True. Raises an exception if the final Dataset doesn’t conform to the data product definition.
add_archive_path_prefix (bool) – Note: do not use this to write to a processing dropbox! L2 devs do not need this kwarg. Default False. If True, adds the archive path prefix to the output path when generating the full output path.
- Returns:
Filename object containing the full path to the written NetCDF4 data product file.
- Return type: