ocmw.dataproc.otm_extraction module¶
Open Telemac-Mascaret data extraction functions.
Initialise Selafin file for reading, inlcuding setting up mesh search tree. |
|
Convert OTM timestamp into a python date number |
|
Convert OTM timestamp to date strings |
|
Convert OTM timestamp information into an array of python date numbers. |
|
Get the triangular element and node the contain the point (LocX,LocY) from SLF file handle |
|
Get the barycentric weigthing factors to interpolate from element nodes onto the point (LocX,LocY) from Selafin file |
|
Get the triangular element and node the contain the point (LocX,LocY) from mesh dictionary |
|
Get the barycentric weigthing factors to interpolate from element nodes onto the point (LocX,LocY) from mesh dictionary data |
Functions for saving extracted model data into standard OCMW file format.
Generate output path + filename string |
|
Create data dictionary of extracted node and location data and save to an OCMW format file. |
|
Create data dictionary of extracted location data and save to an OCMW file |
|
Create data dictionary of extracted node data and save to an OCMW file |
Functions for extracting the model mesh into a standard OCMW format.
Add element cntroid locations and barycentric weighting to centroid |
|
Extract model mesh from a Selafin output file |
|
Extract the model mesh from the OTM Selafin geometry file used to run the model |
Functions for extracting 2D fields from multiple model output files.
Get time series of surface elevation at a user defined location |
|
Gect a multi-file time series of model surface elevation at a user defined location. |
|
Extract timeseries of model surface elevation for animation frames. |
|
Extract timeseries of 2D model field data for particular model variable. |
Functions for extracting data at set of geospatial locations.
Get variable time series extracted from Selafin file |
|
Extract time series for default set of 2D model fields |
|
Extract time series for default set of 3D model fields |
|
Get timeseries of model data for nodes around a location and interpolate onto location |
|
Extract OTM model 2D field data interpolated onto a user defined location |
|
Extract OTM 3D field data interpolated onto a user defined location |
|
Extract OTM model data for a set of user defined locations |
Functions for extracting data at points along a linear transect.
Define transect data locations based on start and end points, and spacing |
|
Extract a transect of 2-D or 3-D data from Selafin file |
Functions for extracting data at a set of model nodes.
Extract timeseries of data for a particular model variable a set of model nodes. |
|
Extract timeseries of data for a specific model node. |
|
Extract timeseries of data for a set of model nodes. |
|
Extract data from a set of nodes based on user supplied run file. |
Functions for extracting data for nodes within a polygon
Extract mesh node indices and node coordinates from a 2D Selafine file |
|
Extract data from nodes within a polygon based on user supplied run file. |
Parsers for user supplied ascii run file used by processLocDataFile, processNodesDataFile, and processPolygonDataFile.
Parser to read run parameters from a configuration file for an extract at user defined locations |
|
Parser to read run parameters from a configuration file for an extract at model nodes |
|
Parser to read run parameters from a configuration file for extract along a trnasect |
|
Parser to read run parameters from a configuration file for an extract of nodes within a polygon |
Open Telemac-Mascaret output data extraction built on the HR Wallingford parser tools supplied with OTM.
Chris Old IES, School of Engineering, University of Edinburgh Feb 2020
- class ocmw.dataproc.otm_extraction.slfFile(fileName)[source]¶
Bases:
SelafinClass structure for reading OTM Selafin files.
Inhereting properties from the Selafin object in the OTM python scripts.
Intialisation of the class
@param file_name (string) Name of the file
- ocmw.dataproc.otm_extraction.InitialiseFile(FileName)[source]¶
Initialise Selafin file for reading, inlcuding setting up mesh search tree.
- Parameters:
FileName (Str) – Selafin filename including path to location
- Returns:
SLF (Selafin obj) – OTM object based on the Selafin class
- ocmw.dataproc.otm_extraction.OTMDate2Num(timestamp)[source]¶
Convert OTM timestamp into a python date number
- Parameters:
timestamp (numpy.array, int32) – Array of date time fields [year,month,day,hour,minute,seccond].
- Returns:
datenum (float) – Date number.
- ocmw.dataproc.otm_extraction.OTMDate2Str(timestamp)[source]¶
Convert OTM timestamp to date strings
- Parameters:
timestamp (numpy.array, int32) – Array of date time fields [year,month,day,hour,minute,seccond].
- Returns:
datestr (str) – Date string.
- ocmw.dataproc.otm_extraction.genOTMTimeStamps(idate, times, epoch=array([1900, 1, 1, 0, 0, 0]))[source]¶
Convert OTM timestamp information into an array of python date numbers.
- Parameters:
idate (numpy.array, int32) – Array of date time fields [year,month,day,hour,minute,seccond].
times (numpy.array, float) – Timestep offset from idate in seconds
epoch (numpy.array, int32, optional) – Time epoch to use when generating timestampes. The default is default_epoch.
- Returns:
timeStamp (numpy.array, float) – Timestamp as date number in days from epoch.
- ocmw.dataproc.otm_extraction.getSlfTriangle(slfHnd, LocX, LocY)[source]¶
Get the triangular element and node the contain the point (LocX,LocY) from SLF file handle
- Parameters:
- Returns:
NNodes (list[int64]) – Indices for the nodes surrounding the location
Elem (int64) – Index for the mesh element corresponding to the nodes
- ocmw.dataproc.otm_extraction.getSlfNodesWeights(slfHnd, LocX, LocY)[source]¶
Get the barycentric weigthing factors to interpolate from element nodes onto the point (LocX,LocY) from Selafin file
- Parameters:
- Returns:
Elem (TYPE) – Index of the element containing the point
NNodes (list, int64) – Indices of the nodes for the element surrounding the point (LocX,LocY)
NWghts (list, float) – Barycebtric weights from element nodes to point (LocX,LocY)
NLocs (list, list[float,float]) – Location of nodes surroundng the point (LocX,LocY)
- ocmw.dataproc.otm_extraction.getMeshTriangle(mesh, LocX, LocY)[source]¶
Get the triangular element and node the contain the point (LocX,LocY) from mesh dictionary
- Parameters:
- Returns:
NNodes (list, int64) – Indices for the nodes surrounding the location
Elem (int64) – Index for the mesh element corresponding to the nodes
- ocmw.dataproc.otm_extraction.getMeshNodesWeights(mesh, LocX, LocY)[source]¶
Get the barycentric weigthing factors to interpolate from element nodes onto the point (LocX,LocY) from mesh dictionary data
- Parameters:
- Returns:
Elem (TYPE) – Index of teh element containing the point
NNodes (list, int64) – Indices of the nodes for the element surrounding the point (LocX,LocY)
NWghts (list, float) – Barycebtric weights from element nodes to point (LocX,LocY)
NLocs (list, list[float,float]) – Location of nodes surroundng the point (LocX,LocY)
- ocmw.dataproc.otm_extraction.generateOutputFileStr(filePath, runStr)[source]¶
Generate output path + filename string
- ocmw.dataproc.otm_extraction.save2ocmw(outfname, glbAttr, Loc, nodes, Data2D, Data3D)[source]¶
Create data dictionary of extracted node and location data and save to an OCMW format file.
- Parameters:
outfname (str) – Full path and filename for data output.
glbAttr (str) – Global attribute dictionary generated using “generateGlobalAttributes”.
nodes (list, [float,float]) – Element corner nodes surrounding location.
Data2D (dict) – Data dictionary containg the node and interpolated model 2D fields.
Data3D (dict) – Data dictionary containg the node and interpolated model 3D fields.
- Returns:
None.
- ocmw.dataproc.otm_extraction.saveLoc2ocmw(outfname, glbAttr, loc, crs, Data2D, Data3D)[source]¶
Create data dictionary of extracted location data and save to an OCMW file
- Parameters:
outfname (str) – Full path and filename for data output.
glbAttr (str) – Global attribute dictionary generated using “generateGlobalAttributes”.
crs (str) – Coordinate reference system used for location data.
Data2D (dict) – Data dictionary containg the interpolated model 2D fields.
Data3D (dict) – Data dictionary containg the interpolated model 3D fields.
- Returns:
None.
- ocmw.dataproc.otm_extraction.saveNodes2ocmw(outfname, glbAttr, nodes, Data2D, Data3D)[source]¶
Create data dictionary of extracted node data and save to an OCMW file
- Parameters:
outfname (str) – Full path and filename for data output.
glbAttr (str) – Global attribute dictionary generated using “generateGlobalAttributes”.
nodes (list, float) – Indices of nodes where data are extracted.
Data2D (dict) – Data dictionary containg the nodes model 2D fields.
Data3D (dict) – Data dictionary containg the nodes model 3D fields.
- Returns:
None.
- ocmw.dataproc.otm_extraction.enhanceMesh(mesh)[source]¶
Add element cntroid locations and barycentric weighting to centroid
- Parameters:
mesh (dict) – Mesh data strcuture generated by either extractMesh or extractGeometry
- Returns:
mesh (dict) – Dictionary strcuture contining the mesh data.
- ocmw.dataproc.otm_extraction.extractMesh(slfFile, enhance=True, meshFile=None, saveMesh=True)[source]¶
Extract model mesh from a Selafin output file
- Parameters:
slfFile (str or slfObj) – Full path and file name of to Selfin file or handle to corresponding Selfin object
enhance (bool, optional) – Toggle to add mesh enhancment data. The default is True.
meshFile (str, optional) – Output mesh file name. The default is None.
saveMesh (bool, optional) – Toggle saving of mesh data to a file. The default is True.
- Returns:
meshData (dict) – Dictionary strcuture contining the mesh data.
- ocmw.dataproc.otm_extraction.extractGeometry(geomFile, enhance=True, saveMesh=False)[source]¶
Extract the model mesh from the OTM Selafin geometry file used to run the model
- Parameters:
- Returns:
meshData (dict) – Dictionary strcuture contining the mesh data.
- ocmw.dataproc.otm_extraction.get2DElevation(vals, wgts, varNames)[source]¶
Get time series of surface elevation at a user defined location
- Parameters:
- Returns:
elev2D (dict) – Dictionary structure contiaining elevation data (nodes and location).
- ocmw.dataproc.otm_extraction.getMultiFileLocElevation(datapath, files, Loc, glbAttrTitle='Model tidal harmonics at XTRACK locations')[source]¶
Gect a multi-file time series of model surface elevation at a user defined location. Used for validation of model against X-Track surface elevation data
- Parameters:
datapath (str) – Path to set of Selafin 2D model output files.
files (list, str) – List of model 2D Selafin files to process.
Loc (list, [float,float]) – Coordinates [x,y] of location elevation calculation.
glbAttrTitle (str, optional) – Title string describing use of time series. The default is ‘Model tidal harmonics at XTRACK locations’.
- Returns:
tsData (dict) – Dictionary structure contain time series of elevation at nodes and location.
- ocmw.dataproc.otm_extraction.extractElevationFrames(filePath, runStr)[source]¶
Extract timeseries of model surface elevation for animation frames.
- ocmw.dataproc.otm_extraction.extractMultiFile2DField(filePath, modStr, startStr, nFiles, varStr, outSuffix=None, saveFile=True)[source]¶
Extract timeseries of 2D model field data for particular model variable.
- ocmw.dataproc.otm_extraction.getVariableData(slfData, slfVarNames, varName)[source]¶
Get variable time series extracted from Selafin file
- ocmw.dataproc.otm_extraction.getLoc2DVars(vals, wgts, varNames)[source]¶
Extract time series for default set of 2D model fields
- Parameters:
- Returns:
vars2D (dict) – Data dictionary containg the interpolated default model 2D fields
- ocmw.dataproc.otm_extraction.getLoc3DVars(vals, wgts, varNames)[source]¶
Extract time series for default set of 3D model fields
- Parameters:
- Returns:
vars3D (dict) – Data dictionary containg the interpolated default model 3D fields
- ocmw.dataproc.otm_extraction.getLocTS(slfHnd, Elem, NNodes, NWghts)[source]¶
Get timeseries of model data for nodes around a location and interpolate onto location
- Parameters:
- Returns:
tsData (dict) – Dictionary structure containing the data at the nodes and requested location.
- ocmw.dataproc.otm_extraction.extract2DLocData(slf2D, Loc)[source]¶
Extract OTM model 2D field data interpolated onto a user defined location
- Parameters:
- Returns:
list – Set of output data. Elem = index of element containing the location NNodes = indices of the corner nodes of the element NWghts = Barycentric weights for interpolation from nodes to location Data2D = dictionary containing the 2D data for the nodes and location
- ocmw.dataproc.otm_extraction.extract3DLocData(slf3D, Loc)[source]¶
Extract OTM 3D field data interpolated onto a user defined location
- Parameters:
- Returns:
list – Set of output data. Elem = index of element containing the location NNodes = indices of the corner nodes of the element NWghts = Barycentric weights for interpolation from nodes to location Data2D = dictionary containing the 2D data for the nodes and location Data3D = dictionary containing the 3D data for the nodes and location
- ocmw.dataproc.otm_extraction.processLocsDataFile(filePath, runStr, locIDs, procStr, locs)[source]¶
Extract OTM model data for a set of user defined locations
- Parameters:
filePath (str) – Path to Selfin files
runStr (str) – Prefix identifying file to be processes i.e. filename excluding “_2D.slf” or “_3D.slf”
locIDs (list, str) – Identifiers used to name extract file for each location.
modelVer (TYPE) – DESCRIPTION.
procStr (TYPE) – DESCRIPTION.
locs (TYPE) – DESCRIPTION.
- Returns:
None.
- ocmw.dataproc.otm_extraction.getTransectPoints(loc01, loc02, dL)[source]¶
Define transect data locations based on start and end points, and spacing
- Parameters:
- Returns:
Locs (numpy.array, [float,float]) – Coordinates of transect data points.
Theta (float) – Direction of transect - mathematical convention.
- ocmw.dataproc.otm_extraction.extract2DTransect(filePath, runStr, tranStr, loc01, loc02, dL, crs)[source]¶
Extract a transect of 2-D data from Selafin file
- Parameters:
- Returns:
Trans_Data (dict) – Data dictionary containing transect data
- ocmw.dataproc.otm_extraction.extract3DTransect(filePath, runStr, tranStr, loc01, loc02, dL, crs)[source]¶
Extract a transect of 3-D data from Selafin file
- Parameters:
- Returns:
Trans_Data (dict) – Data dictionary containing transect data
- ocmw.dataproc.otm_extraction.extractTransect(filePath, runStr, tranStr, loc01, loc02, dL, crs, only2D=False)[source]¶
Extract a transect of 2-D or 3-D data from Selafin file
- Parameters:
filePath (str) – Path to Selfin files
runStr (str) – Prefix identifying file to be processes i.e. filename excluding “_2D.slf” or “_3D.slf”
tranStr (str) – String containing transect description for setting the Global Attributes title.
dL (float) – Transect sample separation in m
only2D (bool, optional) – Toggle to extract only 2D data. The default is False.
- Returns:
Trans_Data (dict) – Data dictionary containing transect data
- ocmw.dataproc.otm_extraction.getVarTimeSeries(slfHnd, nodes, varStr)[source]¶
Extract timeseries of data for a particular model variable a set of model nodes.
- ocmw.dataproc.otm_extraction.getNodesTS(slfHnd, nodes)[source]¶
Extract timeseries of data for a specific model node.
- ocmw.dataproc.otm_extraction.extractNodeTSData(filePath, fileStr, nodes, only2D=False)[source]¶
Extract timeseries of data for a set of model nodes.
- ocmw.dataproc.otm_extraction.processNodeDataFile(filePath, runStr, idStr, procStr, nodes)[source]¶
Extract data from a set of nodes based on user supplied run file.
- ocmw.dataproc.otm_extraction.getMeshNodeLocs(filePath, runStr, setStr=None)[source]¶
Extract mesh node indices and node coordinates from a 2D Selafine file
- Parameters:
filePath (TYPE) – DESCRIPTION.
runStr (TYPE) – DESCRIPTION.
setStr (TYPE, optional) – DESCRIPTION. The default is None.
- Returns:
nnodes (TYPE) – DESCRIPTION.
meshx (TYPE) – DESCRIPTION.
meshy (TYPE) – DESCRIPTION.
- ocmw.dataproc.otm_extraction.processPolygonDataFile(filePath, runStr, idStr, procStr, polygon)[source]¶
Extract data from nodes within a polygon based on user supplied run file.
- ocmw.dataproc.otm_extraction.parseLocsRunFile(fileName)[source]¶
Parser to read run parameters from a configuration file for an extract at user defined locations
- Parameters:
fileName (str) – Full path and file name for run configuration file.
- Returns:
params (dict) – Dicttionary containing the run paramters.
- ocmw.dataproc.otm_extraction.parseNodesRunFile(fileName)[source]¶
Parser to read run parameters from a configuration file for an extract at model nodes
- Parameters:
fileName (str) – Full path and file name for run configuration file.
- Returns:
params (dict) – Dicttionary containing the run paramters.
- ocmw.dataproc.otm_extraction.parseTransectRunFile(fileName)[source]¶
Parser to read run parameters from a configuration file for extract along a trnasect
- Parameters:
fileName (str) – Full path and file name for run configuration file.
- Returns:
params (dict) – Dicttionary containing the run paramters.
- ocmw.dataproc.otm_extraction.parsePolygonRunFile(fileName)[source]¶
Parser to read run parameters from a configuration file for an extract of nodes within a polygon
- Parameters:
fileName (str) – Full path and file name for run configuration file.
- Returns:
params (dict) – Dicttionary containing the run paramters.