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));
128 return (endL-startL)/(
count-1);
156 fvalue
at(
size_t index)
const
158 assert(index <
count || (index == 0 &&
count == 0));
164 fvalue operator[](
size_t index)
const
168 Range operator*(fvalue in)
const
172 Range operator/(fvalue in)
const
174 return operator*(
static_cast<fvalue
>(1.0)/in);
176 Range operator*(
int in)
const
178 return operator*(
static_cast<fvalue
>(in));
180 Range operator/(
int in)
const
182 return operator*(
static_cast<fvalue
>(1.0)/in);
184 Range(fvalue startI, fvalue endI,
size_t countI,
bool logI =
false):
start(startI),
end(endI),
count(countI),
log(logI){}
237 parse_errror(
const std::string& whatIn): whatStr(whatIn)
239 virtual const char* what()
const noexcept override
241 return whatStr.c_str();
249 file_error(
const std::string& whatIn): whatStr(whatIn)
251 virtual const char* what()
const noexcept override
253 return whatStr.c_str();
260 static constexpr int F_VERSION_MAJOR = 1;
261 static constexpr int F_VERSION_MINOR = 0;
262 static constexpr int F_VERSION_PATCH = 0;
263 static constexpr char F_MAGIC[] =
"EISF";
266 std::vector<DataPoint> data;
269 std::vector<double> labels;
270 std::vector<std::string> labelNames;
282 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
283 std::vector<double> labels = std::vector<double>(),
284 std::vector<std::string> labelNames = std::vector<std::string>());
296 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
297 std::vector<float> labels, std::vector<std::string> labelNames = std::vector<std::string>());
309 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
310 std::vector<size_t> labels, std::vector<std::string> labelNames = std::vector<std::string>());
322 EisSpectra(
const std::vector<DataPoint>& data,
const std::string& model,
const std::string& header,
323 size_t label,
size_t maxLabel, std::vector<std::string> labelNames = std::vector<std::string>());
441std::pair<std::valarray<fvalue>, std::valarray<fvalue>>
eisToValarrays(
const std::vector<eis::DataPoint>& b);
450fvalue
eisDistance(
const std::vector<eis::DataPoint>& a,
const std::vector<eis::DataPoint>& b);
462fvalue
eisNyquistDistance(
const std::vector<eis::DataPoint>& a,
const std::vector<eis::DataPoint>& b);
468std::ostream &operator<<(std::ostream &s,
eis::DataPoint const& dp);
470std::ostream &operator<<(std::ostream &s,
eis::Range const& range);
472std::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 a 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 a EisSpectra this function differs from the above only in the datatype of the label.
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 a EIS file from disk.
Definition eistype.h:331
void setLabels(const std::vector< double > &labelsIn)
Sets the input values of this model.
void setLabel(size_t label, size_t maxLabel)
Constructs a EisSpectra by loading a EIS file from a stream.
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 a EisSpectra this function differs from the above only in the datatype of the label.
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 a EisSpectra this function differs from the above only in the datatype of the label.
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:136
fvalue stepSize() const
calculates the distance between elements in the range will calculate the log10 of the distance if the...
Definition eistype.h:124
bool isSane() const
checks if the values of this range are sane this checks for some common errors like having a end < be...
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:146
fvalue at(size_t index) const
calculates the value at the given index
Definition eistype.h:156
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
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 he given spectra.
std::pair< std::valarray< fvalue >, std::valarray< fvalue > > eisToValarrays(const std::vector< eis::DataPoint > &b)
Returns the a vector of DataPoints as a pair of valarrays.
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