Skip to content

Commit

Permalink
Fix #3459 (#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
StasJ committed Oct 19, 2023
1 parent b76ce2f commit 3efa962
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/params/DataStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ void DataStatus::GetActiveExtents(const ParamsMgr *paramsMgr, string winName, st
// If we didn't find any enabled variable use the first variables
// found in each data set
//
size_t l_ts;
varMap = _getFirstVar(dataSetName, l_ts);
ts = l_ts;
varMap = _getFirstVar(dataSetName, ts);
}

_getExtents(ts, varMap, minExts, maxExts);
Expand Down
13 changes: 11 additions & 2 deletions lib/vdc/DataMgrUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "vapor/VAssert.h"
#include <algorithm>
#include <cfloat>
#include <vector>
#include <numeric>

#include <vapor/DataMgr.h>
#include <vapor/Proj4API.h>
Expand Down Expand Up @@ -375,9 +377,16 @@ double DataMgrUtils::Get2DRendererDefaultZ(DataMgr *dataMgr, size_t ts, int refL
bool DataMgrUtils::GetFirstExistingVariable(DataMgr *dataMgr, int level, int lod, int ndim, string &varname, size_t &ts)
{
varname.clear();
ts = 0;
size_t numTS = dataMgr->GetTimeCoordinates().size();
for (size_t l_ts = 0; l_ts < numTS; l_ts++) {

if (ts < 0 || ts >= numTS)
ts = 0;

std::vector<size_t> timesteps(numTS);
std::iota(timesteps.begin(), timesteps.end(), 0);
std::sort(timesteps.begin(), timesteps.end(), [ts](size_t a, size_t b) { return abs((long)ts-(long)a) < abs((long)ts-(long)b); });

for (size_t l_ts : timesteps) {
bool ok = GetFirstExistingVariable(dataMgr, l_ts, level, lod, ndim, varname);
if (ok) {
ts = l_ts;
Expand Down

0 comments on commit 3efa962

Please sign in to comment.