Browse Source

List of supported variables in action=info

interpolate
Michael Uleysky 2 years ago
parent
commit
e59669b31b
  1. 27
      include/NEMO.h
  2. 19
      include/vartype.h

27
include/NEMO.h

@ -4,6 +4,7 @@
#include "specfunc.h" #include "specfunc.h"
#include "vartype.h" #include "vartype.h"
#include <regex.h> #include <regex.h>
#include <set>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
@ -252,6 +253,29 @@ class NEMOData
MString d; MString d;
for(size_t i = 0; i < NDepths(); i++) d += MString(" ") + "(" + i + " " + Depth(i) + ")"; for(size_t i = 0; i < NDepths(); i++) d += MString(" ") + "(" + i + " " + Depth(i) + ")";
std::set<VarType> vars;
for(const auto& f: nc)
{
auto head = f.Header();
for(const auto& v: head.Variables())
{
if(v.Name() == "thetao") vars.emplace("temp");
if(v.Name() == "so") vars.emplace("sal");
if(v.Name() == "mlotst") vars.emplace("mld");
if(v.Name() == "zos") vars.emplace("ssh");
if(v.Name() == "wo") vars.emplace("w");
}
}
MString svars;
{
bool first = true;
for(const auto& v: vars)
{
svars += (first ? "" : ", ") + v.ShortName();
first = false;
}
}
// clang-format off // clang-format off
return return
"Dataset: " + Title() + "\n" + "Dataset: " + Title() + "\n" +
@ -259,7 +283,8 @@ class NEMOData
" End date: " + Time(NTimes()-1).ToString() + "\n" + " End date: " + Time(NTimes()-1).ToString() + "\n" +
" Time step: " + Timestep() + " seconds\n" + " Time step: " + Timestep() + " seconds\n" +
" Time moments: " + NTimes() + "\n" + " Time moments: " + NTimes() + "\n" +
" Depths:" + d; " Depths:" + d + "\n" +
" Supported variables: " + svars;
// clang-format on // clang-format on
} }

19
include/vartype.h

@ -84,10 +84,27 @@ class VarType: public vartype::VartypeUnion
return "none"; return "none";
} }
MString ShortName() const
{
switch(VT())
{
case(vartype::Vartype::NONE): return "none";
case(vartype::Vartype::U): return "u";
case(vartype::Vartype::V): return "v";
case(vartype::Vartype::TEMP): return "temp";
case(vartype::Vartype::SAL): return "sal";
case(vartype::Vartype::CHL): return "chl";
case(vartype::Vartype::MLD): return "mld";
case(vartype::Vartype::SSH): return "ssh";
case(vartype::Vartype::W): return "w";
}
return "none";
}
bool Ok() const { return VT() != vartype::Vartype::NONE; } bool Ok() const { return VT() != vartype::Vartype::NONE; }
explicit operator bool() const { return Ok(); } explicit operator bool() const { return Ok(); }
bool operator==(const VarType& vt) const { return VT() == vt.VT(); } bool operator==(const VarType& vt) const { return VT() == vt.VT(); }
bool operator!=(const VarType& vt) const { return VT() != vt.VT(); } auto operator<=>(const VarType& vt) const { return VT() <=> vt.VT(); }
template<class Data> bool isSupported() const template<class Data> bool isSupported() const
{ {
return std::visit( return std::visit(

Loading…
Cancel
Save