librelaxisloader 1.0.x
relaxisloader.h
1/*
2 * relaxisloader.h
3 * Copyright (C) Carl Philipp Klemm 2023 <carl@uvos.xyz>
4 *
5 * relaxisloader is free software: you can redistribute it and/or modify it
6 * under the terms of the lesser GNU General Public License as published by the
7 * Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * relaxisloader is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the lesser GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20#include <stdbool.h>
21#include <time.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
34struct rlxfile;
35
40 int id;
41 char* name;
42 time_t date;
43};
44
53void rlx_project_free(struct rlx_project* proj);
54
62void rlx_project_free_array(struct rlx_project** proj_array);
63
68 double im;
69 double re;
70 double omega;
71};
72
90
99void rlx_spectra_free(struct rlx_spectra* spectra);
100
108void rlx_spectra_free_array(struct rlx_spectra** spectra_array);
109
111 int spectra_id;
112 int p_index;
113 char* name;
114 double value;
115 double error;
116 double lower_limit;
117 double upper_limit;
118};
119
125void rlx_fitparam_free(struct rlx_fitparam* param);
126
132void rlx_fitparam_free_array(struct rlx_fitparam** param_array);
133
142struct rlxfile* rlx_open_file(const char* path, const char** error);
143
144void rlx_close_file(struct rlxfile* file);
145
155struct rlx_project** rlx_get_projects(struct rlxfile* file, size_t* length);
156
166struct rlx_spectra** rlx_get_all_spectra(struct rlxfile* file, const struct rlx_project* project);
167
179int* rlx_get_spectra_ids(struct rlxfile* file, const struct rlx_project* project, size_t* length);
180
191struct rlx_spectra* rlx_get_spectra(struct rlxfile* file, const struct rlx_project* project, int id);
192
204int rlx_get_float_arrays(const struct rlx_spectra *spectra, float **re, float **im, float **omega);
205
217int rlx_get_double_arrays(const struct rlx_spectra *spectra, double **re, double **im, double **omega);
218
230struct rlx_fitparam** rlx_get_fit_parameters(struct rlxfile* file, const struct rlx_project* project, int id, size_t *length);
231
237int rlx_get_errnum(const struct rlxfile* file);
238
244const char* rlx_get_errnum_str(int errnum);
245
251#ifdef __cplusplus
252}
253#endif
void rlx_spectra_free(struct rlx_spectra *spectra)
This frees a spectra struct.
const char * rlx_get_errnum_str(int errnum)
Returns a human readable error string for a given error number.
struct rlx_project ** rlx_get_projects(struct rlxfile *file, size_t *length)
Gets all the projects in a given RelaxIS file.
int rlx_get_errnum(const struct rlxfile *file)
Returns the last error returned on a file operation.
struct rlxfile * rlx_open_file(const char *path, const char **error)
Frees a project struct.
struct rlx_spectra * rlx_get_spectra(struct rlxfile *file, const struct rlx_project *project, int id)
Loads spectra with a given spectra id and project from file.
void rlx_project_free(struct rlx_project *proj)
This frees a project struct.
void rlx_project_free_array(struct rlx_project **proj_array)
This frees an array of project structs.
void rlx_fitparam_free(struct rlx_fitparam *param)
Frees a fitparam struct.
int rlx_get_float_arrays(const struct rlx_spectra *spectra, float **re, float **im, float **omega)
transforms a rlx_spectra struct into a set of newly allocated arrays, float version.
struct rlx_spectra ** rlx_get_all_spectra(struct rlxfile *file, const struct rlx_project *project)
Loads all spectra from file in given project.
struct rlx_fitparam ** rlx_get_fit_parameters(struct rlxfile *file, const struct rlx_project *project, int id, size_t *length)
Loads the parameters for a given spectra id from file.
int * rlx_get_spectra_ids(struct rlxfile *file, const struct rlx_project *project, size_t *length)
Loads spectra ids that are associated with a given project.
void rlx_fitparam_free_array(struct rlx_fitparam **param_array)
Frees an array of fitparam structs.
int rlx_get_double_arrays(const struct rlx_spectra *spectra, double **re, double **im, double **omega)
transforms a rlx_spectra struct into a set of newly allocated arrays, double version.
void rlx_spectra_free_array(struct rlx_spectra **spectra_array)
Frees an array of spectra structs.
This struct is used to house a single impedance data point.
Definition relaxisloader.h:67
double re
Real part of the measurement in Ohms.
Definition relaxisloader.h:69
double im
Imaginary part of the measurement in Ohms.
Definition relaxisloader.h:68
double omega
Frequency of the measurement in rad/s.
Definition relaxisloader.h:70
Definition relaxisloader.h:110
This struct represents a RelaxIS "project" containing any number of spectra.
Definition relaxisloader.h:39
time_t date
Project creation time.
Definition relaxisloader.h:42
int id
Project id.
Definition relaxisloader.h:40
char * name
Name of the project.
Definition relaxisloader.h:41
This struct is used to house an EIS spectra and associated meta-data.
Definition relaxisloader.h:76
time_t date_fitted
UNIX time the spectra was last fitted.
Definition relaxisloader.h:88
double freq_lower_limit
Lower limit of frequency range of this spectrum.
Definition relaxisloader.h:85
int project_id
Id of the project this spectrum belongs to.
Definition relaxisloader.h:84
time_t date_added
UNIX time the spectra was added.
Definition relaxisloader.h:87
int id
Spectra id, also called "file" in RelaxIS.
Definition relaxisloader.h:77
double freq_upper_limit
Upper limit of frequency range of this spectrum.
Definition relaxisloader.h:86
size_t length
Amount of data points in the spectrum.
Definition relaxisloader.h:80
struct rlx_datapoint * datapoints
Data points of the spectrum.
Definition relaxisloader.h:79
bool fitted
True if circuit has been fitted to spectrum.
Definition relaxisloader.h:83
char * circuit
RelaxIS circuit description string.
Definition relaxisloader.h:82