5. Configuration Overview
In this section we outline the standard structure for the configuration file used as the starting point for generating an environmental mesh using the MeshiPhi software package. These configuration files are written in JSON, can be passed to MeshiPhi as command-line arguments or through a Python interpreter.
Example configuration files are provided in the examples/environment_config/
directory on GitHub.
Descriptions of the configuration options for the Mesh Construction can be found in the Configuration - Mesh Construction section of the documentation.
5.2. Config Validation
The configs supplied by the user are validated using a template JSON Schema. This schema checks that the correct keywords and datatypes are provided in the config JSON file. They also perform rudimentary checks on the values within the config to ensure that they make sense (e.g. start_time is before end_time).
- meshiphi.config_validation.config_validator.flexi_json_input(config)
Allows flexible inputs. If a string is parsed, then assume it’s a file path and read in as a json. If a dict is parsed, then assume it’s already a valid loaded json, and return it as is
- Parameters:
config (str or dict) – Input to translate into a dict.
- Raises:
TypeError – If input is neither a str nor a dict, then wrong input type
- Returns:
Dictionary read from JSON
- Return type:
dict
- meshiphi.config_validation.config_validator.validate_mesh_config(config)
Validates a mesh config
- Parameters:
config (str or dict) – Mesh config to be validated. If type ‘str’, tries to read in as a filename and open file as json If type ‘dict’, assumes it’s already read in from a json file
- Raises:
TypeError – Incorrect config parsed in. Must be ‘str’ or ‘dict’
FileNotFoundError – Could not read in file if ‘str’ parsed
ValidationError – Malformed mesh config
- meshiphi.config_validation.config_validator.validate_route_config(config)
Validates a route config
- Parameters:
config (str or dict) – route config to be validated. If type ‘str’, tries to read in as a filename and open file as json If type ‘dict’, assumes it’s already read in from a json file
- Raises:
TypeError – Incorrect config parsed in. Must be ‘str’ or ‘dict’
FileNotFoundError – Could not read in file if ‘str’ parsed
ValidationError – Malformed route config
- meshiphi.config_validation.config_validator.validate_vessel_config(config)
Validates a vessel config
- Parameters:
config (str or dict) – Vessel config to be validated. If type ‘str’, tries to read in as a filename and open file as json If type ‘dict’, assumes it’s already read in from a json file
- Raises:
TypeError – Incorrect config parsed in. Must be ‘str’ or ‘dict’
FileNotFoundError – Could not read in file if ‘str’ parsed
ValidationError – Malformed vessel config
- meshiphi.config_validation.config_validator.validate_waypoints(waypoints)
_summary_
- Parameters:
waypoints (str or pd.DataFrame) – _description_
- Raises:
TypeError – Incorrect config parsed in. Must be ‘str’ or ‘pd.DataFrame’
FileNotFoundError – Could not read in file if ‘str’ parsed
AssertionError – Malformed waypoints config