Skip to content

Visualisation expects all boundary conditions provided, even when the process in turned off #284

@ghendrickx

Description

@ghendrickx

Seen behaviour

When running aeolis with the visualization-argument set to True, the function expects that the p-variable contains arrays for p['wind_file'], p['wave_file'], and p['tide_file']. However, when these files are not provided - e.g., because (part of) these processes are not enabled - this results in an IndexError.

Expected behaviour

The expected behaviour is that when (part of) these files are not provided - especially when the corresponding processes are disabled - the visualisation is not generated for these timeseries without raising an error; i.e., the visualisation should skip this boundary condition. PS. I can understand that the p['wind_file'] is considered mandatory, and thus should always be provided.

Code suggestion

Instead of the current if-statements (i.e., if np.shape(p['wave_file'])[1] == 3: and if np.shape(p['tide_file'])[1] == 2:), there is a check whether these processes are enabled and/or the entries are defined. Applying the np.shape()-function on a NoneType (i.e., undefined) results in an empty tuple (i.e., ()), which cannot be indexed (there are no entries after all). Thus instead, the above if-statements should be preceded by if p['wave_file'] is not None: and if p['tide_file'] is not None:.

Thus, e.g., the below code could replace the existing code:

if p['wave_file'] is not None and np.shape(p['wave_file'])[1]== 3:
    w_t = p['wave_file'][:,0]
    w_Hs = p['wave_file'][:,1]
    w_Tp = p['wave_file'][:,2]
    axs[2].plot(w_t, w_Hs, 'k')
    axs[3].plot(w_t, w_Tp, 'k')
    axs[2].set_title('Wave height, Hs (m)')
    axs[3].set_title('Wave period, Tp (sec)')

# Read the user input (tide)
if p['tide_file'] is not None and np.shape(p['tide_file'])[1]==2:
    T_t = p['tide_file'][:,0]
    T_zs = p['tide_file'][:,1]
    axs[4].plot(T_t, T_zs, 'k')
    axs[4].set_title('Water level, zs (m)')

This will result in empty plots, which could be accommodated for by setting the number of plots dynamically, based on the provided data; or, it can be left empty intentionally to highlight the missing timeseries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions