Esmvaltool: Better diagnostic organization

Created on 6 Oct 2017  Β·  14Comments  Β·  Source: ESMValGroup/ESMValTool

Currently all diagnostics are in a directory esmvaltool/diag_scripts and bits of NCL code are scattered throughout the Python library. It would be good to take diag_scripts folder out of the esmvaltool python package and add some organization, with a standard location to add library functions. I discussed with Niels and we came up with the following proposal for a safer and cleaner directory structure.

Example:

esmdiagnostics/
β”œβ”€β”€ ncl
β”‚Β Β  β”œβ”€β”€ my_diag
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_pr.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_ta.ncl
β”‚Β Β  β”‚Β Β  └── test_ta_no2.ncl
β”‚Β Β  β”œβ”€β”€ perfmetrics
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ grading_collect.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ grading.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_collect.ncl
β”‚Β Β  β”‚Β Β  └── taylor.ncl
β”‚Β Β  └── shared
β”‚Β Β      └── aux_perfmetrics.ncl
β”œβ”€β”€ python
β”‚Β Β  β”œβ”€β”€ my_diag
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  β”‚Β Β  └── test_ta.py
β”‚Β Β  β”œβ”€β”€ shared
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ esmdiaglib.py
β”‚Β Β  β”‚Β Β  └── mylib
β”‚Β Β  β”‚Β Β      └── __init__.py
β”‚Β Β  └── some_other_diag
β”‚Β Β      β”œβ”€β”€ test_pr.py
β”‚Β Β      β”œβ”€β”€ test_ta_no2.py
β”‚Β Β      └── test_ta.py
└── r
    β”œβ”€β”€ shared
    └── some_r_diagnostic
        └── xxx.r

The idea is to create a single directory esmdiagnostics, which contains all diagnostics and related code organized in a single directory per language. Every diagnostic will live in it's own directory and per language there is one directory shared in which all shared code is placed. Diagnostic developers can then create a file (or a subdirectory containing a collection of related files) in the shared directory if something is shared between multiple diagnostics.

When running a diagnostic from ESMValTool via a namelist, the path of the diagnostic itself will be available in an environmental variable ESM_DIAG_PATH. The path of the shared directory of the language that the diagnostic is written in, will be available in the environmental variable ESM_DIAG_SHARED_PATH, e.g. for an NCL diagnostic ESM_DIAG_SHARED_PATH=/esmdiagostics/ncl/shared.

NCL diagnostics
In NCL, load paths starting with ./ can thus be eliminated in favour of paths starting with either "$ESM_DIAG_PATH" or "$ESM_DIAG_SHARED_PATH", to avoid having to set the current working directory to the location of the NCL diagnostic scripts when executing.

Python diagnostics
ESM_DIAG_SHARED_PATH will also be appended to PYTHONPATH, so in the example above it is possible to do import mylib in the python diagnostic scripts, e.g. in test_pr.py. A library function esmdiaglib.get_diag_path() will be made available that returns the value of ESM_DIAG_PATH to avoid having to use the environmental variables directly from Python in diagnostic scripts. Python functions from the esmvaltool module can also be used in Python diagnostics by using import esmvaltool after installation of the package.

All diagnostics should be executable scripts that take no command line arguments.

Preferably all paths should be lower case only.

enhancement

Most helpful comment

Another possibility would be the following. This would make it easier for users to find the diagnostic they are looking for, because diagnostics are no longer organized per language, which also allows using multiple languages related to a single diagnostic theme. This solution also addresses the issue raised by @BenMGeo .

esmdiagnostics/
β”œβ”€β”€ my_diag
β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  └── test_ta.py
β”œβ”€β”€ my_ncl_diag
β”‚Β Β  β”œβ”€β”€ test_pr.ncl
β”‚Β Β  β”œβ”€β”€ test_ta.ncl
β”‚Β Β  └── test_ta_no2.ncl
β”œβ”€β”€ perfmetrics
β”‚Β Β  β”œβ”€β”€ grading_collect.ncl
β”‚Β Β  β”œβ”€β”€ grading.ncl
β”‚Β Β  β”œβ”€β”€ main.ncl
β”‚Β Β  β”œβ”€β”€ taylor_collect.ncl
β”‚Β Β  └── taylor.ncl
β”œβ”€β”€ shared
β”‚Β Β  β”œβ”€β”€ ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ aux_perfmetrics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ latlon.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legacy_code
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── statistics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ misc_function.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ plot
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ aux_plotting.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ contour_maps.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ contourplot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ GO_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legacy_code
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── aux_plotting.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legends.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mjo_level1.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mjo_level2.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ monsoon_domain_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ monsoon_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ portrait_plot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ amwg.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eyring_toz.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ qcm3.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rainbow.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── red-blue.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scatterplot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ styles
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CCMVal1.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CCMVal2.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMIP5.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ DEFAULT.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── righi15gmd.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_diagram_less_hardcoded.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_plot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ vector_scalar_map_polar.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ xy_line.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── zonalmean_profile.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ regridding.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scaling.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ set_operators.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ statistics.ncl
β”‚Β Β  β”‚Β Β  └── style.ncl
β”‚Β Β  β”œβ”€β”€ python
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ esmdiaglib.py
β”‚Β Β  β”‚Β Β  └── mylib
β”‚Β Β  β”‚Β Β      └── __init__.py
β”‚Β Β  └── r
β”œβ”€β”€ sm_pr_diag
β”‚Β Β  β”œβ”€β”€ global_rain_sm.f90
β”‚Β Β  β”œβ”€β”€ sample_events.f90
β”‚Β Β  β”œβ”€β”€ sm_pr_diag_nml.py
β”‚Β Β  └── sm_pr_diag_test.py
β”œβ”€β”€ some_other_diag
β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  └── test_ta.py
β”œβ”€β”€ some_r_diagnostic
β”‚Β Β  └── xxx.r
└── WAMonsoon
    β”œβ”€β”€ 10W10E_1D_basic.ncl
    β”œβ”€β”€ 10W10E_3D_basic.ncl
    β”œβ”€β”€ autocorr.ncl
    β”œβ”€β”€ cmap_difference_pres.rgb
    β”œβ”€β”€ cmap_difference.rgb
    β”œβ”€β”€ cmap_difference_tas.rgb
    β”œβ”€β”€ cmap_difference_theta.rgb
    β”œβ”€β”€ cmap_difference_wind.rgb
    β”œβ”€β”€ contour_basic.ncl
    β”œβ”€β”€ exact_panel_positions_pres.ncl
    β”œβ”€β”€ exact_panel_positions_pr-mmday.ncl
    β”œβ”€β”€ exact_panel_positions_tas.ncl
    β”œβ”€β”€ exact_panel_positions_wind.ncl
    β”œβ”€β”€ isv_filtered.ncl
    β”œβ”€β”€ precip_IAV.ncl
    β”œβ”€β”€ precip_seasonal.ncl
    └── wind_basic.ncl

All 14 comments

Example with more content:

β”œβ”€β”€ ncl
β”‚Β Β  β”œβ”€β”€ my_diag
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_pr.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_ta.ncl
β”‚Β Β  β”‚Β Β  └── test_ta_no2.ncl
β”‚Β Β  β”œβ”€β”€ perfmetrics
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ grading_collect.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ grading.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_collect.ncl
β”‚Β Β  β”‚Β Β  └── taylor.ncl
β”‚Β Β  β”œβ”€β”€ shared
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ aux_perfmetrics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ latlon.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legacy_code
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── statistics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ misc_function.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ regridding.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ amwg.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eyring_toz.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ qcm3.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rainbow.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── red-blue.rgb
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scaling.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ set_operators.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ statistics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ style.ncl
β”‚Β Β  β”‚Β Β  └── styles
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ CCMVal1.style
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ CCMVal2.style
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ CMIP5.style
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ DEFAULT.style
β”‚Β Β  β”‚Β Β      └── righi15gmd.style
β”‚Β Β  └── WAMonsoon
β”‚Β Β      β”œβ”€β”€ 10W10E_1D_basic.ncl
β”‚Β Β      β”œβ”€β”€ 10W10E_3D_basic.ncl
β”‚Β Β      β”œβ”€β”€ autocorr.ncl
β”‚Β Β      β”œβ”€β”€ cmap_difference_pres.rgb
β”‚Β Β      β”œβ”€β”€ cmap_difference.rgb
β”‚Β Β      β”œβ”€β”€ cmap_difference_tas.rgb
β”‚Β Β      β”œβ”€β”€ cmap_difference_theta.rgb
β”‚Β Β      β”œβ”€β”€ cmap_difference_wind.rgb
β”‚Β Β      β”œβ”€β”€ contour_basic.ncl
β”‚Β Β      β”œβ”€β”€ exact_panel_positions_pres.ncl
β”‚Β Β      β”œβ”€β”€ exact_panel_positions_pr-mmday.ncl
β”‚Β Β      β”œβ”€β”€ exact_panel_positions_tas.ncl
β”‚Β Β      β”œβ”€β”€ exact_panel_positions_wind.ncl
β”‚Β Β      β”œβ”€β”€ isv_filtered.ncl
β”‚Β Β      β”œβ”€β”€ precip_IAV.ncl
β”‚Β Β      β”œβ”€β”€ precip_seasonal.ncl
β”‚Β Β      └── wind_basic.ncl
β”œβ”€β”€ python
β”‚Β Β  β”œβ”€β”€ my_diag
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  β”‚Β Β  └── test_ta.py
β”‚Β Β  β”œβ”€β”€ shared
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ esmdiaglib.py
β”‚Β Β  β”‚Β Β  └── mylib
β”‚Β Β  β”‚Β Β      └── __init__.py
β”‚Β Β  β”œβ”€β”€ sm_pr_diag
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ global_rain_sm.f90
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sample_events.f90
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ sm_pr_diag_nml.py
β”‚Β Β  β”‚Β Β  └── sm_pr_diag_test.py
β”‚Β Β  └── some_other_diag
β”‚Β Β      β”œβ”€β”€ test_pr.py
β”‚Β Β      β”œβ”€β”€ test_ta_no2.py
β”‚Β Β      └── test_ta.py
└── r
    β”œβ”€β”€ shared
    └── some_r_diagnostic
        └── xxx.r

This would be fine, if none overlap exists, e.g. a ncl script running a py script to calculate some subroutines. I support this idea.

Another possibility would be the following. This would make it easier for users to find the diagnostic they are looking for, because diagnostics are no longer organized per language, which also allows using multiple languages related to a single diagnostic theme. This solution also addresses the issue raised by @BenMGeo .

esmdiagnostics/
β”œβ”€β”€ my_diag
β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  └── test_ta.py
β”œβ”€β”€ my_ncl_diag
β”‚Β Β  β”œβ”€β”€ test_pr.ncl
β”‚Β Β  β”œβ”€β”€ test_ta.ncl
β”‚Β Β  └── test_ta_no2.ncl
β”œβ”€β”€ perfmetrics
β”‚Β Β  β”œβ”€β”€ grading_collect.ncl
β”‚Β Β  β”œβ”€β”€ grading.ncl
β”‚Β Β  β”œβ”€β”€ main.ncl
β”‚Β Β  β”œβ”€β”€ taylor_collect.ncl
β”‚Β Β  └── taylor.ncl
β”œβ”€β”€ shared
β”‚Β Β  β”œβ”€β”€ ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ aux_perfmetrics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ latlon.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legacy_code
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ensemble.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── statistics.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ misc_function.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ plot
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ aux_plotting.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ contour_maps.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ contourplot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ GO_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legacy_code
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── aux_plotting.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ legends.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mjo_level1.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mjo_level2.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ monsoon_domain_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ monsoon_panels.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ portrait_plot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ amwg.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ eyring_toz.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-od550aer.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-precip.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas-delta.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ipcc-tas.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ qcm3.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rainbow.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── red-blue.rgb
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scatterplot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ styles
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CCMVal1.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CCMVal2.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMIP5.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ DEFAULT.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── righi15gmd.style
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_diagram_less_hardcoded.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ taylor_plot.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ vector_scalar_map_polar.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ xy_line.ncl
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── zonalmean_profile.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ regridding.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ scaling.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ set_operators.ncl
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ statistics.ncl
β”‚Β Β  β”‚Β Β  └── style.ncl
β”‚Β Β  β”œβ”€β”€ python
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ esmdiaglib.py
β”‚Β Β  β”‚Β Β  └── mylib
β”‚Β Β  β”‚Β Β      └── __init__.py
β”‚Β Β  └── r
β”œβ”€β”€ sm_pr_diag
β”‚Β Β  β”œβ”€β”€ global_rain_sm.f90
β”‚Β Β  β”œβ”€β”€ sample_events.f90
β”‚Β Β  β”œβ”€β”€ sm_pr_diag_nml.py
β”‚Β Β  └── sm_pr_diag_test.py
β”œβ”€β”€ some_other_diag
β”‚Β Β  β”œβ”€β”€ test_pr.py
β”‚Β Β  β”œβ”€β”€ test_ta_no2.py
β”‚Β Β  └── test_ta.py
β”œβ”€β”€ some_r_diagnostic
β”‚Β Β  └── xxx.r
└── WAMonsoon
    β”œβ”€β”€ 10W10E_1D_basic.ncl
    β”œβ”€β”€ 10W10E_3D_basic.ncl
    β”œβ”€β”€ autocorr.ncl
    β”œβ”€β”€ cmap_difference_pres.rgb
    β”œβ”€β”€ cmap_difference.rgb
    β”œβ”€β”€ cmap_difference_tas.rgb
    β”œβ”€β”€ cmap_difference_theta.rgb
    β”œβ”€β”€ cmap_difference_wind.rgb
    β”œβ”€β”€ contour_basic.ncl
    β”œβ”€β”€ exact_panel_positions_pres.ncl
    β”œβ”€β”€ exact_panel_positions_pr-mmday.ncl
    β”œβ”€β”€ exact_panel_positions_tas.ncl
    β”œβ”€β”€ exact_panel_positions_wind.ncl
    β”œβ”€β”€ isv_filtered.ncl
    β”œβ”€β”€ precip_IAV.ncl
    β”œβ”€β”€ precip_seasonal.ncl
    └── wind_basic.ncl

In principle, a better organization of the diagnostic scripts would be nice. The proposed ideas sound good for the easy cases, but I guess things become a bit more complicated for some other cases. Some code of the SAMonsoon diagnostic, for instance, is also used by the diagnostics DiurnalCycle, Evapotranspiration, Global Ocean, IPCC Ch. 9, and WAMonsoon, which might make sorting the diagnostics in the proposed way difficult if not confusing. I have no better idea yet, but I guess this might need some more fine tuning...

@axel-lauer The case you describe above seems to be covered by the proposed directory structure.

The WAMonsoon code that is shared with other diagnostics could for example go into
esmdiagnostics/shared/ncl/monsoon
or if it is code for plotting it could go into
esmdiagnostics/shared/ncl/plot
This would make it easier to see that this code is shared.

Maybe it would be better to also get rid of the language specific subdirectories in the shared directory and instead create a subdirectory for scripts that are related for some reason, e.g. like this:
esmdiagnostics/shared/monsoon
esmdiagnostics/shared/plot
esmdiagnostics/shared/statistics
This would make it easier to find tools related to a particular task, plus a single set of tools might use multiple languages.

We discussed this internally.

We find the idea good in principle but we are also afraid that it could generate a lot of issues (see above comment by Axel). Since our main focus now is to get the new backend and interface running, we would propose to postpone it.

Once the backend is finalized, we plan to have a coding workshop where we will focus on testing all namelist and diagnostics in the new version. That could be the opportunity to discuss this issue again, but for the moment we shall focus on the other issues which are more urgent.

@ESMValGroup/esmvaltool-coreteam

I fully second this.

Ben

On 12.12.2017 13:20, Mattia Righi wrote:
>

We discussed this internally.

We find the idea good in principle but we are also afraid that it
could generate a lot of issues (see above comment by Axel). Since our
main focus now is to get the new backend and interface running, we
would propose to postpone it.

Once the backend is finalized, we plan to have a coding workshop where
we will focus on testing all namelist and diagnostics in the new
version. That could be the opportunity to discuss this issue again,
but for the moment we shall focus on the other issues which are more
urgent.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ESMValGroup/ESMValTool/issues/106#issuecomment-351035774,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AOSImkL3nuy7mXDwCrdAUCxo9mo6uz1Jks5s_m-dgaJpZM4PwafY.

--
M. Sc.
Scientific Programmer
Department of Geography
LMU - Ludwig-Maximilians-Universitaet

Luisenstraße 37
80333 MΓΌnchen

Tel.: 089-2180-6724
E-Mail: B.[email protected]

I think this issue needs to be addressed before starting to port the diagnostics from version 1.x to version 2 of esmvaltool, as it will be much harder to change this afterwards.

As discussed above, we shall avoid too complicated nestings.
My suggestion would be to simply sort diagnostics by language (as in plots_scripts):

diag_scripts\ncl\*.ncl
diag_scripts\ncl\lib\*.ncl
diag_scripts\python\*.py
diag_scripts\python\lib\*.py
diag_scripts\R\*.r
diag_scripts\R\lib\*.r

As long as we port the diag script to v2, we might also think about introducing a naming convention for the scripts (e.g., avoid upper-case, see #12).

@axel-lauer

One of the concerns raised at the sprint at KNMI last week was that we may end up writing the same functionality in many different languages (Python, NCL, R, ..). Therefore I would recommend against creating language specific directories, as this makes it harder for diagnostic developers to find functionality that is already implemented.

With the new namelist format, it is quite easy to use functionality implemented in a different language: a single diagnostic section in the namelist can use diagnostic scripts in multiple languages, the ancestors keyword can be used to run multiple diagnostic scripts one after the other, while the output of one or more scripts is used as the input of the next script. See e.g. the perfmetrics namelist for an example of this.

There seemed to be some agreement on the structure I proposed on October 9. I would propose to go for that, but drop the language specific directories. It does impose some grouping of diagnostic scripts, but not much:

diag_scripts/
β”œβ”€β”€ my_diag
β”‚   β”œβ”€β”€ test_pr.py
β”‚   β”œβ”€β”€ test_ta_no2.py
β”‚   └── test_ta.py
β”œβ”€β”€ my_ncl_diag
β”‚   β”œβ”€β”€ test_pr.ncl
β”‚   β”œβ”€β”€ test_ta.ncl
β”‚   └── test_ta_no2.ncl
β”œβ”€β”€ perfmetrics
β”‚   β”œβ”€β”€ grading_collect.ncl
β”‚   β”œβ”€β”€ grading.ncl
β”‚   β”œβ”€β”€ main.ncl
β”‚   β”œβ”€β”€ taylor_collect.ncl
β”‚   └── taylor.ncl
β”œβ”€β”€ shared
β”‚   β”œβ”€β”€ aux_perfmetrics.ncl
β”‚   β”œβ”€β”€ ensemble.ncl
β”‚   β”œβ”€β”€ latlon.ncl
β”‚   β”œβ”€β”€ legacy_code
β”‚   β”‚   β”œβ”€β”€ ensemble.ncl
β”‚   β”‚   └── statistics.ncl
β”‚   β”œβ”€β”€ misc_function.ncl
β”‚   β”œβ”€β”€ plot
β”‚   β”‚   β”œβ”€β”€ aux_plotting.ncl
β”‚   β”‚   β”œβ”€β”€ contour_maps.ncl
β”‚   β”‚   β”œβ”€β”€ contourplot.ncl
β”‚   β”‚   β”œβ”€β”€ GO_panels.ncl
β”‚   β”‚   β”œβ”€β”€ legacy_code
β”‚   β”‚   β”‚   └── aux_plotting.ncl
β”‚   β”‚   β”œβ”€β”€ legends.ncl
β”‚   β”‚   β”œβ”€β”€ mjo_level1.ncl
β”‚   β”‚   β”œβ”€β”€ mjo_level2.ncl
β”‚   β”‚   β”œβ”€β”€ monsoon_domain_panels.ncl
β”‚   β”‚   β”œβ”€β”€ monsoon_panels.ncl
β”‚   β”‚   β”œβ”€β”€ portrait_plot.ncl
β”‚   β”‚   β”œβ”€β”€ rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ amwg.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ eyring_toz.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-od550aer-delta.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-od550aer.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-precip-delta.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-precip.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-tas-delta.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ ipcc-tas.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ qcm3.rgb
β”‚   β”‚   β”‚   β”œβ”€β”€ rainbow.rgb
β”‚   β”‚   β”‚   └── red-blue.rgb
β”‚   β”‚   β”œβ”€β”€ scatterplot.ncl
β”‚   β”‚   β”œβ”€β”€ styles
β”‚   β”‚   β”‚   β”œβ”€β”€ CCMVal1.style
β”‚   β”‚   β”‚   β”œβ”€β”€ CCMVal2.style
β”‚   β”‚   β”‚   β”œβ”€β”€ CMIP5.style
β”‚   β”‚   β”‚   β”œβ”€β”€ DEFAULT.style
β”‚   β”‚   β”‚   └── righi15gmd.style
β”‚   β”‚   β”œβ”€β”€ taylor_diagram_less_hardcoded.ncl
β”‚   β”‚   β”œβ”€β”€ taylor_plot.ncl
β”‚   β”‚   β”œβ”€β”€ vector_scalar_map_polar.ncl
β”‚   β”‚   β”œβ”€β”€ xy_line.ncl
β”‚   β”‚   └── zonalmean_profile.ncl
β”‚   β”œβ”€β”€ regridding.ncl
β”‚   β”œβ”€β”€ scaling.ncl
β”‚   β”œβ”€β”€ set_operators.ncl
β”‚   β”œβ”€β”€ statistics.ncl
β”‚   └── style.ncl
β”‚   β”œβ”€β”€ esmdiaglib.py
β”‚   └── mylib
β”‚       └── __init__.py
β”œβ”€β”€ sm_pr_diag
β”‚   β”œβ”€β”€ global_rain_sm.f90
β”‚   β”œβ”€β”€ sample_events.f90
β”‚   β”œβ”€β”€ sm_pr_diag_nml.py
β”‚   └── sm_pr_diag_test.py
β”œβ”€β”€ some_other_diag
β”‚   β”œβ”€β”€ test_pr.py
β”‚   β”œβ”€β”€ test_ta_no2.py
β”‚   └── test_ta.py
β”œβ”€β”€ some_r_diagnostic
β”‚   └── xxx.r
└── WAMonsoon
    β”œβ”€β”€ 10W10E_1D_basic.ncl
    β”œβ”€β”€ 10W10E_3D_basic.ncl
    β”œβ”€β”€ autocorr.ncl
    β”œβ”€β”€ cmap_difference_pres.rgb
    β”œβ”€β”€ cmap_difference.rgb
    β”œβ”€β”€ cmap_difference_tas.rgb
    β”œβ”€β”€ cmap_difference_theta.rgb
    β”œβ”€β”€ cmap_difference_wind.rgb
    β”œβ”€β”€ contour_basic.ncl
    β”œβ”€β”€ exact_panel_positions_pres.ncl
    β”œβ”€β”€ exact_panel_positions_pr-mmday.ncl
    β”œβ”€β”€ exact_panel_positions_tas.ncl
    β”œβ”€β”€ exact_panel_positions_wind.ncl
    β”œβ”€β”€ isv_filtered.ncl
    β”œβ”€β”€ precip_IAV.ncl
    β”œβ”€β”€ precip_seasonal.ncl
    └── wind_basic.ncl

Basically this structure is as simple as: if all required functionality for a diagnostic is implemented in a single file, create a file, if it is implemented in multiple files, put them together in a directory. If the functionality in a diagnostic script is shared across multiple diagnostic scripts, move those functions to the shared directory, again either as a single file or as a set of files in a directory. This will facilitate easy discovery of available functionality and helps to keep track of what is shared by multiple diagnostics (this also helps to discover what is already implemented, as the shared code is much more likely to be relevant for new diagnostic development than what is available in other diagnostic scripts).

I had a discussion with @nielsdrost and we both thought that shared was a slightly clearer name than lib for the location where code shared between multiple diagnostics is stored, but if this is an issue for you we can keep lib of course.

Let me discuss this again with @axel-lauer et al. and then take a decision.
As you said above, we need to come up with a structure, before start including other diags.

I am fine with the last proposed option including no language specific folders and moving code from "lib" and "aux" to "shared".

Working on this issue here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

valeriupredoi picture valeriupredoi  Β·  4Comments

nielsdrost picture nielsdrost  Β·  3Comments

valeriupredoi picture valeriupredoi  Β·  3Comments

valeriupredoi picture valeriupredoi  Β·  4Comments

bascrezee picture bascrezee  Β·  5Comments