oceanpack.app.models.filesource

File source model and source type enumeration for managing OceanPack log file ingestion.

Classes

FileSourceModel

Orchestrates reading, cleaning, and processing of OceanPack log files.

Functions

collect_files(→ list[pathlib.Path])

Collect files from a given path.

Module Contents

class oceanpack.app.models.filesource.FileSourceModel(source_type: FileSourceType = None)[source]

Orchestrates reading, cleaning, and processing of OceanPack log files.

Resolves the appropriate file handler for the configured source type, reads all log files into a pandas DataFrame, and exposes the result as an xarray Dataset. The source type can be set explicitly or inferred automatically from the file header.

Initialize the model, optionally setting the source type and resolving the file handler.

Parameters:

source_type (FileSourceType)

clean_data()[source]

Drops rows with a missing index value and removes duplicate timestamps, keeping the first occurrence.

load_data(path: str)[source]

Collect all log files at the given path and read them into a single DataFrame.

Parameters:

path (str)

process_data()[source]

Casts all columns to numeric, drops any that cannot be converted, sorts by index, and builds the xarray Dataset.

to_netcdf(output_file)[source]

Writes the xarray Dataset to a NetCDF file at the specified path.

df = None
ds = None
history = ''
property source_type: FileSourceType | None

The active source type used to select the file handler.

Return type:

FileSourceType | None

oceanpack.app.models.filesource.collect_files(path: str, suffix='log') list[pathlib.Path][source]

Collect files from a given path.

Parameters:
  • path (str) – The path to the file or directory.

  • suffix (str, optional) – The file suffix to filter by. Defaults to ‘log’.

Returns:

A list of paths to the detected files.

Return type:

list[Path]