49 std::complex<fvalue>
im;
52 DataPoint(std::complex<fvalue> imIn, fvalue omegaIn = 0):
im(imIn),
omega(omegaIn){}
57 bool operator>(
const DataPoint& in)
const
59 return omega > in.omega;
61 bool operator==(
const DataPoint& in)
const
65 DataPoint operator-(
const DataPoint& in)
const
68 out.im = out.im - in.im;
71 DataPoint operator+(
const DataPoint& in)
const
74 out.im = out.im + in.im;
77 DataPoint operator/(fvalue in)
const
83 DataPoint operator*(fvalue in)
const
89 DataPoint operator/=(fvalue in)
101 return std::sqrt(std::pow(
im.real(), 2) + std::pow(
im.imag(), 2));
129 return (endL-startL)/(
count-1);
157 fvalue
at(
size_t index)
const
159 assert(index <
count || (index == 0 &&
count == 0));
165 fvalue operator[](
size_t index)
const
169 Range operator*(fvalue in)
const
173 Range operator/(fvalue in)
const
175 return operator*(
static_cast<fvalue
>(1.0)/in);
177 Range operator*(
int in)
const
179 return operator*(
static_cast<fvalue
>(in));
181 Range operator/(
int in)
const
183 return operator*(
static_cast<fvalue
>(1.0)/in);
185 Range(fvalue startI, fvalue endI,
size_t countI,
bool logI =
false):
start(startI),
end(endI),
count(countI),
log(logI){}
239 parse_errror(
const std::string& whatIn): whatStr(whatIn)
241 virtual const char* what()
const noexcept override
243 return whatStr.c_str();
251 file_error(
const std::string& whatIn): whatStr(whatIn)
253 virtual const char* what()
const noexcept override
255 return whatStr.c_str();
262 static constexpr int F_VERSION_MAJOR = 1;
263 static constexpr int F_VERSION_MINOR = 0;
264 static constexpr int F_VERSION_PATCH = 0;
265 static constexpr char F_MAGIC[] =
"EISF";
268 std::vector<DataPoint> data;
271 std::vector<double> labels;
272 std::vector<std::string> labelNames;
284 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
285 std::vector<double> labels = std::vector<double>(),
286 std::vector<std::string> labelNames = std::vector<std::string>());
299 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
300 std::vector<float> labels, std::vector<std::string> labelNames = std::vector<std::string>());
313 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
314 std::vector<size_t> labels, std::vector<std::string> labelNames = std::vector<std::string>());
327 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
328 size_t label,
size_t maxLabel, std::vector<std::string> labelNames = std::vector<std::string>());
451std::pair<std::valarray<fvalue>, std::valarray<fvalue>>
eisToValarrays(
const std::vector<eis::DataPoint>& data);
462fvalue
eisDistance(
const std::vector<eis::DataPoint>& a,
const std::vector<eis::DataPoint>& b);
476fvalue
eisNyquistDistance(
const std::vector<eis::DataPoint>& a,
const std::vector<eis::DataPoint>& b);
482std::ostream &operator<<(std::ostream &s,
eis::DataPoint const& dp);
484std::ostream &operator<<(std::ostream &s,
eis::Range const& range);
486std::ostream &operator<<(std::ostream &s,
eis::EisSpectra const& spectra);
Basic singular EIS data point.
Definition eistype.h:47
fvalue complexVectorLength() const
Calculates the absolute value of the complex impedance.
Definition eistype.h:99
std::complex< fvalue > im
Complex impedance.
Definition eistype.h:49
fvalue omega
Frequency of the complex impedance.
Definition eistype.h:50
std::vector< size_t > getSzLabels() const
Sets the input values of this model.
bool isMulticlass()
Returns true if there are multiple inputs, false otherwise.
EisSpectra(const std::vector< DataPoint > &data, const std::string &model, const std::string &header, std::vector< double > labels=std::vector< double >(), std::vector< std::string > labelNames=std::vector< std::string >())
Constructs an EisSpectra.
size_t getLabel()
Gets the input value of this model, where it is a single value.
EisSpectra(const std::vector< DataPoint > &data, const std::string &model, const std::string &header, std::vector< size_t > labels, std::vector< std::string > labelNames=std::vector< std::string >())
Constructs an EisSpectra.
void setLabels(const std::vector< float > &labelsIn)
Sets the input values of this model.
void saveToStream(std::ostream &stream) const
Saves the spectra in the given stream.
EisSpectra(const std::filesystem::path &path)
Constructs a EisSpectra by loading an EIS file from disk.
Definition eistype.h:336
void setLabels(const std::vector< double > &labelsIn)
Sets the input values of this model.
void setLabel(size_t label, size_t maxLabel)
Sets all input values up to a maximum given by maxLabel to the value given by label.
void setSzLabels(std::vector< size_t > label)
Sets the input values of this model.
static EisSpectra loadFromStream(std::istream &stream)
Constructs a EisSpectra by loading a EIS file from a stream.
static EisSpectra loadFromDisk(const std::filesystem::path &path)
Constructs a EisSpectra by loading a EIS file from disk.
EisSpectra(const std::vector< DataPoint > &data, const std::string &model, const std::string &header, size_t label, size_t maxLabel, std::vector< std::string > labelNames=std::vector< std::string >())
Constructs an EisSpectra.
EisSpectra(const std::vector< DataPoint > &data, const std::string &model, const std::string &header, std::vector< float > labels, std::vector< std::string > labelNames=std::vector< std::string >())
Constructs an EisSpectra.
std::vector< fvalue > getFvalueLabels()
Returns the inputs as a vector.
bool saveToDisk(const std::filesystem::path &path) const
Saves the spectra to disk.
A range.
Definition eistype.h:110
fvalue stepValue() const
Calculates the value of the current step.
Definition eistype.h:137
fvalue stepSize() const
Calculates the distance between elements in the range.
Definition eistype.h:125
bool isSane() const
Checks if the values of this range are sane/.
static std::vector< Range > rangesFromParamString(const std::string ¶mStr, size_t count)
This function creates a vector ranges from the parseable parameter array string.
std::vector< fvalue > getRangeVector() const
This function constructs a vector that contains all elements of this range.
fvalue end
End of the range.
Definition eistype.h:113
std::string getString() const
Gets a machine parseable string encoding this range.
void print(int level) const
Prints the range to stdout via eis::Log.
size_t step
Currently active step.
Definition eistype.h:115
fvalue center() const
Calculates the mean of the start and the end values.
Definition eistype.h:147
fvalue at(size_t index) const
Calculates the value at the given index.
Definition eistype.h:157
fvalue start
Start of the range.
Definition eistype.h:112
static Range fromString(std::string str, size_t count)
This function creates a range from the parseable string.
size_t count
Number of elements in the range.
Definition eistype.h:114
bool log
True if the elements in the range are to be spaced in log10 increments.
Definition eistype.h:116
std::pair< std::valarray< fvalue >, std::valarray< fvalue > > eisToValarrays(const std::vector< eis::DataPoint > &data)
Returns the a vector of DataPoints as a pair of valarrays.
EisSpectra loadFromDisk(const std::filesystem::path &path)
Deprecated function use eis::EisSpectra::loadFromDisk instead.
bool saveToDisk(const EisSpectra &data, const std::filesystem::path &path)
Deprecated function use eis::EisSpectra::saveToDisk instead.
fvalue eisDistance(const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
Returns the mean l2 element wise distance of the given spectra.
fvalue eisNyquistDistance(const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
Returns the mean distance of the points in a to the linearly interpolated nyquist curve of b.
eisgenerator Copyright (C) 2021 Carl Klemm
Definition basicmath.h:26