You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
2 years ago
|
#pragma once
|
||
|
#include "DataAdapters/ncfilealt.h"
|
||
|
#include "mdatetime.h"
|
||
|
#include <set>
|
||
|
#include <tuple>
|
||
|
|
||
|
using michlib::MDateTime;
|
||
|
using michlib::MString;
|
||
|
using michlib::NCFileA;
|
||
|
|
||
|
class NCFuncs
|
||
|
{
|
||
|
public:
|
||
|
struct CoordNames
|
||
|
{
|
||
|
MString lonname, latname, depthname, timename;
|
||
|
size_t nx, ny, nz, nt;
|
||
|
};
|
||
|
|
||
|
static MString StName2Name(const MString& stname);
|
||
|
static std::tuple<MDateTime, time_t, bool> Refdate(const MString& refdate);
|
||
|
static void GetVars(const NCFileA& nc, std::set<MString>& vars);
|
||
|
static CoordNames GetCNames(const NCFileA& nc);
|
||
|
static CoordNames GetDNames(const NCFileA& nc);
|
||
|
static bool HaveVar(const NCFileA& nc, const MString& vname);
|
||
|
template<class HV> static bool CheckVar(const MString& vname, HV hv)
|
||
|
{
|
||
|
if(!hv(vname))
|
||
|
{
|
||
|
bool varexist = false;
|
||
|
if(vname == "temp" && hv("ptemp") && hv("sal")) varexist = true;
|
||
|
if(vname == "ptemp" && hv("temp") && hv("sal")) varexist = true;
|
||
|
if(vname == "pdens" && (hv("ptemp") || hv("temp")) && hv("sal")) varexist = true;
|
||
|
if((vname == "U" || vname == "U2") && hv("u") && hv("v")) varexist = true;
|
||
|
if(!varexist) return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
};
|