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.
104 lines
2.9 KiB
104 lines
2.9 KiB
#define MICHLIB_NOSOURCE |
|
#include "actionuv.h" |
|
|
|
void UVMethods::StPoints::WriteBinBile(const MString& name, const michlib_internal::ParameterListEx& pars) const |
|
{ |
|
BFileW stp; |
|
stp.Create(name, 3); |
|
stp.SetColumnName(1, lonlat ? "Longitude" : "x"); |
|
stp.SetColumnName(2, lonlat ? "Latitude" : "x"); |
|
stp.SetColumnName(3, "Stability (0 - saddle, 1 - st. anticicl. focus, 2 - st. knot, 3 - unst. anticicl. focus, 4 - unst. knot, 5 - st. cicl. focus, 6 - unst. cicl. focus)"); |
|
stp.SetParameters(pars); |
|
|
|
for(size_t i = 0; i < N(); i++) |
|
{ |
|
stp.Write(x[i]); |
|
stp.Write(y[i]); |
|
stp.Write(michlib::int_cast<size_t>(t[i])); |
|
} |
|
stp.Finalize(); |
|
stp.Close(); |
|
} |
|
|
|
MString UVMethods::StPoints::CreateNcFile(const MString& name, const michlib_internal::ParameterListEx& pars, const MString& history, int comp, const TimeData& tdata, bool timedep) |
|
{ |
|
tdep = timedep; |
|
|
|
const MString xname = lonlat ? "longitude" : "x"; |
|
const MString yname = lonlat ? "latitude" : "y"; |
|
|
|
nc.Open(name); |
|
if(!nc) return "Can't create netcdf file " + name + ": " + nc.ErrMessage(); |
|
|
|
nc.AddAtt("history", history); |
|
nc.AddAtts(pars); |
|
nc.AddDim("i", N()); |
|
nc.AddDim("time", tdata.steps.size()); |
|
|
|
nc.AddVar("time", decltype(nc)::Type2NCType<decltype(tdata.steps)::value_type>, "time"); |
|
nc.SetComp("time", comp); |
|
nc.AddAtt("time", "standard_name", "time"); |
|
nc.AddAtt("time", "long_name", "time"); |
|
nc.AddAtt("time", "units", tdata.UnitName()); |
|
|
|
if(tdep) |
|
{ |
|
nc.AddVar(xname, NC_FLOAT, "time", "i"); |
|
nc.AddVar(yname, NC_FLOAT, "time", "i"); |
|
} |
|
else |
|
{ |
|
nc.AddVar(xname, NC_FLOAT, "i"); |
|
nc.AddVar(yname, NC_FLOAT, "i"); |
|
} |
|
nc.SetComp(xname, comp); |
|
nc.SetComp(yname, comp); |
|
|
|
if(lonlat) |
|
{ |
|
nc.AddAtt(xname, "standard_name", "longitude"); |
|
nc.AddAtt(xname, "long_name", "Longitude"); |
|
nc.AddAtt(yname, "standard_name", "latitude"); |
|
nc.AddAtt(yname, "long_name", "Latitude"); |
|
} |
|
else |
|
{ |
|
nc.AddAtt(xname, "long_name", "x-coordinate"); |
|
nc.AddAtt(yname, "long_name", "y-coordinate"); |
|
} |
|
|
|
if(tdep) |
|
nc.AddVar("type", NC_UBYTE, "time", "i"); |
|
else |
|
nc.AddVar("type", NC_UBYTE, "i"); |
|
nc.SetComp("type", comp); |
|
nc.AddAtt("type", "long_name", |
|
"Stationary point type, 0 - saddle, 1 - st. anticicl. focus, 2 - st. knot, 3 - unst. anticicl. focus, 4 - unst. knot, 5 - st. cicl. focus, 6 - unst. cicl. focus"); |
|
|
|
nc.WriteVar("time", tdata.steps.data()); |
|
|
|
if(!nc) return "Can't set grid in the netcdf file " + name + ": " + nc.ErrMessage(); |
|
return ""; |
|
} |
|
|
|
MString UVMethods::StPoints::WriteNcFile(size_t it) |
|
{ |
|
const MString xname = lonlat ? "longitude" : "x"; |
|
const MString yname = lonlat ? "latitude" : "y"; |
|
|
|
if(tdep) |
|
{ |
|
nc.WriteVar(xname, it, x.data()); |
|
nc.WriteVar(yname, it, y.data()); |
|
nc.WriteVar("type", it, t.data()); |
|
} |
|
else |
|
{ |
|
nc.WriteVar(xname, x.data()); |
|
nc.WriteVar(yname, y.data()); |
|
nc.WriteVar("type", t.data()); |
|
} |
|
|
|
if(!nc) return MString("Can't write data to the netcdf file: ") + nc.ErrMessage(); |
|
return ""; |
|
}
|
|
|