libera_utils.io.filenaming.LiberaVersionPartitionedDataProductFilename#
- class libera_utils.io.filenaming.LiberaVersionPartitionedDataProductFilename(*args, **kwargs)#
Bases:
AbstractDataProductFilenameFilename validation class for version-partitioned Libera SDC data products.
A version-partitioned product, such as an ADM, is valid over more than one day (indefinitely until the next version update). Its filename carries no time range, so it has no applicable date. The period it covers is recorded in the file’s variables and metadata. Only a DataProductIdentifier whose
partition_schemeisPartitionScheme.VERSIONis accepted. A daily product is named byLiberaDataProductFilename.Version-partitioned data product filenames follow the convention:
LIBERA_{data_level}_{product_name}_{version}_{revision}.nc
e.g.
LIBERA_AUX_ADM-CAM_V1-2-3_R20270103T080910123456.ncdata_levelis the string value of the product’sDataLevel, which must be thedata_levelof its DataProductIdentifier.product_nameis the string value of aDataProductIdentifierwhosepartition_schemeisPartitionScheme.VERSION.versionis the algorithm semantic version inVM-m-p[RCn]form.revisionis the UTC creation time of the file,Rfollowed byYYYYMMDDTHHMMSSffffff(microseconds).
- __init__(*args, **kwargs)#
Methods
from_file_path(*args, **kwargs)Factory method to produce an AbstractValidFilename from a valid Libera file path (str or Path)
from_filename_parts(*, product_name, version)Create instance from filename parts.
generate_prefixed_path(parent_path)Generates an absolute path of the form {parent_path}/{prefix_structure}/{file_basename} The parent_path can be an S3 bucket or an absolute local filepath (must start with /)
regex_match(path)Parse and validate a given path against class-attribute defined regex
Attributes
Property that contains the generated prefix for archiving,
<product_name>/<version>Property that contains the DataProductIdentifier for this file type
Property that contains a namespace of filename parts
Property containing the file path
Property that contains the ProcessingStepIdentifier that generates this file
- classmethod _format_filename_parts(*, data_level: str, product_name: str, version: str, revision: datetime)#
Construct a filename from filename parts
- Parameters:
data_level (str) – Data level of the product, e.g. AUX.
product_name (str) – Version-partitioned product type, e.g. ADM-CAM.
version (str) – Software version that the file was created with, as VM-m-p or a semantic version M.m.p.
revision (datetime.datetime) – Time when the file was created.
- Returns:
Formatted filename
- Return type:
- classmethod _from_filename_parts(*, basepath: str | Path | S3Path | None = None, **parts: Any)#
Create instance from filename parts.
The part kwarg names are named according to the regex for the file type.
- Parameters:
basepath (Union[str, Path, S3Path], Optional) – Allows prepending a basepath or prefix.
parts (Any) – Passed directly to _format_filename_parts. This is a dict of variable kwargs that will differ in each filename class based on the required parts for that particular filename type.
- Return type:
- _parse_filename_parts()#
Parse the filename parts into objects from regex matched strings
- Returns:
namespace object containing filename parts as parsed objects
- Return type:
- static _parse_match(d: dict[str, Any]) SimpleNamespace#
Parse regex matched filename parts into objects
- Parameters:
d (dict) – Named groups from matching the filename regex
- Returns:
namespace object containing filename parts as parsed objects
- Return type:
- Raises:
ValueError – If revision is not a real UTC time.
- property archive_prefix: str#
Property that contains the generated prefix for archiving,
<product_name>/<version>Each file is archived once under this prefix, whatever period it covers.
- property data_product_id: DataProductIdentifier#
Property that contains the DataProductIdentifier for this file type
- property filename_parts#
Property that contains a namespace of filename parts
- classmethod from_file_path(*args, **kwargs)#
Factory method to produce an AbstractValidFilename from a valid Libera file path (str or Path)
- Parameters:
*args – Positional arguments passed unchanged to each candidate class, normally the single file path as a
str,pathlib.Path, orcloudpathlib.S3Path.**kwargs – Keyword arguments passed unchanged to each candidate class.
- Returns:
An instance of the first class that accepts the path, trying in order L0Filename, LiberaGroundCcsdsFilename, LiberaDataProductFilename, LiberaVersionPartitionedDataProductFilename, and ManifestFilename.
- Return type:
- Raises:
ValueError – If none of the candidate classes accepts the path.
- classmethod from_filename_parts(*, product_name: str | DataProductIdentifier, version: str, revision: datetime | None = None, basepath: str | Path | S3Path | None = None)#
Create instance from filename parts.
- Parameters:
product_name (str | DataProductIdentifier) – Version-partitioned product type, e.g. ADM-CAM.
version (str) – Software version that the file was created with, as VM-m-p or a semantic version M.m.p. Corresponds to the algorithm version as determined by the algorithm software.
revision (datetime.datetime | None) – Time when the file was created. Default None uses the current UTC time.
basepath (str | Path | S3Path | None) – Allows prepending a basepath or prefix.
- Return type:
- Raises:
ValueError – If product_name is not a DataProductIdentifier, if it names a product whose partition scheme is not VERSION, or if version is not a valid version string.
- generate_prefixed_path(parent_path: str | CloudPath | Path) CloudPath | Path#
Generates an absolute path of the form {parent_path}/{prefix_structure}/{file_basename} The parent_path can be an S3 bucket or an absolute local filepath (must start with /)
- Parameters:
parent_path (Union[str, Path, S3Path]) – Absolute path to the parent directory or S3 bucket prefix. The generated path prefix is appended to the parent path and followed by the file basename.
- Return type:
- property processing_step_id: ProcessingStepIdentifier | None#
Property that contains the ProcessingStepIdentifier that generates this file