librelaxisloader 1.0.x
librelaxisloader manual

librelaxisloader is a shared library that allows you to load data from RelaxIS3 files. This library supports only files with a DatabaseFormat of "1"

An API reference can be found here: User API

For instructions on how to build this library please see the Readme

Example usage:


#include <stdio.h>
#include <relaxisloader.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
if(argc < 2) {
printf("Usage %s [FILE]\n", argc == 1 ? argv[0] : "NULL");
return 1;
}
// Open a RelaxIS3 file and check for errors
const char *error;
struct rlxfile *file = rlx_open_file(argv[1], &error);
if(!file) {
printf("Unable to open %s: %s\n", argv[1], error);
return 2;
}
// Read all projects from the file just opened
size_t projectCount;
struct rlx_project** projects = rlx_get_projects(file, &projectCount);
if(projectCount < 1) {
printf("File contains no projects: %s\n", rlx_get_errnum_str(rlx_get_errnum(file)));
return 4;
}
// Get the ids of specra associated with the first project in the file
size_t idCount;
int *ids = rlx_get_spectra_ids(file, projects[0], &idCount);
for(int i = 0; i < idCount; ++i)
printf("PROJECT: %d ID: %d\n", projects[0]->id, ids[i]);
if(idCount < 1) {
printf("No spectra in project %d: %s\n", projects[0]->id, rlx_get_errnum_str(rlx_get_errnum(file)));
return 3;
}
printf("%p %d\n", projects[0], projects[0]->id);
// Grab the first spectrum
struct rlx_spectra* spectra = rlx_get_spectra(file, projects[0], ids[0]);
if(!spectra) {
printf("Could not load spectra for %d %d: %s\n", projects[0]->id, ids[0], rlx_get_errnum_str(rlx_get_errnum(file)));
return 3;
}
printf("Spectra for PROJECT: %d ID: %d\nomega, re, im\n", projects[0]->id, ids[0]);
for(size_t i = 0; i < spectra->length; ++i) {
printf("%f,%f,%f\n", spectra->datapoints[i].omega, spectra->datapoints[i].re, spectra->datapoints[i].im);
}
size_t paramCount;
// Grab the parameters for the first spectrum
struct rlx_fitparam** params = rlx_get_fit_parameters(file, projects[0], ids[0], &paramCount);
if(!params) {
printf("Could not get parameters for project %d spectra %d: %s\n", projects[0]->id, ids[0], rlx_get_errnum_str(rlx_get_errnum(file)));
return 4;
}
for(size_t i = 0; i < paramCount; ++i) {
printf("Parameter %d: Name: %s Value: %f Error: %f\n", params[i]->p_index, params[i]->name, params[i]->value, params[i]->error);
}
// Free aquired structs
rlx_spectra_free(spectra);
free(ids);
// Close RelaxIS3 file
rlx_close_file(file);
return 0;
}
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_array(struct rlx_project **proj_array)
This frees an array of project structs.
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.
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
This struct is used to house an EIS spectra and associated meta-data.
Definition relaxisloader.h:76
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

librelaxisloader is licensed to you under the Gnu Lesser General Public License Version 3.0