|
|
@ -22,6 +22,9 @@ MString LayeredData::Info() const |
|
|
|
if(vars.contains("ptemp") && vars.contains("sal")) vars.emplace("temp"); |
|
|
|
if(vars.contains("ptemp") && vars.contains("sal")) vars.emplace("temp"); |
|
|
|
if(vars.contains("temp") && vars.contains("sal")) vars.emplace("ptemp"); |
|
|
|
if(vars.contains("temp") && vars.contains("sal")) vars.emplace("ptemp"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(vars.contains("u") && vars.contains("v")) vars.emplace("U"); |
|
|
|
|
|
|
|
if(vars.contains("u") && vars.contains("v")) vars.emplace("U2"); |
|
|
|
|
|
|
|
|
|
|
|
MString svars; |
|
|
|
MString svars; |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool first = true; |
|
|
|
bool first = true; |
|
|
@ -146,6 +149,7 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern |
|
|
|
if(ppar->varname == "temp" && HaveVar("ptemp") && HaveVar("sal")) varexist = true; |
|
|
|
if(ppar->varname == "temp" && HaveVar("ptemp") && HaveVar("sal")) varexist = true; |
|
|
|
if(ppar->varname == "ptemp" && HaveVar("temp") && 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 == "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(!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>(); |
|
|
@ -217,11 +221,6 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(out.Lon(ind) != temp.Lon(ind) || out.Lon(ind) != sal.Lon(ind) || out.Lat(ind) != temp.Lat(ind) || out.Lat(ind) != sal.Lat(ind)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
michlib::errmessage("Internal error"); |
|
|
|
|
|
|
|
exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
@ -241,11 +240,6 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(out.Lon(ind) != temp.Lon(ind) || out.Lon(ind) != sal.Lon(ind) || out.Lat(ind) != temp.Lat(ind) || out.Lat(ind) != sal.Lat(ind)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
michlib::errmessage("Internal error"); |
|
|
|
|
|
|
|
exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
@ -266,11 +260,6 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
auto out = temp; |
|
|
|
auto out = temp; |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(out.Lon(ind) != temp.Lon(ind) || out.Lon(ind) != sal.Lon(ind) || out.Lat(ind) != temp.Lat(ind) || out.Lat(ind) != sal.Lat(ind)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
michlib::errmessage("Internal error"); |
|
|
|
|
|
|
|
exit(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
@ -279,6 +268,26 @@ LayeredData::Data LayeredData::Read(const BaseParameters* ip, size_t i) const |
|
|
|
} |
|
|
|
} |
|
|
|
return out; |
|
|
|
return out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// U and U2 from u and v
|
|
|
|
|
|
|
|
if(p->varname == "U" || p->varname == "U2") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool square = p->varname == "U2"; |
|
|
|
|
|
|
|
struct Parameters params = *p; |
|
|
|
|
|
|
|
params.varname = "u"; |
|
|
|
|
|
|
|
auto u = Read(¶ms, i); |
|
|
|
|
|
|
|
params.varname = "v"; |
|
|
|
|
|
|
|
auto v = Read(¶ms, i); |
|
|
|
|
|
|
|
if(!(u && v)) return Data(); |
|
|
|
|
|
|
|
auto out = u; |
|
|
|
|
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(u.IsFill(ind) || v.IsFill(ind)) |
|
|
|
|
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
out.V(ind) = square ? (u(ind) * u(ind) + v(ind) * v(ind)) : michlib::Hypot(u(ind), v(ind)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return out; |
|
|
|
|
|
|
|
} |
|
|
|
return Data(); |
|
|
|
return Data(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|