mirror of
https://github.com/MartinOpat/cuda-based-raytrace.git
synced 2025-06-07 02:13:10 +02:00
loaded data using netcdfcxx
This commit is contained in:
25
src/hurricanedata/datareader.cu
Normal file
25
src/hurricanedata/datareader.cu
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user