loaded data using netcdfcxx

This commit is contained in:
Robin
2024-12-19 18:53:05 +01:00
parent cdef3b2589
commit cfc1774679
20 changed files with 74 additions and 404 deletions

View File

@@ -0,0 +1,25 @@
#include "datareader.h"
#include <netcdf>
using namespace std;
using namespace netCDF;
std::vector<float> readData(std::string path, std::string variableName) {
netCDF::NcFile data(path, netCDF::NcFile::read);
multimap<string, NcVar> vars = data.getVars();
NcVar var = vars.find(variableName)->second;
int length = 1;
for (NcDim dim: var.getDims()) {
length *= dim.getSize();
}
vector<float> vec(length);
var.getVar(vec.data());
return vec;
}