Compare commits

...

4 Commits

  1. 5
      CMakeLists.txt
  2. 7
      actions/actiontsc.h
  3. 2
      actions/actionuv.cpp
  4. 12
      actions/actionuv.h
  5. 6
      include/ParseArgs.h
  6. 12
      sources/COPERNICUS.cpp
  7. 6
      sources/VYLET.cpp
  8. 2
      src/ParseArgs.cpp

5
CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.20)
# Make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
@ -41,6 +41,9 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
include_directories(include sources sources-add GSW-C)
add_compile_options(-Wall -Wno-deprecated-declarations)
set(CONFIG_FILE "/etc/odm.conf" CACHE STRING "Path to config file")
add_compile_options(-DCONFIGFILE="${CONFIG_FILE}")
# Dwarf-4 support check
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-gdwarf-4 COMPILER_SUPPORTS_DWARF4)

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;
}

6
include/ParseArgs.h

@ -5,5 +5,9 @@ using michlib::MString;
using michlib::SList;
using CLArgs = std::map<MString, MString>;
CLArgs ParseArgs(int argc, char** argv);
CLArgs ParseArgs(int argc, char** argv);
MString GetExt(const MString& fname);
#ifndef CONFIGFILE
#define CONFIGFILE "/etc/odm.conf"
#endif

12
sources/COPERNICUS.cpp

@ -37,6 +37,13 @@ RetVal<std::vector<struct FileInfo>> COPERNICUSData::ReadRemoteFileList(const MS
bool next = true;
CURLRAII chandle;
{
auto oldprefix = michlib::GPL.UsePrefix("COPERNICUS");
auto proxyurl = michlib::GPL.ParameterSValue("Proxy", "");
if(proxyurl.Exist()) curl_easy_setopt(chandle, CURLOPT_PROXY, proxyurl.Buf());
michlib::GPL.UsePrefix(oldprefix);
}
while(next)
{
MString url = bucket + "?list-type=2&prefix=" + prefix;
@ -133,6 +140,11 @@ Error COPERNICUSData::Mirror(const CLArgs& args) const
if(filter.Compile() != 0) return Error(pref, MString("Can't compile regular expression ") + filter.RegStr());
CURLRAII chandle;
{
auto proxyurl = michlib::GPL.ParameterSValue("Proxy", "");
if(proxyurl.Exist()) curl_easy_setopt(chandle, CURLOPT_PROXY, proxyurl.Buf());
}
for(const auto& dset: dsets)
{
michlib::message("Mirroring " + dset);

6
sources/VYLET.cpp

@ -258,7 +258,7 @@ VYLETData::Data VYLETData::ReadL() const
{
time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]);
lambda = (*vylet)[lcol - 1][iy * lons.size() + ix];
days = (time - start).D();
days = (invtime ? -1.0 : 1.0) * (time - start).D();
out(ix, iy) = lambda / days;
}
@ -297,7 +297,7 @@ VYLETData::Data VYLETData::ReadT() const
x = (*vylet)[2][iy * lons.size() + ix];
y = (*vylet)[3][iy * lons.size() + ix];
time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]);
days = (time - start).D();
days = (invtime ? -1.0 : 1.0) * (time - start).D();
if(days <= tstep * 1.5) days = 0.0;
inside = x > xl && x < xr && y > yd && y < yu;
maxtime = days >= maxdays - tstep * 0.5;
@ -515,7 +515,7 @@ VYLETData::Data VYLETData::ReadTmask() const
for(size_t ix = 0; ix < lons.size(); ix++)
{
time = R2Time((*vylet)[tcol - 1][iy * lons.size() + ix]);
days = (time - start).D();
days = (invtime ? -1.0 : 1.0) * (time - start).D();
maxtime = days >= maxdays - tstep * 0.5;
out(ix, iy) = maxtime ? 1.0 : NAN;
}

2
src/ParseArgs.cpp

@ -29,7 +29,7 @@ CLArgs ParseArgs(int argc, char** argv)
}
SList sl;
michlib_internal::ParseParameterFile("/etc/odm.conf", sl, 0);
michlib_internal::ParseParameterFile(CONFIGFILE, sl, 0);
return out;
}

Loading…
Cancel
Save