PySeison - Tutorial 6: Validation class

In [1]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib

1. PySeidon-dvt - Validation object initialisation

"Validation class" is a hybrid class which requires both a numerical-model-based object (e.g. "FVCOM" or "Station" object) and at least one measurement-based object (e.g. "ADCP", "TideGauge" or "Drifter" object or a list of their combination). Its aim is to provide validation benchmarks in order to access the accuracy of a FVCOM simulation compared to matching measurements.

1.1. Package importation

As any other library in Python, PySeidon-dvt has to be first imported before to be used. Here we will use an alternative import statement compared to the one previoulsy presented:

In [2]:
from pyseidon_dvt import *
/home/grumpynounours/anaconda/lib/python2.7/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

Star here means all. Usually this form of statements would import the entire library. In the case of PySeidon-dvt, this statement will import the following object classes: FVCOM, Station, Validation, ADCP, Tidegauge and Drifter. Only the Validation class will be tackle in this tutorial.

1.2. Object definition

Python is by definition an object oriented language...and so is matlab. PySeidon-dvt is based on this notion of object, so let us define our first "Validation" object.

Exercise 1:

  • Unravel Drifter documentation with Ipython shortcuts

Answer:

In [3]:
Validation?

According to the documentation, in order to define a Validation object, the required inputs are:

  • standalone or list of PySeidon-dvt measurement objects (e.g. ADCP, TideGauge, Drifter)
  • standalone or list PySeidon-dvt simulation objects (i.e. FVCOM or Station)

Note:

  • flow option permits to impose flow comparison by surface flow ('sf'), depth-averaged flow ('daf') or at any depth (float). If this option is not provided, the option choice will be prompted to the user.
  • if the time period between simulation and measurement objects does not match, one can use harmonic_reconstruction option in order to extrapolate and interpolate measurements' periods based on an harmonic analysis. Warning: this option may lead to spurious extrapolations.

Exercise 2:

  • Initialize adcp, tidegauge and drifter objects from the templates provided in ./data4tutorial/drifter_GP_01aug2013.mat
  • Tip: adapt the file's path to your local machine.
  • Initialize station and fvcom objects from the following opendap urls: http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/Station3D_dngrid_BF_20130730_20130809.nc and http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_GP_20130801_20130802.nc
  • Initialize val1, a Validation object using as input the adcp object and the station object and 'flow' option to 10.0 m depth from sea bottom upwards
  • Initialize val2, a Validation object using as input a list of all the measurement objects and the FVCOM object and 'flow' option to 'daf'.
  • Initialize val2, a Validation object using as input a list of all the measurement objects and the FVCOM object and 'flow' option to 5.0 from the sea surface downwards.
  • Initialize val3, a Validation object using as input a list of all the measurement objects and the FVCOM object and 'flow' option to 'daf' using the harmonic_reconstruct option on.

Answer:

In [4]:
drift = Drifter('./data4tutorial/drifter_GP_01aug2013.mat')
adcp = ADCP('./data4tutorial/adcp_GP_01aug2013.mat')
tg = TideGauge('./data4tutorial/tidegauge_GP_01aug2013.mat')
station = Station('http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/Station3D_dngrid_BF_20130730_20130809.nc')
fvcom = FVCOM('http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_GP_20130801_20130802.nc')
val1 = Validation(adcp, station, flow=10.0)
val2 = Validation([adcp, drift, tg], fvcom, flow='daf')
val3 = Validation(adcp, fvcom, flow=-5.0)
Retrieving data from /media/grumpynounours/Seagate Backup Plus Drive/FVCOM_simulations/sim_tuto/Station3D_dngrid_BF_20130730_20130809.nc ...
Initialisation...
Retrieving data from /media/grumpynounours/Seagate Backup Plus Drive/FVCOM_simulations/sim_tuto/FVCOM3D_dngrid_GP_20130801_20130802.nc ...
Initialisation...
Station site: GP_130730_TA

1.3. Object attributes, functions, methods & special methods

The Validation object possesses 2 attributes and 5 methods. They would appear by typing val1. Tab for instance.

An attribute is a quantity intrinsic to its object. A method is an intrinsic function which changes an attribute of its object. Contrarily a function will generate its own output:

object.method(inputs) output = object.function(inputs)

The Validation attributes are:

  • History: history metadata that keeps track of the object changes
  • Variables: gathers the hydrodynamics related data. Note that methods will generate new fields in this attribute
  • Benchmarks: gathers the standard validation benchmarks. Note that this attribute will only appear once one of the validate methods has been ran.

The Validation methods & functions are:

  • benchmarks_map: plots bathymetric map & model validation benchmarks
  • validate_data: computes series of standard validation benchmarks based on time-series analysis
  • validate_harmonics: This method computes and store in a csv file the error in % for each component of the harmonic analysis (i.e. *_error.csv).
  • taylor_diagram: plots Taylor diagram based on the results of 'validate_data'
  • Write validation_report: This method writes a report (*.pdf) based on the validation methods' results
  • save_as: saves the current Validation structure into a pickle or a mat file

2. PySeidon-dvt - Hands-on (15 minutes)

Exercise 3:

  • Perform data validation of val1 with the plot option to True, save_csv option to True and filename to 'test1'.
  • Notice that folder adcp_GP_01aug2013 has been created.
  • Plot the val1's taylor diagram
  • Perform harmonic validation of val1 with filename option = 'test2'.
  • Note that test_el_harmo_error.csv and test_vel0_harmo_error.csv have been created.

Answer:

In [5]:
val1.validate_data(plot=True, save_csv=True, filename='test1')
val1.taylor_diagram()
val1.validate_harmonics(filename='test2')
/home/grumpynounours/anaconda/lib/python2.7/site-packages/numpy/lib/nanfunctions.py:703: RuntimeWarning: Mean of empty slice
  warnings.warn("Mean of empty slice", RuntimeWarning)
/home/grumpynounours/anaconda/lib/python2.7/site-packages/matplotlib/figure.py:397: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
  "matplotlib is currently using a non-GUI backend, "