Tools

MIKE+Py provides access to several MIKE+ data processing tools through the mikepluspy.tools module. These tools allow you to perform common data manipulation and preparation tasks programmatically.

Available Tools

The following tools are available:

  • ImportTool: Imports data into your MIKE+ model using an XML configuration file.
  • TopoRepairTool: Detects and repairs common topology issues in your network model.
  • InterpolationTool: Interpolates and assigns attribute values between model features or from external data sources (e.g., DEMs).
  • ConnectionRepairTool: Repairs network connectivity issues.
  • CatchSlopeLengthProcess: Calculates catchment slope and length. (Note: The class name in the library might be CathSlopeLengthProcess).

General Usage

To use a tool, first import it from mikepluspy.tools. Then, create an instance of the tool, passing your opened Database object to its constructor.

from mikepluspy.tools import InterpolationTool
# Assuming 'db' is your opened mikepluspy.Database object
interpolation_tool = InterpolationTool(db)

Once you have a tool instance, you can call its methods to perform specific actions.

Examples

Here are a couple of examples to illustrate how to use these tools.

Import Tool

The ImportTool can import data into your MIKE+ model using an XML configuration file. For instance, to import data from an XML file:

from mikepluspy.tools import ImportTool

import_tool = ImportTool("path/to/your/xml/file.xml", db)
import_tool.run()

InterpolationTool

The InterpolationTool can assign values to features based on proximity or DEM data. For instance, to interpolate the GroundLevel for nodes in the msm_Node table from a DEM file:

# interpolation_tool = InterpolationTool(db) # Instantiated as above
tool_parameters = {
    "target_Db_Name": "msm_Node",
    "target_attribute": "GroundLevel",
    "raster_file": "path/to/your/dem.dfs2", # Replace with actual path
    "item_number": 1
}
interpolation_tool.interpolate_from_DEM(**tool_parameters)

TopoRepairTool

The TopoRepairTool helps clean up network topology. To delete unlinked nodes and dissolve overlapping nodes, you can use its run method:

from mikepluspy.tools import TopoRepairTool
# repair_tool = TopoRepairTool(db) # Instantiate with your db object
repair_tool.run(
    delete_unLink_node_Link=True, 
    dissolve_overlap_node=True
)

Further Information

For detailed information on all available parameters and methods for each tool, please consult the MIKE+ software documentation or the specific API reference for mikepluspy.