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.
70 lines
2.1 KiB
70 lines
2.1 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::WriteNcFile(const MString& name, const michlib_internal::ParameterListEx& pars, const MString& history, int comp) const |
|
{ |
|
NCFileWBase nc; |
|
|
|
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.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"); |
|
} |
|
|
|
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"); |
|
|
|
if(!nc) return "Can't set grid in the netcdf file " + name + ": " + nc.ErrMessage(); |
|
|
|
nc.EndDef(); |
|
|
|
nc.WriteVar(xname, x.data()); |
|
nc.WriteVar(yname, y.data()); |
|
nc.WriteVar("type", t.data()); |
|
|
|
if(!nc) return "Can't write data to the netcdf file " + name + ": " + nc.ErrMessage(); |
|
|
|
return ""; |
|
}
|
|
|