aiqclib.nrtqc.step4_compare_flags packageο
Submodulesο
aiqclib.nrtqc.step4_compare_flags.compare_base moduleο
This module provides the CompareFlagsBase class, the NRT QC moduleβs optional step 4: comparing existing NRT QC flags with the newly computed ones.
For every configured variable that carries an existing flag column (the
flag entry of its qc_variable_set definition, e.g. temp_qc),
a summary report is built with three sections:
contingencyβ the cross-tabulation of existing flag value and new NRT flag value with counts and percentages. Works with any existing flag scheme; no value mapping is required.agreementβ binary agreement metrics (accuracy, precision, recall plus the underlying confusion counts), reported only whenpos_flag_values/neg_flag_valuesare configured for the variable, using the same convention as the other modules.item_breakdownβ per enabled QC item, how many observations the item flagged within each existing flag value, showing which items drive agreement or disagreement.
Variables without a configured flag are silently skipped; a configured flag column that is absent from the data raises an error (no silent skip on typos).
- class aiqclib.nrtqc.step4_compare_flags.compare_base.CompareFlagsBase(config, merged_data=None)[source]ο
Bases:
DataSetBaseBase class for the existing-vs-new flag comparison (step
"compare").Takes the final frame produced by step 3 (
merged_data, holding both the existing flag columns from the input and the newly computed{variable}_nrt_flagcolumns) and builds one report per comparable variable, stored inreportsand written as TSV files.- Parameters:
config (ConfigBase)
merged_data (DataFrame | None)
- compare(target_name, flag_column)[source]ο
Build the comparison report for a single variable.
- Parameters:
target_name (
str) β The variable to compare.flag_column (
str) β The variableβs existing flag column.
- Returns:
The report frame (see
REPORT_SCHEMA).- Return type:
DataFrame- Raises:
polars.exceptions.ColumnNotFoundError β If the existing flag column or the new NRT flag column is absent from the data.
- compare_targets()[source]ο
Build the comparison report for every comparable variable.
Variables without a configured existing flag are skipped silently (there is nothing to compare against).
- Raises:
ValueError β If
merged_datais empty.polars.exceptions.ColumnNotFoundError β If a configured flag column is absent from the data.
- Return type:
None
- default_file_name: strο
The default per-variable report file name pattern.
- merged_data: DataFrame | Noneο
- output_file_names: Dict[str, str]ο
A dictionary mapping variable names to report file paths.
- reports: Dict[str, DataFrame]ο
A dictionary mapping variable names to comparison reports.
- aiqclib.nrtqc.step4_compare_flags.compare_base.REPORT_SCHEMA: Dict = {'count': Int64, 'existing_flag': Int64, 'item': String, 'metric': String, 'new_flag': Int64, 'percent': Float64, 'section': String, 'value': Float64}ο
Column schema of the comparison report (long format, one section column).
aiqclib.nrtqc.step4_compare_flags.dataset_all moduleο
This module defines the CompareFlagsAll class, the concrete implementation of the NRT QC moduleβs step 4 (existing-vs-new flag comparison) for Copernicus CTD data.
- class aiqclib.nrtqc.step4_compare_flags.dataset_all.CompareFlagsAll(config, merged_data=None)[source]ο
Bases:
CompareFlagsBaseA specialized implementation of
aiqclib.nrtqc.step4_compare_flags.compare_base.CompareFlagsBasethat compares the flags of all observations.- Variables:
expected_class_name (str) β The class identifier used for configuration matching.
- Parameters:
config (ConfigBase)
merged_data (DataFrame | None)
- expected_class_name: str = 'CompareFlagsAll'ο