pelagos_py.steps.input_output.write_report_python#

pelagos_py.steps.input_output.write_report_python.qc_status(flag_counts: dict)[source]#

Return the stoplight status and whether flag 8 occurred.

Any variable can include a flag 8 - it’s handy to denote this differently than by color.

Argo flags 0, 8, and 9 can’t be considered as “good” or “bad” and therefore should be excluded from the % good spectrum.

This spectrum is (arbitrarily) assigned as follows: * Grey - no evaluated points remain after excluding flags 0, 8, and 9. * Green - all evaluated points are good or probably good (flags 1, 2). * Yellow - up to yellow_pts evaluated points are bad or have another non-good flag, with fewer than orange_per bad. * Orange - more than yellow_pts evaluated points are bad or have another non-good flag, with fewer than orange_per bad. * Red - at least orange_per of evaluated points are bad, but not all are bad. * Black - all evaluated points are bad (flags 3, 4).

In the future, these flag tolerances could be an optional kwarg that the user could specify in their configuration yaml.

pelagos_py.steps.input_output.write_report_python.build_qc_stoplight_summary(qc_dict: dict, n_points: int)[source]#

Build a flaxible matrix of QC methods and variables

For each method picked out of the qc_dict, add that to the columns in tests. For each variable, add that to the rows. Then assess the contents of QC dict for each column in the row with qc_status to assign the stoplight for the cell.

pelagos_py.steps.input_output.write_report_python.qc_section(pdf: ReportPDF, data: xarray.Dataset) → None[source]#

Write the Quality Control tables.

This consists of two tables: * A stoplight summary table, highlighting which tests were ran on which QC variables and how many were successful. * A row-by-row variable summary, listing the number of each flag that were determined from the individual tests.

pelagos_py.steps.input_output.write_report_python.glidertest_section(pdf: ReportPDF, data: xarray.Dataset, outdir: str, log=print, log_warn=print) → None[source]#

Runs plotting routines from glidertest and inserts them into the document.

class pelagos_py.steps.input_output.write_report_python.WriteDataReportPython(name, parameters=None, diagnostics=False, context=None)[source]#

Bases: pelagos_py.steps.base_step.BaseStep

Writes a PDF report summarising the data, plots and QC at the end of a pipeline.

The report is built directly with fpdf2, so no external toolchain (LaTeX, Sphinx) is required to produce the PDF. It opens with a title page (run provenance, pipeline name/description and a glider track map) and then writes a sequence of sections, each of which can be toggled off:

  • Cross-section plots — the headline view: PRES vs TIME panels, each coloured by a variable (temperature, salinity, density, oxygen, chlorophyll, backscatter).

  • Format Checker results — compliance-checker findings (only when the Format Checker step ran).

  • Configuration — the run configuration as paste-ready YAML.

  • Step diagnostics — the diagnostic plot(s) captured for each step.

  • Quality control summary — a table of QC test flag counts.

  • QC plots — a histogram per QC variable.

  • Logfile — the run log, terminal-styled.

  • Index — contents, QC flag glossary, variable index and glider information.

All parameters are optional. With no configuration a full report is written, named after the input file (see the first example below).

Parameters:
  • title (str, optional) – Report title, shown on the title page and running header. Defaults to a title derived from the input filename.

  • fname (str, optional) – Output .pdf filename. Defaults to the input filename core; a .pdf extension is appended if missing.

  • delete_figures (bool, optional) – When True (default) the plot images are written to a temporary folder and removed once the PDF is built. When False they are kept in a uniquely named folder beside the report so successive runs don’t overwrite each other.

  • show_cross_section_plots (bool, optional) – Include the cross-section plots section. Default True.

  • show_format_check (bool, optional) – Include the Format Checker results (when that step ran). Default True.

  • show_configuration (bool, optional) – Include the run configuration (YAML) section. Default True.

  • show_diagnostic_plots (bool, optional) – Include the per-step diagnostic plots section. Default True.

  • show_qc_summary (bool, optional) – Include the quality control summary table. Default True.

  • show_qc_plots (bool, optional) – Include the QC histogram plots section. Default True.

  • show_logs (bool, optional) – Include the logfile section. Default True.

  • show_index (bool, optional) – Include the closing index section. Default True.

  • logo_path (str, optional) – Path to a logo image for the title page. Defaults to the NOC logo.

Examples

The defaults write a full report, so the simplest valid configuration sets no parameters at all:

steps:
  - name: Write Data Report (Python)

Any subset of parameters may be supplied. The block below names the report, keeps the generated figures beside it, and omits the logfile section:

steps:
  - name: Write Data Report (Python)
    parameters:
      title: "SG579 Mission Report"
      fname: "sg579_report.pdf"
      delete_figures: false
      show_logs: false