Populating the interactive namespace from numpy and matplotlib
Similarly to the "Station class", the "FVCOM 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:
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 FVCOM 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 "FVCOM" object.
According to the documentation, in order to define a FVCOM object, the only required input is a *filename. This string input represents path to a file (e.g. testFvcom=FVCOM('./path_to_FVOM_output_file/filename') and whose file can be a pickle file (i.e. .p) or a netcdf file (i.e. .nc). Additionally, either a local file path or a OpenDap url could be used.
Optionally, one can extract spatial and/or temporal data from the designated file by respectively defining ax and *tx keywords. ax can be defined as a list of min/max longitudes and latitudes (e.g. ax = [minimum longitude, maximum longitude, minimum latitude, maximum latitude]) or as a pre-defined region tag (e.g. ax = 'GP', 'PP', 'DG' or 'MP'). Whereas tx can be defined as a list of date (e.g. tx = ['2012-11-07T12:00:00','2012.11.09T12:00:00']).
One should note that throughout the package, the following conventions apply:
Retrieving data through OpenDap server... Initialisation...
ax=[-65.77, -65.75, 44.675, 44.685] tx1=['2013-06-20 12:00:00', '2013-06-21 12:00:00'] tx2=['2013-06-21 12:00:00', '2013-06-21 18:00:00'] fvcomPartial1=FVCOM('http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_BF_20130619_20130621.nc', ax=ax, tx=tx1) fvcomPartial2=FVCOM('http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_BF_20130619_20130621.nc', ax=ax, tx=tx2)
Retrieving data through OpenDap server... Initialisation... Re-indexing may take some time... -Now working in bounding box- -Now working in time box- Retrieving data through OpenDap server... Initialisation... Re-indexing may take some time... -Now working in bounding box- -Now working in time box-
The FVCOM object possesses 4 attributes, 4 methods (or 3 for 2D simulations) and 1 special method. They would appear by typing fvcomOD. 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 FVCOM attributes are:
The FVCOM methods & functions are:
The special FVCOM method permits to stack two FVCOM objects (e.g. fvcom1 and fvcom2) through a simple addition, as such:
However, fvcom1 and fvcom2 must share the exact same spatial domain and be consecutive in time (e.g. fvcom1 before in time compared to fvcom2).
['Created from http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_BF_20130619_20130621.nc', 'Bounding box =[-65.77, -65.75, 44.675, 44.685]', 'Temporal domain from 2013-06-20 12:00:00 to 2013-06-21 12:00:00']
fvcomPartial1 += fvcomPartial2
['Created from http://ecoii.acadiau.ca/thredds/dodsC/ecoii/test/FVCOM3D_dngrid_BF_20130619_20130621.nc', 'Bounding box =[-65.77, -65.75, 44.675, 44.685]', 'Temporal domain from 2013-06-20 12:00:00 to 2013-06-21 12:00:00', 'Data from FVCOM3D_dngrid_BF_20130619_20130621.nc has been stacked']
Note how the History attribute has changed
fvcomPartial1.Plots.colormap_var(fvcomPartial1.Grid.h, title='Bathymetry (m)', mesh=False)
fvcomOD.Plots.colormap_var(fvcomOD.Grid.h, title='Bathymetry (m)', isoline='none')
refPoint=[-65.761, 44.68] pointA=[-65.76178, 44.68057] pointB=[-65.76053, 44.68023] pointC=[-65.76123, 44.67942] pointD=[-65.76246, 44.67976] fI, eI, pa, pav= fvcomPartial1.Util2D.ebb_flood_split_at_point(refPoint, refPoint) fvcomPartial1.Util3D.velo_norm() ebbNorm = np.mean(fvcomPartial1.Variables.velo_norm[eI,:,:], 0) floodNorm = np.mean(fvcomPartial1.Variables.velo_norm[fI,:,:], 0) fvcomPartial1.Plots.vertical_slice(ebbNorm, pointD, pointB, title='Time-averaged velocity norm (m/s)') fvcomPartial1.Plots.vertical_slice(floodNorm, pointA, pointC, title='Time-averaged velocity norm (m/s)') fvcomPartial1.History
-Velocity norm added to FVCOM.Variables.-