Cell2Fire
A large-scale forest fire simulator.
Loading...
Searching...
No Matches
CSVWriter Class Reference

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
 

Constructor & Destructor Documentation

◆ CSVWriter()

CSVWriter::CSVWriter ( std::string  filename,
std::string  delm = "," 
)

Constructor for CSVWriter object.

Parameters
filenamename of output file
delmdelimeter to use in output file

Member Function Documentation

◆ addDatainRow()

template<typename T >
void CSVWriter::addDatainRow ( first,
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.

Template Parameters
TAn input iterator type pointing to elements that can be streamed to a file (e.g., std::vector<std::string>::iterator).
Parameters
firstIterator to the beginning of the range.
lastIterator to the end of the range.
Here is the caller graph for this function:

◆ asciiHeader()

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.

Parameters
rowsnumber of rows
colsnumber of columns
xllcornerX-coordinate of the lower left corner cell
yllcornerY-coordinate of the lower left corner cell
cellsidelength of the side of a cell
Here is the caller graph for this function:

◆ MakeDir()

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.

Parameters
pathPlotPath to the new directory
Here is the caller graph for this function:

◆ printASCII()

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.

Parameters
rowsnumber of rows in grid
colsnumber of columns in grid
xllcornerx-coordinate of lower left corner cell
yllcornery-coordiante of lower left corner cell
cellsidelength of the side of a cell
statusCellsfloat vector with cell data to print
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printASCIIInt()

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.

Parameters
rowsnumber of rows in grid
colsnumber of columns in grid
xllcornerx-coordinate of lower left corner cell
yllcornery-coordiante of lower left corner cell
cellsidelength of the side of a cell
statusCellsint vector with cell data to print
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printCSV()

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.

Parameters
rowsNumber of rows in the grid.
colsNumber of columns in the grid.
statusCellsFlattened vector of size (rows * cols) storing the status of each cell.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printIgnitions()

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.

Parameters
ignitionsHistory
Here is the caller graph for this function:

◆ printWeather()

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.

Parameters
weatherHistoryString vector with weather file names
Here is the caller graph for this function:

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