From ce443cd82718450577a6f53a17e4d1ffcf79983c Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Sat, 21 Dec 2024 14:23:06 +1000 Subject: [PATCH] Added obfuscate parameter for actions tsc and uv --- actions/actiontsc.h | 7 ++++--- actions/actionuv.cpp | 2 +- actions/actionuv.h | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/actions/actiontsc.h b/actions/actiontsc.h index 40ac3d0..cb8b8bc 100644 --- a/actions/actiontsc.h +++ b/actions/actiontsc.h @@ -41,8 +41,9 @@ template 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) return "Gradient calculation not supported for this source"; @@ -140,7 +141,7 @@ template 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()); diff --git a/actions/actionuv.cpp b/actions/actionuv.cpp index 1c5ffd2..f0af589 100644 --- a/actions/actionuv.cpp +++ b/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()); diff --git a/actions/actionuv.h b/actions/actionuv.h index ebe4d41..38ee485 100644 --- a/actions/actionuv.h +++ b/actions/actionuv.h @@ -136,7 +136,8 @@ template 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 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 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 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; }