mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
New tool for analyzing real data. Factorized the getopt generation procedure in CMake
This commit is contained in:
parent
07a3be4db0
commit
3e638974d3
2 changed files with 80 additions and 0 deletions
57
mytools/particleInfo.cpp
Normal file
57
mytools/particleInfo.cpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#include <netcdfcpp.h>
|
||||||
|
#include <CosmoTool/fortran.hpp>
|
||||||
|
#include "particleInfo.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace CosmoTool;
|
||||||
|
|
||||||
|
bool loadParticleInfo(ParticleInfo& info,
|
||||||
|
const std::string& particles,
|
||||||
|
const std::string& extra_info)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UnformattedRead f(particles);
|
||||||
|
|
||||||
|
int numpart;
|
||||||
|
|
||||||
|
f.beginCheckpoint();
|
||||||
|
numpart = f.readInt32();
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
info.particles.resize(numpart);
|
||||||
|
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (int i = 0; i < numpart; i++)
|
||||||
|
info.particles[i].x = f.readReal32();
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (int i = 0; i < numpart; i++)
|
||||||
|
info.particles[i].y = f.readReal32();
|
||||||
|
f.endCheckpoint();
|
||||||
|
|
||||||
|
f.beginCheckpoint();
|
||||||
|
for (int i = 0; i < numpart; i++)
|
||||||
|
info.particles[i].z = f.readReal32();
|
||||||
|
f.endCheckpoint();
|
||||||
|
}
|
||||||
|
catch (const NoSuchFileException& e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NcFile f_info(extra_info.c_str());
|
||||||
|
|
||||||
|
if (!f_info.is_valid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
info.ranges[0][0] = f_info.get_att("range_x_min")->as_double(0);
|
||||||
|
info.ranges[0][1] = f_info.get_att("range_x_max")->as_double(0);
|
||||||
|
info.ranges[1][0] = f_info.get_att("range_y_min")->as_double(0);
|
||||||
|
info.ranges[1][1] = f_info.get_att("range_y_max")->as_double(0);
|
||||||
|
info.ranges[2][0] = f_info.get_att("range_z_min")->as_double(0);
|
||||||
|
info.ranges[2][1] = f_info.get_att("range_z_max")->as_double(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
23
mytools/particleInfo.hpp
Normal file
23
mytools/particleInfo.hpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef _PARTICLE_INFO_HEADER_HPP
|
||||||
|
#define _PARTICLE_INFO_HEADER_HPP
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct ParticleData {
|
||||||
|
float x, y, z;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<ParticleData> ParticleVector;
|
||||||
|
|
||||||
|
struct ParticleInfo
|
||||||
|
{
|
||||||
|
ParticleVector particles;
|
||||||
|
float ranges[3][2];
|
||||||
|
};
|
||||||
|
|
||||||
|
bool loadParticleInfo(ParticleInfo& info,
|
||||||
|
const std::string& particles,
|
||||||
|
const std::string& extra_info);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue