8#ifndef PYEXPORTParser_H_INCLUDED
9#define PYEXPORTParser_H_INCLUDED
21#include "boost/python.hpp"
26BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readrasters_overloads,readRasters, 3, 6)
27BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readvectors_overloads,readVectors, 4, 8)
28BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getschemeneighbors_overloads, getSchemeNeighbors, 5, 10)
29BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getclusters_overloads,getClusters,6, 11)
30BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addoutputs_overloads,addOutputs,6, 7)
31BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(vectormaptoFMTforest_overloads,vectormaptoFMTforest,5,11)
32BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(vectorfieldtoraster_overloads, vectorFieldToRaster,4,5)
35BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writeforest_overloads,writeForest, 5, 6)
37BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writepredictors_overloads,writePredictors, 5, 7)
39BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readmodel_overloads, read, 8, 9)
40BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getconstraintsfromstring_overloads,getConstraintsFromString,2,3)
43BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readproject_overloads, readproject,1,5)
44BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writeresults_overloads, writeResults, 5, 7)
49 namespace bp = boost::python;
50 bp::object ParserModule(bp::handle<>(bp::borrowed(PyImport_AddModule(
"FMT.Parser"))));
51 bp::scope().attr(
"Parser") = ParserModule;
52 bp::scope Parser_scope = ParserModule;
53 bp::scope().attr(
"__doc__") =
".. module:: Parser\n"
55 " :platform: Unix, Windows\n"
56 " :synopsis: Module used to import Woodstock models.\n"
59 bp::class_<Parser::FMTParser, bp::bases<Core::FMTObject>>(
"FMTparser",
"@DocString(FMTParser)");
61 definePyDict<std::string,std::string>();
67 const std::vector<std::string>&,
const std::string&,
const std::string&,
70 bp::class_<Parser::FMTAreaParser, bp::bases<Parser::FMTParser>>(
"FMTareaparser",
"@DocString(FMTAreaParser)")
73 .def(
"readvectors", &
Parser::FMTAreaParser::readVectors,readvectors_overloads(bp::args(
"themes",
"data_vectors",
"agefield",
"areafield",
"areafactor",
"lockfield",
"minimalarea"),
"@DocString(FMTAreaParser::readvectors)"))
74 .def(
"readrasters", &
Parser::FMTAreaParser::readRasters,readrasters_overloads(bp::args(
"themes",
"data_rasters",
"age",
"agefactor",
"areafactor",
"lock"),
"@DocString(FMTAreaParser::readrasters)"))
75 .def(
"writeforest",writeForestPtr,writeforest_overloads(bp::args(
"for_layer",
"themes",
"data_rasters",
"age",
"lock",
"mapping"),
"@DocString(FMTAreaParser::writeforest)"))
78 .def(
"writepredictors", &
Parser::FMTAreaParser::writePredictors,writepredictors_overloads(bp::args(
"location",
"spatialsolution",
"yieldnames",
"model",
"period",
"withGCBMid"),
"@DocString(FMTAreaParser::writepredictors)"))
79 .def(
"vectormaptoFMTforest", &
Parser::FMTAreaParser::vectormaptoFMTforest,vectormaptoFMTforest_overloads(bp::args(
"data_vectors",
"resolution",
"themes",
"agefield",
"areafield",
"agefactor",
"areafactor",
"lockfield",
"minimalarea",
"writeforestfolder",
"fittoforel"),
"@DocString(FMTAreaParser::vectormaptoFMTforest)"))
80 .def(
"vectorfieldtoraster", &
Parser::FMTAreaParser::vectorFieldToRaster, vectorfieldtoraster_overloads(bp::args(
"data_vectors",
"tifpathandname",
"resolution",
"field",
"fittoforel"),
"@DocString(FMTAreaParser::vectorfieldtoraster)"))
82 .def(
"getschemeneighbors",&
Parser::FMTAreaParser::getSchemeNeighbors, getschemeneighbors_overloads(bp::args(
"operatingareaparameters",
"themes",
"data_vectors",
"agefield",
"areafield",
"agefactor",
"areafractor",
"lockfield",
"minimal_area",
"buffersize"),
"@DocString(FMTAreaParser::getschemeneighbors)"))
83 .def(
"getclusters",&
Parser::FMTAreaParser::getClusters,getclusters_overloads(bp::args(
"operatingareaparameters",
"themes",
"data_vectors",
"agefield",
"areafield",
"maximaldistance",
"agefactor",
"areafractor",
"lockfield",
"minimal_area",
"buffersize"),
"@DocString(FMTAreaParser::getclusters)"))
87 "@DocString(FMTAreaParser::write)");
88 bp::class_<Parser::FMTLandscapeParser, bp::bases<Parser::FMTParser>>(
"FMTlandscapeparser",
"@DocString(FMTLandscapeParser)")
90 "@DocString(FMTLandscapeParser::read)")
93 "@DocString(FMTLandscapeParser::readvectors)")
95 "@DocString(FMTLandscapeParser::readrasters)")
98 "@DocString(FMTLandscapeParser::write)");
99 bp::class_<Parser::FMTActionParser, bp::bases<Parser::FMTParser>>(
"FMTactionparser",
"@DocString(FMTActionParser)")
101 "@DocString(FMTActionParser::read)")
103 "@DocString(FMTActionParser::write)");
104 bp::class_<Parser::FMTTransitionParser, bp::bases<Parser::FMTParser>>(
"FMTtransitionparser",
"@DocString(FMTTransitionParser)")
106 "@DocString(FMTTransitionParser::read)")
108 "@DocString(FMTTransitionParser::write)")
110 "@DocString(FMTTransitionParser::readGCBM)")
112 "@DocString(FMTTransitionParser::writeGCBM)");
113 bp::class_<Parser::FMTConstantParser, bp::bases<Parser::FMTParser>>(
"FMTconstantparser",
"@DocString(FMTConstantParser)")
115 "@DocString(FMTConstantParser::read)")
117 "@DocString(FMTConstantParser::write)");
118 bp::class_<Parser::FMTLifespanParser, bp::bases<Parser::FMTParser>>(
"FMTlifespanparser",
"@DocString(FMTLifespanParser)")
120 "@DocString(FMTLifespanParser::read)")
122 "@DocString(FMTLifespanParser::write)");
123 bp::class_<Parser::FMTYieldParser, bp::bases<Parser::FMTParser>>(
"FMTyieldparser",
"@DocString(FMTYieldParser)")
125 "@DocString(FMTYieldParser::read)")
127 "@DocString(FMTYieldParser::write)");
128 bp::class_<Parser::FMTOutputParser, bp::bases<Parser::FMTParser>>(
"FMToutputparser",
"@DocString(FMTOutputParser)")
130 "@DocString(FMTOutputParser::read)")
131 .def(
"addoutputs",&
Parser::FMTOutputParser::addOutputs,addoutputs_overloads(bp::args(
"oldoutputs",
"themes",
"actions",
"ylds",
"constants",
"location",
"outputsname"),
"@DocString(FMTOutputParser::addoutputs)"))
133 "@DocString(FMTOutputParser::write)");
134 bp::class_<Parser::FMTOptimizationParser, bp::bases<Parser::FMTParser>>(
"FMToptimizationparser",
"@DocString(FMTOptimizationParser)")
136 "@DocString(FMTOptimizationParser::read)")
138 "@DocString(FMTOptimizationParser::write)");
139 bp::class_<Parser::FMTModelParser, bp::bases<Parser::FMTParser>>(
"FMTmodelparser",
"@DocString(FMTModelParser)")
140 .def(
"read",&
Parser::FMTModelParser::read, readmodel_overloads(bp::args(
"con",
"lan",
"lif",
"are",
"yld",
"act",
"tr",
"out",
"opt"),
"@DocString(FMTModel::read)"))
141 .def(
"readproject", &
Parser::FMTModelParser::readproject, readproject_overloads(bp::args(
"primary_location",
"scenarios",
"readarea",
"readoutputs",
"readoptimize"),
"@DocString(FMTModel::readproject)"))
144 "@DocString(FMTModelParser::readSchedules)")
147 writeresults_overloads(bp::args(
"model",
"theoutputs",
"firstperiod",
"lastperiod",
"outlocation",
"outputlevel",
"gdaldrivername"),
148 "@DocString(FMTModelParser::writeresults)"))
151 "@DocString(FMTModelParser::write)");
152 bp::class_<Parser::FMTScheduleParser, bp::bases<Parser::FMTParser>>(
"FMTscheduleparser",
"@DocString(FMTScheduleParser)")
154 "@DocString(FMTScheduleParser::read)")
156 "@DocString(FMTScheduleParser::write)");
std::vector< Core::FMTAction > read(const std::vector< Core::FMTTheme > &themes, const Core::FMTYields &yields, const Core::FMTConstants &constants, const std::string &location)
Read actions from an action file.
void write(const std::vector< Core::FMTAction > &actions, const std::string &location, bool withgcbmagg=false) const
Write actions to an action file.
Parser dealing with the spatial aspects used in multiple FMTModel children, reading and writing the a...
Definition: FMTAreaParser.h:67
std::vector< std::vector< Graph::FMTPredictor > > writePredictors(const std::string &location, const Spatial::FMTSpatialSchedule &spatialsolution, const std::vector< std::string > &yieldnames, const Models::FMTModel &model, const int &period, bool periodonevalues=false, bool withGCBMid=true) const
Write the predictor ids into a raster file and return the corresponding predictors for the period.
std::vector< Heuristics::FMTOperatingAreaScheme > getSchemeNeighbors(std::vector< Heuristics::FMTOperatingAreaScheme > operatingareaparameters, const std::vector< Core::FMTTheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimal_area=0.0, double buffersize=100) const
Return the operating area schemes with their neighbors filled from a vector file.
std::vector< Core::FMTActualDevelopment > readVectors(const std::vector< Core::FMTTheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimalarea=0.0) const
Return the actual developments present in a vector file.
Spatial::FMTForest vectormaptoFMTforest(const std::string &data_vectors, const int &resolution, const std::vector< Core::FMTTheme > &themes, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimalarea=0.0, const std::string &writeforestfolder="", const bool &fittoforel=true) const
Rasterize a vector file and return the corresponding forest.
std::vector< Core::FMTGCBMTransition > writeDisturbances(const std::string &location, const Spatial::FMTSpatialSchedule &disturbances, const std::vector< Core::FMTAction > &actions, const std::vector< Core::FMTTheme > &themes, const int &period) const
Write the disturbances into a raster file and return the corresponding GCBM transitions for the perio...
void vectorFieldToRaster(const std::string &data_vectors, const std::string &tifpathandname, const int &resolution, const std::string &field, bool fittoforel=true) const
Create a raster file of a given resolution from a vector file field.
bool writeForest(const Spatial::FMTForest &for_layer, const std::vector< Core::FMTTheme > &themes, const std::vector< std::string > &data_rasters, const std::string &age, const std::string &lock, std::vector< std::map< std::string, std::string > > mapping=std::vector< std::map< std::string, std::string > >()) const
Write a forest into multiple raster files.
Spatial::FMTForest readRasters(const std::vector< Core::FMTTheme > &themes, const std::vector< std::string > &data_rasters, const std::string &age, double agefactor=1.0, double areafactor=0.0001, std::string lock="") const
Generate a FMTForest layer from raster files.
std::vector< Heuristics::FMTOperatingAreaCluster > getClusters(const std::vector< Heuristics::FMTOperatingArea > &operatingareas, const std::vector< Core::FMTTheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, const double &maximaldistance, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimal_area=0.0, double buffersize=100) const
Return the operating area clusters with their linker mask from a vector file.
std::vector< Core::FMTActualDevelopment > read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read a regular area section and return the actual developments.
void write(const std::vector< Core::FMTActualDevelopment > &areas, const std::string &location) const
Write an area section from a vector of actual developments.
void write(const Core::FMTConstants &constants, const std::string &location) const
Write constants to a file.
Core::FMTConstants read(const std::string &location)
Read a constants file.
std::vector< Core::FMTTheme > readRasters(const std::vector< std::string > &locations)
Return the themes present in a vector of raster files, one theme per raster.
std::vector< Core::FMTTheme > readVectors(const std::string &location)
Return the themes present in a spatial vector file.
std::vector< Core::FMTTheme > read(const Core::FMTConstants &constants, const std::string &location)
Read the landscape section and return the themes.
void write(const std::vector< Core::FMTTheme > &themes, const std::string &location) const
Write a landscape section from a vector of themes.
void write(const Core::FMTLifespans &lifespan, const std::string &location) const
Write the lifespan section.
Core::FMTLifespans read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read the lifespan section.
std::vector< Core::FMTConstraint > getConstraintsFromString(std::string constraintstr, const Models::FMTModel &model, Core::FMTConstants constants=Core::FMTConstants())
Get constraints from a string.
void writeResults(const Models::FMTModel &model, const std::vector< Core::FMTOutput > &theoutputs, const int &firstPeriod, const int &lastPeriod, const std::string &location, Core::FMToutputlevel level=Core::FMToutputlevel::standard, std::string gdaldrivername="CSV") const
Write the results of a model from the first to the last period for a vector of outputs into a GDAL dr...
std::vector< std::vector< Core::FMTSchedule > > readSchedules(const std::string &primarym_location, const std::vector< Models::FMTModel > &models)
Read the schedule files of the models based on a primary file.
void write(const Models::FMTModel &model, const std::string &folder) const
Write a model into a folder, naming the files based on the model name.
Models::FMTModel read(const std::string &con, const std::string &lan, const std::string &lif, const std::string &are, const std::string &yld, const std::string &act, const std::string &tr, const std::string &out, std::string opt=std::string())
Read a single model and return it as a FMTModel.
std::vector< Models::FMTModel > readproject(const std::string &primarym_location, std::vector< std::string >scenarios=std::vector< std::string >(), bool readarea=true, bool readoutputs=true, bool readoptimize=true)
Read multiple scenarios based on a primary file location.
std::vector< Core::FMTConstraint > read(const std::vector< Core::FMTTheme > &p_themes, const std::vector< Core::FMTAction > &p_actions, const Core::FMTConstants &p_constants, const std::vector< Core::FMTOutput > &p_outputs, const Core::FMTYields &p_yields, std::vector< Core::FMTAction > &p_excluded, const std::string &pm_location)
Read an optimization file.
void write(const std::vector< Core::FMTConstraint > &p_constraints, const std::string &pm_location) const
Write the constraints into an optimization file.
std::vector< Core::FMTOutput > addOutputs(const std::vector< Core::FMTOutput > oldoutputs, const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location, std::vector< std::string > outputsnames=std::vector< std::string >())
Read an output file and add the desired outputs to a vector of outputs.
std::vector< Core::FMTOutput > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location)
Read an output file.
void write(const std::vector< Core::FMTOutput > &outputs, const std::string &location) const
Write a vector of outputs to a file.
void write(const std::vector< Core::FMTSchedule > &schedules, const std::string &location, bool append=false) const
Write a vector of schedules to a schedule file.
std::vector< Core::FMTSchedule > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const std::string &location, double tolerance=FMT_DBL_TOLERANCE)
Read a schedule section and turn it into a vector of schedules.
void writeGCBM(const std::vector< Core::FMTGCBMTransition > &transitions, const std::string &location) const
Write a vector of GCBM transitions to a text file.
std::vector< Core::FMTGCBMTransition > readGCBM(const std::string &location) const
Read GCBM transitions from a text file.
void write(const std::vector< Core::FMTTransition > &transitions, const std::string &location) const
Write a vector of transitions to a file.
std::vector< Core::FMTTransition > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location)
Read a vector of transitions.
Core::FMTYields read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read a yield file into a FMTYields object.
void write(const Core::FMTYields &yields, const std::string &location) const
Write a FMTYields object to a file.
Spatially referenced layer of Core::FMTDevelopment representing the forest.
Definition: FMTForest.h:33
Definition: PYdefinitions.h:14
void exportParser()
Definition: PYexportParser.h:47