Casys Report

Casys Toolbox implements its own Report, ReportChapter and ReportSection classes specifically designed to ease the configuration of a report using these tools.
In order to do so, each Casys toolbox object (NadirData, SwathData, CasysPlot, TextParams, …) and each method of these objects has been associated with a configuration representation allowing to write configuration files for these elements.

Casys report configuration

Casys Toolbox report’s implementation defines the following elements:

Report

A ReportCasys is a specialization of the Report class allowing the representation of a Casys Toolbox report.
Class representing a Casys report.

Parameters
----------
ges_table_dir
    GES_TABLE_DIR environment variable
metadata
    Report metadata (used in PDF exports).
data
    Dictionary of AltiData representations.
chapters
    Dictionary of chapters.
    A chapter has a list of sections as a section's parameter, each section
    containing a plot or a grid of plots.
misc
    Dictionary of miscellaneous data.
level
    Report's level.
    If the report level is 100 (default), only chapters and sections with a level
    less or equal to 100 will be included.
report_structure.yaml
ges_table_dir: <ges_table_dir>

metadata: <ReportMetadata_representation>

data:
    <alti_data1>:
        <AltiData_representation>

    <alti_data2>:
        <AltiData__representation>
    ...

chapters:
    <chapter1>:
        <ReportChapter_representation>
    <chapter2>:
        <ReportChapter_representation>
    ...

misc:
    <dictionary>

level: <report_level>

Report’s metadata

Casys Toolbox metadata are regular metadata.

Report’s data

Casys Toolbox data are ReportSection containing NadirData objects.

Note

AltiData representations accept an additional operations parameter describing operations to apply.
Each operation is mapped to a method and its representation should respect the method parameters.
These operations types are:
Operations can be randomly grouped (each operation has to specify its type):
operations:
  g1:
    - type: TEMPORAL
      name: swh_day_ts
      field:
        name: swh
        source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
        unit: m
      freq: day
      stats: ['mean']

    - type: compute

    - type: store
      name: report_1.back
      overwrite: True

    - type: TEMPORAL
      name: swh_pass_ts
      field:
        name: swh
        source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
        unit: m
      freq: pass
      stats: ['mean']

    - type: compute

    - type: store
      name: report_2.back
      overwrite: True
Or regrouped by type :
operations:
  time_stat:
    - name: swh_day_ts
      field:
        name: swh
        source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
        unit: m
      freq: day
      stats: ['mean']

    - name: swh_pass_ts
      field:
        name: swh
        source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
        unit: m
      freq: pass
      stats: ['mean']

  compute:
    - type: compute
data_example.yaml
data:
  data1:
    date_start: 2019-07-22
    date_end: 2019-07-31
    source: TABLE_C_J3_B_GDRD
    orf: C_J3_GDRD
    longitude: LONGITUDE
    latitude: LATITUDE
    time: time
    operations:
      all:
        - type: time_stat
          name: swh_day_ts
          field:
            name: swh
            source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
            unit: m
          freq: day
          stats: ['mean']

       - type: time_stat
          name: swh_pass_ts
          field:
            name: swh
            source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
            unit: m
          freq: pass
          stats: ['mean']

       - type: compute
  ...

Report’s chapter

Casys Toolbox chapters are regular chapters.

Report’s section

There are two types of Casys Toolbox sections

Note

CasysPlot representations accept an additional operations parameter describing operations to apply.
Each operation is mapped to a method and its representation should respect the method parameters.
These operations types are:

Plot’s section

ReportSectionPlot sections contain a CasysPlot.
The plot keyword can be used instead of content to indicate it’s a content of type plot.
Representation of a section containing a plot.

Parameters
----------
title
    Section's title.
text
    Section's text.
content
    plot's representation.
    Should map CasysPlot parameters
misc
    Miscellaneous section's data.
reference
    A reference to this section.
sections
    List of subsections.
level
    Section's level.
    Only sections with a level less or equal to the report's level will be included.
plot_section_structure.yaml
title: <section_title>

text: <section_text>

plot: <CasysPlot_representation>

misc:
    <dictionary>

reference: <section_reference>

sections:
    - <ReportSection_representation>
    - <ReportSection_representation>
    ...

level: <section_level>

Grid’s section

ReportSectionGrid sections contain a grid of CasysPlot.
The grid keyword can be used instead of content to indicate it’s a content of type grid.
Representation of a report section containing a grid of plots.

Parameters
----------
title
    Section's title.
text
    Section's text.
content
    Grid's representation.
    Should map the create_image_grid parameters
misc
    Miscellaneous section's data.
reference
    A reference to this section.
sections
    List of subsections.
level
    Section's level.
    Only sections with a level less or equal to the report's level will be included.
grid_section_structure.yaml
title: <section_title>

text: <section_text>

grid: <CasysPlot.create_image_grid_representation>

misc:
    <dictionary>

sections:
- <ReportSection_representation>
- <ReportSection_representation>
...

level: <section_level>

Complete Example

Report’s configuration

casys_report_conf.yaml
ges_table_dir: /data/cvl_exj3/TABLES/DSC

data:
  data1:
    date_start: 2019-07-22
    date_end: 2019-07-31
    source: TABLE_C_J3_B_GDRD
    orf: C_J3_GDRD
    longitude: LONGITUDE
    latitude: LATITUDE
    time: time

    operations:
      all:
        - type: time_stat
          name: swh_day_ts
          field:
            name: swh
            source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
            unit: m
          freq: day
          stats: ['mean']

        - type: time_stat
          name: swh_pass_ts
          field:
            name: swh
            source: IIF(FLAG_VAL.ALTI==0, SWH.ALTI, DV)
            unit: m
          freq: pass
          stats: ['mean']

        - type: compute

chapters:

  swh_monitoring:
    title: Sea waves height Monitoring
    sections:
      - title: Daily statistics of mean SWH
        plot:
          data: data1
          data_name: swh_day_ts
          stat: mean
          text_params:
            title: Day Mean SWH
          plot_params:
            grid: True
          operations:
            - type: show

      - title: Pass statistics of mean SWH
        plot:
          data: data1
          data_name: swh_pass_ts
          stat: mean
          text_params:
            title: Pass Mean SWH
          plot_params:
            grid: True
          operations:
            - type: show

      - title: Another section title
        text: Text of the other section


  another_chapter:
    title: Another chapter title
    text: Text of the other chapter

With a generic template like this one.

from casys.report import ReportCasys
from octantng.data.report import ReportManager
from octantng.parameters.configuration import Config

conf = Config.from_file("casys_report_conf.yaml")
r = ReportCasys.load(conf)

rm = ReportManager(template="generic_template.ipynb", report=r)

Expanding template

rm.expand_template()
rm.store_notebook(path="casys_notebook_expanded.ipynb")

Will generate the following expanded notebook.

Executing expanded notebook

rm.execute_notebook()
rm.store_notebook_executed(path="casys_notebook_executed.ipynb")

Will generate the following executed notebook.