fastwater.otm_gpl.selafin module

Contains the class Selafin

class fastwater.otm_gpl.selafin.Selafin(file_name)[source]

Bases: object

(DOXYGEN parsing) Class Selafin

@brief

Read and create Selafin files with python

@details

The idea is to be able to set float_type and float_type_size from outside when we start to write a selafinfiles. This will make it possible to do some kind of converters

@history
  • switch between big/little endian

  • switch to double precission only for float

@TODO
  • changes where only tested for simple reading, writing must still be done

  • get_series was not tested

  • all appen and put functions must be tested

  • needs some intensive testing

Intialisation of the class

@param file_name (string) Name of the file

alter_endian()[source]

Alter Endian for the file

alter_float()[source]

Alter the precision for float

alter_values(vrs=None, m_z=1, p_z=0)[source]

Set alter values

append_core_time_slf(time)[source]

Write time value

@param time (float) Time value

append_core_vars_slf(varsor)[source]

Write variable informations

@param varsor (list) List of value for each variable

append_header_slf()[source]

Write the header part of the file

datetime = array([1972,    7,   13,   17,   24,   27])
get_header_floats_slf()[source]

Reads the mesh coordinates

get_header_integers_slf()[source]

Reads nelem, npoin, ndp3, nplan, ikle and ipobo

get_header_metadata_slf()[source]

Reads title, variable names and units, date and time

get_series(nodes, vars_indexes=None, showbar=True)[source]

Return the value for a list of nodes on variables given in vars_indexes for each time step

@param nodes (list) list of nodes for which to extract data @param vars_indexes (list) List of variables to extract data for @param showbar (boolean) If True display a showbar for the progress

get_time_history_slf()[source]

Reads all result values

get_values(time)[source]

Get values for all variables for a give time step If alter_values were set it applies modification

get_variables_at(frame, vars_indexes)[source]

Get values for a given time step and a list of variables

@param frame (int) Time step to extract @param vars_indexes (list) List of variable indices

@return (np.array) array containg the values for each variable

put_content(file_name, showbar=True)[source]

Write content of the object into a Serafin file

@param file_name (string) Name of the serafin file @param showbar (boolean) If True displays a showbar

set_kd_tree(reset=False)[source]

Builds a KDTree (impoves search of neighbors)

@param reset (boolean) Force reset of tree

set_mpl_tri(reset=False)[source]

Build neighbours from matplotlib

@param reset (boolean) Force computing neighbours