ocmw.dataproc.otm_vectorfield module

Functions for extracting velocity, velocity gradient, and vorticity 2D fields from Open Telemac-Mascret model output.

initialiseVectorField

Get Selafin structure data to set parameters for the vector field data

getVariableAtNodes

Get timeseries of data for the requested nodes and field variable

getVariablesAtTime

Get variable data for all mesh nodes at the requested time step

vectorFieldAtLocation

Get the 2-D vector field data at a specifc geospatial location

characteriseAtNode

Calculate a timeseries of characteristic parameters for a given model node

getVelocityField

Generate a series of single time 2D velocity field data for animations

frameSetIndices

Get subset of time steps for batch process generation of animation frames from 2D model fields.

getCirculationField

Generate a series of single time 2D circulation data files for animations.

mergeCirculationFrames

Merge a set of circulation data frames into a single data strcuture.

processNodeSet

Calculate field gradients and vorticty for a set of nodes in a batch process and save to a set file for merging.

processNodesInPolygon

Calculate field gradients and vorticty at nodes inside a polygon and save to an OCMW format output file.

processLocation

Calculate dynamic parameters for a specifc geospatial location

Functions for extracting velocity, velocity gradient, and vorticity 2D fields from Open Telemac-Mascret model output.

Chris Old IES, School of Engineering, University of Edinburgh Sep 2023

ocmw.dataproc.otm_vectorfield.initialiseVectorField(slf)[source]

Get Selafin structure data to set parameters for the vector field data

Parameters:

slf (Selafin obj) – Selafin file handle.

Returns:

  • times (numpy.ndarray, float) – Timestamp as an offset in seconds from idate.

  • idate (numpy.ndarray, int32) – Start time as an array of integers [year,month,day,hour,minute,second].

  • nsteps (int) – Number of time steps in file.

  • nnodes (int) – Number of mesh nodes.

  • meshx (numpy.ndarray, float) – X coordinate of mesh node locations.

  • meshy (numpy.ndarray, float) – Y coordinate of mesh node locations.

  • elems (numpy.ndarray, int32) – Indices of nodes that define each mesh triangular element.

  • edges (numpy.ndarray, int32) – Indices of node that define every element edge.

ocmw.dataproc.otm_vectorfield.getVariableAtNodes(slf, nodes, varIndex)[source]

Get timeseries of data for the requested nodes and field variable

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • nodes (numpy.ndarray, int) – Indices of nodes to be processed.

  • varIndex (int) – Index of OTM variable in Selafin data structure.

Returns:

var (numpy.ndarray) – Array containing variable timeseries for all requested nodes.

ocmw.dataproc.otm_vectorfield.getVariablesAtTime(slf, frame, varIndex)[source]

Get variable data for all mesh nodes at the requested time step

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • frame (int) – Index of the required model time step.

  • varIndex (int) – Index of OTM variable in Selafin data structure.

Returns:

vars (numpy.ndarray, float) – Array of variable data for requested time step.

ocmw.dataproc.otm_vectorfield.vectorFieldAtLocation(slf, Loc, d_off=0.0)[source]

Get the 2-D vector field data at a specifc geospatial location

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • Loc (list, float) – Geospatial coordinates of location [x,y].

  • d_off (float, optional) – Mean sea level correction if used in model configuration. The default is 0.0.

Returns:

vect (dict) – Dictionary strcutre containing the vector field data at the location.

ocmw.dataproc.otm_vectorfield.characteriseAtNode(slf, node)[source]

Calculate a timeseries of characteristic parameters for a given model node

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • node (int) – Node index.

Returns:

vect (dict) – Dictionary structure containing timeseries of characteristic parameter at the node requested.

ocmw.dataproc.otm_vectorfield.getVelocityField(slfHnd, mesh, dispFreq=5000)[source]

Generate a series of single time 2D velocity field data for animations

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • mesh (dict) – Dictionary structure containing enhanced mesh

  • dispFreq (float, optional) – How often to display cell processing progress. The default is 5000.

Returns:

fname (str) – Name of model output file processed.

ocmw.dataproc.otm_vectorfield.frameSetIndices(nFrames, nCores, setNum)[source]

Get subset of time steps for batch process generation of animation frames from 2D model fields.

Parameters:
  • nFrames (int) – Number of frames in 2D Selafin file.

  • nCores (int) – Number of cores to spread processing across.

  • setNum (int) – Sube set to get incides for.

Returns:

frameSet (list) – Time stpe indices for frames to be generated.

ocmw.dataproc.otm_vectorfield.getCirculationField(slfHnd, mesh, tsteps=[], dispFreq=5000)[source]

Generate a series of single time 2D circulation data files for animations.

Parameters:
  • slf (Selfin obj) – Handle to the Selafin file being processed.

  • mesh (dict) – Dictionary structure containing enhanced mesh

  • dispFreq (float, optional) – How often to display cell processing progress. The default is 5000.

Returns:

fname (str) – Name of model output file processed.

ocmw.dataproc.otm_vectorfield.mergeCirculationFrames(dataPath, fileList)[source]

Merge a set of circulation data frames into a single data strcuture.

Parameters:
  • dataPath (str) – Path to location of files to be merged.

  • fileList (list, str) – List of file names for the files to be merged.

Returns:

circ_frames (dict) – Dictionary data strcutre containing the merged data frames.

ocmw.dataproc.otm_vectorfield.processNodeSet(fPath, fName, nCores=1, setNum=0)[source]

Calculate field gradients and vorticty for a set of nodes in a batch process and save to a set file for merging.

Parameters:
  • fPath (str) – DESCRIPTION.

  • fName (str) – Name of Selafin file containing 2D field data.

  • nCores (int, optional) – Number of cores to split processing across. The default is 1.

  • setNum (int, optional) – Index of batch processing set. The default is 0.

Returns:

None.

ocmw.dataproc.otm_vectorfield.processNodesInPolygon(fPath, fName, polygon)[source]

Calculate field gradients and vorticty at nodes inside a polygon and save to an OCMW format output file.

Parameters:
  • fPath (str) – DESCRIPTION.

  • fName (str) – Name of Selafin file containing 2D field data.

  • polygon (list, float) – List of coordinates for vertices of the polygon [[x,y],[x,y],…].

Returns:

None.

ocmw.dataproc.otm_vectorfield.processLocation(filePath, runStr, suffix, Loc, depthOffset: float = 0.0, modelVer=None, saveData=False)[source]

Calculate dynamic parameters for a specifc geospatial location

Parameters:
  • filePath (str) – File path to Selfin file containing 2D fields.

  • runStr (str) – Selfin file with out “_2D.slf”.

  • suffix (str) – Identifier string for location.

  • Loc (list, float) – Coordinates of the geospatial location [x,y].

  • depthOffset (float, optional) – Mean sea level correction used in model configuration. The default is 0.0.

  • modelVer (int, optional) – Model version number. The default is None.

  • saveData (bool, optional) – Toggle for activating saving data to a file. The default is False.

Returns:

vect (dict) – Dictionary structure containing the parameters at the requested location.