libera_utils.io.filenaming.LiberaDataProductFilename#
- class libera_utils.io.filenaming.LiberaDataProductFilename(*args, **kwargs)#
Bases:
AbstractDataProductFilenameFilename validation class for Libera SDC data products.
- Attributes:
applicable_dateProperty that returns the applicable date based on the midpoint of start and end times.
archive_prefixProperty that contains the generated prefix for L1B and L2 archiving
data_product_idProperty that contains the DataProductIdentifier for this file type
filename_partsProperty that contains a namespace of filename parts
pathProperty containing the file path
processing_step_idProperty that contains the ProcessingStepIdentifier that generates this file
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, ...[, ...])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
- __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, ...[, ...])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 returns the applicable date based on the midpoint of start and end times.
Property that contains the generated prefix for L1B and L2 archiving
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, utc_start: datetime, utc_end: datetime, revision: datetime, extension: str)#
Construct a path from filename parts
- Parameters:
data_level (str) – L1B or L2
product_name (str) – Libera instrument, cam or rad for L1B and cloud-fraction etc. for L2. May contain anything except for underscores.
version (str) – Software version that the file was created with. Corresponds to the algorithm version as determined by the algorithm software.
utc_start (datetime.datetime) – First timestamp in the SPK
utc_end (datetime.datetime) – Last timestamp in the SPK
revision (datetime.datetime) – Time when the file was created.
extension (str) – File extension (.nc or .h5)
- 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:
- property applicable_date: date#
Property that returns the applicable date based on the midpoint of start and end times.
Issues a warning if the time range covers more than 24 hours.
- Returns:
The date of the midpoint between utc_start and utc_end
- Return type:
- 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)
- classmethod from_filename_parts(*, product_name: str | DataProductIdentifier, version: str, utc_start: datetime, utc_end: datetime, data_level: str | DataLevel | None = None, revision: datetime = datetime.datetime(2025, 12, 3, 17, 17, 11, 830160, tzinfo=datetime.timezone.utc), extension: str | None = None, basepath: str | Path | S3Path | None = None)#
Create instance from filename parts. All keyword arguments other than basepath are required!
This method exists primarily to expose typehinting to the user for use with the generic _from_filename_parts. The part names are named according to the regex for the file type.
- Parameters:
data_level (str | DataLevel | None) – L1B or L2 identifying the level of the data product. Default None will infer the data level from the product name (DataProductIdentifier)
product_name (str | DataProductIdentifier) – Product type. e.g. CF-RAD for L2 or RAD-4CH for L1B. May contain anything except for underscores.
version (str) – Software version that the file was created with. Corresponds to the algorithm version as determined by the algorithm software.
utc_start (datetime.datetime) – First timestamp in the SPK
utc_end (datetime.datetime) – Last timestamp in the SPK
revision (datetime.datetime) – Time when the file was created. Default is now in UTC time.
extension (str | None) – File extension. Default None will infer extension based on product_name.
basepath (Optional[Union[str, Path, S3Path]]) – Allows prepending a basepath or prefix.
- Return type:
- 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