|
|
|
@ -233,10 +233,7 @@ bool LayeredDataZ::Read(const MString& vname, std::map<MString, LayeredDataZ::Da
|
|
|
|
|
if(v.Name() == name) |
|
|
|
|
{ |
|
|
|
|
if(v.NDim() == 3) nodepth = true; |
|
|
|
|
if(v.Type() == NcZarrTypes::VarType::INT2) data = ReadVarRaw<int2>(nc[id], name, tid, nodepth, p); |
|
|
|
|
if(v.Type() == NcZarrTypes::VarType::INT4) data = ReadVarRaw<int>(nc[id], name, tid, nodepth, p); |
|
|
|
|
if(v.Type() == NcZarrTypes::VarType::FLOAT) data = ReadVarRaw<float>(nc[id], name, tid, nodepth, p); |
|
|
|
|
if(v.Type() == NcZarrTypes::VarType::DOUBLE) data = ReadVarRaw<double>(nc[id], name, tid, nodepth, p); |
|
|
|
|
data = ReadVarRaw(nc[id], name, tid, nodepth, p); |
|
|
|
|
if(data) |
|
|
|
|
{ |
|
|
|
|
cache[vname] = std::move(data); |
|
|
|
@ -247,10 +244,9 @@ bool LayeredDataZ::Read(const MString& vname, std::map<MString, LayeredDataZ::Da
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<class DataType> LayeredDataZ::Data LayeredDataZ::ReadVarRaw(const NC& f, const MString& name, size_t i, bool nodepth, const struct LayeredDataZ::Parameters* p) const |
|
|
|
|
LayeredDataZ::Data LayeredDataZ::ReadVarRaw(const NC& f, const MString& name, size_t i, bool nodepth, const struct LayeredDataZ::Parameters* p) const |
|
|
|
|
{ |
|
|
|
|
real unitmul = 1.0; |
|
|
|
|
//DataType fill;
|
|
|
|
|
real offset = 0.0, scale = 1.0; |
|
|
|
|
|
|
|
|
|
if(f.HasAtt(name, "add_offset")) offset = f.AttReal(name, "add_offset"); |
|
|
|
@ -266,7 +262,7 @@ template<class DataType> LayeredDataZ::Data LayeredDataZ::ReadVarRaw(const NC& f
|
|
|
|
|
|
|
|
|
|
Data data((p->xb < p->xe) ? (p->xe - p->xb + 1) : (dname.nx + p->xe - p->xb + 1), p->ye - p->yb + 1, Lon(p->xb), Lat(p->yb), lonstep, latstep, std::move(unit)); |
|
|
|
|
|
|
|
|
|
auto trans = [scale, offset, unitmul](auto raw) -> DataType { return (raw * scale + offset) * unitmul; }; |
|
|
|
|
auto trans = [scale, offset, unitmul](auto raw) -> real { return (raw * scale + offset) * unitmul; }; |
|
|
|
|
|
|
|
|
|
auto rlayer = depthinv ? depths.size() - p->layer - 1 : p->layer; |
|
|
|
|
|
|
|
|
|