|
|
|
#pragma once
|
|
|
|
#include "DataAdapters/ncfilealt.h"
|
|
|
|
#include "ParseArgs.h"
|
|
|
|
#include "basedata.h"
|
|
|
|
#include "mdatetime.h"
|
|
|
|
#include "mregex.h"
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <set>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
using michlib::Ceil;
|
|
|
|
using michlib::Floor;
|
|
|
|
using michlib::GPL;
|
|
|
|
using michlib::MDateTime;
|
|
|
|
using michlib::pointer_cast;
|
|
|
|
using michlib::RegExp;
|
|
|
|
using michlib::uint2;
|
|
|
|
using michlib::uint4;
|
|
|
|
|
|
|
|
class MODISBINLOCALData
|
|
|
|
{
|
|
|
|
MString datapath;
|
|
|
|
std::vector<MString> dataset;
|
|
|
|
std::vector<MDateTime> times;
|
|
|
|
|
|
|
|
bool SufFromDataset(const MString& datasetstr);
|
|
|
|
|
|
|
|
struct Parameters: public BaseParameters
|
|
|
|
{
|
|
|
|
real lonb, latb, lone, late;
|
|
|
|
virtual ~Parameters() override = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
static constexpr const char* name = "MODISBINLOCAL";
|
|
|
|
|
|
|
|
static constexpr const char* disabledactions = "genintfile uv";
|
|
|
|
|
|
|
|
using Data = UngriddedData;
|
|
|
|
|
|
|
|
MString Info() const;
|
|
|
|
MString Open(const CLArgs& args);
|
|
|
|
bool Read(const MString& vname, std::map<MString, Data>& cache, const BaseParameters* ip, size_t tind) const;
|
|
|
|
Data ReadFile(const MString& suf, const struct Parameters* p, size_t tind) const;
|
|
|
|
|
|
|
|
MString DefaultVars() const
|
|
|
|
{
|
|
|
|
if(dataset.size() == 0) return "";
|
|
|
|
if(dataset[0] == "CHL" || dataset[0] == "T_CHL" || dataset[0] == "A_CHL")
|
|
|
|
return "chl";
|
|
|
|
else
|
|
|
|
return "temp";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<const BaseParameters*, MString> Parameters(michlib_internal::ParameterListEx& pars, const CLArgs& args, const struct Region& reg) const;
|
|
|
|
|
|
|
|
VarPresence CheckVar(const MString& vname) const
|
|
|
|
{
|
|
|
|
if(dataset.empty()) return VarPresence::NONE;
|
|
|
|
bool ischl = dataset.front() == "A_CHL" || dataset.front() == "T_CHL";
|
|
|
|
if((vname == "chl" && ischl) || (vname == "temp" && !ischl)) return VarPresence::INTERNAL;
|
|
|
|
return VarPresence::NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isOk() const { return times.size() > 0; }
|
|
|
|
|
|
|
|
size_t NTimes() const { return times.size(); }
|
|
|
|
|
|
|
|
MDateTime Time(size_t i) const
|
|
|
|
{
|
|
|
|
if(!isOk() || i >= times.size()) return MDateTime();
|
|
|
|
return times[i];
|
|
|
|
}
|
|
|
|
};
|