In [1]:
%pylab inline
Similarly to the "FVCOM class", the "Station class" is a numerical-model-based object.
As any other library in Python, PySeidon 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 import *
Star here means all. Usually this form of statements would import the entire library. In the case of PySeidon, this statement will import the following object classes: FVCOM, Station, Validation, ADCP, Tidegauge and Drifter. Only the Station class will be tackle in this tutorial. However note should note that the architecture design and functioning between each classes are very similar.
Python is by definition an object oriented language...and so is matlab. PySeidon is based on this notion of object, so let us define our first "Station" object.
Exercise 1:
Answer:
In [3]:
Station?
According to the documentation, in order to define a Station object, the only required input is a *filename. This string input represents path to a file or a folder containing files (e.g. testStation=Station('./path_to_Station_output_file/filename') or testStation=Station('./path_to_Station_output_file/folder/') ) and whose file can be a pickle file (i.e. .p) or a netcdf file (i.e. .nc).
Note that the specified folder must contain station's netcdf/pickle files which could be sorted time wise thanks to their names (e.g. by adding a time stamp to the file name for instance) and with the word 'station' in their name.
Additionally, either a local file path or a OpenDap url could be used!
Exercise 2:
Answer:
In [4]:
station=Station('http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/Station3D_dngrid_BF_20130730_20130809.nc')
The Station object possesses 4 attributes, 5 methods (or 4 for 2D simulations) and 1 special method. They would appear by typing station. 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:
The Station attributes are:
The Station methods & functions are:
The special Station method permits to stack two station objects (e.g. station1 and station2) through a simple addition, as such:
However, station1 and station2 must be consecutive in time (e.g. station1 before in time compared to station2). Note that the History attribute will be changed accordingly.
Exercise 3:
Answer:
In [5]:
print station.Grid.name
flowDir, velNorm = station.Util2D.flow_dir('GP_120726_BPa')
flowDir, velNorm = station.Util2D.flow_dir('GP_120726_BPa', exceedance=True)
fI, eI, pa, pav = station.Util2D.ebb_flood_split('GP_120726_BPa')
print "Flood mean flow speed: " + str(velNorm[fI].mean()) + " m/s"
print "Ebb mean flow speed: " + str(velNorm[eI].mean()) + " m/s"
station.Util2D.speed_histogram('Westport')
station.Util2D.speed_histogram('DG_1a')
station.Util2D.speed_histogram('PP-120917-BPa')
harmo = station.Util2D.Harmonic_analysis_at_point('GP_120726_BPa', velocity=True, elevation=False)
print harmo
velos = station.Util2D.Harmonic_reconstruction(harmo)
Exercise 4:
Answer:
In [6]:
vs = station.Util3D.verti_shear('GP_120726_BPa', time_ind=eI)
norm = station.Util3D.velo_norm('GP_120726_BPa', time_ind=fI)
fd = station.Util3D.flow_dir('GP_120726_BPa', time_ind=fI, vertical=True)
depths = station.Util3D.depth('GP_120726_BPa')
meandepths = np.mean(depths[fI], axis=0)
meanfd = np.mean(fd,axis=0)
station.Plots.plot_xy(meanfd, meandepths, title='Flood flow direction at GP_120726_BPa', xlabel='direction', ylabel='depth')
Exercise 5:
Answer:
In [7]:
station.dump_profile_data(meanfd, meandepths, title='Flood flow direction at GP_120726_BPa', xlabel='direction', ylabel='depth')
As beta tester, your first assignement is to report bugs...yet not everything is a bug. The first thing to check before to report a bug is to verify that your version of PySeidon is up-to-date. The best way to keep up with the package evolution is to git to clone the repository, use pull to update it and re-install it if needed.
The second thing to check before to report a bug is to verify that the bug is reproducible. When running into a bug, double check that your inputs fit the description of the documentation then turn the debug flag on (e.g. output = stationobject.function(inputs, debug=True)) and submit the command again. If the error re-occurs then report it (i.e. copy entire error message + command and send it to package administrator)
Your second role as beta-tester is to submit suggestions and critics to the developpers regarding the functioning and functionality of the package. Beta testing phase is the best opportunity to steer a project towards the applications you would like to be tackled...