LSDTopoTools
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Protected Attributes | List of all members
LSDParameterParser Class Reference

Object to perform flow routing. More...

#include <LSDParameterParser.hpp>

Public Member Functions

 LSDParameterParser ()
 The create function. This is default and throws an warning. More...
 
 LSDParameterParser (string PathName, string FileName)
 Creates a LSDParamParser object using a path and filename. More...
 
void LSDPP_parse_line (ifstream &infile, string &parameter, string &value)
 This is the function for reading parameters @ detail It is identical to the parse_line function in LSDStatsTools but has a bigger buffer to cope with long path names. More...
 
void LSDPP_parse_file_into_parameter_map (string FullName)
 This takes a parameter file and parses all the parameters into a map with string keys and values. Further functions are used to convert these into the appropriate data types. More...
 
void parse_file_IO ()
 This parses all the required information for File I/O You need to get the parameter map first. More...
 
void force_parse ()
 This forces parsing of all the parameters into strings It is used for copying parameter files. More...
 
void parse_all_parameters (map< string, float > default_map_f, map< string, int > default_map_i, map< string, bool > default_map_b, map< string, string > default_map_s)
 This parses all of the defalt parameter maps. More...
 
void parse_all_parameters (map< string, float > default_map_f, map< string, int > default_map_i, map< string, bool > default_map_b, map< string, string > default_map_s, map< string, double > default_map_d)
 This parses all of the defalt parameter maps Overloaded to include doubles. More...
 
void parse_float_parameters (map< string, float > default_map)
 This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file. More...
 
void parse_int_parameters (map< string, int > default_map)
 This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file. More...
 
void parse_bool_parameters (map< string, bool > default_map)
 This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file. More...
 
void parse_string_parameters (map< string, string > default_map)
 This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file. More...
 
void parse_double_parameters (map< string, double > default_map)
 This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file. More...
 
vector< string > parse_string_vector (string key)
 This function takes a parameter from the string map and parses it into a vector of strings. More...
 
vector< int > parse_int_vector (string key)
 This function takes a parameter from the string map and parses it into a vector of ints. More...
 
vector< float > parse_float_vector (string key)
 This function takes a parameter from the string map and parses it into a vector of floats. More...
 
void force_bil_extension ()
 This forces the read and write extensions to bil. More...
 
string get_dem_read_extension () const
 
string get_dem_write_extension () const
 
string get_write_path () const
 
string get_read_path () const
 
string get_write_fname () const
 
string get_read_fname () const
 
string get_CHeads_file () const
 
string get_BaselevelJunctions_file () const
 
string get_ChannelSegments_file () const
 
string get_Floodplain_file () const
 
vector< string > get_boundary_conditions () const
 
map< string, float > get_float_parameters () const
 
map< string, int > get_int_parameters () const
 
map< string, bool > get_bool_parameters () const
 
map< string, string > get_string_parameters () const
 
map< string, double > get_double_parameters () const
 
void set_read_fname (string new_read_fname)
 set the read_fname parameter with a string More...
 
void set_write_fname (string new_write_fname)
 set the read_fname parameter with a string More...
 
void check_boundary_conditions ()
 This checks to see if boundary condtions have been assigned and if not defaults to no flux boundaries. More...
 
void check_file_extensions_and_paths ()
 This check to see if the filenames, paths and extensions have been assigned. If not it changes these to defaults. More...
 
string get_string_before_dot (string this_string)
 this returns the string before the last dot in a string. so for example if you gave it paramfile.param it would return paramfile More...
 
void print_parameters ()
 This prints your parameters to file so you can check if the parameters have been ingested properly. More...
 
void print_parameters (string fname_prefix)
 This prints your parameters to file so you can check if the parameters have been ingested properly. You tell it what the file is called. More...
 
void replace_and_print_parameter_file (string parameter_fname, string new_read_path, string new_read_fname, string new_write_path, string new_write_fname, map< string, string > replace_parameters)
 This is used to update a parameter file within LSDTopoTools and is primarily intended to be used in spawning operations, e.g. where you select a bunch of catchemetns and create driver functions for each one that can be run on different CPUs. More...
 

Protected Attributes

string param_file_path
 The path to the parameter file (used if no read or wirte path is supplied)
 
string param_fname
 The path to the parameter file (used if no read or wirte path is supplied)
 
string dem_read_extension
 The exteniosn of the rasters; either bil, asc or flt.
 
string dem_write_extension
 The exteniosn of the rasters; either bil, asc or flt.
 
string write_path
 Path to which files will be written.
 
string read_path
 Path from which files will be written.
 
string write_fname
 Prefix of files to be written (i.e., no path, no extension)
 
string read_fname
 Prefix of files to be read (i.e., no path, no extension)
 
string CHeads_file
 The prefix of the channelheads filename.
 
string BaselevelJunctions_file
 The prefix of the baselevel junctions filename.
 
string ChannelSegments_file
 The prefix of the channel segments filename.
 
string Floodplain_file
 The prefix of the floodplain mask filename.
 
vector< string > boundary_conditions
 the four boundary conditions on the raster for the flow info object
 
map< string, string > parameter_map
 
map< string, string > defaults_used_map
 
map< string, string > parameters_read_map
 
map< string, float > float_parameters
 This holds float parameters.
 
map< string, int > int_parameters
 This holds integer parameters.
 
map< string, string > string_parameters
 This holds string parameters.
 
map< string, bool > bool_parameters
 This holds bool parameters.
 
map< string, double > double_parameters
 This holds double parameters.
 

Detailed Description

Object to perform flow routing.

Constructor & Destructor Documentation

LSDParameterParser::LSDParameterParser ( )
inline

The create function. This is default and throws an warning.

Author
SMM
Date
11/02/16
LSDParameterParser::LSDParameterParser ( string  PathName,
string  FileName 
)
inline

Creates a LSDParamParser object using a path and filename.

Parameters
PathNamethe name of the path
FileNamethe name of the parameter file
Author
SMM
Date
3/07/2015

Member Function Documentation

void LSDParameterParser::check_boundary_conditions ( )

This checks to see if boundary condtions have been assigned and if not defaults to no flux boundaries.

Author
SMM
Date
02/11/2016
void LSDParameterParser::check_file_extensions_and_paths ( )

This check to see if the filenames, paths and extensions have been assigned. If not it changes these to defaults.

Author
SMM
Date
02/11/2016
void LSDParameterParser::force_bil_extension ( )

This forces the read and write extensions to bil.

Author
SMM
Date
02/11/16
void LSDParameterParser::force_parse ( )

This forces parsing of all the parameters into strings It is used for copying parameter files.

Author
SMM
Date
16/03/2017
string LSDParameterParser::get_BaselevelJunctions_file ( ) const
inline
Returns
BaseLevelJunctions_file
map<string,bool> LSDParameterParser::get_bool_parameters ( ) const
inline
Returns
the float parameters
vector<string> LSDParameterParser::get_boundary_conditions ( ) const
inline
Returns
the boundary conditions
string LSDParameterParser::get_ChannelSegments_file ( ) const
inline
Returns
ChannelSegments_file
string LSDParameterParser::get_CHeads_file ( ) const
inline
Returns
CHeads_file
string LSDParameterParser::get_dem_read_extension ( ) const
inline
Returns
read_extension
string LSDParameterParser::get_dem_write_extension ( ) const
inline
Returns
write_extension
map<string,double> LSDParameterParser::get_double_parameters ( ) const
inline
Returns
the double parameters
map<string,float> LSDParameterParser::get_float_parameters ( ) const
inline
Returns
the float parameters
string LSDParameterParser::get_Floodplain_file ( ) const
inline
Returns
Floodplain_file
map<string,int> LSDParameterParser::get_int_parameters ( ) const
inline
Returns
the float parameters
string LSDParameterParser::get_read_fname ( ) const
inline
Returns
read_fname
string LSDParameterParser::get_read_path ( ) const
inline
Returns
read_path
string LSDParameterParser::get_string_before_dot ( string  this_string)

this returns the string before the last dot in a string. so for example if you gave it paramfile.param it would return paramfile

Parameters
this_stringthe string you want truncated
Returns
the truncated string
Author
SMM
Date
29/07/2014
map<string,string> LSDParameterParser::get_string_parameters ( ) const
inline
Returns
the float parameters
string LSDParameterParser::get_write_fname ( ) const
inline
Returns
write_fname
string LSDParameterParser::get_write_path ( ) const
inline
Returns
write_path
void LSDParameterParser::LSDPP_parse_file_into_parameter_map ( string  FullName)

This takes a parameter file and parses all the parameters into a map with string keys and values. Further functions are used to convert these into the appropriate data types.

Author
SMM
Date
03/11/2016
void LSDParameterParser::LSDPP_parse_line ( ifstream &  infile,
string &  parameter,
string &  value 
)

This is the function for reading parameters @ detail It is identical to the parse_line function in LSDStatsTools but has a bigger buffer to cope with long path names.

Parameters
infileThe file being read
pramatera string of the parameter name: returned from the parser this is always changed to lower case only!!
valueA string holding a value. It will need to be further parsed depending on the name of the parameter (i.e., to a float, int, string, etc)
Author
SMM
Date
02/11/16
void LSDParameterParser::parse_all_parameters ( map< string, float >  default_map_f,
map< string, int >  default_map_i,
map< string, bool >  default_map_b,
map< string, string >  default_map_s 
)

This parses all of the defalt parameter maps.

Parameters
default_param_fa map of the default parameters, keys are string, values are floats
default_param_ia map of the default parameters, keys are string, values are int
default_param_ba map of the default parameters, keys are string, values are bool
default_param_sa map of the default parameters, keys are string, values are string
Author
SMM
Date
09/11/2016
void LSDParameterParser::parse_all_parameters ( map< string, float >  default_map_f,
map< string, int >  default_map_i,
map< string, bool >  default_map_b,
map< string, string >  default_map_s,
map< string, double >  default_map_d 
)

This parses all of the defalt parameter maps Overloaded to include doubles.

Parameters
default_param_fa map of the default parameters, keys are string, values are floats
default_param_ia map of the default parameters, keys are string, values are int
default_param_ba map of the default parameters, keys are string, values are bool
default_param_sa map of the default parameters, keys are string, values are string
Author
FJC
Date
20/11/17
void LSDParameterParser::parse_bool_parameters ( map< string, bool >  default_map)

This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file.

Parameters
default_parama map of the default parameters, keys are string, values are bool
Author
SMM
Date
03/11/2016
void LSDParameterParser::parse_double_parameters ( map< string, double >  default_map)

This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file.

Parameters
default_parama map of the default parameters, keys are string, values are doubles
Author
FJC
Date
20/11/2017
void LSDParameterParser::parse_file_IO ( )

This parses all the required information for File I/O You need to get the parameter map first.

Author
SMM
Date
03/11/2016
void LSDParameterParser::parse_float_parameters ( map< string, float >  default_map)

This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file.

Parameters
default_parama map of the default parameters, keys are string, values are floats
Author
SMM
Date
03/11/2016
vector< float > LSDParameterParser::parse_float_vector ( string  key)

This function takes a parameter from the string map and parses it into a vector of floats.

Parameters
keythe string that is the key into the string map
Returns
A vector of floats
Author
SMM
Date
09/17/2016
void LSDParameterParser::parse_int_parameters ( map< string, int >  default_map)

This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file.

Parameters
default_parama map of the default parameters, keys are string, values are int
Author
SMM
Date
03/11/2016
vector< int > LSDParameterParser::parse_int_vector ( string  key)

This function takes a parameter from the string map and parses it into a vector of ints.

Parameters
keythe string that is the key into the string map
Returns
A vector of ints
Author
SMM
Date
09/11/2016
void LSDParameterParser::parse_string_parameters ( map< string, string >  default_map)

This function takes a default map and converts it into the parameters by comparing the keys to the parsed parameter file.

Parameters
default_parama map of the default parameters, keys are string, values are strings
Author
SMM
Date
03/11/2016
vector< string > LSDParameterParser::parse_string_vector ( string  key)

This function takes a parameter from the string map and parses it into a vector of strings.

Parameters
keythe string that is the key into the string map
Returns
A vector of strings
Author
SMM
Date
09/11/2016
void LSDParameterParser::print_parameters ( )

This prints your parameters to file so you can check if the parameters have been ingested properly.

Author
SMM
Date
01/11/2016
void LSDParameterParser::print_parameters ( string  fname_prefix)

This prints your parameters to file so you can check if the parameters have been ingested properly. You tell it what the file is called.

Parameters
fname_prefixthe name of the fname (with extension, no path)
Author
SMM
Date
16/03/2017
void LSDParameterParser::replace_and_print_parameter_file ( string  parameter_fname,
string  new_read_path,
string  new_read_fname,
string  new_write_path,
string  new_write_fname,
map< string, string >  replace_parameters 
)

This is used to update a parameter file within LSDTopoTools and is primarily intended to be used in spawning operations, e.g. where you select a bunch of catchemetns and create driver functions for each one that can be run on different CPUs.

Parameters
parameter_fnamethe name of the output parameter file
new_read_paththe new path.
new_read_fnamethe new read filename (no extension!)
new_write_pathsays what it does on the tin
new_write_fnameno extension for this file
replace_parametersa map of <string,string> that replaces parameters
Author
SMM
Date
15/03/2017
void LSDParameterParser::set_read_fname ( string  new_read_fname)
inline

set the read_fname parameter with a string

Parameters
new_read_fnamestring containing the new read filename
Author
MDH
Date
13/10/2017
void LSDParameterParser::set_write_fname ( string  new_write_fname)
inline

set the read_fname parameter with a string

Parameters
new_read_fnamestring containing the new read filename
Author
MDH
Date
13/10/2017

Member Data Documentation

map<string,string> LSDParameterParser::defaults_used_map
protected

This is used for bug checking: all defaults used are then passed to this map, which can be printed and used to check the spelling of the default parameters

map<string,string> LSDParameterParser::parameter_map
protected

This is the map of all the paramters read from file, in string format you use the default parameter maps to convert the strings to the parameter values you want.

map<string,string> LSDParameterParser::parameters_read_map
protected

Also for bug checking: contains the parameters where parameters have been read from the file


The documentation for this class was generated from the following files: