Skip to content

Commit

Permalink
Netcdf Plotting : fix bug in the interpretation of the date in hivmol…
Browse files Browse the repository at this point in the history
…ler plots type
  • Loading branch information
sylvielamythepaut committed Feb 16, 2023
1 parent c04596b commit 30084f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/decoders/NetcdfData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ double NetVariable::getDefaultMissing() {

string Netcdf::detect(const string& var, const string& type, bool use_cache) const {

if ( std::find(ignoredDimensions_.begin(), ignoredDimensions_.end(), type) != ignoredDimensions_.end() )
// Here we force to ignore the dimension type
return "";
if ( use_cache ) {
auto cache = detected_.find(var);
if ( cache != detected_.end() )
Expand Down
3 changes: 3 additions & 0 deletions src/decoders/NetcdfData.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ class Netcdf {
}

map<string, NetAttribute> getAttributes() { return attributes_; }
void ignoreDimension(const string& dim) { ignoredDimensions_.push_back(dim); }
void interpretDimension(const string& dim) { std::remove( ignoredDimensions_.begin(), ignoredDimensions_.end(), dim ); }


protected:
Expand All @@ -486,6 +488,7 @@ class Netcdf {
map<string, NetAttribute> attributes_;
double missing_;
mutable map<string, string> detected_;
vector <string> ignoredDimensions_;

private:
int file_;
Expand Down
2 changes: 2 additions & 0 deletions src/decoders/NetcdfMatrixInterpretor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ void NetcdfMatrixInterpretor::interpret(Netcdf& netcdf, vector<double>& rows, ve
x.precision(20);
y.precision(20);

netcdf.ignoreDimension("time"); // here we send time as expressed in the data, not as a date.
y << y_ << "/" << *r << "/" << *r;
x << x_ << "/" << columns.front() << "/" << columns.back();
netcdf.interpretDimension("time");
}
std::copy(dimension_.begin(), dimension_.end(), std::back_inserter(dims));
dims.push_back(y.str());
Expand Down

0 comments on commit 30084f3

Please sign in to comment.