Browse Source

Added obfuscate parameter for actions tsc and uv

master
Michael Uleysky 3 weeks ago
parent
commit
ce443cd827
  1. 7
      actions/actiontsc.h
  2. 2
      actions/actionuv.cpp
  3. 12
      actions/actionuv.h

7
actions/actiontsc.h

@ -41,8 +41,9 @@ template<class D> MString ActionTSC::DoAction(const CLArgs& args, D& ds)
}
}
bool average = args.contains("average");
bool gradient = args.contains("gradient");
bool average = args.contains("average");
bool gradient = args.contains("gradient");
bool obfuscate = args.contains("obfuscate");
if(gradient)
if constexpr(!ReadIs2DGeoArray<D>) return "Gradient calculation not supported for this source";
@ -140,7 +141,7 @@ template<class D> MString ActionTSC::DoAction(const CLArgs& args, D& ds)
if(!err.Exist() && !headwrited) err = ncfw.Create(data[0], name, compress);
if(!err.Exist() && !headwrited) err = ncfw.AddTimeData(tdata, !average);
if(!err.Exist() && !headwrited) err = ncfw.AddAtts(pars);
if(!err.Exist() && !headwrited && !obfuscate) err = ncfw.AddAtts(pars);
for(size_t i = 0; i < data.size(); i++)
if(!err.Exist() && !headwrited)
err = ncfw.AddVariable((gradient ? "G" : "") + vnames[i], data[i].StandartName(), data[i].LongName(), data[i].Unit() + (gradient ? "/km" : ""), data[i].Comment());

2
actions/actionuv.cpp

@ -30,7 +30,7 @@ MString UVMethods::StPoints::CreateNcFile(const MString& name, const michlib_int
nc.Open(name);
if(!nc) return "Can't create netcdf file " + name + ": " + nc.ErrMessage();
nc.AddAtt("history", history);
if(history.Exist()) nc.AddAtt("history", history);
nc.AddAtts(pars);
nc.AddDim("i", N());
nc.AddDim("time", tdata.steps.size());

12
actions/actionuv.h

@ -136,7 +136,8 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
auto [tindexes, err] = GetTIndexes(ds, args, pars);
if(err.Exist()) return err;
bool average = args.contains("average");
bool average = args.contains("average");
bool obfuscate = args.contains("obfuscate");
int compress = 3;
if(args.contains("compress")) compress = args.at("compress").ToInt();
@ -231,7 +232,7 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
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 && !obfuscate) 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, "");
@ -287,7 +288,7 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
if(!err.Exist() && !headwrited) err = fwfilt.Create(sdata, namevel, compress);
if(!err.Exist() && !headwrited) err = fwfilt.AddTimeData(tdata, !average);
if(!err.Exist() && !headwrited) err = fwfilt.AddAtts(pars);
if(!err.Exist() && !headwrited && !obfuscate) 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);
@ -312,7 +313,10 @@ template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds)
else if(outfmtstp == "nc" || outfmtstp == "netcdf")
{
MString err;
if(!err.Exist() && !headwrited) err = stp.CreateNcFile(namestp, pars, args.at("_cmdline"), compress, tdata, !average);
{
michlib_internal::ParameterListEx epars;
if(!err.Exist() && !headwrited) err = stp.CreateNcFile(namestp, obfuscate ? epars : pars, obfuscate ? "" : args.at("_cmdline"), compress, tdata, !average);
}
if(!err.Exist()) err = stp.WriteNcFile(it);
if(err.Exist()) return err;
}

Loading…
Cancel
Save