|
|
@ -141,17 +141,6 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_ptr<struct Parameters> ppar{new struct Parameters}; |
|
|
|
std::unique_ptr<struct Parameters> ppar{new struct Parameters}; |
|
|
|
|
|
|
|
|
|
|
|
if(!args.contains("var")) return {nullptr, "Variable not specified"}; |
|
|
|
|
|
|
|
ppar->varname = args.at("var"); |
|
|
|
|
|
|
|
if(!HaveVar(ppar->varname)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool varexist = false; |
|
|
|
|
|
|
|
if(ppar->varname == "temp" && HaveVar("ptemp") && HaveVar("sal")) varexist = true; |
|
|
|
|
|
|
|
if(ppar->varname == "ptemp" && HaveVar("temp") && HaveVar("sal")) varexist = true; |
|
|
|
|
|
|
|
if(ppar->varname == "pdens" && (HaveVar("ptemp") || HaveVar("temp")) && HaveVar("sal")) varexist = true; |
|
|
|
|
|
|
|
if((ppar->varname == "U" || ppar->varname == "U2") && HaveVar("u") && HaveVar("v")) varexist = true; |
|
|
|
|
|
|
|
if(!varexist) return {nullptr, "Variable " + ppar->varname + " not exists in this dataset"}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(args.contains("layer")) ppar->layer = args.at("layer").ToInteger<size_t>(); |
|
|
|
if(args.contains("layer")) ppar->layer = args.at("layer").ToInteger<size_t>(); |
|
|
|
if(!args.contains("depth") && ppar->layer >= NDepths()) return {nullptr, MString("Layer ") + ppar->layer + " is too deep!"}; |
|
|
|
if(!args.contains("depth") && ppar->layer >= NDepths()) return {nullptr, MString("Layer ") + ppar->layer + " is too deep!"}; |
|
|
|
real depth = args.contains("depth") ? args.at("depth").ToReal() : Depth(ppar->layer); |
|
|
|
real depth = args.contains("depth") ? args.at("depth").ToReal() : Depth(ppar->layer); |
|
|
@ -188,7 +177,6 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pars.SetParameter("variable", ppar->varname); |
|
|
|
|
|
|
|
pars.SetParameter("depth", Depth(ppar->layer)); |
|
|
|
pars.SetParameter("depth", Depth(ppar->layer)); |
|
|
|
pars.SetParameter("layer", ppar->layer); |
|
|
|
pars.SetParameter("layer", ppar->layer); |
|
|
|
pars.SetParameter("dataset", Title()); |
|
|
|
pars.SetParameter("dataset", Title()); |
|
|
@ -200,23 +188,20 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern |
|
|
|
return {ppar.release(), ""}; |
|
|
|
return {ppar.release(), ""}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
LayeredData::Data LayeredData::Read(const MString& vname, const BaseParameters* ip, size_t i) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!isOk()) return Data(); |
|
|
|
if(!isOk()) return Data(); |
|
|
|
bool nodepth = false; |
|
|
|
bool nodepth = false; |
|
|
|
|
|
|
|
|
|
|
|
auto p = dynamic_cast<const struct Parameters*>(ip); |
|
|
|
auto p = dynamic_cast<const struct Parameters*>(ip); |
|
|
|
auto [name, id, tid] = VarNameLoc(p->varname, times[i]); |
|
|
|
auto [name, id, tid] = VarNameLoc(vname, times[i]); |
|
|
|
if(!name.Exist()) // Conversion read
|
|
|
|
if(!name.Exist()) // Conversion read
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// ptemp from temp and sal
|
|
|
|
// ptemp from temp and sal
|
|
|
|
if(p->varname == "ptemp") |
|
|
|
if(vname == "ptemp") |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct Parameters params = *p; |
|
|
|
auto temp = Read("temp", ip, i); |
|
|
|
params.varname = "temp"; |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
auto temp = Read(¶ms, i); |
|
|
|
|
|
|
|
params.varname = "sal"; |
|
|
|
|
|
|
|
auto sal = Read(¶ms, i); |
|
|
|
|
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
@ -229,13 +214,10 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
return out; |
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
// temp from ptemp and sal
|
|
|
|
// temp from ptemp and sal
|
|
|
|
if(p->varname == "temp") |
|
|
|
if(vname == "temp") |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct Parameters params = *p; |
|
|
|
auto temp = Read("ptemp", ip, i); |
|
|
|
params.varname = "ptemp"; |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
auto temp = Read(¶ms, i); |
|
|
|
|
|
|
|
params.varname = "sal"; |
|
|
|
|
|
|
|
auto sal = Read(¶ms, i); |
|
|
|
|
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
@ -248,14 +230,11 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
return out; |
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
// pdens from temp and sal
|
|
|
|
// pdens from temp and sal
|
|
|
|
if(p->varname == "pdens") |
|
|
|
if(vname == "pdens") |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct Parameters params = *p; |
|
|
|
|
|
|
|
bool tempispot = HaveVar("ptemp"); |
|
|
|
bool tempispot = HaveVar("ptemp"); |
|
|
|
params.varname = tempispot ? "ptemp" : "temp"; |
|
|
|
auto temp = Read(tempispot ? "ptemp" : "temp", ip, i); |
|
|
|
auto temp = Read(¶ms, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
params.varname = "sal"; |
|
|
|
|
|
|
|
auto sal = Read(¶ms, i); |
|
|
|
|
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
@ -269,14 +248,11 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
return out; |
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
// U and U2 from u and v
|
|
|
|
// U and U2 from u and v
|
|
|
|
if(p->varname == "U" || p->varname == "U2") |
|
|
|
if(vname == "U" || vname == "U2") |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool square = p->varname == "U2"; |
|
|
|
bool square = vname == "U2"; |
|
|
|
struct Parameters params = *p; |
|
|
|
auto u = Read("u", ip, i); |
|
|
|
params.varname = "u"; |
|
|
|
auto v = Read("v", ip, i); |
|
|
|
auto u = Read(¶ms, i); |
|
|
|
|
|
|
|
params.varname = "v"; |
|
|
|
|
|
|
|
auto v = Read(¶ms, i); |
|
|
|
|
|
|
|
if(!(u && v)) return Data(); |
|
|
|
if(!(u && v)) return Data(); |
|
|
|
auto out = u; |
|
|
|
auto out = u; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|