![]() |
Cell2Fire
A large-scale forest fire simulator.
|
Public Member Functions | |
CSVWriter (std::string filename, std::string delm=",") | |
Constructor for CSVWriter object. | |
template<typename T > | |
void | addDatainRow (T first, T last) |
Writes a row of data to a file Takes a range of values and appends them as a single row to the output file. If it's the first line being written, the file is truncated (cleared), otherwise, new rows are appended. | |
void | printCSV (int rows, int cols, std::vector< int > statusCells) |
Writes a 2D grid of cell statuses to a CSV file. | |
void | printCSVDouble (int rows, int cols, std::vector< double > network) |
void | printCSVDouble_V2 (int rows, int cols, std::vector< double > network) |
void | printASCII (int rows, int cols, double xllcorner, double yllcorner, int cellside, std::vector< float > statusCells) |
Writes a raster layer with float data in ASCII format onto a file. | |
void | printASCIIInt (int rows, int cols, double xllcorner, double yllcorner, int cellside, std::vector< int > statusCells) |
Writes a raster layer with int data in ASCII format onto a file. | |
void | asciiHeader (int rows, int cols, double xllcorner, double yllcorner, int cellside) |
Writes the ascii header onto a raster file. | |
void | printWeather (std::vector< std::string > weatherHistory) |
writes the weather file history onto an output file | |
void | printIgnitions (std::unordered_map< int, int > ignitionsHistory) |
writes the ignition point history onto an output file | |
void | printCSV_V2 (int rows, int cols, std::vector< int > statusCells) |
void | MakeDir (std::string pathPlot) |
Creates the directory for a given path. | |
Public Attributes | |
std::string | fileName |
std::string | delimeter |
int | linesCount |
CSVWriter::CSVWriter | ( | std::string | filename, |
std::string | delm = "," |
||
) |
Constructor for CSVWriter object.
filename | name of output file |
delm | delimeter to use in output file |
void CSVWriter::addDatainRow | ( | T | first, |
T | last | ||
) |
Writes a row of data to a file Takes a range of values and appends them as a single row to the output file. If it's the first line being written, the file is truncated (cleared), otherwise, new rows are appended.
Each element in the range is written to the file, separated by the configured delimiter.
T | An input iterator type pointing to elements that can be streamed to a file (e.g., std::vector<std::string>::iterator). |
first | Iterator to the beginning of the range. |
last | Iterator to the end of the range. |
void CSVWriter::asciiHeader | ( | int | rows, |
int | cols, | ||
double | xllcorner, | ||
double | yllcorner, | ||
int | cellside | ||
) |
Writes the ascii header onto a raster file.
Opens the output file and writes the first few lines of metadata. These indicate the number of rows and columns, the coordinates of the lower left corner cell, cellside length and which value indicates there's no data for a cell.
rows | number of rows |
cols | number of columns |
xllcorner | X-coordinate of the lower left corner cell |
yllcorner | Y-coordinate of the lower left corner cell |
cellside | length of the side of a cell |
void CSVWriter::MakeDir | ( | std::string | pathPlot | ) |
Creates the directory for a given path.
Distinguishes between Linux/MacOS systems and Windows systems, and calls the appropriate command to create the given directory. It can create only one new directory per call, so only the last component of pathPlot
can name a new directory.
pathPlot | Path to the new directory |
void CSVWriter::printASCII | ( | int | rows, |
int | cols, | ||
double | xllcorner, | ||
double | yllcorner, | ||
int | cellside, | ||
std::vector< float > | statusCells | ||
) |
Writes a raster layer with float data in ASCII format onto a file.
Creates a raster file in ASCII format from the contents of statusCells
. It includes the corresponding ASCII header. statusCells
must be a vector of float
type values.
rows | number of rows in grid |
cols | number of columns in grid |
xllcorner | x-coordinate of lower left corner cell |
yllcorner | y-coordiante of lower left corner cell |
cellside | length of the side of a cell |
statusCells | float vector with cell data to print |
void CSVWriter::printASCIIInt | ( | int | rows, |
int | cols, | ||
double | xllcorner, | ||
double | yllcorner, | ||
int | cellside, | ||
std::vector< int > | statusCells | ||
) |
Writes a raster layer with int data in ASCII format onto a file.
Creates a raster file in ASCII format from the contents of statusCells
. It includes the corresponding ASCII header. statusCells
must be a vector of int
type values.
rows | number of rows in grid |
cols | number of columns in grid |
xllcorner | x-coordinate of lower left corner cell |
yllcorner | y-coordiante of lower left corner cell |
cellside | length of the side of a cell |
statusCells | int vector with cell data to print |
void CSVWriter::printCSV | ( | int | rows, |
int | cols, | ||
std::vector< int > | statusCells | ||
) |
Writes a 2D grid of cell statuses to a CSV file.
Converts a flattened 1D vector representing cell statuses in row-major order into a 2D CSV format and writes it using the configured delimiter.
Each row in the grid corresponds to one line in the CSV file.
rows | Number of rows in the grid. |
cols | Number of columns in the grid. |
statusCells | Flattened vector of size (rows * cols) storing the status of each cell. |
void CSVWriter::printIgnitions | ( | std::unordered_map< int, int > | ignitionsHistory | ) |
writes the ignition point history onto an output file
Outputs the list of ignition points that were randomly selected for each simulation.
ignitionsHistory |
void CSVWriter::printWeather | ( | std::vector< std::string > | weatherHistory | ) |
writes the weather file history onto an output file
Outputs the list of weather files that were randomly selected in each simulation.
weatherHistory | String vector with weather file names |