generating radspecs from pcfs
This commit is contained in:
parent
c5baf04952
commit
2bc40926b8
517 changed files with 57914 additions and 111 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "utk/metrics/PCF.hpp"
|
||||
#include "utk/metrics/RDF_Heck.hpp"
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <utk/metrics/RadialSpectrum.hpp>
|
||||
#include <utk/samplers/SamplerStep.hpp>
|
||||
#include <utk/utils/Pointset.hpp>
|
||||
|
|
@ -10,57 +12,35 @@
|
|||
#define NBINS 1000
|
||||
#define SEED 8970
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void writeSpectrumToFile(const std::string &filename, std::vector<T> spectrum) {
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
|
||||
file << DIMENSION << std::endl;
|
||||
file << DIMENSION << std::endl;
|
||||
|
||||
for (auto freq : spectrum) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << freq << std::endl;
|
||||
}
|
||||
for (auto freq: spectrum) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << freq << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void writePCFToFile(const std::string &filename, std::vector<T> spectrum) {
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
|
||||
for (auto freq : spectrum) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << freq << std::endl;
|
||||
}
|
||||
for (auto freq: spectrum) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << freq << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void writeRadspecToFile(const std::string &filename,
|
||||
std::pair<std::vector<T>, std::vector<T>> radspec) {
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
|
||||
auto xs = radspec.first;
|
||||
auto ys = radspec.second;
|
||||
|
||||
if (xs.size() != ys.size()) {
|
||||
std::cerr << "Dimensions of radial spactrum are unequal: xDim: "
|
||||
<< xs.size() << " yDim: " << ys.size() << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
for (int i = 0; i < xs.size(); ++i) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << xs[i] << ", " << ys[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void writeRDFtoFile(const std::string &filename,
|
||||
std::pair<std::vector<T>, std::vector<T>> radspec) {
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
|
||||
|
|
@ -80,34 +60,64 @@ void writeRDFtoFile(const std::string &filename,
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void writeRDFtoFile(const std::string &filename,
|
||||
std::pair<std::vector<T>, std::vector<T>> radspec) {
|
||||
std::ofstream file;
|
||||
file.open(filename);
|
||||
|
||||
auto xs = radspec.first;
|
||||
auto ys = radspec.second;
|
||||
|
||||
if (xs.size() != ys.size()) {
|
||||
std::cerr << "Dimensions of radial spectrum are unequal: xDim: "
|
||||
<< xs.size() << " yDim: " << ys.size() << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
for (int i = 0; i < xs.size(); ++i) {
|
||||
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
||||
<< std::fixed;
|
||||
file << xs[i] << ", " << ys[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// load Points from file and generate metrics
|
||||
auto loadedPoints =
|
||||
utk::read_pointsets<long double>("../result_data/sampled.txt")[0];
|
||||
auto pointView =
|
||||
utk::Pointset<long double>::View(loadedPoints.Data(), NSAMPLES, 2);
|
||||
auto resultDataPath =
|
||||
std::filesystem::path{"../result_data/pointset_series/pointsets/"};
|
||||
auto outputPath =
|
||||
std::filesystem::path{"../result_data/pointset_series/radspecs/"};
|
||||
|
||||
// Radial spectrum
|
||||
std::cout << "Calculating radial spectrum with " << NBINS
|
||||
<< " bins and resolution " << DIMENSION << std::endl;
|
||||
auto radSpec =
|
||||
utk::RadialSpectrum(NBINS, 0.5, DIMENSION, true).compute(pointView);
|
||||
std::vector<std::pair<std::string, utk::Pointset<long double>>> pointsets;
|
||||
|
||||
writeRadspecToFile("radSpec.txt", radSpec);
|
||||
for (const auto &file: std::filesystem::directory_iterator(resultDataPath)) {
|
||||
|
||||
for (float i = 0.015625f; i <= 0.5f; i += 0.015625f) {
|
||||
// PCF
|
||||
std::cout << "Calculating RDF with " << NBINS << " bins for max radius " << i << "…" << std::endl;
|
||||
auto rdf = utk::RDF{true, NBINS, i}.compute(pointView);
|
||||
auto loadedPoints =
|
||||
utk::read_pointsets<long double>(file.path().c_str())[0];
|
||||
|
||||
writeRDFtoFile("rdffiles/rdf_" + std::to_string(i) + ".txt", rdf);
|
||||
}
|
||||
auto copiedPointset = utk::Pointset<long double>(std::move(loadedPoints));
|
||||
|
||||
// FFT based spectrum
|
||||
std::cout << "Calculating spectrum with resolution " << DIMENSION << "…"
|
||||
<< std::endl;
|
||||
pointsets.emplace_back(file.path().stem().string(), copiedPointset);
|
||||
}
|
||||
|
||||
auto spec = utk::Spectrum{DIMENSION, true}.compute(pointView);
|
||||
writeSpectrumToFile("spectrum.txt", spec);
|
||||
auto radSpec =
|
||||
utk::RadialSpectrum(
|
||||
0, // Number of bins
|
||||
0.5,// Scale for distances (compress / expands bins size)
|
||||
0, // Resolution for underlying fourier spectrum, only odd number.
|
||||
// If even will use res - 1
|
||||
true// Cancel DC
|
||||
);
|
||||
|
||||
|
||||
for (auto &pointset: pointsets) {
|
||||
std::cout << "computing radial spectrum for " << pointset.first << std::endl;
|
||||
|
||||
auto result = radSpec.compute(pointset.second);
|
||||
|
||||
writeRadspecToFile((outputPath / pointset.first).string() + ".rdf", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue