|
|
|
@ -70,6 +70,8 @@ class UVMethods
|
|
|
|
|
std::vector<real> x, y; |
|
|
|
|
std::vector<michlib::uint1> t; |
|
|
|
|
bool lonlat; |
|
|
|
|
NCFileWBase nc; |
|
|
|
|
bool tdep; |
|
|
|
|
|
|
|
|
|
size_t N() const { return t.size(); } |
|
|
|
|
|
|
|
|
@ -86,9 +88,19 @@ class UVMethods
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WriteBinBile(const MString& name) const; |
|
|
|
|
void Reset() |
|
|
|
|
{ |
|
|
|
|
x.clear(); |
|
|
|
|
y.clear(); |
|
|
|
|
t.clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WriteBinBile(const MString& name, const michlib_internal::ParameterListEx& pars) const; |
|
|
|
|
|
|
|
|
|
MString WriteNcFile(const MString& name, const MString& history, int comp) const; |
|
|
|
|
MString CreateNcFile(const MString& name, const michlib_internal::ParameterListEx& pars, const MString& history, int comp, const TimeData& tdata, bool timedep); |
|
|
|
|
MString WriteNcFile(size_t it); |
|
|
|
|
|
|
|
|
|
void CloseNcFile() { nc.Close(); } |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -105,12 +117,18 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
|
|
|
|
|
michlib_internal::ParameterListEx pars; |
|
|
|
|
pars.UsePrefix(""); |
|
|
|
|
pars.SetParameter("source", args.at("source")); |
|
|
|
|
pars.SetParameter("history", args.at("_cmdline")); |
|
|
|
|
|
|
|
|
|
bool mode = args.contains("geostrophic"); |
|
|
|
|
|
|
|
|
|
auto [tindexes, err] = GetTIndexes(ds, args, pars); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
|
|
|
|
|
bool average = args.contains("average"); |
|
|
|
|
|
|
|
|
|
int compress = 3; |
|
|
|
|
if(args.contains("compress")) compress = args.at("compress").ToInt(); |
|
|
|
|
|
|
|
|
|
std::unique_ptr<const BaseParameters> sourcepars; |
|
|
|
|
if constexpr(ParametersSupported<D>) |
|
|
|
|
{ |
|
|
|
@ -129,157 +147,188 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
|
|
|
|
|
} |
|
|
|
|
auto p = sourcepars.get(); |
|
|
|
|
|
|
|
|
|
auto data = ReadUV(ds, p, tindexes, mode); |
|
|
|
|
if(!data) return "Can't read data"; |
|
|
|
|
TimeData tdata(ds, tindexes); |
|
|
|
|
|
|
|
|
|
// Main file
|
|
|
|
|
MString name = args.contains("out") ? args.at("out") : ""; |
|
|
|
|
MString outfmt = args.contains("outformat") ? args.at("outformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
MString name = args.contains("out") ? args.at("out") : ""; |
|
|
|
|
MString outfmt = args.contains("outformat") ? args.at("outformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
MString namevel = args.contains("velout") ? args.at("velout") : ""; |
|
|
|
|
MString outfmtvel = args.contains("veloutformat") ? args.at("veloutformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
MString namestp = args.contains("stpout") ? args.at("stpout") : ""; |
|
|
|
|
MString outfmtstp = args.contains("stpoutformat") ? args.at("stpoutformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
|
|
|
|
|
MString u = data.Unit().Exist() ? data.Unit() : "unknown", d = data.DUnit().Exist() ? data.DUnit() : "unknown"; |
|
|
|
|
size_t shiftx = args.contains("shiftx") ? args.at("shiftx").ToInteger<size_t>() : 0; |
|
|
|
|
size_t shifty = args.contains("shifty") ? args.at("shifty").ToInteger<size_t>() : 0; |
|
|
|
|
size_t skipx = args.contains("skipx") ? args.at("skipx").ToInteger<size_t>() : 1; |
|
|
|
|
size_t skipy = args.contains("skipy") ? args.at("skipy").ToInteger<size_t>() : 1; |
|
|
|
|
|
|
|
|
|
if(name.Exist()) |
|
|
|
|
{ |
|
|
|
|
if(outfmt == "bin") |
|
|
|
|
{ |
|
|
|
|
BFileW fw; |
|
|
|
|
fw.Create(name, 9); |
|
|
|
|
fw.SetColumnName(1, "Longitude"); |
|
|
|
|
fw.SetColumnName(2, "Latitude"); |
|
|
|
|
fw.SetColumnName(3, "u, " + u); |
|
|
|
|
fw.SetColumnName(4, "v, " + u); |
|
|
|
|
fw.SetColumnName(5, "Div, (" + u + ")/" + d); |
|
|
|
|
fw.SetColumnName(6, "Rot, (" + u + ")/" + d); |
|
|
|
|
fw.SetColumnName(7, "Okubo-Weiss parameter, (" + u + ")2/" + d + "2"); |
|
|
|
|
fw.SetColumnName(8, "Kinetic energy, (" + u + ")2"); |
|
|
|
|
fw.SetColumnName(9, "Eddy kinetic energy, (" + u + ")2"); |
|
|
|
|
fw.SetParameters(pars); |
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < data.N(); i++) |
|
|
|
|
{ |
|
|
|
|
fw.Write(data.Lon(i)); |
|
|
|
|
fw.Write(data.Lat(i)); |
|
|
|
|
fw.Write(data.U(i) == data.Fillval() ? NAN : data.U(i)); |
|
|
|
|
fw.Write(data.V(i) == data.Fillval() ? NAN : data.V(i)); |
|
|
|
|
fw.Write(data.Div(i) == data.Fillval() ? NAN : data.Div(i)); |
|
|
|
|
fw.Write(data.Rot(i) == data.Fillval() ? NAN : data.Rot(i)); |
|
|
|
|
fw.Write(data.OW(i) == data.Fillval() ? NAN : data.OW(i)); |
|
|
|
|
fw.Write(data.U2(i) == data.Fillval() ? NAN : data.U2(i)); |
|
|
|
|
fw.Write((data.U(i) == data.Fillval() || data.V(i) == data.Fillval()) ? NAN : (data.U2(i) - (data.U(i) * data.U(i) + data.V(i) * data.V(i)))); |
|
|
|
|
} |
|
|
|
|
fw.Finalize(); |
|
|
|
|
fw.Close(); |
|
|
|
|
} |
|
|
|
|
else if(outfmt == "nc" || outfmt == "netcdf") |
|
|
|
|
{ |
|
|
|
|
int compress = 3; |
|
|
|
|
NCFileW fw; |
|
|
|
|
MString err; |
|
|
|
|
|
|
|
|
|
if(args.contains("compress")) compress = args.at("compress").ToInt(); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.Create(data, name, args.at("_cmdline"), compress); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("u", "", "Eastward velocity", u, ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("v", "", "Northward velocity", u, ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("div", "", "Velocity divergence", "(" + u + ")/" + d, ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("rot", "", "Velocity rotor", "(" + u + ")/" + d, ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("ow", "", "Okubo-Weiss parameter", "(" + u + ")2/" + d + "2", ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("ke", "", "Squared velocity module, u^2+v^2", "(" + u + ")2", ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("eke", "", "Squared velocity dispersion aka eddy kinetic energy, <u^2+v^2>-<u>^2-<v>^2", "(" + u + ")2", ""); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.WriteGrid(data); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "u", [&data = std::as_const(data)](size_t i, size_t j) { return data.U(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "v", [&data = std::as_const(data)](size_t i, size_t j) { return data.V(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "div", [&data = std::as_const(data)](size_t i, size_t j) { return data.Div(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "rot", [&data = std::as_const(data)](size_t i, size_t j) { return data.Rot(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "ow", [&data = std::as_const(data)](size_t i, size_t j) { return data.OW(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(data, "ke", [&data = std::as_const(data)](size_t i, size_t j) { return data.U2(i, j); }); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable(data, "eke", [&data = std::as_const(data)](size_t i, size_t j) { return data.U2(i, j) - (data.U(i, j) * data.U(i, j) + data.V(i, j) * data.V(i, j)); }); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
if(!average && tindexes.size() > 1 && ((name.Exist() && outfmt == "bin") || (namevel.Exist() && outfmtvel == "bin") || (namestp.Exist() && outfmtstp == "bin"))) |
|
|
|
|
return "Multiple time moments does'nt supported by the bin format"; |
|
|
|
|
|
|
|
|
|
fw.Close(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmt; |
|
|
|
|
} |
|
|
|
|
bool headwrited = false; |
|
|
|
|
|
|
|
|
|
MString velunit, distunit; |
|
|
|
|
NCFileW fw, fwfilt; |
|
|
|
|
|
|
|
|
|
StPoints stp(true); |
|
|
|
|
|
|
|
|
|
// Filtered vectors file
|
|
|
|
|
name = args.contains("velout") ? args.at("velout") : ""; |
|
|
|
|
outfmt = args.contains("veloutformat") ? args.at("veloutformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
if(name.Exist()) |
|
|
|
|
for(size_t it = 0; it < tindexes.size(); it++) |
|
|
|
|
{ |
|
|
|
|
size_t shiftx = args.contains("shiftx") ? args.at("shiftx").ToInteger<size_t>() : 0; |
|
|
|
|
size_t shifty = args.contains("shifty") ? args.at("shifty").ToInteger<size_t>() : 0; |
|
|
|
|
size_t skipx = args.contains("skipx") ? args.at("skipx").ToInteger<size_t>() : 1; |
|
|
|
|
size_t skipy = args.contains("skipy") ? args.at("skipy").ToInteger<size_t>() : 1; |
|
|
|
|
auto data = average ? ReadUV(ds, p, tindexes, mode) : ReadUV(ds, p, tindexes[it], mode); |
|
|
|
|
if(!headwrited) |
|
|
|
|
{ |
|
|
|
|
velunit = data.Unit().Exist() ? data.Unit() : "unknown"; |
|
|
|
|
distunit = data.DUnit().Exist() ? data.DUnit() : "unknown"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Sparser<decltype(data)> sdata(data, shiftx, shifty, skipx, skipy); |
|
|
|
|
if(outfmt == "bin") |
|
|
|
|
// Main file
|
|
|
|
|
if(name.Exist()) |
|
|
|
|
{ |
|
|
|
|
BFileW vel; |
|
|
|
|
vel.Create(name, 4); |
|
|
|
|
vel.SetColumnName(1, "Longitude"); |
|
|
|
|
vel.SetColumnName(2, "Latitude"); |
|
|
|
|
vel.SetColumnName(3, "u, " + u); |
|
|
|
|
vel.SetColumnName(4, "v, " + u); |
|
|
|
|
|
|
|
|
|
for(size_t ix = 0; ix < sdata.Nx(); ix++) |
|
|
|
|
for(size_t iy = 0; iy < sdata.Ny(); iy++) |
|
|
|
|
if(outfmt == "bin") |
|
|
|
|
{ |
|
|
|
|
BFileW fw; |
|
|
|
|
fw.Create(name, 9); |
|
|
|
|
fw.SetColumnName(1, "Longitude"); |
|
|
|
|
fw.SetColumnName(2, "Latitude"); |
|
|
|
|
fw.SetColumnName(3, "u, " + velunit); |
|
|
|
|
fw.SetColumnName(4, "v, " + velunit); |
|
|
|
|
fw.SetColumnName(5, "Div, (" + velunit + ")/" + distunit); |
|
|
|
|
fw.SetColumnName(6, "Rot, (" + velunit + ")/" + distunit); |
|
|
|
|
fw.SetColumnName(7, "Okubo-Weiss parameter, (" + velunit + ")2/" + distunit + "2"); |
|
|
|
|
fw.SetColumnName(8, "Kinetic energy, (" + velunit + ")2"); |
|
|
|
|
fw.SetColumnName(9, "Eddy kinetic energy, (" + velunit + ")2"); |
|
|
|
|
fw.SetParameters(pars); |
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < data.N(); i++) |
|
|
|
|
{ |
|
|
|
|
vel.Write(sdata.Lon(ix, iy)); |
|
|
|
|
vel.Write(sdata.Lat(ix, iy)); |
|
|
|
|
vel.Write(sdata.U(ix, iy) == sdata.Fillval() ? NAN : sdata.U(ix, iy)); |
|
|
|
|
vel.Write(sdata.V(ix, iy) == sdata.Fillval() ? NAN : sdata.V(ix, iy)); |
|
|
|
|
fw.Write(data.Lon(i)); |
|
|
|
|
fw.Write(data.Lat(i)); |
|
|
|
|
fw.Write(data.U(i) == data.Fillval() ? NAN : data.U(i)); |
|
|
|
|
fw.Write(data.V(i) == data.Fillval() ? NAN : data.V(i)); |
|
|
|
|
fw.Write(data.Div(i) == data.Fillval() ? NAN : data.Div(i)); |
|
|
|
|
fw.Write(data.Rot(i) == data.Fillval() ? NAN : data.Rot(i)); |
|
|
|
|
fw.Write(data.OW(i) == data.Fillval() ? NAN : data.OW(i)); |
|
|
|
|
fw.Write(data.U2(i) == data.Fillval() ? NAN : data.U2(i)); |
|
|
|
|
fw.Write((data.U(i) == data.Fillval() || data.V(i) == data.Fillval()) ? NAN : (data.U2(i) - (data.U(i) * data.U(i) + data.V(i) * data.V(i)))); |
|
|
|
|
} |
|
|
|
|
vel.Finalize(); |
|
|
|
|
vel.Close(); |
|
|
|
|
fw.Finalize(); |
|
|
|
|
fw.Close(); |
|
|
|
|
} |
|
|
|
|
else if(outfmt == "nc" || outfmt == "netcdf") |
|
|
|
|
{ |
|
|
|
|
MString err; |
|
|
|
|
|
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.Create(data, name, compress); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddTimeData(tdata, !average); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddAtts(pars); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("u", "", "Eastward velocity", velunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("v", "", "Northward velocity", velunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("div", "", "Velocity divergence", "(" + velunit + ")/" + distunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("rot", "", "Velocity rotor", "(" + velunit + ")/" + distunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("ow", "", "Okubo-Weiss parameter", "(" + velunit + ")2/" + distunit + "2", ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("ke", "", "Squared velocity module, u^2+v^2", "(" + velunit + ")2", ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.AddVariable("eke", "", "Squared velocity dispersion aka eddy kinetic energy, <u^2+v^2>-<u>^2-<v>^2", "(" + velunit + ")2", ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fw.WriteGrid(data); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "u", [&data = std::as_const(data)](size_t i, size_t j) { return data.U(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "v", [&data = std::as_const(data)](size_t i, size_t j) { return data.V(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "div", [&data = std::as_const(data)](size_t i, size_t j) { return data.Div(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "rot", [&data = std::as_const(data)](size_t i, size_t j) { return data.Rot(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "ow", [&data = std::as_const(data)](size_t i, size_t j) { return data.OW(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "ke", [&data = std::as_const(data)](size_t i, size_t j) { return data.U2(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fw.WriteVariable( |
|
|
|
|
data, "eke", [&data = std::as_const(data)](size_t i, size_t j) { return data.U2(i, j) - (data.U(i, j) * data.U(i, j) + data.V(i, j) * data.V(i, j)); }, it); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmt; |
|
|
|
|
} |
|
|
|
|
else if(outfmt == "nc" || outfmt == "netcdf") |
|
|
|
|
{ |
|
|
|
|
int compress = 3; |
|
|
|
|
NCFileW fw; |
|
|
|
|
MString err; |
|
|
|
|
|
|
|
|
|
if(args.contains("compress")) compress = args.at("compress").ToInt(); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.Create(sdata, name, args.at("_cmdline"), compress); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("u", "", "Eastward velocity", u, ""); |
|
|
|
|
if(!err.Exist()) err = fw.AddVariable("v", "", "Northward velocity", u, ""); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.WriteGrid(sdata); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(sdata, "u", [&data = std::as_const(sdata)](size_t i, size_t j) { return data.U(i, j); }); |
|
|
|
|
if(!err.Exist()) err = fw.WriteVariable(sdata, "v", [&data = std::as_const(sdata)](size_t i, size_t j) { return data.V(i, j); }); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
|
|
|
|
|
fw.Close(); |
|
|
|
|
// Filtered file
|
|
|
|
|
if(namevel.Exist()) |
|
|
|
|
{ |
|
|
|
|
Sparser<decltype(data)> sdata(data, shiftx, shifty, skipx, skipy); |
|
|
|
|
if(outfmtvel == "bin") |
|
|
|
|
{ |
|
|
|
|
BFileW vel; |
|
|
|
|
vel.Create(name, 4); |
|
|
|
|
vel.SetColumnName(1, "Longitude"); |
|
|
|
|
vel.SetColumnName(2, "Latitude"); |
|
|
|
|
vel.SetColumnName(3, "u, " + velunit); |
|
|
|
|
vel.SetColumnName(4, "v, " + velunit); |
|
|
|
|
vel.SetParameters(pars); |
|
|
|
|
|
|
|
|
|
for(size_t ix = 0; ix < sdata.Nx(); ix++) |
|
|
|
|
for(size_t iy = 0; iy < sdata.Ny(); iy++) |
|
|
|
|
{ |
|
|
|
|
vel.Write(sdata.Lon(ix, iy)); |
|
|
|
|
vel.Write(sdata.Lat(ix, iy)); |
|
|
|
|
vel.Write(sdata.U(ix, iy) == sdata.Fillval() ? NAN : sdata.U(ix, iy)); |
|
|
|
|
vel.Write(sdata.V(ix, iy) == sdata.Fillval() ? NAN : sdata.V(ix, iy)); |
|
|
|
|
} |
|
|
|
|
vel.Finalize(); |
|
|
|
|
vel.Close(); |
|
|
|
|
} |
|
|
|
|
else if(outfmtvel == "nc" || outfmtvel == "netcdf") |
|
|
|
|
{ |
|
|
|
|
MString err; |
|
|
|
|
|
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.Create(sdata, name, compress); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.AddTimeData(tdata, !average); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.AddAtts(pars); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.AddVariable("u", "", "Eastward velocity", velunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.AddVariable("v", "", "Northward velocity", velunit, ""); |
|
|
|
|
if(!err.Exist() && !headwrited) err = fwfilt.WriteGrid(sdata); |
|
|
|
|
|
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fwfilt.WriteVariable( |
|
|
|
|
sdata, "u", [&data = std::as_const(sdata)](size_t i, size_t j) { return data.U(i, j); }, it); |
|
|
|
|
if(!err.Exist()) |
|
|
|
|
err = fwfilt.WriteVariable( |
|
|
|
|
sdata, "v", [&data = std::as_const(sdata)](size_t i, size_t j) { return data.V(i, j); }, it); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmtvel; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Stationary points
|
|
|
|
|
name = args.contains("stpout") ? args.at("stpout") : ""; |
|
|
|
|
outfmt = args.contains("stpoutformat") ? args.at("stpoutformat") : (GetExt(name) == "nc" ? "nc" : "bin"); |
|
|
|
|
if(name.Exist()) |
|
|
|
|
{ |
|
|
|
|
StPoints p(true); |
|
|
|
|
for(size_t ix = 0; ix < data.Nx() - 1; ix++) |
|
|
|
|
for(size_t iy = 0; iy < data.Ny() - 1; iy++) p.Add(data.StablePoints(ix, iy)); |
|
|
|
|
|
|
|
|
|
if(outfmt == "bin") |
|
|
|
|
p.WriteBinBile(name); |
|
|
|
|
else if(outfmt == "nc" || outfmt == "netcdf") |
|
|
|
|
// Stationary points
|
|
|
|
|
if(namestp.Exist()) |
|
|
|
|
{ |
|
|
|
|
int compress = args.contains("compress") ? args.at("compress").ToInt() : 3; |
|
|
|
|
MString err = p.WriteNcFile(name, args.at("_cmdline"), compress); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
stp.Reset(); |
|
|
|
|
for(size_t ix = 0; ix < data.Nx() - 1; ix++) |
|
|
|
|
for(size_t iy = 0; iy < data.Ny() - 1; iy++) stp.Add(data.StablePoints(ix, iy)); |
|
|
|
|
|
|
|
|
|
if(outfmtstp == "bin") |
|
|
|
|
stp.WriteBinBile(name, pars); |
|
|
|
|
else if(outfmtstp == "nc" || outfmtstp == "netcdf") |
|
|
|
|
{ |
|
|
|
|
MString err; |
|
|
|
|
if(!err.Exist() && !headwrited) err = stp.CreateNcFile(name, pars, args.at("_cmdline"), compress, tdata, !average); |
|
|
|
|
if(!err.Exist()) err = stp.WriteNcFile(it); |
|
|
|
|
if(err.Exist()) return err; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmt; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return "Unknown format: " + outfmt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(average) break; |
|
|
|
|
headwrited = true; |
|
|
|
|
} |
|
|
|
|
fw.Close(); |
|
|
|
|
fwfilt.Close(); |
|
|
|
|
stp.CloseNcFile(); |
|
|
|
|
return ""; |
|
|
|
|
}; |
|
|
|
|