openModeller
Version 1.4.0
|
#include <OpenModeller.hh>
Defines and implements all commands to interface with the model generator.
Definition at line 71 of file OpenModeller.hh.
Definition at line 76 of file OpenModeller.cpp.
References _actualAreaStats, _error, and _estimatedAreaStats.
Definition at line 90 of file OpenModeller.cpp.
References _actualAreaStats, and _estimatedAreaStats.
AlgMetadata const * OpenModeller::algorithmMetadata | ( | char const * | algorithm_id | ) |
Returns a specific algorithm metadata
algorithm_id | Identifier of the algorithm. |
Definition at line 126 of file OpenModeller.cpp.
Referenced by RequestFile::_setAlgorithm().
AlgMetadata const ** OpenModeller::availableAlgorithms | ( | ) |
Finds the system available algorithms' metadata.
The pointer returned are copied from an internal storage of algorithms. So they can not be deallocated. Another point is that the AlgMetadata will be reallocated the next time this method is called.
Definition at line 117 of file OpenModeller.cpp.
Referenced by main().
void OpenModeller::calculateModelStatistics | ( | const ConstConfigurationPtr & | config | ) |
Definition at line 648 of file OpenModeller.cpp.
References _alg, _confusion_matrix, _roc_curve, _samp, RocCurve::calculate(), ConfusionMatrix::calculate(), CONF_MATRIX_DEFAULT_THRESHOLD, Log::debug(), Log::error(), getModel(), RocCurve::getPartialAreaRatio(), getSampler(), ConfusionMatrix::getThreshold(), RocCurve::getTotalArea(), Log::info(), RocCurve::initialize(), Log::instance(), ConfusionMatrix::reset(), RocCurve::reset(), ROC_DEFAULT_RESOLUTION, ConfusionMatrix::setLowestTrainingThreshold(), and UNUSED.
Referenced by main().
int OpenModeller::createMap | ( | const EnvironmentPtr & | env, |
char const * | output_file, | ||
MapFormat & | format | ||
) |
Create and save distribution map to disk using the specified projection environment and output format.
env | Pointer to Environment object with the layers to project the model onto. |
output_file | Output file name. |
format | Georeferenced map file which will define cell size, extent, WKT projection, no data value, and file type for the output map. |
Definition at line 265 of file OpenModeller.cpp.
References _actualAreaStats, _alg, _callback_wrapper, _format, _projEnv, MapFormat::copyDefaults(), Log::error(), MapFormat::GreyBMP, Log::info(), Log::instance(), RasterFactory::instance(), MapFormat::setFormat(), and Log::warn().
Referenced by createMap(), main(), and RequestFile::makeProjection().
int OpenModeller::createMap | ( | const EnvironmentPtr & | env, |
char const * | output_file | ||
) |
Create and save distribution map to disk using the specified projection environment. Output format defaults to the output mask format.
env | Pointer to Environment object with the layers to project the model onto. |
output_file | Output file name. |
Definition at line 335 of file OpenModeller.cpp.
References _format, and createMap().
int OpenModeller::createMap | ( | char const * | output_file, |
MapFormat & | format | ||
) |
Create and save distribution map to disk using the specified output format. Projection environment defaults to the same environment used during model creation and previously set by calling the setEnvironment() method.
output_file | Output file name. |
format | Georeferenced map file which will define cell size, extent, WKT projection, no data value, and file type for the output map. |
Definition at line 356 of file OpenModeller.cpp.
References _env, _projEnv, and createMap().
int OpenModeller::createMap | ( | char const * | output_file | ) |
Create and save distribution map to disk. Projection environment defaults to the same environment used during model creation and previously set by calling the setEnvironment() method. Output format defaults to the output mask format.
output_file | Output file name. |
Definition at line 343 of file OpenModeller.cpp.
References _env, _format, _projEnv, and createMap().
int OpenModeller::createModel | ( | ) |
Run the algorithm to create the model.
Definition at line 231 of file OpenModeller.cpp.
References _alg, _callback_wrapper, _confusion_matrix, _roc_curve, _samp, Log::error(), Log::info(), Log::instance(), ConfusionMatrix::reset(), and RocCurve::reset().
Referenced by main(), and RequestFile::makeModel().
char* OpenModeller::error | ( | ) | [inline] |
Definition at line 304 of file OpenModeller.hh.
Referenced by RequestFile::makeModel().
Returns a pointer to the model AreaStats object which contains statistics about areas on the map generated by OM. IMPORTANT: you should delete the pointer because it returns a copy of the internal object!
Definition at line 405 of file OpenModeller.cpp.
References _actualAreaStats.
Referenced by main().
AlgorithmPtr OpenModeller::getAlgorithm | ( | ) | [inline] |
Returns the current algorithm setting.
Definition at line 139 of file OpenModeller.hh.
Referenced by main().
const ConfusionMatrix *const OpenModeller::getConfusionMatrix | ( | ) |
Returns a pointer to the internal object representing the confusion matrix that was calculated from the last generated model. IMPORTANT: you should NOT delete the returned pointer!
Definition at line 462 of file OpenModeller.cpp.
References _confusion_matrix, ConfusionMatrix::calculate(), getModel(), getSampler(), and ConfusionMatrix::ready().
Referenced by main(), and RequestFile::makeModel().
EnvironmentPtr OpenModeller::getEnvironment | ( | ) | [inline] |
Returns the current environment related to model creation.
Definition at line 133 of file OpenModeller.hh.
Referenced by draw_occur(), and main().
AreaStats * OpenModeller::getEstimatedAreaStats | ( | double | proportionAreaToSample = 0.01 | ) |
Returns a pointer to the model AreaStats object which contains statistics about areas on the map generated by OM. This one uses only a random sample of the data points to estimate prediction areas. IMPORTANT: you should NOT delete the returned pointer!
proportionAreaToSample | Proportion of the area of interest (mask or intersection of all layers extents) to use as sample size. |
Definition at line 413 of file OpenModeller.cpp.
References _env.
AreaStats * OpenModeller::getEstimatedAreaStats | ( | const ConstEnvironmentPtr & | env, |
double | proportionAreaToSample = 0.01 |
||
) |
Definition at line 421 of file OpenModeller.cpp.
References _alg, _estimatedAreaStats, AreaStats::addPrediction(), and AreaStats::reset().
Model OpenModeller::getModel | ( | ) | const [inline] |
Returns model created by the algorithm.
Definition at line 145 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), getConfusionMatrix(), getRocCurve(), and main().
Definition at line 492 of file OpenModeller.cpp.
References _alg, _confusion_matrix, _roc_curve, _samp, RocCurve::getConfiguration(), ConfusionMatrix::getConfiguration(), RocCurve::ready(), and ConfusionMatrix::ready().
Referenced by main(), and RequestFile::makeModel().
RocCurve *const OpenModeller::getRocCurve | ( | ) |
Returns a pointer to the internal object representing the ROC curve that was calculated from the last generated model. IMPORTANT: you should NOT delete the returned pointer!
Definition at line 476 of file OpenModeller.cpp.
References _roc_curve, RocCurve::calculate(), getModel(), getSampler(), and RocCurve::ready().
Referenced by main(), and RequestFile::makeModel().
const SamplerPtr& OpenModeller::getSampler | ( | ) | const [inline] |
Returns current sampler setting.
Definition at line 151 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), getConfusionMatrix(), getRocCurve(), main(), and RequestFile::makeModel().
Scalar OpenModeller::getValue | ( | const ConstEnvironmentPtr & | env, |
Coord | x, | ||
Coord | y | ||
) |
Get prediction at a given point.
env | Pointer to Environment class with the layers to get environmental values from. |
x | X coordinate of point being queried |
y | Y coordinate of point being queried |
Definition at line 369 of file OpenModeller.cpp.
References _alg, _env, and Sample::size().
Referenced by draw_niche().
Scalar OpenModeller::getValue | ( | Scalar const * | environment_values | ) |
Get prediction at a given point.
environment_values | Vector with environment values. |
Definition at line 395 of file OpenModeller.cpp.
std::string OpenModeller::getVersion | ( | ) |
Returns the openModeller client interface version in the format "n.m"
Definition at line 109 of file OpenModeller.cpp.
Referenced by main().
bool OpenModeller::hasEnvironment | ( | ) | [private] |
Definition at line 141 of file OpenModeller.cpp.
References _env, and _presence.
Referenced by setAlgorithm().
Number of available algorithms. If the algorithms are not already searched in the system, searchs them first.
Definition at line 135 of file OpenModeller.cpp.
int OpenModeller::run | ( | ) | [inline] |
Compatibility with old oM client versions.
Definition at line 283 of file OpenModeller.hh.
void OpenModeller::setAbortionCallback | ( | AbortionCallback | func, |
void * | param = 0 |
||
) |
Sets a callback function to be called during model creation and map projection to check if the job should be aborted.
func | Pointer to the callback function. |
param | User parameter to be passed to the callback function. |
Definition at line 65 of file OpenModeller.cpp.
References _callback_wrapper, and CallbackWrapper::setAbortionCallback().
int OpenModeller::setAlgorithm | ( | std::string const | id, |
int | nparam, | ||
AlgParameter const * | param | ||
) |
Define algorithm that will be used to generate the model.
id | Algorithm's identifier. Must match the Algorithm::getID() returned string. |
nparam | Number of parameters. |
param | Vector with all parameters. The address 'param' points to must exist when the method "run()" is called. |
Definition at line 185 of file OpenModeller.cpp.
References _absence, _alg, _env, _error, _presence, _samp, createSampler(), Log::error(), hasEnvironment(), Log::instance(), AlgorithmFactory::newAlgorithm(), setSampler(), and Log::warn().
Referenced by RequestFile::_setAlgorithm(), and main().
void OpenModeller::setEnvironment | ( | std::vector< std::string > | categ_map, |
std::vector< std::string > | continuous_map, | ||
const std::string & | mask | ||
) |
Defines environmental layers and the mask using STL arguments. Also creates the Environment object used for native range projection.
categ_map | Vector of strings containing the file names of categorical map layers. |
continuous_map | Vector of strings containing the file names of continuous map layers. |
mask | File name of the mask map layer. |
Definition at line 167 of file OpenModeller.cpp.
References _env, and createEnvironment().
Referenced by RequestFile::_setEnvironment().
void OpenModeller::setLogLevel | ( | Log::Level | level | ) |
Sets the log level on the global Log g_log object.
Note: We need to add control over the log file and prefix as well.
Definition at line 100 of file OpenModeller.cpp.
References Log::instance(), and Log::setLevel().
void OpenModeller::setMapCallback | ( | ModelProjectionCallback | func, |
void * | param = 0 |
||
) |
Sets a callback function to be called after each map distribution line generation.
func | Pointer to the callback function. |
param | User parameter to be passed to the callback function. |
Definition at line 60 of file OpenModeller.cpp.
References _callback_wrapper, and CallbackWrapper::setModelProjectionCallback().
Referenced by main().
void OpenModeller::setModelCallback | ( | ModelCreationCallback | func, |
void * | param = 0 |
||
) |
Sets a callback function to be called after each iteration of the model creation.
func | Pointer to the callback function. |
param | User parameter to be passed to the callback function. |
Definition at line 55 of file OpenModeller.cpp.
References _callback_wrapper, and CallbackWrapper::setModelCreationCallback().
Referenced by main().
void OpenModeller::setModelConfiguration | ( | const ConstConfigurationPtr & | config | ) |
Definition at line 529 of file OpenModeller.cpp.
References _absence, _alg, _confusion_matrix, _env, _presence, _roc_curve, _samp, createSampler(), Log::debug(), Log::instance(), AlgorithmFactory::newAlgorithm(), ConfusionMatrix::reset(), and RocCurve::reset().
Referenced by main(), and RequestFile::makeModel().
int OpenModeller::setOccurrences | ( | const OccurrencesPtr & | presence, |
const OccurrencesPtr & | absence = OccurrencesPtr() |
||
) |
Define occurrence points to be used.
presence | Occurrence points which the abundance attribute is not zero. |
absence | Occurrence points which the abundance attribute is zero. |
Definition at line 149 of file OpenModeller.cpp.
References _absence, _presence, Log::error(), and Log::instance().
Referenced by RequestFile::_setOccurrences().
void OpenModeller::setProjectionConfiguration | ( | const ConstConfigurationPtr & | config | ) |
Definition at line 584 of file OpenModeller.cpp.
References _actualAreaStats, _alg, _format, _projEnv, createEnvironment(), Log::debug(), Log::error(), Log::instance(), AlgorithmFactory::newAlgorithm(), AreaStats::reset(), MapFormat::setFormat(), and UNUSED.
Referenced by main().
void OpenModeller::setSampler | ( | const SamplerPtr & | sampler | ) |
Defines sampler to be used for modeling.
sampler | Sampler object to be used for modeling |
Definition at line 177 of file OpenModeller.cpp.
References _samp.
Referenced by setAlgorithm().
OccurrencesPtr OpenModeller::_absence [private] |
Definition at line 376 of file OpenModeller.hh.
Referenced by setAlgorithm(), setModelConfiguration(), and setOccurrences().
AreaStats* OpenModeller::_actualAreaStats [private] |
Definition at line 391 of file OpenModeller.hh.
Referenced by createMap(), getActualAreaStats(), OpenModeller(), setProjectionConfiguration(), and ~OpenModeller().
AlgorithmPtr OpenModeller::_alg [private] |
Definition at line 370 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), createMap(), createModel(), getEstimatedAreaStats(), getModelConfiguration(), getValue(), setAlgorithm(), setModelConfiguration(), and setProjectionConfiguration().
Definition at line 382 of file OpenModeller.hh.
Referenced by createMap(), createModel(), setAbortionCallback(), setMapCallback(), and setModelCallback().
Definition at line 395 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), createModel(), getConfusionMatrix(), getModelConfiguration(), and setModelConfiguration().
EnvironmentPtr OpenModeller::_env [private] |
Definition at line 379 of file OpenModeller.hh.
Referenced by createMap(), getEstimatedAreaStats(), getValue(), hasEnvironment(), setAlgorithm(), setEnvironment(), and setModelConfiguration().
char OpenModeller::_error[256] [private] |
Definition at line 400 of file OpenModeller.hh.
Referenced by OpenModeller(), and setAlgorithm().
AreaStats* OpenModeller::_estimatedAreaStats [private] |
Definition at line 392 of file OpenModeller.hh.
Referenced by getEstimatedAreaStats(), OpenModeller(), and ~OpenModeller().
MapFormat OpenModeller::_format [private] |
Definition at line 385 of file OpenModeller.hh.
Referenced by createMap(), and setProjectionConfiguration().
OccurrencesPtr OpenModeller::_presence [private] |
Definition at line 373 of file OpenModeller.hh.
Referenced by hasEnvironment(), setAlgorithm(), setModelConfiguration(), and setOccurrences().
EnvironmentPtr OpenModeller::_projEnv [private] |
Definition at line 388 of file OpenModeller.hh.
Referenced by createMap(), and setProjectionConfiguration().
RocCurve OpenModeller::_roc_curve [private] |
Definition at line 398 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), createModel(), getModelConfiguration(), getRocCurve(), and setModelConfiguration().
SamplerPtr OpenModeller::_samp [private] |
Definition at line 367 of file OpenModeller.hh.
Referenced by calculateModelStatistics(), createModel(), getModelConfiguration(), setAlgorithm(), setModelConfiguration(), and setSampler().