ship.fmp.datunits package

Submodules

ship.fmp.datunits.bridgeunit module

Summary:
Contains the BridgeUnit, BridgeUspbrUnit and BridgeArchUnit classed. The BridgeUnit is a superclass to the other containing default shared behaviour and content. These hold all of the data read in from the bridge units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class BridgeUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Subclass of AUnit storing Isis Bridge Unit data.

Note

This really an abstract class for any bridge unit and is not really intended to be used directly.

Contains a reference to a rowdatacollection for storing and accessing all the row data. i.e. the geometry data for the section, containing the chainage, elevation, roughness, etc values. Methods for accessing the data in these objects and adding removing rows are available.

FILE_KEY = None
FILE_KEY2 = None
UNIT_CATEGORY = 'bridge'
UNIT_TYPE = 'bridge'
addRow(row_vals, rowdata_key='main', index=None, **kwargs)[source]

Adds a new row to one of this bridge units row_collection’s.

The new row will be added at the given index. If no index is given it will be appended to the end of the collection.

If no chainage or elevation values are given an AttributeError will be raised as they cannot have default values. All other values can be ommitted. If they are they will be given defaults.

Examples

>>> import ship.fmp.datunits.rdt as rdt
>>> unit.addRow({rdt.CHAINAGE:5.0, rdt.ELEVATION:36.2}, index=4)
Parameters:
  • row_vals (Dict) – keys must be datunits.rdt with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index=None (int) – the row to insert into. The existing row at the given index will be moved up by one.
  • collection_name=None (str) – If None the self.row_collection with the bridges geometry data will be updated. If a string it will be looked for in the self.additional_row_collections dictionary or raise an AttributeError if it doesn’t exist.
Raises:
  • AttributeError – If required values are not given for the rowdata_key collection. See _checkRowKeys().
  • KeyError – if the collection_name does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

area()[source]

Returns the cross sectional area of the bridge openings.

Returns:
Dict - containing the area of the opening(s). keys = ‘total’, then
‘1’, ‘2’, ‘n’ for all openings found.
checkOpening(data_obj, value, index)[source]

Ensures that the bridge opening values are ok.

OPEN_END must be > OPEN_START on the same row. OPEN_START must be > than OPEN_END on a previous row. OPEN_END must be > OPEN_START on a previous row.

Parameters:
  • data_obj (RowDataObj) – to check the values for.
  • value (float) – the new value to check.
  • index (int) – the index the value will be inserted or updated at.
Raises:

ValueError - if value failes tests at index.

getData()[source]

Retrieve the data in this unit.

See also

AUnit - getData()

Returns:String list - output data formated the same as in the .DAT file.
icLabels()[source]
linkLabels()[source]

Overriddes superclass method.

numberOfOpenings()[source]
readUnitData(unit_data, file_line)[source]

Reads the unit data into the geometry objects.

See also

AUnit

Parameters:unit_data (list) – The section of the isis dat file pertaining to this section.
setupRowData()[source]

Setup the main geometry and opening RowCollection’s.

These are used by all BridgeUnits, but they’re added to a method called by the constructor in cases anyone need to override them.

updateRow(row_vals, index, collection_name=None, **kwargs)[source]

Updates the row at the given index in the river units row_collection.

The row will be updated at the given index.

Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index – the row to update.
  • collection_name=None (str) – If None the self.row_collection with the bridges geometry data will be updated. If a string it will be looked for in the self.additional_row_collections dictionary or raise an AttributeError if it doesn’t exist.
Raises:
  • KeyError – If collection_name key does not exist.
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

class BridgeUnitArch(**kwargs)[source]

Bases: ship.fmp.datunits.bridgeunit.BridgeUnit

Concrete implementation of BridgeUnit for USBPR type bridges.

Contains methods that override superclass with USBPR specific variables and file read/write behaviour.

FILE_KEY = 'BRIDGE'
FILE_KEY2 = 'ARCH'
UNIT_CATEGORY = 'bridge'
UNIT_TYPE = 'arch'
class BridgeUnitUsbpr(**kwargs)[source]

Bases: ship.fmp.datunits.bridgeunit.BridgeUnit

Concrete implementation of BridgeUnit for USBPR type bridges.

Contains methods that override superclass with USBPR specific variables and file read/write behaviour.

FILE_KEY = 'BRIDGE'
FILE_KEY2 = 'USBPR1978'
UNIT_CATEGORY = 'bridge'
UNIT_TYPE = 'usbpr'
checkOrifice(data_obj, value, index)[source]

TODO: implement this

logger = <logging.Logger object at 0x06A91610>

logging references with a __name__ set to this module.

ship.fmp.datunits.culvertunit module

Summary:
Contains the Culvert unit type classes. This holds all of the data read in from the culvert units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan Runnacles
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class CulvertUnit[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Class for dealing with Inlet Culvert units in the .dat file.

FILE_KEY = 'CULVERT'
FILE_KEY2 = None
UNIT_CATEGORY = 'culvert'
UNIT_TYPE = 'culvert'
class CulvertUnitInlet(**kwargs)[source]

Bases: ship.fmp.datunits.culvertunit.CulvertUnit

FILE_KEY = 'CULVERT'
FILE_KEY2 = 'INLET'
UNIT_CATEGORY = 'culvert'
UNIT_TYPE = 'culvert_inlet'
getData()[source]

Returns the formatted data for this unit.

See also

isisunit.

Returns:List of strings formatted for writing to the new dat file.
icLabels()[source]

Overriddes superclass method.

readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

See also

isisunit.

Parameters:unit_data (list) – The raw file data to be processed.
class CulvertUnitOutlet[source]

Bases: ship.fmp.datunits.culvertunit.CulvertUnit

CATEGORY = 'culvert'
FILE_KEY = 'CULVERT'
FILE_KEY2 = 'OUTLET'
UNIT_TYPE = 'culvert_outlet'
getData()[source]

Returns the formatted data for this unit.

See also

isisunit.

Returns:List of strings formatted for writing to the new dat file.
icLabels()[source]

Overriddes superclass method.

readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

See also

isisunit.

Parameters:unit_data (list) – The raw file data to be processed.
logger = <logging.Logger object at 0x06AA4350>

logging references with a __name__ set to this module.

ship.fmp.datunits.gisinfounit module

Summary:
Contains the GisInfoUnit, as subclass of isisunit. It’s used to hold the details in the gis section of the dat file which sets up the ixy or gxy files.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

Todo

Not really implemented at the moment - see class TODO.

Updates:

class GisInfoUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

isisunit for storing the GIS info.

Stores the GIS info found at the bottom of .dat file.

Warning

Reads the file by simply parsing until it reaches EOF. This isn’t necessarily the case as there can be information about photos attached to the model below it. Be careful of this.

See also

isisunit

Todo

Actually do something with this class. At the moment it might as well be an UnknownSection.

FILE_KEY = 'GISINFO'
FILE_KEY2 = None
UNIT_CATEGORY = 'gis_info'
UNIT_TYPE = 'gis_info'
getData()[source]
readUnitData(unit_data, file_line)[source]
logger = <logging.Logger object at 0x06A91270>

logging references with a __name__ set to this module.

ship.fmp.datunits.htbdyunit module

Summary:
Contains the HtbdyUnit class. This holds all of the data read in from the HTBDY units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan R.
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class HtbdyUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Concrete implementation of AUnit storing Isis HTBDY Unit data.

Contains a reference to a rowdatacollection for storing and accessing all the row data. i.e. the stage-time data for the section. Methods for accessing the data in these objects and adding removing rows are available.

See also

AUnit

FILE_KEY = 'HTBDY'
FILE_KEY2 = None
UNIT_CATEGORY = 'boundary_ds'
UNIT_TYPE = 'htbdy'
addRow(row_vals, data_key='main', index=None, **kwargs)[source]

Args:

Raises:
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObjects.

See also

ADataObject and subclasses for information on the parameters.

getData()[source]

Retrieve the data in this unit.

The String[] returned is formatted for printing in the fashion of the .dat file.

Returns:list of output data formated the same as in the .DAT file.
icLabels()[source]
readUnitData(unit_data, file_line)[source]

Reads the unit data into the geometry objects.

Parameters:unit_data (list) – The part of the isis dat file pertaining to this section

See also

AUnit - readUnitData()

logger = <logging.Logger object at 0x06AA4650>

logging references with a __name__ set to this module.

ship.fmp.datunits.initialconditionsunit module

Summary:
Contains the InitialConditionsUnit class. This is a holder for all of the data in the initial conditions section of the dat file.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

Todo

Not fully implemented at the moment - see class TODO comment for details.

Updates:

class InitialConditionsUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

isisunit for storing the initial conditions.

Stores the initial conditions data; near the end of the .dat file.

FILE_KEY = 'INITIAL'
FILE_KEY2 = None
UNIT_CATEGORY = 'initial_conditions'
UNIT_TYPE = 'initial_conditions'
addRow(row_vals, unit_type, **kwargs)[source]

Adds a new row to the InitialCondition units row_collection.

The new row will be added at the given index. If no index is given it will be appended to the end of the collection.

If no LABEL value is given a AttributeError will be raised as it cannot have a default value. All other values can be ommitted. If they are they will be given defaults.

Examples

>>> import ship.fmp.datunits.ROW_DATA_TYPES as rdt
>>> ics.addRow({rdt.LABEL:UNITNAME, rdt.STAGE:10.2}, index=4)
Parameters:

row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.

Raises:
  • AttributeError – If LABEL is not given.
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

deleteRowByName(unit_name, unit_type, **kwargs)[source]

Delete one of the RowDataCollection objects in the row_collection.

This calls the AUnit deleteRow method, but obtains the index of the row to be deleted from the name first.

Parameters:section_name (str) – the name of the AUnit to be removed from the initial conditions.
Raises:KeyError - if section_name does not exist.
getData()[source]
node_count
readUnitData(unit_data, file_line, **kwargs)[source]
rowByName(section_name)[source]

Get the data vals in a particular row by name.

This is the same functionality as the AUnit’s getRow(int) method which returns a row in the RowDataCollection by the index value given. In this case it will find the index based on the section label and return the same dictionary of row values.

Parameters:section_name (str) – the name of the AUnit to be removed from the initial conditions.
Returns:dict - containing the values for the requested row.
updateRow(row_vals, index, **kwargs)[source]

Updates the row at the given index in the row_collection.

Changes the state of the values in the initial conditions list of the .dat file at the given index.

Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index – the row to update.
Raises:
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

updateRowByName(row_vals, name, **kwargs)[source]

Updates the row for the entry with the give name.

Changes the state of the values in the initial conditions list for the the .dat file for the unit with the given name.

Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • name – the name of the unit who’s ic’s should be updated.
Raises:
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.
  • AttributeError – If the given name doesn’t exists in the collection.

See also

ADataObject and subclasses for information on the parameters.

ship.fmp.datunits.interpolateunit module

Summary:
Contains the InterpolateUnit class. These hold all of the data read in from the interpolate units in the dat file.
Author:
Duncan Runnacles
Created:
23 July 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class InterpolateUnit[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Class for dealing with Interpolate units in the .dat file.

FILE_KEY = 'INTERPOLATE'
FILE_KEY2 = None
UNIT_CATEGORY = 'interpolate'
UNIT_TYPE = 'interpolate'
getData()[source]

Returns the formatted data for this unit.

See also

isisunit.

Returns:List of strings formatted for writing to the new dat file.
readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

See also

isisunit.

Parameters:unit_data (list) – The raw file data to be processed.
logger = <logging.Logger object at 0x06AA4750>

logging references with a __name__ set to this module.

ship.fmp.datunits.isisunit module

Summary:
Contains the AUnit, CommentUnit, HeaderUnit and UnknownSection classes. The AUnit is an abstract base class for all types of Isis unit read in through the ISIS data file. All section types that are built should inherit from the AUnit baseclass.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class AUnit(**kwargs)[source]

Bases: object

Abstract base class for all Dat file units.

This class must be inherited by all classes representing an isis data file unit (such as River, Junction, Culvert, etc).

Every subclass should override the readUnitData() and getData() methods to ensure they are specific to the setup of the individual units variables. If they are not overridden this class will simply take the data and store it as read and provide it back in the same state.

All calls from the client to these classes should create the object and then call the readUnitData() method with the raw data.

There is an UknownSection class at the bottom of this file that can be used for all parts of the isis dat file that have not had a class defined. It just calls the basic read-in read-out methods from this class and understands nothing about the structure of the file section it is holding.

If you are creating subclass of this that has row_data (see below) you should make sure that you call the setDummyRow() method in each of the RowDataCollections. Otherwise, if the user doesn’t add any rows, FMP will throw errors.

See also

UnknownSection

addRow(row_vals, rowdata_key='main', index=None, **kwargs)[source]

Add a new data row to one of the row data collections.

Provides the basics of a function for adding additional row dat to one of the RowDataCollection’s held by an AUnit type.

Checks that key required variables: ROW_DATA_TYPES.CHAINAGE amd ROW_DATA_TYPES.ELEVATION are in the kwargs and that inserting chainge in the specified location is not negative, unless check_negatie == False.

It then passes the kwargs directly to the RowDataCollection’s addNewRow function. It is the concrete class implementations respnsobility to ensure that these are the expected values for it’s row collection and to set any defaults. If they are not as expected by the RowDataObjectCollection a ValueError will be raised.

**kwargs:
These are passed onto the RowDataCollection. See there for details.
Parameters:
  • row_vals (dict) – Named arguments required for adding a row to the collection. These will be as stipulated by the way that a concrete implementation of this class setup the collection.
  • rowdata_key='main' (str) – the name of the RowDataCollection held by this to add the new row to. If None it is the self.row_collection. Otherwise it is the name of one of the entries in the self.additional_row_collections dictionary.
  • index=None (int) – the index in the RowDataObjectCollection to insert the row into. If None it will be appended to the end.
checkIncreases(data_obj, value, index)[source]

Checks that: prev_value < value < next_value.

If the given value is not greater than the previous value and less than the next value it will return False.

If an index greater than the number of rows in the row_data it will check that it’s greater than previous value and return True if it is.

Note

the ARowDataObject class accepts a callback function called update_callback which is called whenever an item is added or updated. That is how this method is generally used.

Parameters:
  • data_obj (RowDataObject) – containing the values to check against.
  • value (float | int) – the value to check.
  • index=None (int) – index to check ajacent values against. If None it will assume the index is the last on in the list.
Returns:

False if not prev_value < value < next_value. Otherwise True.

copy()[source]

Returns a copy of this unit with it’s own memory allocation.

deleteRow(index, rowdata_key='main', **kwargs)[source]

Removes a data row from the RowDataCollection.

**kwargs:
These are passed onto the RowDataCollection. See there for details.
getData()[source]

Getter for the unit data.

Return the file geometry data formatted ready for saving in the style of an ISIS .dat file

Note

This method should be overriden by the sub class to restore the data to the format required by the dat file.

Returns:List of strings - formatted for writing to .dat file.
has_ics
has_row_data
head_data = None

Dictionary containing set values that are always present in the file.

In a RiverUnit this includes values like slope and distance. I.e. values that appear in set locations, usually at the top of the unit data in the .dat file.

icLabels()[source]

Returns the initial_conditions values for this object.

This method should be overriden by all classes that contain intial conditions.

For example a BridgeUnit type will have two initial conditions labels; the upstream and downstream label names.

By default this will return an empty list.

Returns:list - of intial condition label names.
linkLabels()[source]

Dict of all the names that the unit references.

For a RiverUnit this is only the self.name + spills and laterals, for a bridge it would be self.name, self.name_ds, self.remote_us, self.remote_ds and for a JunctionUnit it could be many more. It can be used to identify which other units are directly associated to this one in some way.

Returns:dict - containing all referenced names.
name
name_ds
readUnitData(data, file_line, **kwargs)[source]

Reads the unit data supplied to the object.

This method is called by the FmpUnitFactory class when constructing the Isis unit based on the data passed in from the dat file. The default hook just copies all the data parsed in the buildUnit() method of the factory and aves it to the given unit. This is exactly what happens for the UnknownUnit class that just maintains a copy of the unit data exactly as it was read in.

Parameters:data (list) – raw data for the section as supplied to the class.

Note

When a class inherits from AUnit it should override this method with unit specific load behaviour. This is likely to include: populate unit specific header value dictionary and in some units creating row data object.

See also

RiverSection for an example of overriding this method with a
concrete class.
row(index, rowdata_key='main')[source]

Get the data vals in a particular row by index.

Parameters:index (int) – the index of the row to return.
Returns:dict - containing the values for the requested row.
rowDataObject(key, rowdata_key='main')[source]

Returns the row data object as a list.

This will return the row_collection data object referenced by the key provided in list form.

If you intend to update the values you should use getRowDataObject instead as the data provided will be mutable and therefore reflected in the values held by the row_collection. If you just want a quick way to loop through the values in one of the data objects and only intend to read the data then use this.

Parameters:
  • key (int) – the key for the data object requested. It is best to use the class constants (i.e. RiverUnit.CHAINAGE) for this.
  • rowdata_key (str) – key to a RowDataCollection in row_data.
Returns:

List containing the data in the DataObject that the key points

to. Returns false if there is no row collection.

Raises:

KeyError – If key or rowdata_key don’t exist.

row_data = None

Collection containing all of the ADataRow objects.

This is the main collection for row data in any unit that contains it. In a RiverUnit, for example, this will hold the RowDataObject’s containing the CHAINAGE, ELEVATION, etc.

unit_category
unit_type
updateRow(row_vals, index, rowdata_key='main', **kwargs)[source]

Update an existing data row in one of the RowDataCollection’s.

**kwargs:
These are passed onto the RowDataCollection. See there for details.
Parameters:
  • row_vals (dict) – Named arguments required for adding a row to the collection. These will be as stipulated by the way that a concrete implementation of this class setup the collection.
  • rowdata_key='main' (str) – the name of the RowDataCollection held by this to add the new row to. If None it is the self.row_collection. Otherwise it is the name of one of the entries in the self.additional_row_collections dictionary.
  • index=None (int) – the index in the RowDataObjectCollection to update with the row_vals
class CommentUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Holds the data in COMMENT sections of the .dat file.

This is very similar to the UnknownSection in that all it does is grab the data between the comment tags and save it. It then prints out the same data in the same format with the COMMENT tags around it.

FILE_KEY = 'COMMENT'
FILE_KEY2 = None
UNIT_CATEGORY = 'meta'
UNIT_TYPE = 'comment'
addCommentText(text)[source]
getData()[source]
readUnitData(data, file_line)[source]
class HeaderUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

This class deals with the data file values at the top of the file.

These contain the global variables for the model such as water temperature, key matrix coefficients and the total number of nodes.

There is only ever one of these units in every dat file - at the very top - so it seems convenient to put it in this module.

FILE_KEY = 'HEADER'
FILE_KEY2 = None
UNIT_CATEGORY = 'meta'
UNIT_TYPE = 'header'
getData()[source]

Getter for the formatted data to write back to the .dat file.

Returns:List - data formatted for writing to the new dat file.
readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

Parameters:unit_data (list) – The raw file data to be processed.
class UnknownUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Catch all section for unknown parts of the .dat file.

This can be used for all sections of the isis dat file that have not had a unit class constructed.

It has no knowledge of the file section that it contains and will store it without altering it’s state and return it in exactly the same format that it received it.

This class is designed to be a fall-back class for any parts of the dat file for which it is deemed unnecessary to deal with more carefully.

It has a ‘Section’ suffix rather that ‘Unit’ which is the naming convention for the other unit objects because it is not necessarily a single unit. It could be many different units.

It is created whenever the DatLoader finds parts of the dat file that it doesn’t Know how to load (i.e. there is no *Unit defined for it. It will then put all the dat file data in one of these until it reaches a part of the file that it does recognise.

FILE_KEY = 'UNKNOWN'
FILE_KEY2 = None
getData()[source]
readUnitData(data)[source]
logger = <logging.Logger object at 0x06A78BF0>

logging references with a __name__ set to this module.

ship.fmp.datunits.junctionunit module

Summary:
Contains the JuntionUnit type classes. This holds all of the data read in from the junction units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan Runnacles
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class JunctionUnit[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Class for dealing with Junction units in the .dat file.

FILE_KEY = 'JUNCTION'
FILE_KEY2 = None
UNIT_CATEGORY = 'junction'
UNIT_TYPE = 'junction'
getData()[source]

Returns the formatted data for this unit.

See also

isisunit.

Returns:List of strings formatted for writing to the new dat file.
icLabels()[source]

Overriddes superclass method.

linkLabels()[source]

Overriddes superclass method.

name
readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

See also

isisunit.

Parameters:unit_data (list) – The raw file data to be processed.
logger = <logging.Logger object at 0x06A7AFD0>

logging references with a __name__ set to this module.

ship.fmp.datunits.orificeunit module

Summary:

Contains the OrificeUnit type classes. This holds all of the data read in from the orifice units in the dat file. Can be called to load in the data and read and update the contents held in the object.

The OutfallUnit is also in here. It has the same setup as the OrificeUnit so it subclasses orifice.

Author:
Duncan Runnacles
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class FloodReliefUnit(**kwargs)[source]

Bases: ship.fmp.datunits.orificeunit.OrificeUnit

Class for dealing with flood relief arch units in the .dat file.

Subclasses the orifice unit because they are essentially the same as far as the .dat file setup goes.

CATEGORY = 'orifice'
FILE_KEY = 'FLOOD RELIEF'
FILE_KEY2 = None
UNIT_TYPE = 'flood_relief'
class OrificeUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Class for dealing with Orifice units in the .dat file.

FILE_KEY = 'ORIFICE'
FILE_KEY2 = None
UNIT_CATEGORY = 'orifice'
UNIT_TYPE = 'orifice'
getData()[source]

Returns the formatted data for this unit.

See also

isisunit.

Returns:List of strings formatted for writing to the new dat file.
icLabels()[source]

Overriddes superclass method.

linkLabels()[source]

Overriddes superclass method.

readUnitData(unit_data, file_line)[source]

Reads the given data into the object.

See also

isisunit.

Parameters:unit_data (list) – The raw file data to be processed.
class OutfallUnit(**kwargs)[source]

Bases: ship.fmp.datunits.orificeunit.OrificeUnit

Class for dealing with Outfall units in the .dat file.

Subclasses the orifice unit because they are essentially the same as far as the .dat file setup goes.

FILE_KEY = 'OUTFALL'
FILE_KEY2 = None
UNIT_CATEGORY = 'orifice'
UNIT_TYPE = 'outfall'
logger = <logging.Logger object at 0x06AA4070>

logging references with a __name__ set to this module.

ship.fmp.datunits.refhunit module

Summary:
Contains the Refh class. This holds all of the data read in from the refh units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class RefhUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Concrete implementation of AUnit storing Isis River Unit data.

Contains a reference to a rowdatacollection for storing and accessing all the row data. i.e. the geometry data for the section, containing the chainage, elevation, roughness, etc values.

Methods for accessing the data in these objects and adding removing rows are available.

See also

AUnit

FILE_KEY = 'REFHBDY'
FILE_KEY2 = None
UNIT_CATEGORY = 'inflows'
UNIT_TYPE = 'refh'
getData()[source]

Retrieve the data in this unit.

The String[] returned is formatted for printing in the fashion of the .dat file.

Returns:List of strings formated for writing to .dat file.
readUnitData(unit_data, file_line)[source]

Reads the unit data into the geometry objects.

See also

AUnit - readUnitData for more information.

Parameters:unit_data (list) – The section of the isis dat file pertaining to this section
logger = <logging.Logger object at 0x06A91E30>

logging references with a __name__ set to this module.

ship.fmp.datunits.riverunit module

Summary:
Contains the RiverUnit class. This holds all of the data read in from the river units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan Runnacles
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class RiverUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Concrete implementation of AUnit storing Isis River Unit data.

Contains a reference to a rowdatacollection for storing and accessing all the row data. i.e. the geometry data for the section, containing the chainage, elevation, roughness, etc values.

Methods for accessing the data in these objects and adding removing rows are available.

See also

AUnit

FILE_KEY = 'RIVER'
FILE_KEY2 = 'SECTION'
UNIT_CATEGORY = 'river'
UNIT_TYPE = 'river'
addRow(row_vals, index=None, **kwargs)[source]

Adds a new row to the river units row_data.

The new row will be added at the given index. If no index is given it will be appended to the end of the collection.

If no chainage or elevation values are given a AttributeError will be raised as they cannot have default values. All other values can be ommitted. If they are they will be given defaults.

Examples

>>> import ship.fmp.datunits.ROW_DATA_TYPES as rdt
>>> river_unit.addDataRow({rdt.CHAINAGE:5.0, rdt.ELEVATION:36.2}, index=4)
Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index=None (int) – the row to insert into. The existing row at the given index will be moved up by one.
Raises:
  • AttributeError – If CHAINAGE or ELEVATION are not given.
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

getData()[source]

Retrieve the data in this unit.

The String[] returned is formatted for printing in the fashion of the .dat file.

Returns:List of strings formated for writing to .dat file.
head_data = None

Add the new row data types to the object collection All of them must have type, output format, and position in the row all other arguments are excepted as **kwargs.

icLabels()[source]

Overriddes superclass method.

linkLabels()[source]

Overriddes superclass method.

readUnitData(unit_data, file_line)[source]

Reads the unit data into the geometry objects.

See also

AUnit - readUnitData for more information.

Parameters:unit_data (list) – The section of the isis dat file pertaining to this section
updateRow(row_vals, index, **kwargs)[source]

Updates the row at the given index in the river units row_data.

The row will be updated at the given index.

Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index – the row to update.
Raises:
  • AttributeError – If CHAINAGE or ELEVATION are not given.
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObject’s.

See also

ADataObject and subclasses for information on the parameters.

logger = <logging.Logger object at 0x06A7AE10>

logging references with a __name__ set to this module.

ship.fmp.datunits.spillunit module

Summary:
Contains the SpillUnit class. This holds all of the data read in from the spill units in the dat file. Can be called to load in the data and read and update the contents held in the object.
Author:
Duncan R.
Created:
01 Apr 2016
Copyright:
Duncan Runnacles 2016

TODO:

Updates:

class SpillUnit(**kwargs)[source]

Bases: ship.fmp.datunits.isisunit.AUnit

Concrete implementation of AUnit storing Isis Spill Unit data.

Contains a reference to a rowdatacollection for storing and accessing all the row data. i.e. the geometry data for the section, containing the chainage, elevation, etc values. Methods for accessing the data in these objects and adding removing rows are available.

See also

AUnit

FILE_KEY = 'SPILL'
FILE_KEY2 = None
UNIT_CATEGORY = 'spill'
UNIT_TYPE = 'spill'
addRow(row_vals, rowdata_key='main', index=None, **kwargs)[source]

Adds a new row to the spill unit.

Ensures that certain requirements of the data rows, such as the chainage needing to increase for each row down are met, then call the addNewRow() method in the row_collection.

Parameters:
  • row_vals (Dict) – keys must be datunits.ROW_DATA_TYPES with a legal value assigned for the DataType. Chainage and Elevation MUST be included.
  • index=None (int) – the row to insert into. The existing row at the given index will be moved up by one.
Returns:

False if the addNewRow() method is unsuccessful.

Raises:
  • IndexError – If the index does not exist.
  • ValueError – If the given value is not accepted by the DataObjects.

See also

ADataObject and subclasses for information on the parameters.

getData()[source]

Retrieve the data in this unit.

The String[] returned is formatted for printing in the fashion of the .dat file.

Returns:list of output data formated the same as in the .DAT file.
icLabels()[source]
linkLabels()[source]

Overriddes superclass method.

readUnitData(unit_data, file_line)[source]

Reads the unit data into the geometry objects.

Parameters:unit_data (list) – The part of the isis dat file pertaining to this section

See also

AUnit - readUnitData()

logger = <logging.Logger object at 0x06A7A9D0>

logging references with a __name__ set to this module.

Module contents