postprocessing

Contains some helper functions for Marthe/PEST model postprocessing

Classes

PestPostProcessing

Helper class to manage some post-processing operation

Module Contents

class postprocessing.PestPostProcessing(pst)

Helper class to manage some post-processing operation (especially for plotting purpose).

phi_progress(pest_exe='++', log=True, phimlim=False, phimaccept=False, filename=None)

Plot the objective function (phi) evolution.

Parameters:
  • (str (filename) –

    Can be:
    • ’++’ : pestpp (-glm, -opt ,-swp, …)

    • ’hp’ : pesthp

    Default is ‘++’.

  • optional) (output file name to save plot on disk.) –

    Can be:
    • ’++’ : pestpp (-glm, -opt ,-swp, …)

    • ’hp’ : pesthp

    Default is ‘++’.

  • (bool (phimaccept) – Default is True.

  • optional) – Default is True.

  • (bool – Default is False.

  • optional) – Default is False.

  • (bool – Default is False.

  • optional) – Default is False.

  • (str – If None, the plot will not be saving on disk. Default is None.

  • optional) – If None, the plot will not be saving on disk. Default is None.

  • Returns

  • --------

  • (AxeSubplot) (ax) –

Examples

ppp = PestPostProcessing(‘mypst.pst’) ppp.phi_progress(phimlim=True, filename=’phi_progress.png’)

phi_components(obs_groups=None, explode=0.05, filename=None)

Plot the contribution of each observation group to the total objective function.

Parameters:
  • (str/list[str] (obs_groups) – If None, all observation groups will be considered. Default is None.

  • optional) (output file name to save plot on disk.) – If None, all observation groups will be considered. Default is None.

  • (float (explode) – Default is 0.05.

  • optional) – Default is 0.05.

  • (str (filename) – If None, the plot will not be saving on disk. Default is None.

  • optional) – If None, the plot will not be saving on disk. Default is None.

  • Returns

  • --------

  • (AxeSubplot) (ax) –

Examples

ppp = PestPostProcessing(‘mypst.pst’) ppp.phi_components(filename=’phi_components.png’)

export_stats(filename, cmap='YlGnBu', engine='excel')

Export/save some pest criterias (rss, mae, rmse, nrmse) for each observation groups as data table.

Parameters:
  • (str) (filename) –

  • (str (engine) – use on table values. Default is ‘YlGnBu’.

  • optional) (required exporting provider.) – use on table values. Default is ‘YlGnBu’.

  • (str

    Can be:
    • ’excel’ (‘.xlsx’)

    • ’latex’ (‘.tex’)

    • ’html’ (‘.html’)

    Default is ‘excel’.

  • optional)

    Can be:
    • ’excel’ (‘.xlsx’)

    • ’latex’ (‘.tex’)

    • ’html’ (‘.html’)

    Default is ‘excel’.

  • Returns

  • --------

Examples

ppp = PestPostProcessing(‘mypst.pst’) ppp.export_stats(‘stats.xlsx’, cmap=’viridis’)

obs_vs_sim(kind='1to1', reifile=None, obs_groups=None, figsize=None, onefile=True, path=None)

Graphical analysis of observed vs simulated values.

Parameters:
  • (str (path) –

    Can be :
    • ’1to1’ : (x=measured, y=modelled)

    • ’record’ : (x=observations, y=measured & modelled)

    • ’residual’ : (x=observations, y=measured - modelled)

    Default is ‘1to1’.

  • optional) (whatever export the produced plots.) –

    Can be :
    • ’1to1’ : (x=measured, y=modelled)

    • ’record’ : (x=observations, y=measured & modelled)

    • ’residual’ : (x=observations, y=measured - modelled)

    Default is ‘1to1’.

  • (str – Format: ‘pst_name’ + ‘.rei’ + ‘n°itération’ (ex: ‘cal.rei5’) If None, the .res attriut in input pst wil be considered, generally it refers to the last iteration. Default is None.

  • optional) – Format: ‘pst_name’ + ‘.rei’ + ‘n°itération’ (ex: ‘cal.rei5’) If None, the .res attriut in input pst wil be considered, generally it refers to the last iteration. Default is None.

  • (str/list[str] (obs_groups) – If None, all observation groups with at least one not null observation will be considered. Default is None.

  • optional) – If None, all observation groups with at least one not null observation will be considered. Default is None.

  • (tup (figsize) –

    Default is:
    • ’1to1’ : (6,6)

    • ’record’ : (9,5)

    • ’residual’ : (9,4)

  • optional)

    Default is:
    • ’1to1’ : (6,6)

    • ’record’ : (9,5)

    • ’residual’ : (9,4)

  • (bool (onefile) – Default is True.

  • optional) – Default is True.

  • (str

    If None, plots will not be saved. Otherwise:

    If onefile is True: output file name to save pdf file on disk. If onefile is False: folder path to save plots on disk.

    Default is None.

  • optional)

    If None, plots will not be saved. Otherwise:

    If onefile is True: output file name to save pdf file on disk. If onefile is False: folder path to save plots on disk.

    Default is None.

  • Returns

  • --------

  • (dict) (axs) – Format: {loc_id: ax} (ex: {‘well_03’: <AxesSubplot>})

Examples

ppp = PestPostProcessing(‘mypst.pst’)

ppp.obs_vs_sim(kind=’record’, reifile=’cal_r_lizonne.rei9’,

obs_groups=[obg if obg.startswith(‘p’) for obg in ppp.nnz_obs_group], onefile=True, path=’obs_vs_sim_records.pdf’)

ppp.obs_vs_sim(kind=’1to1’, reifile=’cal_r_lizonne.rei13’,

onefile=False, path=’pest/post_proc’)

get_css_df(parnames=None)

Read Composite Scaled Sensitivities (CSS) as pandas DataFrame.

Parameters:
  • (str/list[str] (parnames) – If None, all adjustable parameters will be considred. Default is None.

  • optional) (required parameters full name(s).) – If None, all adjustable parameters will be considred. Default is None.

  • Returns

  • --------

  • (DataFrame) (css_df) –

    Format:

    param1 .. paramN

    iteration

    1 7.733360e-08 .. 2.357000e-08 2 5.316330e-08 1.575150e-07 3 5.066230e-08 .. 5.618370e-09

Examples

ppp = PestPostProcessing(‘mypst.pst’) css_df = ppp.get_css_df()

export_css(filename, parnames=None, cmap='YlGnBu', engine='excel')

Export Composite Scaled Sensitivities (CSS).

Parameters:
  • (str) (filename) –

  • (str (engine) – use on table values. Default is ‘YlGnBu’.

  • optional) (required exporting provider.) – use on table values. Default is ‘YlGnBu’.

  • (str

    Can be:
    • ’excel’ (‘.xlsx’)

    • ’latex’ (‘.tex’)

    • ’html’ (‘.html’)

    Default is ‘excel’.

  • optional)

    Can be:
    • ’excel’ (‘.xlsx’)

    • ’latex’ (‘.tex’)

    • ’html’ (‘.html’)

    Default is ‘excel’.

  • Returns

  • --------

Examples

ppp = PestPostProcessing(‘mypst.pst’) ppp.export_css(‘css.xlsx’)

static to_onefile(axs, filename)

Combine multiple plots into a unique pdf file.

Parameters:
  • (list) (axs) –

  • (str) (filename) – Note: must have the ‘.pdf’ extension.

  • Returns

  • --------

Examples

df = pd.DataFrame(data={‘r’:np.linspace(5,58,50)}) axs = [df.plot(), (df*df).plot(), df.add(22).plot()] PestPostProcessing.to_onefile(axs, ‘all_plots.pdf’)

parameter_progress(parnames=None, pargroups=None, pest_exe='++', figsize=None, onefile=True, path=None)

Graphical analysis of the parameters values evolution along iteration from PEST calibration process.

Parameters:
  • (str/list[str] (pargroups) –

    If None, all adjustable parameters will be considred.

    Default is None.

  • optional) (whatever export the produced plots.) –

    If None, all adjustable parameters will be considred.

    Default is None.

  • (str/list[str] – If None, all adjustable parameter groups will be considred. Default is None.

  • optional) – If None, all adjustable parameter groups will be considred. Default is None.

  • (str (path) –

    Can be:
    • ’++’ : pestpp (-glm, -opt ,-swp, …)

    • ’hp’ : pesthp

    Default is ‘++’.

  • optional)

    Can be:
    • ’++’ : pestpp (-glm, -opt ,-swp, …)

    • ’hp’ : pesthp

    Default is ‘++’.

  • (tup (figsize) – Default is (9,4).

  • optional) – Default is (9,4).

  • (bool (onefile) – Default is True.

  • optional) – Default is True.

  • (str

    If None, plots will not be saved. Otherwise:

    If onefile is True: output file name to save pdf file on disk. If onefile is False: folder path to save plots on disk.

    Default is None.

  • optional)

    If None, plots will not be saved. Otherwise:

    If onefile is True: output file name to save pdf file on disk. If onefile is False: folder path to save plots on disk.

    Default is None.

  • Returns

  • --------

  • (dict) (axs) – Format: {parnme: ax} (ex: {‘hk_zpc_l11_z01’: <AxesSubplot>})

Examples

ppp = PestPostProcessing(‘mypst.pst’)

ppp.parameter_progress(pargroups=’soil’, onefile=True,

path=’soil_params_evolution.pdf’)

ppp.obs_vs_sim(parnames= [p if p.startswith(‘cap_sol’) for p in ppp.pst.adj_par_names()]

onefile=False, path=’pest/post_proc’)

__str__()

Internal string method.