Browse Source

Interfaces of UVData classes made more consistent with interfaces of BaseData classes

interpolate
Michael Uleysky 1 year ago
parent
commit
fd7d7f8a5f
  1. 22
      include/uvdata.h

22
include/uvdata.h

@ -21,6 +21,7 @@ class UVDataStorage
std::vector<real> u, v, u2; std::vector<real> u, v, u2;
size_t nx = 0, ny = 0; size_t nx = 0, ny = 0;
Metric metric; Metric metric;
MString unit;
UVDataStorage() = default; UVDataStorage() = default;
real D(real lon1, real lat1, real lon2, real lat2) const real D(real lon1, real lat1, real lon2, real lat2) const
@ -38,6 +39,8 @@ class UVDataStorage
real Ud(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : U(ix, iy); } real Ud(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : U(ix, iy); }
real Vd(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : V(ix, iy); } real Vd(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : V(ix, iy); }
void SetUnit(const MString& str) { unit = str; }
public: public:
enum STPOINT enum STPOINT
{ {
@ -82,7 +85,22 @@ class UVDataStorage
bool IsCoast(size_t i) const { return U(i) == fillval || V(i) == fillval; } bool IsCoast(size_t i) const { return U(i) == fillval || V(i) == fillval; }
bool IsCoast(size_t ix, size_t iy) const { return U(ix, iy) == fillval || V(ix, iy) == fillval; } bool IsCoast(size_t ix, size_t iy) const { return U(ix, iy) == fillval || V(ix, iy) == fillval; }
bool IsFill(size_t i) const { return IsCoast(i); }
bool IsFill(size_t ix, size_t iy) const { return IsCoast(ix, iy); }
static real Fillval() { return fillval; } static real Fillval() { return fillval; }
const MString& Unit() const { return unit; }
const MString DUnit() const
{
switch(metric)
{
case(Metric::EUCLID): return "";
case(Metric::SPHERIC): return "km";
}
return "";
}
}; };
template<class OneVarData, bool isgrid> class UVDataDims; template<class OneVarData, bool isgrid> class UVDataDims;
@ -128,6 +146,7 @@ template<class OneVarData> class UVDataDims<OneVarData, true>: public UVDataStor
U2(i) = u(i) * u(i) + v(i) * v(i); U2(i) = u(i) * u(i) + v(i) * v(i);
} }
} }
SetUnit(u.Unit());
} }
public: public:
@ -138,6 +157,9 @@ template<class OneVarData> class UVDataDims<OneVarData, true>: public UVDataStor
real XStep() const { return xstep; } real XStep() const { return xstep; }
real YStep() const { return ystep; } real YStep() const { return ystep; }
real Ix2Lon(size_t ix) const { return x0 + ix * xstep; }
real Iy2Lat(size_t iy) const { return y0 + iy * ystep; }
}; };
template<class OneVarData> class UVDataDims<OneVarData, false>: public UVDataStorage template<class OneVarData> class UVDataDims<OneVarData, false>: public UVDataStorage

Loading…
Cancel
Save