loaded data using netcdfcxx

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

No files matched your search

+25
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;
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef DATAREADER_H
#define DATAREADER_H
#include <vector>
#include <string>
std::vector<float> readData(std::string path, std::string variableName);
#endif //DATAREADER_H
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.