update for eisgenerator compat
This commit is contained in:
		
							parent
							
								
									e9d6869500
								
							
						
					
					
						commit
						eb39967226
					
				
					 2 changed files with 45 additions and 4 deletions
				
			
		| 
						 | 
					@ -7,7 +7,11 @@ set(COMMON_SRC_FILES
 | 
				
			||||||
	src/common.cpp
 | 
						src/common.cpp
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(COMMON_LINK_LIBRARIES -leisgenerator)
 | 
					if(WIN32)
 | 
				
			||||||
 | 
						set(COMMON_LINK_LIBRARIES -leisgenerator_static -static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive -Bdynamic)
 | 
				
			||||||
 | 
					else()
 | 
				
			||||||
 | 
						set(COMMON_LINK_LIBRARIES -leisgenerator)
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_compile_options(
 | 
					add_compile_options(
 | 
				
			||||||
	"-Wall"
 | 
						"-Wall"
 | 
				
			||||||
| 
						 | 
					@ -24,7 +28,7 @@ set_property(TARGET madaptoeis PROPERTY CXX_STANDARD 17)
 | 
				
			||||||
install(TARGETS madaptoeis RUNTIME DESTINATION bin)
 | 
					install(TARGETS madaptoeis RUNTIME DESTINATION bin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(relaxistoeis ${COMMON_SRC_FILES} src/relaxis.cpp)
 | 
					add_executable(relaxistoeis ${COMMON_SRC_FILES} src/relaxis.cpp)
 | 
				
			||||||
target_link_libraries(relaxistoeis ${COMMON_LINK_LIBRARIES} -lrelaxisloaderpp)
 | 
					target_link_libraries(relaxistoeis -lrelaxisloaderpp -Wl,-allow-multiple-definition ${COMMON_LINK_LIBRARIES})
 | 
				
			||||||
set_property(TARGET relaxistoeis PROPERTY CXX_STANDARD 17)
 | 
					set_property(TARGET relaxistoeis PROPERTY CXX_STANDARD 17)
 | 
				
			||||||
install(TARGETS relaxistoeis RUNTIME DESTINATION bin)
 | 
					install(TARGETS relaxistoeis RUNTIME DESTINATION bin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
#include <eisgenerator/translators.h>
 | 
					#include <eisgenerator/translators.h>
 | 
				
			||||||
#include <eisgenerator/eistype.h>
 | 
					#include <eisgenerator/eistype.h>
 | 
				
			||||||
#include <eisgenerator/model.h>
 | 
					#include <eisgenerator/model.h>
 | 
				
			||||||
 | 
					#include <eisgenerator/basicmath.h>
 | 
				
			||||||
#include <relaxisloaderpp/relaxisloaderpp.h>
 | 
					#include <relaxisloaderpp/relaxisloaderpp.h>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
| 
						 | 
					@ -11,6 +12,42 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common.h"
 | 
					#include "common.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool saveDataRlx(const rlx::Spectra& data, const std::filesystem::path& outDir, const std::filesystem::path& originFile)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						std::filesystem::path filename;
 | 
				
			||||||
 | 
						std::string modelStrWithoutParams = data.model;
 | 
				
			||||||
 | 
						eis::purgeEisParamBrackets(modelStrWithoutParams);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size_t classIndex = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						do
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							filename.assign("relaxisExport_");
 | 
				
			||||||
 | 
							filename.concat(modelStrWithoutParams);
 | 
				
			||||||
 | 
							filename.concat("_");
 | 
				
			||||||
 | 
							filename.concat(std::to_string(classIndex));
 | 
				
			||||||
 | 
							filename.concat(".csv");
 | 
				
			||||||
 | 
							++classIndex;
 | 
				
			||||||
 | 
						} while(std::filesystem::exists(outDir/filename));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::vector<std::string> labelNames;
 | 
				
			||||||
 | 
						std::vector<double> labels;
 | 
				
			||||||
 | 
						for(auto const& meta : data.metadata)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							labelNames.push_back(meta.first);
 | 
				
			||||||
 | 
							labels.push_back(meta.second);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						eis::EisSpectra eisSpectra(data.data, data.model, originFile, labels, labelNames);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(!eisSpectra.saveToDisk(outDir/filename))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							std::cerr<<"Unable to save to "<<outDir/filename;
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char** argv)
 | 
					int main(int argc, char** argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(argc < 2)
 | 
						if(argc < 2)
 | 
				
			||||||
| 
						 | 
					@ -80,7 +117,7 @@ int main(int argc, char** argv)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							std::vector<eis::DataPoint> genData = model.executeSweep(omega);
 | 
												std::vector<eis::DataPoint> genData = model.executeSweep(omega);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							fvalue dist = eisNyquistDistance(spectra.data, genData);
 | 
												fvalue dist = eis::eisNyquistDistance(spectra.data, genData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							if(std::isnan(dist))
 | 
												if(std::isnan(dist))
 | 
				
			||||||
							{
 | 
												{
 | 
				
			||||||
| 
						 | 
					@ -101,7 +138,7 @@ int main(int argc, char** argv)
 | 
				
			||||||
							data.data = spectra.data;
 | 
												data.data = spectra.data;
 | 
				
			||||||
							data.modelStr = spectra.model;
 | 
												data.modelStr = spectra.model;
 | 
				
			||||||
							data.id = std::to_string(spectra.id);
 | 
												data.id = std::to_string(spectra.id);
 | 
				
			||||||
							saveData("relaxis", data, outDir, argv[arg]);
 | 
												saveDataRlx(spectra, outDir, argv[arg]);
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						catch(const eis::file_error& err)
 | 
											catch(const eis::file_error& err)
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue