From a243d507d23e7037ad2b112e82c8c65a8f03b7c4 Mon Sep 17 00:00:00 2001 From: Fernando Ii Date: Fri, 10 Jul 2020 09:54:01 -0300 Subject: [PATCH 01/24] MagLog: comment out a few MagLog calls to speed up Metview mPlot [MAGP-1220] --- src/decoders/ObsDecoder.cc | 12 +++--- src/visualisers/Filter.cc | 36 ++++++++-------- src/visualisers/ObsItemFamily.cc | 70 ++++++++++++++++---------------- src/visualisers/ObsTable.cc | 5 ++- 4 files changed, 61 insertions(+), 62 deletions(-) diff --git a/src/decoders/ObsDecoder.cc b/src/decoders/ObsDecoder.cc index 016df6006..d68a8a07c 100644 --- a/src/decoders/ObsDecoder.cc +++ b/src/decoders/ObsDecoder.cc @@ -303,8 +303,8 @@ class BufrMultiValueAccessor : public BufrAccessor { virtual void operator()(const ObsDecoder&, MvObs& obs, double& val) const { const BufrIdentifiers& table = BufrIdentTable::get(obs.originatingCentre()); val = obs.valueByOccurrence(index_, descriptor_); - MagLog::dev() << "BufrMultiValueAccessor-Descriptor--->" << descriptor_ << " INDEX--->" << index_ - << " Value--->" << val << endl; + //FMagLog::dev() << "BufrMultiValueAccessor-Descriptor--->" << descriptor_ << " INDEX--->" << index_ + //F << " Value--->" << val << endl; } virtual void print() {} @@ -418,14 +418,14 @@ class BufrThicknessAccessor : public BufrAccessor { val = 0; } else { - // MagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel(); + //FMagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel(); // upper-air data if (type == 5 || type == 4) val = 0; else // Multi-level data { val = abs(obs.valueByPressureLevel(decoder.level_, table.ident(keyword_)) - obs.valueByPressureLevel(decoder.level2_, table.ident(keyword_))); - // MagLog::dev()<< " : get --->" << val << endl; + //FMagLog::dev()<< " : get --->" << val << endl; } } @@ -623,7 +623,7 @@ void ObsDecoder::getInfo(const std::set& tokens, multimap::const_iterator no = noduplicate.begin(); no != noduplicate.end(); ++no) { - MagLog::debug() << " ObsDecoderToken: " << *token << " -> " << *no << "\n"; + //FMagLog::debug() << " ObsDecoderToken: " << *token << " -> " << *no << "\n"; // here we add it to the list, only if it is the obs_types_list! if (findInTypes(*no)) @@ -691,7 +691,7 @@ void ObsDecoder::customisedPoints(const Transformation& transformation, const st ostringstream title; title << "[ type = " << obs.messageType() << " , subtype = " << obs.messageSubtype() << "]"; title_ = title.str(); - MagLog::debug() << " ObsTitle: " << title_ << "\n"; + //FMagLog::debug() << " ObsTitle: " << title_ << "\n"; first = false; } diff --git a/src/visualisers/Filter.cc b/src/visualisers/Filter.cc index f98f3bc93..dfab9d3d9 100644 --- a/src/visualisers/Filter.cc +++ b/src/visualisers/Filter.cc @@ -145,8 +145,7 @@ bool MinMaxFilter::Process() { // Initialize input buffer if (this->InitBuffer() == false) { - MagLog::debug() << " InitBuffer Error" - << "\n"; + //FMagLog::debug() << " InitBuffer Error" << "\n"; return false; } @@ -177,7 +176,7 @@ bool MinMaxFilter::Process() { if (found) // minimum found { - // MagLog::debug() << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; + //FMagLog::debug() << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; lo = lo + 1; push_back(UserPoint(this->matrix_.column(lin + fcr, col + fcc), this->matrix_.row(lin + fcr, col + fcc), val)); @@ -205,7 +204,7 @@ bool MinMaxFilter::Process() { if (found) // minimum found { - // MagLog::debug() << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; + //FMagLog::debug() << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; hi = hi + 1; push_back(UserPoint(this->matrix_.column(lin + fcr, col + fcc), this->matrix_.row(lin + fcr, col + fcc), val)); @@ -219,8 +218,8 @@ bool MinMaxFilter::Process() { break; } - MagLog::debug() << "TOTAL POINTS LOW = " << lo << "\n" - << "TOTAL POINTS HI = " << hi << "\n"; + //FMagLog::debug() << "TOTAL POINTS LOW = " << lo << "\n" + //F << "TOTAL POINTS HI = " << hi << "\n"; return true; } @@ -242,8 +241,7 @@ void MinMaxFilter::test_build_data() { // Initialize input buffer if (this->InitBuffer() == false) { - MagLog::debug() << " InitBuffer Error" - << "\n"; + //FMagLog::debug() << " InitBuffer Error" << "\n"; return; } @@ -252,11 +250,11 @@ void MinMaxFilter::test_build_data() { // Processing for (lin = 0; lin <= this->matrix_.rows() - this->nrows_; lin++) { printf("\n"); - for (i = 0; i < this->nrows_; i++) { - for (j = 0; j < this->matrix_.columns(); j++) - MagLog::debug() << this->fbuf_[i][j] << " "; - printf("\n"); - } + //Ffor (i = 0; i < this->nrows_; i++) { + //F for (j = 0; j < this->matrix_.columns(); j++) + //FMagLog::debug() << this->fbuf_[i][j] << " "; + //F printf("\n"); + //F} for (col = 0; col <= this->matrix_.columns() - this->ncols_; col++) { // check min value @@ -278,8 +276,8 @@ void MinMaxFilter::test_build_data() { if (found) // minimum found { - MagLog::debug() << "\n" - << "Min " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; + //FMagLog::debug() << "\n" + //F << "Min " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; lo = lo + 1; } } @@ -303,8 +301,8 @@ void MinMaxFilter::test_build_data() { if (found) // minimum found { - MagLog::debug() << "\n" - << "Max " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; + //FMagLog::debug() << "\n" + //F << "Max " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; hi = hi + 1; } } @@ -314,8 +312,8 @@ void MinMaxFilter::test_build_data() { break; } - MagLog::debug() << "TOTAL POINTS LOW=" << lo << "\n"; - MagLog::debug() << "TOTAL POINTS HI =" << hi << "\n"; + //FMagLog::debug() << "TOTAL POINTS LOW=" << lo << "\n"; + //FMagLog::debug() << "TOTAL POINTS HI =" << hi << "\n"; printf("\n\nEND TEST\n"); } diff --git a/src/visualisers/ObsItemFamily.cc b/src/visualisers/ObsItemFamily.cc index 9093062bc..7cd5642cd 100644 --- a/src/visualisers/ObsItemFamily.cc +++ b/src/visualisers/ObsItemFamily.cc @@ -60,9 +60,9 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { map::iterator it = point.begin(); map::iterator en = point.end(); - for (; it != en; ++it) { - MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - } + //for (; it != en; ++it) { + //F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; + //F} Colour colour = owner_->wind_colour_->automatic() ? *owner_->colour_ : *owner_->wind_colour_; CustomisedPoint::const_iterator speed = point.find(speed_); @@ -79,9 +79,9 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { const string origin = "circle"; - MagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - << "\n\twind_speed: " << point[speed_] << "\n\twind_direction: " << point[direction_] - << "\n\tcloud amount: " << point["total_cloud"] << " -> " << origin << std::endl; + //FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() + //F << "\n\twind_speed: " << point[speed_] << "\n\twind_direction: " << point[direction_] + //F << "\n\tcloud amount: " << point["total_cloud"] << " -> " << origin << std::endl; flag->setOriginHeight(owner_->ring_size_); @@ -129,13 +129,13 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) map::iterator it = point.begin(); map::iterator en = point.end(); - for (; it != en; ++it) { - MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - } + //Ffor (; it != en; ++it) { + //F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; + //F} symbol.setHeight(owner_->size_); int total_cloud = maground((point["total_cloud"] / 100.) * 8); - MagLog::debug() << "total_cloud-->" << point["total_cloud"] << "--->" << total_cloud << endl; + //FMagLog::debug() << "total_cloud-->" << point["total_cloud"] << "--->" << total_cloud << endl; map::const_iterator marker = origins_.find(total_cloud); string origin; @@ -176,11 +176,11 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) flag->thickness(1.5); - MagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - << "\n\twind_speed: " << point["wind_speed"] - << "\n\twind_direction: " << point["wind_direction"] - << "\n\tcloud amount: " << point["total_cloud"] << "--->" << total_cloud << "--->" << origin - << std::endl; + //FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() + //F << "\n\twind_speed: " << point["wind_speed"] + //F << "\n\twind_direction: " << point["wind_direction"] + //F << "\n\tcloud amount: " << point["total_cloud"] << "--->" << total_cloud << "--->" << origin + //F << std::endl; flag->setOriginHeight(owner_->ring_size_ * 1.75); flag->setOriginMarker(origin); @@ -234,7 +234,7 @@ void ObsPressure::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons object->text(os.str()); - MagLog::debug() << "\tPressure: " << value->second << " = " << pressure << " -> " << os.str() << "\n"; + //FMagLog::debug() << "\tPressure: " << value->second << " = " << pressure << " -> " << os.str() << "\n"; object->font(font); symbol.add(object); @@ -264,7 +264,7 @@ void ObsPressureLevel::operator()(CustomisedPoint& point, ComplexSymbol& symbol) object->text(tostring(pressure)); - MagLog::debug() << "\tPressureLevel: " << value->second << " = " << pressure << "\n"; + //FMagLog::debug() << "\tPressureLevel: " << value->second << " = " << pressure << "\n"; font.size(owner_->size_); object->font(font); symbol.add(object); @@ -319,7 +319,7 @@ void ObsPressureTendency::operator()(CustomisedPoint& point, ComplexSymbol& symb oss << "a_" << value->second; tendancy->symbol(oss.str()); - MagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n"; + //FMagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n"; tendancy->height(owner_->size_ * 0.8); // A bit too big ! symbol.add(tendancy); @@ -349,7 +349,7 @@ void ObsDewPoint::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons // The temperature is displayed in Celsius. const double tempe = maground(value->second - 273.15); - MagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n"; + //FMagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n"; object->text(tostring(tempe)); object->font(font); @@ -395,7 +395,7 @@ void ObsVisibility::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co object->text(val); - MagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n"; + //FMagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n"; font.size(owner_->size_); object->font(font); @@ -483,7 +483,7 @@ void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol object->symbol(ww); - MagLog::debug() << "\tPresent Weather--->" << ww << " in " << colour << "\n"; + //FMagLog::debug() << "\tPresent Weather--->" << ww << " in " << colour << "\n"; // time->setJustification(MRIGHT); object->height(owner_->size_); symbol.add(object); @@ -510,7 +510,7 @@ void ObsTemperature::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c // The temperature is displayed in Celsius. double tempe = maground(value->second - 273.15); - MagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; + //FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; object->text(tostring(tempe)); // object->setJustification(MCENTRE); @@ -532,7 +532,7 @@ void ObsTimePlot::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons if (value == point.end()) return; - MagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl; + //FMagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->time_plot_colour_->automatic() ? *owner_->colour_ : *owner_->time_plot_colour_; @@ -566,7 +566,7 @@ void ObsHeight::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const return; double geop = maground(value->second / 98.1); - MagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl; + //FMagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->height_colour_->automatic() ? *owner_->colour_ : *owner_->height_colour_; TextItem* height = new TextItem(); MagFont font("sansserif"); @@ -598,7 +598,7 @@ void ObsThickness::operator()(CustomisedPoint& point, ComplexSymbol& symbol) con return; const double thickness = maground(value->second / 98.1); #ifdef OBS_DEBUG_ - MagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl; + //FMagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl; #endif Colour colour = owner_->thickness_colour_->automatic() ? *owner_->colour_ : *owner_->thickness_colour_; TextItem* object = new TextItem(); @@ -627,7 +627,7 @@ void ObsIdentifier::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co return; TextItem* time = new TextItem(); #ifdef OBS_DEBUG_ - MagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << endl; + //FMagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << endl; #endif Colour colour = owner_->identifier_colour_->automatic() ? *owner_->colour_ : *owner_->identifier_colour_; MagFont font("sansserif"); @@ -716,7 +716,7 @@ void ObsPastWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c object->symbol(ww->second); - MagLog::debug() << "\tPast Weather 1-> " << ww->second << "\n"; + //FMagLog::debug() << "\tPast Weather 1-> " << ww->second << "\n"; object->height(owner_->size_ * .75); symbol.add(object); @@ -734,7 +734,7 @@ void ObsPastWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c object2->symbol(ww->second); - MagLog::debug() << "\tPast Weather 2-> " << ww->second << "\n"; + //FMagLog::debug() << "\tPast Weather 2-> " << ww->second << "\n"; object2->height(owner_->size_ * .75); symbol.add(object2); @@ -876,7 +876,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { font.colour(*owner_->low_colour_); font.size(owner_->size_ * 0.9); - MagLog::debug() << "\tLow Cloud--->" << nh.str() << "\n"; + //FMagLog::debug() << "\tLow Cloud--->" << nh.str() << "\n"; object->text(nh.str()); object->font(font); symbol.add(object); @@ -893,7 +893,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->symbol(low->second); - MagLog::debug() << "\tLow Cloud--->" << value->second << "-->" << low->second << "\n"; + //FMagLog::debug() << "\tLow Cloud--->" << value->second << "-->" << low->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -911,7 +911,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->medium_colour_); cloud->symbol(medium->second); - MagLog::debug() << "\tMedium Cloud--->" << value->second << " --> " << medium->second << "\n"; + //FMagLog::debug() << "\tMedium Cloud--->" << value->second << " --> " << medium->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -929,7 +929,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->high_colour_); cloud->symbol(high->second); - MagLog::debug() << "\tHigh Cloud--->" << value->second << "-->" << high->second << "\n"; + //FMagLog::debug() << "\tHigh Cloud--->" << value->second << "-->" << high->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -956,7 +956,7 @@ void ObsDemoItem1::visit(std::set& tokens) { void ObsDemoItem1::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (point.find("temperature") == point.end()) { - MagLog::debug() << "No info for temperature given!" << endl; + //FMagLog::debug() << "No info for temperature given!" << endl; return; } @@ -1108,7 +1108,7 @@ void ObsSeaTemperature::operator()(CustomisedPoint& point, ComplexSymbol& symbol // The temperature is displayed in Celsius. double tempe = maground(value->second - 273.15); - MagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; + //FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; object->text(tostring(tempe)); @@ -1143,7 +1143,7 @@ void ObsWave::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (period == point.end() || height == point.end()) return; - MagLog::debug() << "\theight: " << height->second << " period " << period->second << "\n"; + //FMagLog::debug() << "\theight: " << height->second << " period " << period->second << "\n"; // height of waves in units of 0.5 double h = maground(height->second / 0.5); double p = maground(period->second); diff --git a/src/visualisers/ObsTable.cc b/src/visualisers/ObsTable.cc index 3ff1262a4..df4dd3c86 100644 --- a/src/visualisers/ObsTable.cc +++ b/src/visualisers/ObsTable.cc @@ -56,7 +56,7 @@ ObsTable::ObsTable() { XML_SetUserData(parser, this); XML_SetElementHandler(parser, startElement, endElement); - MagLog::dev() << "Load observation templates --->" << filename << endl; + //FMagLog::dev() << "Load observation templates --->" << filename << endl; FILE* in = fopen(filename.c_str(), "r"); if (!in) @@ -107,7 +107,8 @@ void ObsTable::add(const string& tag, const map& def) { current_->push_back(obs); } catch (NoFactoryException&) { - MagLog::dev() << "can not find ObsItem for : " << tag << "\n"; + //FMagLog::dev() << "can not find ObsItem for : " << tag << "\n"; + cout << "can not find ObsItem for : " << tag << "\n"; } } } From db8accea0aeb87de18fedf2361b80ff093b4395c Mon Sep 17 00:00:00 2001 From: Sylvie Date: Mon, 13 Jul 2020 09:21:58 +0100 Subject: [PATCH 02/24] Adding clang-format --- do_formattting.sh | 29 ++ src/decoders/ObsDecoder.cc | 12 +- src/eckit_readers/MvBufrObs.h | 377 +++++++++--------- src/eckit_readers/MvObs.cc | 650 +++++++++++-------------------- src/eckit_readers/MvObs.h | 2 +- src/eckit_readers/MvObsSet.cc | 340 +++++++--------- src/eckit_readers/MvObsSet.h | 122 +++--- src/visualisers/Filter.cc | 34 +- src/visualisers/ObsItemFamily.cc | 71 ++-- src/visualisers/ObsTable.cc | 4 +- 10 files changed, 689 insertions(+), 952 deletions(-) create mode 100644 do_formattting.sh diff --git a/do_formattting.sh b/do_formattting.sh new file mode 100644 index 000000000..f2d8a6641 --- /dev/null +++ b/do_formattting.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Script to check whether a repo has been properly formatted with clang-format. + +# The find `-regex` arg on Linux and Darwin works differently. Normally +# the Darwin path would not need to be invoked unless testing the script locally. +unameOut="$(uname -s)" +base_dir="." +case "${unameOut}" in + Darwin*) files=$(find -E $base_dir -regex '.*\.(cpp|hpp|cc|cxx|h|c)');; + Linux*) files=$(find $base_dir -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|c\)') +esac + +for file in $files; do + if [[ $file =~ "drivers/minizip" ]]; then + # Skip minizip because clang-format breaks this code to the point where it doesn't + # compile. + echo "Skipping autoformat check for file: $file" + else + ORIG=$(cat "$file") + # The `--style=file` argument will automatically find the .clang-format and + # it doesn't take a file path but just the string `file`. + # If .clang-format is missing the script will exit. + AUTO=$(clang-format --style=file --fallback-style=none "$file") + diff <(echo "$ORIG") <(echo "$AUTO") > /dev/null || { echo "$file is not formatted, Applying format";clang-format -i $file; } + fi +done + +echo "Format check complete" diff --git a/src/decoders/ObsDecoder.cc b/src/decoders/ObsDecoder.cc index d68a8a07c..e643c8d95 100644 --- a/src/decoders/ObsDecoder.cc +++ b/src/decoders/ObsDecoder.cc @@ -303,8 +303,8 @@ class BufrMultiValueAccessor : public BufrAccessor { virtual void operator()(const ObsDecoder&, MvObs& obs, double& val) const { const BufrIdentifiers& table = BufrIdentTable::get(obs.originatingCentre()); val = obs.valueByOccurrence(index_, descriptor_); - //FMagLog::dev() << "BufrMultiValueAccessor-Descriptor--->" << descriptor_ << " INDEX--->" << index_ - //F << " Value--->" << val << endl; + // FMagLog::dev() << "BufrMultiValueAccessor-Descriptor--->" << descriptor_ << " INDEX--->" << index_ + // F << " Value--->" << val << endl; } virtual void print() {} @@ -418,14 +418,14 @@ class BufrThicknessAccessor : public BufrAccessor { val = 0; } else { - //FMagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel(); + // FMagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel(); // upper-air data if (type == 5 || type == 4) val = 0; else // Multi-level data { val = abs(obs.valueByPressureLevel(decoder.level_, table.ident(keyword_)) - obs.valueByPressureLevel(decoder.level2_, table.ident(keyword_))); - //FMagLog::dev()<< " : get --->" << val << endl; + // FMagLog::dev()<< " : get --->" << val << endl; } } @@ -623,7 +623,7 @@ void ObsDecoder::getInfo(const std::set& tokens, multimap::const_iterator no = noduplicate.begin(); no != noduplicate.end(); ++no) { - //FMagLog::debug() << " ObsDecoderToken: " << *token << " -> " << *no << "\n"; + // FMagLog::debug() << " ObsDecoderToken: " << *token << " -> " << *no << "\n"; // here we add it to the list, only if it is the obs_types_list! if (findInTypes(*no)) @@ -691,7 +691,7 @@ void ObsDecoder::customisedPoints(const Transformation& transformation, const st ostringstream title; title << "[ type = " << obs.messageType() << " , subtype = " << obs.messageSubtype() << "]"; title_ = title.str(); - //FMagLog::debug() << " ObsTitle: " << title_ << "\n"; + // FMagLog::debug() << " ObsTitle: " << title_ << "\n"; first = false; } diff --git a/src/eckit_readers/MvBufrObs.h b/src/eckit_readers/MvBufrObs.h index c4a3666e0..629723e7c 100644 --- a/src/eckit_readers/MvBufrObs.h +++ b/src/eckit_readers/MvBufrObs.h @@ -15,10 +15,10 @@ #include -#include -#include #include +#include #include +#include #ifdef METVIEW #include "MvDate.h" @@ -46,8 +46,7 @@ enum EBufrConfState /*! Warning: This is Q&C ("quick&dirty") hack to access * QC FB data behind operator descriptor 222000. */ -class MvBufrConfidence -{ +class MvBufrConfidence { public: MvBufrConfidence(int aSubsetNr); ~MvBufrConfidence(); @@ -68,17 +67,16 @@ class MvBufrConfidence int _startOfConfidences; EBufrConfState _state; }; -#endif //DOXYGEN_SHOULD_SKIP_THIS +#endif // DOXYGEN_SHOULD_SKIP_THIS const float kBufrMissingValue = 1.7e38; const int kBufrMissingIntValue = 2147483647; -class MvEccHandle -{ +class MvEccHandle { public: MvEccHandle(codes_handle* ecH) : ecH_(ecH) {} - codes_handle* handle() const {return ecH_;} - void clear() {ecH_=nullptr;} + codes_handle* handle() const { return ecH_; } + void clear() { ecH_ = nullptr; } protected: codes_handle* ecH_; @@ -116,14 +114,12 @@ typedef std::shared_ptr MvEccHandle_ptr; class MvBufrEdition; -class MvBufrSubsetData -{ +class MvBufrSubsetData { friend class MvObs; public: MvBufrSubsetData() {} - void clear() - { + void clear() { longData_.clear(); doubleData_.clear(); } @@ -142,19 +138,17 @@ class MvBufrSubsetData std::map > doubleData_; }; -class MvObs -{ +class MvObs { friend class MvObsSet; friend class MvObsSetIterator; void _copy(const MvObs& b); public: -//! Constructors -/*! Arguments are mainly used by MvObsSet and MvObsSetIterator. - * Applications normally call this constructor without arguments. - */ - MvObs(MvEccHandle_ptr, int subset_current = 1, bool unpacked = false, - bool cacheCompressedData = true); + //! Constructors + /*! Arguments are mainly used by MvObsSet and MvObsSetIterator. + * Applications normally call this constructor without arguments. + */ + MvObs(MvEccHandle_ptr, int subset_current = 1, bool unpacked = false, bool cacheCompressedData = true); MvObs() {} //! Copy constructor @@ -168,18 +162,18 @@ class MvObs //! Operator to test the validity of a new MvObs /*! In this example operator void*() is used implicitly - * in testing the validity of MvObs object returned by - * MvObsSetIterator object: - *
- *      MvObsSet mySet("/path/to/my/file");
- *      MvObsSetIterator myIter(mySet);
- *      ...
- *      while(myObs=myIter()) //-- void*() is called here
- *      {
- *         ... //-- do the stuff
- *      }
- * 
- */ + * in testing the validity of MvObs object returned by + * MvObsSetIterator object: + *
+     *      MvObsSet mySet("/path/to/my/file");
+     *      MvObsSetIterator myIter(mySet);
+     *      ...
+     *      while(myObs=myIter()) //-- void*() is called here
+     *      {
+     *         ... //-- do the stuff
+     *      }
+     * 
+ */ operator void*(); // Clear/initialise variable members @@ -192,14 +186,14 @@ class MvObs void init(); codes_handle* getHandle() const; -// { -// return *_ecH; -// } + // { + // return *_ecH; + // } -// void setHandle(codes_handle** h) -// { -// _ecH = h; -// } + // void setHandle(codes_handle** h) + // { + // _ecH = h; + // } //---------------------------------------------------------------------------- //-- APIs for requesting info from the Header, BUFR Section 0,1,2 --// @@ -222,15 +216,15 @@ class MvObs //! Returns either the local or the international message subtype /*! In BUFR Edition 3 only the local subtype was available. - * In BUFR Edition 4 the WMO defined international subtype was - * added. Local subtype was left for backwards compatibility. - * - * For BUFR Edition 3 messages this function always returns the local subtype. - * - * For later Editions this function returns the international subtype if - * it has been set. If not set (has a value 255) then the local subtype - * is returned - */ + * In BUFR Edition 4 the WMO defined international subtype was + * added. Local subtype was left for backwards compatibility. + * + * For BUFR Edition 3 messages this function always returns the local subtype. + * + * For later Editions this function returns the international subtype if + * it has been set. If not set (has a value 255) then the local subtype + * is returned + */ int messageSubtype(); //! Returns the locally defined Message Subtype code from BUFR section 1 @@ -238,8 +232,8 @@ class MvObs //! Returns the international Message Subtype code (WMO defined) from BUFR section 1 /*! Note that this code is available only in BUFR Edition 4 messages. For Edition 3 - * messages a value of 255 is returned (255 corresponds to an octet with all bits '1'). - */ + * messages a value of 255 is returned (255 corresponds to an octet with all bits '1'). + */ int messageSubtypeInternational(); int messageRdbtype(); @@ -253,7 +247,7 @@ class MvObs //! Returns the Master Table code from BUFR section 1 /*! Master Table 0 is for Meteorology, 10 is for Oceanography - */ + */ int masterTable(); //! Returns the Master Table version from BUFR section 1 @@ -273,15 +267,15 @@ class MvObs //! Advances to the next subset in a multisubset BUFR message /*! Returns 'false' if current subset is the last (or the only) - * one. Returns 'true' on success. - */ + * one. Returns 'true' on success. + */ bool Advance(); //! Checks whether this MvObs contains a BUFR message or is empty bool operator!(); //! Checks that this MvObs contains a valid decodable BUFR message - //ec maybe can be removed? + // ec maybe can be removed? bool msg_ok() const; // { return _bufr_id == _bufrIn->currentBufrId(); } // ---- A P I f u n c t i o n s : ---- // @@ -290,11 +284,11 @@ class MvObs //! Returns the value of an element defined by 'aDescriptor' /*! Also sets Current Descriptor. - * Missing value indicator is returned if the observation report - * does not contain elements of type 'aDescriptor', or if the element - * does not have value. - */ - double valueC(const std::string&); //input can be a number (descriptor) or a key + * Missing value indicator is returned if the observation report + * does not contain elements of type 'aDescriptor', or if the element + * does not have value. + */ + double valueC(const std::string&); // input can be a number (descriptor) or a key double value(const long, const int occurrence); double value(const long); double value(const std::string&, const int); @@ -303,7 +297,7 @@ class MvObs //! Returns the value of an element defined by 'aDescriptor' as 'long' /*! Also sets Current Descriptor. - */ + */ long intValue(const long, const int occurrence); long intValue(const long); long intValue(const std::string&, const int); @@ -315,7 +309,7 @@ class MvObs //! Returns the value of an element defined by 'aDescriptor' as 'string' /*! Also sets Current Descriptor. - */ + */ std::string stringValue(const long, const int occurrence); std::string stringValue(const long); std::string stringValue(const std::string&, const int); @@ -327,19 +321,19 @@ class MvObs //! Returns the value corresponding to the 'n'th occurrence of descriptor 'descr' /*! Method searches the current subset from the beginning looking - * for descriptors 'descr'. If BUFR message contains 'n' (or more) - * occurrences of descriptor 'descr', the corresponding data value - * is returned, otherwise 'kBufrMissingValue' is returned. - */ - double valueByOccurrenceC(int, const std::string&); //input can be a number (descriptor) or a key + * for descriptors 'descr'. If BUFR message contains 'n' (or more) + * occurrences of descriptor 'descr', the corresponding data value + * is returned, otherwise 'kBufrMissingValue' is returned. + */ + double valueByOccurrenceC(int, const std::string&); // input can be a number (descriptor) or a key double valueByOccurrence(int, const std::string&); double valueByOccurrence(int, long); //! Index access operator returns the 'n'th data value /*! This operator treats BUFR message as an array - * and returns the value of the 'n'th element as 'double'. - * Index 'n' starts from '1', i.e. n=1,2,3,... - */ + * and returns the value of the 'n'th element as 'double'. + * Index 'n' starts from '1', i.e. n=1,2,3,... + */ double operator[](int n); //-- n starts from 1: 1,2,...,n //-- APIs for requesting parameter metadata --// @@ -357,10 +351,7 @@ class MvObs std::string unit(); // Returns the compress data indicator (true: compress, false: uncompress) - bool compressData() - { - return _compressed_data; - } + bool compressData() { return _compressed_data; } // Expand message void expand(); @@ -411,42 +402,42 @@ class MvObs //-- APIs for requesting weather station values --// //! Returns the 5 digit WMO station identifier /*! Looks for WMO block number 'BB' and station identifier 'SSS' - * and returns the value of 'BBSSS' if found. Returns zero if - * 'BB' or 'SSS' is not found. - */ + * and returns the value of 'BBSSS' if found. Returns zero if + * 'BB' or 'SSS' is not found. + */ long WmoIdentNumber(); //! Returns the 2 digit WMO block identifier 'BB' /*! Returns zero if 'BB' not found. - */ + */ int WmoBlockNumber(); //! Returns the 3 digit WMO station identifier 'SSS' /*! Returns zero if 'SSS' not found. - */ + */ int WmoStationNumber(); //! Returns the the value of the "ident" key from ECMWF (centre=98) local section /*! Returns an empty string if "ident" is not defined. -*/ + */ const std::string& headerIdent(); //! Looks for an ident from the BUFR message /*! Looks for the following message identifiers: \n - * - WMO Station Identifier 'BBSSS' \n - * - Ship or mobile land station identifier (001011) \n - * - Buoy/platform identifier (001005) \n - * - Aircraft flight number (001006) \n - * - Satellite identifier (001007) \n - * - Aircraft registration number (001008) \n - * - Stationary buoy platform identifier (001010) \n - * - Storm identifier (001025) - * - WMO storm name (001026) - * - WMO long storm name (001027) - * - * and returns the first one found, as a string. If none - * of the above is found, returns "id???". - */ + * - WMO Station Identifier 'BBSSS' \n + * - Ship or mobile land station identifier (001011) \n + * - Buoy/platform identifier (001005) \n + * - Aircraft flight number (001006) \n + * - Satellite identifier (001007) \n + * - Aircraft registration number (001008) \n + * - Stationary buoy platform identifier (001010) \n + * - Storm identifier (001025) + * - WMO storm name (001026) + * - WMO long storm name (001027) + * + * and returns the first one found, as a string. If none + * of the above is found, returns "id???". + */ std::string findSomeIdent(); //-- APIs for accessing replicated parameters --// @@ -464,93 +455,94 @@ class MvObs //! Returns the value of the specified data for the specified level /*! First looks for a data block related to level 'aLevel' as the - * value of the data element related to level descriptor 'aLevelDescriptor', - * and then looks for a data element related to descriptor 'aDescriptor' - * within this level. - */ - double valueByLevelC(const std::string&, float, const std::string&); //input can be a number (descriptor) or a key + * value of the data element related to level descriptor 'aLevelDescriptor', + * and then looks for a data element related to descriptor 'aDescriptor' + * within this level. + */ + double valueByLevelC(const std::string&, float, const std::string&); // input can be a number (descriptor) or a key double valueByLevel(long, float, long); double valueByLevel(const std::string&, float, const std::string&); - double valueByLevelRangeC(const std::string&, float, float, const std::string&); //input can be a number (descriptor) or a key + double valueByLevelRangeC(const std::string&, float, float, + const std::string&); // input can be a number (descriptor) or a key double valueByLevelRange(long, float, float, long); double valueByLevelRange(const std::string&, float, float, const std::string&); //! Returns the number of pressure levels found in the observation report - /*! Pressure level descriptor is 007004, key "pressure", so this is an - * alias for member function numberOfLevels("pressure"). - */ + /*! Pressure level descriptor is 007004, key "pressure", so this is an + * alias for member function numberOfLevels("pressure"). + */ int numberOfPressureLevels(); //! Returns the value of the first pressure level in hPa /*! Original pressure values are stored in Pa, so this is - * the same as 100.0*firstLevel(7004). - */ + * the same as 100.0*firstLevel(7004). + */ double firstPressureLevel(); //! Returns the value of the next pressure level in hPa /*! Original pressure values are stored in Pa, so this is - * the same as 100.0*nextLevel(7004). - */ + * the same as 100.0*nextLevel(7004). + */ double nextPressureLevel(); //! Returns the value of the data corresponding to 'aDescriptor' on level 'aLevel' /*! Here 'aLevel' is given in hPa. Original pressure values are stored in Pa, - * so this is the same as \n - *
- *      valueByLevel( 7004, 100.0*aLevel, aDescriptor )
- * 
- */ - double valueByPressureLevelC(float, const std::string&); //input can be a number (descriptor) or a key + * so this is the same as \n + *
+     *      valueByLevel( 7004, 100.0*aLevel, aDescriptor )
+     * 
+ */ + double valueByPressureLevelC(float, const std::string&); // input can be a number (descriptor) or a key double valueByPressureLevel(float, long); double valueByPressureLevel(float, const std::string&); - //e This function needs to be updated later. + // e This function needs to be updated later. //! Returns the value of the data corresponding to 'aDescriptor' in a layer /*! Level values are for the top and the bottom pressure values of a layer - * and they are given in hPa. \n \n - * This method looks for two consecutive pressure coordinate descriptors - * 007004 with the given values (hPa is first converted to Pa). If such - * a layer is found and the layer contains 'aDescriptor' then the corresponding - * data value is returned, otherwise 'kBufrMissingValue' is returned. - */ - float valueByLayerC(float, float, const std::string&); //input can be a number (descriptor) or a key + * and they are given in hPa. \n \n + * This method looks for two consecutive pressure coordinate descriptors + * 007004 with the given values (hPa is first converted to Pa). If such + * a layer is found and the layer contains 'aDescriptor' then the corresponding + * data value is returned, otherwise 'kBufrMissingValue' is returned. + */ + float valueByLayerC(float, float, const std::string&); // input can be a number (descriptor) or a key float valueByLayer(float, float, long); //! Prints all data values into standard output /*! For output format see method 'writeAllValues' below - */ + */ bool printAllValues(); //! Writes all data values into output stream 'aStream' /*! Writes the data, one data value per line. Each line consists of: - * - index of the data - * - data value - * - name of the data - * - unit of the data, in square brackets - * - the corresponding BUFR descriptor, in parenthesis - * - * Example output (an extract from a SYNOP report): \n - *
- *       1.      10 Wmo Block Number [NUMERIC] (01001)
- *       2.     500 Wmo Station Number [NUMERIC] (01002)
- *       3.       1 Type Of Station [CODE TABLE 002001] (02001)
- *       4.    2007 Year [YEAR] (04001)
- *       5.      11 Month [MONTH] (04002)
- *       6.       6 Day [DAY] (04003)
- *       7.      22 Hour [HOUR] (04004)
- *       8.       0 Minute [MINUTE] (04005)
- *       9.   50.97 Latitude (High Accuracy) [DEGREE] (05001)
- *      10.    6.05 Longitude (High Accuracy) [DEGREE] (06001)
- *      11.      98 Height Of Station [M] (07001)
- *     ...
- * 
- */ + * - index of the data + * - data value + * - name of the data + * - unit of the data, in square brackets + * - the corresponding BUFR descriptor, in parenthesis + * + * Example output (an extract from a SYNOP report): \n + *
+     *       1.      10 Wmo Block Number [NUMERIC] (01001)
+     *       2.     500 Wmo Station Number [NUMERIC] (01002)
+     *       3.       1 Type Of Station [CODE TABLE 002001] (02001)
+     *       4.    2007 Year [YEAR] (04001)
+     *       5.      11 Month [MONTH] (04002)
+     *       6.       6 Day [DAY] (04003)
+     *       7.      22 Hour [HOUR] (04004)
+     *       8.       0 Minute [MINUTE] (04005)
+     *       9.   50.97 Latitude (High Accuracy) [DEGREE] (05001)
+     *      10.    6.05 Longitude (High Accuracy) [DEGREE] (06001)
+     *      11.      98 Height Of Station [M] (07001)
+     *     ...
+     * 
+ */ bool writeAllValues(std::ostream&); //! Writes all data values into file 'aPathName' /*! For output format see the version of method 'writeAllValues' above - */ + */ bool writeAllValues(const char*); //! Returns 'true' if BUFR message contains local section 2, 'false' if not @@ -560,13 +552,13 @@ class MvObs //! Checks whether the BUFR message contains confidence values or not /*! Returns 'true' if operator descriptor 222000 is found in the - * message, otherwise 'false'. - */ + * message, otherwise 'false'. + */ bool hasConfidences(); //! Returns the confidence value for the current data, if exists /*! Otherwise returns -1. - */ + */ int confidence(); //-- Q&D: valueBySpecifier & specifierIndex made public @@ -600,71 +592,69 @@ class MvObs bool descriptor_to_key(const long, std::string&); protected: - //It is implemeted in MvMiscellanous, but because of magics we cannot - //use MvMisc ... here! + // It is implemeted in MvMiscellanous, but because of magics we cannot + // use MvMisc ... here! template - inline std::string toString(const TYPE& in) - { + inline std::string toString(const TYPE& in) { std::ostringstream os; os << in; return os.str(); } - bool _skipConfidence {true}; // true: skip Confidence values - std::string _currentKey; // mainly to be used in the key iterator within a message - std::string _currentLevelKey; // Level parameter name - int _currentLevelOccurrence {0}; // Level parameter occurrence (1..N) - int _subsetNr {1}; // current subset (1.._number_of_subsets) + bool _skipConfidence{true}; // true: skip Confidence values + std::string _currentKey; // mainly to be used in the key iterator within a message + std::string _currentLevelKey; // Level parameter name + int _currentLevelOccurrence{0}; // Level parameter occurrence (1..N) + int _subsetNr{1}; // current subset (1.._number_of_subsets) // Info from the Header, BUFR Section 1 - bool _compressed_data {false}; // true: compressed, false: uncompress - bool _unpacked {false}; // true: data unpacked, false: data packed - long _messageTotalLen {-1}; - long _editionNumber {-1}; - long _number_of_subsets {-1}; - long _messageType {-1}; - long _subTypeInternational {-1}; - long _subTypeLocal {-1}; - long _rdbType {-1}; - long _originatingCentre {-1}; - long _originatingSubCentre {-1}; + bool _compressed_data{false}; // true: compressed, false: uncompress + bool _unpacked{false}; // true: data unpacked, false: data packed + long _messageTotalLen{-1}; + long _editionNumber{-1}; + long _number_of_subsets{-1}; + long _messageType{-1}; + long _subTypeInternational{-1}; + long _subTypeLocal{-1}; + long _rdbType{-1}; + long _originatingCentre{-1}; + long _originatingSubCentre{-1}; std::string _originatingCentreStr; - long _masterTable {-1}; - long _masterTableVersion {-1}; - long _localTableVersion {-1}; - long _lyear {-1}; - long _lmonth {-1}; - long _lday {-1}; - long _lhour {-1}; - long _lminute {-1}; - std::string headerIdent_ {"__UNDEF__"}; - - MvBufrEdition* _edition {nullptr}; - MvBufrConfidence* _confidence {nullptr}; - - //use eccodes optimisation - bool useSkipExtraAttributes_ {true}; - - //For compressed messages - bool cacheCompressedData_ {true}; + long _masterTable{-1}; + long _masterTableVersion{-1}; + long _localTableVersion{-1}; + long _lyear{-1}; + long _lmonth{-1}; + long _lday{-1}; + long _lhour{-1}; + long _lminute{-1}; + std::string headerIdent_{"__UNDEF__"}; + + MvBufrEdition* _edition{nullptr}; + MvBufrConfidence* _confidence{nullptr}; + + // use eccodes optimisation + bool useSkipExtraAttributes_{true}; + + // For compressed messages + bool cacheCompressedData_{true}; MvBufrSubsetData compressedData_; MvEccHandle_ptr _ecH; - codes_handle* _ecHSS {nullptr}; // handle access to a subset. - // function Destructor should delete it + codes_handle* _ecHSS{nullptr}; // handle access to a subset. + // function Destructor should delete it - codes_bufr_keys_iterator* _ecIter {nullptr}; // eccodes key iterator within a message - const void* _bufferSS {nullptr}; // auxiliary pointer + codes_bufr_keys_iterator* _ecIter{nullptr}; // eccodes key iterator within a message + const void* _bufferSS{nullptr}; // auxiliary pointer }; #ifndef DOXYGEN_SHOULD_SKIP_THIS //--------------------------------------------------------------- MvBufrParam -class MvBufrParam -{ +class MvBufrParam { public: MvBufrParam(const char* aParamName); MvBufrParam(const long anIntAsDescriptor) { fDescriptor = anIntAsDescriptor; } @@ -689,8 +679,7 @@ class MvBufrParam class MvObsSet; -class MvBufrOut -{ +class MvBufrOut { friend class MvObs; friend class MvObsSet; diff --git a/src/eckit_readers/MvObs.cc b/src/eckit_readers/MvObs.cc index 7fc38cbf2..db4d41136 100644 --- a/src/eckit_readers/MvObs.cc +++ b/src/eckit_readers/MvObs.cc @@ -44,11 +44,11 @@ #include "MvObs.h" #include "MvObsSet.h" -#include -#include +#include #include +#include #include -#include +#include using std::string; #include #include @@ -66,19 +66,14 @@ using std::string; // class MvObsSet and contains only one command which calls back class // MvObsSet. Maybe, this class can be removed in the future. //______________________________________________________________________ -\ -MvBufrOut::MvBufrOut(MvObsSet* aSet) : - _outSet(aSet) -{ -} -MvBufrOut::~MvBufrOut() -{ -// _outSet->close(); // the owner should be responsible to close this file +MvBufrOut::MvBufrOut(MvObsSet* aSet) : _outSet(aSet) {} + +MvBufrOut::~MvBufrOut() { + // _outSet->close(); // the owner should be responsible to close this file } -void MvBufrOut::add(MvObs& anObs) -{ +void MvBufrOut::add(MvObs& anObs) { _outSet->write(anObs); } @@ -87,18 +82,17 @@ void MvBufrOut::add(MvObs& anObs) //-------------------------------------------------------- #ifndef DOXYGEN_SHOULD_SKIP_THIS -typedef struct -{ +typedef struct { const char* name; long descriptor; } descriptorStruct; -static descriptorStruct knownParams[] = - { - {"z", 10003}, {"p", 10004}, {"ddd", 11001}, {"ff", 11002}, {"u", 11003}, {"v", 11004}, {"w", 11006}, {"T", 12001}, {"Td", 12003}, {"T(2m)", 12004}, {"Td(2m)", 12006}, {"END", 0}}; +static descriptorStruct knownParams[] = {{"z", 10003}, {"p", 10004}, {"ddd", 11001}, {"ff", 11002}, + {"u", 11003}, {"v", 11004}, {"w", 11006}, {"T", 12001}, + {"Td", 12003}, {"T(2m)", 12004}, {"Td(2m)", 12006}, {"END", 0}}; #endif -//e Remove cPressureCoordinate +// e Remove cPressureCoordinate const long cPressureCoordinate = 7004L; // pressure vertical coord. descriptor value const string sPressureCoordinate = "pressure"; // pressure vertical coord. descriptor value @@ -106,31 +100,23 @@ const string sPressureCoordinate = "pressure"; // pressure vertical coord. desc //====================================================================== MvObs //______________________________________________________________________ -MvObs::MvObs(MvEccHandle_ptr ecH, int subset_current, bool unpacked, - bool cacheCompressedData) : - _subsetNr(subset_current), - _unpacked(unpacked), - cacheCompressedData_(cacheCompressedData), - _ecH(ecH) -{ +MvObs::MvObs(MvEccHandle_ptr ecH, int subset_current, bool unpacked, bool cacheCompressedData) : + _subsetNr(subset_current), _unpacked(unpacked), cacheCompressedData_(cacheCompressedData), _ecH(ecH) { if (_ecH && _ecH->handle()) init(); } -MvObs::MvObs(const MvObs& obs) -{ +MvObs::MvObs(const MvObs& obs) { _copy(obs); } //___________________________________________________________________Destructor -MvObs::~MvObs() -{ +MvObs::~MvObs() { clear(); } //___________________________________________________________________ _copy -void MvObs::_copy(const MvObs& b) -{ +void MvObs::_copy(const MvObs& b) { _subsetNr = b._subsetNr; _compressed_data = b._compressed_data; _unpacked = b._unpacked; @@ -169,8 +155,7 @@ void MvObs::_copy(const MvObs& b) } //___________________________________________________________________ clear -void MvObs::clear() -{ +void MvObs::clear() { // Delete iterator if (_ecH && _ecH->handle() && _ecIter) { codes_bufr_keys_iterator_delete(_ecIter); @@ -190,56 +175,47 @@ void MvObs::clear() } //___________________________________________________________________ operator= -MvObs& -MvObs::operator=(const MvObs& b) -{ +MvObs& MvObs::operator=(const MvObs& b) { clear(); _copy(b); return *this; } //___________________________________________________________________ operator void* -MvObs::operator void*() -{ - return (_ecH)?(_ecH->handle()):nullptr; +MvObs::operator void*() { + return (_ecH) ? (_ecH->handle()) : nullptr; } //___________________________________________________________________ operator! -bool MvObs::operator!() -{ +bool MvObs::operator!() { return !(_ecH && _ecH->handle()); } -codes_handle* MvObs::getHandle() const -{ - return (_ecH)?(_ecH->handle()):nullptr; +codes_handle* MvObs::getHandle() const { + return (_ecH) ? (_ecH->handle()) : nullptr; } //___________________________________________________________________ msg_ok // -bool MvObs::msg_ok() const -{ +bool MvObs::msg_ok() const { return (_ecH && _ecH->handle()); } //___________________________________________________________________ Advance -bool MvObs::Advance() -{ +bool MvObs::Advance() { _subsetNr++; return _subsetNr <= _number_of_subsets; } //____________________________________________________________________ operator[] -double - MvObs::operator[](int index) //-- index starts from 1: 1,2,...,n +double MvObs::operator[](int index) //-- index starts from 1: 1,2,...,n { std::cout << "MvObs::operator[] -> not yet implemented" << std::endl; return kBufrMissingValue; } //____________________________________________________________________ hasSection2 -bool MvObs::hasSection2() -{ +bool MvObs::hasSection2() { long val = intValue("section2Present"); return val ? true : false; } @@ -247,9 +223,7 @@ bool MvObs::hasSection2() //____________________________________________________________________ value // returns 'kBufrMissingValue' if not found! //------------------------------------------------- -double -MvObs::valueC(const std::string& aDescriptor) -{ +double MvObs::valueC(const std::string& aDescriptor) { // Check only positive integer values; otherwise, use "-.0123456789" std::string skey; if (strspn(aDescriptor.c_str(), "0123456789") == aDescriptor.size()) @@ -261,35 +235,27 @@ MvObs::valueC(const std::string& aDescriptor) } // Parameter occurrence must start from 1 -double -MvObs::value(long aDescriptor, int occurrence) -{ +double MvObs::value(long aDescriptor, int occurrence) { // Build key and get value string skey = this->key(aDescriptor, occurrence); double myValue = value(skey); return myValue; } -double -MvObs::value(long aDescriptor) -{ +double MvObs::value(long aDescriptor) { // Build key and get value string skey = this->key(aDescriptor); double myValue = value(skey); return myValue; } -double -MvObs::value(const string& key, const int occurrence) -{ +double MvObs::value(const string& key, const int occurrence) { // Build key and get value string skey = this->key(key, occurrence); return value(skey); } -double -MvObs::value(const string& skey) -{ +double MvObs::value(const string& skey) { // Check input key if (skey.empty()) return kBufrMissingValue; @@ -313,7 +279,7 @@ MvObs::value(const string& skey) // FII 20170922: update this code when function codes_get_double_element can // handle uncompressed data. if (_compressed_data) { - //codes_get_double_element(*_ecH, skey.c_str(), _subsetNr-1, &dvalue); + // codes_get_double_element(*_ecH, skey.c_str(), _subsetNr-1, &dvalue); // Always use a hashtag because the array size will be smaller. Two possibilities: // a) number_of_subsets instead of number_of_subsets*number_of_occurrences @@ -321,11 +287,11 @@ MvObs::value(const string& skey) // By default we retrieve a value from the first occurrence. string sskey = (skey[0] != '#') ? "#1#" + skey : skey; - //We try to use the cached compressed values + // We try to use the cached compressed values if (cacheCompressedData_) { const std::vector& chData = compressedData_.doubleData(sskey); if (!chData.empty()) { - //vector + // vector if (static_cast(chData.size()) == _number_of_subsets) { dvalue = chData[_subsetNr - 1]; } @@ -390,9 +356,7 @@ MvObs::value(const string& skey) } //___________________________________________________________ valueByOccurrence -double -MvObs::valueByOccurrenceC(int anOccurrenceIndex, const std::string& aDescriptor) -{ +double MvObs::valueByOccurrenceC(int anOccurrenceIndex, const std::string& aDescriptor) { // Check only positive integer values; otherwise, use "-.0123456789" std::string skey; if (strspn(aDescriptor.c_str(), "0123456789") == aDescriptor.size()) @@ -403,27 +367,22 @@ MvObs::valueByOccurrenceC(int anOccurrenceIndex, const std::string& aDescriptor) return value(skey); } -double -MvObs::valueByOccurrence(int anOccurrenceIndex, const std::string& aDescriptor) -{ +double MvObs::valueByOccurrence(int anOccurrenceIndex, const std::string& aDescriptor) { // Build key and get value string skey = key(aDescriptor, anOccurrenceIndex); return value(skey); } -double -MvObs::valueByOccurrence(int anOccurrenceIndex, long aDescriptor) -{ +double MvObs::valueByOccurrence(int anOccurrenceIndex, long aDescriptor) { // Build key and get value string skey = this->key(aDescriptor, anOccurrenceIndex); double myValue = value(skey); return myValue; } -//Returns all values of a given key from a message/subset. The key is either a simple string -//e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" -void MvObs::allValues(const string& keyName, std::vector& vals) -{ +// Returns all values of a given key from a message/subset. The key is either a simple string +// e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" +void MvObs::allValues(const string& keyName, std::vector& vals) { // Check input key if (keyName.empty()) return; @@ -449,29 +408,29 @@ void MvObs::allValues(const string& keyName, std::vector& vals) // It is an array of elements if (_compressed_data) { - int maxRank = 1000000; //we do not know how many ranks we have! + int maxRank = 1000000; // we do not know how many ranks we have! int ir = 1; int rank = occurenceFromKey(keyName); - //we read a sing rank only + // we read a sing rank only if (rank >= 1) { ir = rank; maxRank = ir + 1; } - //loop for the ranks + // loop for the ranks while (ir < maxRank) { valLen = 0; std::string rKeyName = keyName; if (rank < 1) rKeyName = "#" + toString(ir) + "#" + keyName; - //We try to use the cached compressed values + // We try to use the cached compressed values bool hasCache = false; if (cacheCompressedData_) { const std::vector& chData = compressedData_.longData(rKeyName); if (!chData.empty()) { - //vector + // vector if (static_cast(chData.size()) == _number_of_subsets) { val = chData[_subsetNr - 1]; } @@ -490,7 +449,7 @@ void MvObs::allValues(const string& keyName, std::vector& vals) if (valLen == 0) break; - //Single value + // Single value if (valLen == 1) { codes_get_double(_ecH->handle(), rKeyName.c_str(), &val); if (cacheCompressedData_) { @@ -498,7 +457,7 @@ void MvObs::allValues(const string& keyName, std::vector& vals) } vals.push_back((val == CODES_MISSING_DOUBLE) ? kBufrMissingValue : val); } - //Array + // Array else if (_subsetNr <= static_cast(valLen)) { if (valArrNum < valLen) { delete[] valArr; @@ -531,7 +490,7 @@ void MvObs::allValues(const string& keyName, std::vector& vals) codes_get_double(_ecH->handle(), rKeyName.c_str(), &val); vals.push_back((val == CODES_MISSING_DOUBLE) ? kBufrMissingValue : val); } - //Array + // Array else { assert(!valArr); valArr = new double[valLen]; @@ -550,36 +509,31 @@ void MvObs::allValues(const string& keyName, std::vector& vals) //____________________________________________________________________ intValue -long MvObs::currentIntValue() -{ +long MvObs::currentIntValue() { return intValue(_currentKey); } -long MvObs::intValue(const long aDescriptor, const int occurrence) -{ +long MvObs::intValue(const long aDescriptor, const int occurrence) { // Build key and get value string skey = this->key(aDescriptor, occurrence); long myValue = intValue(skey); return myValue; } -long MvObs::intValue(const long aDescriptor) -{ +long MvObs::intValue(const long aDescriptor) { // Build key and get value string skey = this->key(aDescriptor); long myValue = intValue(skey); return myValue; } -long MvObs::intValue(const string& key, const int occurrence) -{ +long MvObs::intValue(const string& key, const int occurrence) { // Build key and get value string skey = this->key(key, occurrence); return intValue(skey); } -long MvObs::intValue(const string& skey) -{ +long MvObs::intValue(const string& skey) { // Check input key if (skey.empty()) return kBufrMissingIntValue; @@ -609,11 +563,11 @@ long MvObs::intValue(const string& skey) // By default we retrieve a value from the first occurrence. string sskey = (skey[0] != '#') ? "#1#" + skey : skey; - //We try to use the cached compressed values + // We try to use the cached compressed values if (cacheCompressedData_) { const std::vector& chData = compressedData_.longData(sskey); if (!chData.empty()) { - //vector + // vector if (static_cast(chData.size()) == _number_of_subsets) { value = chData[_subsetNr - 1]; } @@ -624,13 +578,13 @@ long MvObs::intValue(const string& skey) } } - //read the data values + // read the data values codes_get_size(_ecH->handle(), sskey.c_str(), &nelems); if (nelems == 1) // get the unique element { codes_get_long(_ecH->handle(), sskey.c_str(), &value); if (cacheCompressedData_) { - compressedData_.addLongData(sskey, value); //add to cache + compressedData_.addLongData(sskey, value); // add to cache } return value == CODES_MISSING_LONG ? kBufrMissingIntValue : value; } @@ -640,7 +594,7 @@ long MvObs::intValue(const string& skey) codes_get_long_array(_ecH->handle(), sskey.c_str(), v1, &nelems); value = v1[_subsetNr - 1]; if (cacheCompressedData_) { - compressedData_.addLongData(sskey, v1, nelems); //add to cache + compressedData_.addLongData(sskey, v1, nelems); // add to cache } delete[] v1; v1 = 0; @@ -677,10 +631,9 @@ long MvObs::intValue(const string& skey) return value == CODES_MISSING_LONG ? kBufrMissingIntValue : value; } -//Returns all values of a given key from a message/subset. The key is either a simple string -//e.g. "airTemperature" or one containing the rank e.g. "#1#airTemperature" -void MvObs::allIntValues(const string& keyName, std::vector& vals) -{ +// Returns all values of a given key from a message/subset. The key is either a simple string +// e.g. "airTemperature" or one containing the rank e.g. "#1#airTemperature" +void MvObs::allIntValues(const string& keyName, std::vector& vals) { // Check input key if (keyName.empty()) return; @@ -706,29 +659,29 @@ void MvObs::allIntValues(const string& keyName, std::vector& vals) // It is an array of elements if (_compressed_data) { - int maxRank = 1000000; //we do not know how many ranks we have! + int maxRank = 1000000; // we do not know how many ranks we have! int ir = 1; int rank = occurenceFromKey(keyName); - //we read a single rank only + // we read a single rank only if (rank >= 1) { ir = rank; maxRank = ir + 1; } - //loop for the ranks + // loop for the ranks while (ir < maxRank) { valLen = 0; std::string rKeyName = keyName; if (rank < 1) rKeyName = "#" + toString(ir) + "#" + keyName; - //We try to use the cached compressed values + // We try to use the cached compressed values bool hasCache = false; if (cacheCompressedData_) { const std::vector& chData = compressedData_.longData(rKeyName); if (!chData.empty()) { - //vector + // vector if (static_cast(chData.size()) == _number_of_subsets) { val = chData[_subsetNr - 1]; } @@ -747,7 +700,7 @@ void MvObs::allIntValues(const string& keyName, std::vector& vals) if (valLen == 0) break; - //Single value + // Single value if (valLen == 1) { codes_get_long(_ecH->handle(), rKeyName.c_str(), &val); if (cacheCompressedData_) { @@ -755,7 +708,7 @@ void MvObs::allIntValues(const string& keyName, std::vector& vals) } vals.push_back((val == CODES_MISSING_LONG) ? kBufrMissingIntValue : val); } - //Array + // Array else if (_subsetNr <= static_cast(valLen)) { if (valArrNum < valLen) { delete[] valArr; @@ -787,7 +740,7 @@ void MvObs::allIntValues(const string& keyName, std::vector& vals) codes_get_long(_ecH->handle(), rKeyName.c_str(), &val); vals.push_back((val == CODES_MISSING_LONG) ? kBufrMissingIntValue : val); } - //Array + // Array else { assert(!valArr); valArr = new long[valLen]; @@ -805,35 +758,27 @@ void MvObs::allIntValues(const string& keyName, std::vector& vals) } //_________________________________________________________________ stringValue -string -MvObs::stringValue(const long aDescriptor, const int occurrence) -{ +string MvObs::stringValue(const long aDescriptor, const int occurrence) { // Build key and get value string skey = this->key(aDescriptor, occurrence); string myValue = stringValue(skey); return myValue; } -string -MvObs::stringValue(const long aDescriptor) -{ +string MvObs::stringValue(const long aDescriptor) { // Build key and get value string skey = this->key(aDescriptor); string myValue = stringValue(skey); return myValue; } -string -MvObs::stringValue(const string& key, const int occurrence) -{ +string MvObs::stringValue(const string& key, const int occurrence) { // Build key and get value string skey = this->key(key, occurrence); return stringValue(skey); } -string -MvObs::stringValue(const string& skeyi) -{ +string MvObs::stringValue(const string& skeyi) { // skeyi could be a numerical descriptor coded as a string string skey = keyC(skeyi); @@ -854,7 +799,7 @@ MvObs::stringValue(const string& skeyi) size_t len = 1024; if (nelems == 1) { codes_get_string(_ecH->handle(), skey.c_str(), buf, &len); - //buf[len] = 0; //??? + // buf[len] = 0; //??? if (buf[0] == -1) // missing value - cannot convert to string return string(""); else @@ -874,7 +819,7 @@ MvObs::stringValue(const string& skeyi) if (nelems == 1) // get the unique element { codes_get_string(_ecH->handle(), sskey.c_str(), buf, &len); - //buf[len] = 0; //??? + // buf[len] = 0; //??? return string(buf); } @@ -886,8 +831,8 @@ MvObs::stringValue(const string& skeyi) // Get all values and select the required one size_t itotal = isize * nelems; codes_get_string_array(_ecH->handle(), sskey.c_str(), cValues, &itotal); - //for(int i=0; ihandle(), sskey.c_str(), buf, &len); - //buf[len] = 0; //??? + // buf[len] = 0; //??? return string(buf); } else @@ -929,23 +874,20 @@ MvObs::stringValue(const string& skeyi) delete[] cValues; cValues = 0; - //buf[len] = 0; //??? + // buf[len] = 0; //??? return string(buf); } // It should only be used through the iterator -string -MvObs::stringValue() -{ +string MvObs::stringValue() { string myValue = stringValue(_currentKey); return myValue; } -//Returns all values of a given key from a message/subset. The key is either a simple string -//e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" -void MvObs::allStringValues(const std::string& keyName, std::vector& vals) -{ +// Returns all values of a given key from a message/subset. The key is either a simple string +// e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" +void MvObs::allStringValues(const std::string& keyName, std::vector& vals) { // Check input key if (keyName.empty()) return; @@ -970,21 +912,21 @@ void MvObs::allStringValues(const std::string& keyName, std::vector char** valArr = 0; size_t valArrNum = 0; - size_t sLenArr = 128; //the maximum string size we handle + size_t sLenArr = 128; // the maximum string size we handle // It is an array of elements if (_compressed_data) { - int maxRank = 1000000; //we do not know how many ranks we have! + int maxRank = 1000000; // we do not know how many ranks we have! int ir = 1; int rank = occurenceFromKey(keyName); - //we read a sing rank only + // we read a sing rank only if (rank >= 1) { ir = rank; maxRank = ir + 1; } - //loop for the ranks + // loop for the ranks while (ir < maxRank) { valLen = 0; std::string rKeyName = keyName; @@ -996,12 +938,12 @@ void MvObs::allStringValues(const std::string& keyName, std::vector if (valLen == 0) break; - //Single value + // Single value if (valLen == 1) { codes_get_string(_ecH->handle(), rKeyName.c_str(), buf, &sLen); vals.push_back(std::string(buf)); } - //Array + // Array else if (_subsetNr <= static_cast(valLen)) { if (valArrNum < valLen) { for (std::size_t i = 0; i < valArrNum; ++i) @@ -1036,7 +978,7 @@ void MvObs::allStringValues(const std::string& keyName, std::vector codes_get_string(_ecH->handle(), rKeyName.c_str(), buf, &sLen); vals.push_back(std::string(buf)); } - //Array + // Array else { assert(!valArr); valArr = new char*[valLen]; @@ -1060,8 +1002,7 @@ void MvObs::allStringValues(const std::string& keyName, std::vector } -bool MvObs::setFirstDescriptor(bool skipConfidence) -{ +bool MvObs::setFirstDescriptor(bool skipConfidence) { // Set Confidence values flag _skipConfidence = skipConfidence; @@ -1094,8 +1035,7 @@ bool MvObs::setFirstDescriptor(bool skipConfidence) return true; } -bool MvObs::setNextDescriptor() -{ +bool MvObs::setNextDescriptor() { // Advance iterator if (!codes_bufr_keys_iterator_next(_ecIter)) { codes_bufr_keys_iterator_delete(_ecIter); @@ -1125,16 +1065,14 @@ bool MvObs::setNextDescriptor() return flag; } -void MvObs::clearIterator() -{ +void MvObs::clearIterator() { if (_ecIter) { codes_bufr_keys_iterator_delete(_ecIter); _ecIter = 0; } } -void MvObs::expand() -{ +void MvObs::expand() { if (!_unpacked && _ecH && _ecH->handle()) { if (useSkipExtraAttributes_) { codes_set_long(_ecH->handle(), "skipExtraKeyAttributes", 1); @@ -1144,22 +1082,17 @@ void MvObs::expand() } } -long MvObs::currentDescriptor() -{ +long MvObs::currentDescriptor() { string skey = _currentKey + "->code"; long descriptor = intValue(skey); return descriptor; } -const std::string& -MvObs::currentKey() -{ +const std::string& MvObs::currentKey() { return _currentKey; } -const std::string -MvObs::currentKeyWithoutRank() -{ +const std::string MvObs::currentKeyWithoutRank() { // No occurrence tag if (_currentKey[0] != '#') return _currentKey; @@ -1170,27 +1103,22 @@ MvObs::currentKeyWithoutRank() } // It should only be used through the iterator -double -MvObs::currentValue() -{ +double MvObs::currentValue() { double myValue = value(_currentKey); return myValue; } -double -MvObs::nextValue() -{ +double MvObs::nextValue() { std::cout << "MvObs :: nextValue() -> not yet implemented" << std::endl; exit(0); } -MvObs MvObs::cloneSubset(long subset_number) -{ +MvObs MvObs::cloneSubset(long subset_number) { if (!_ecH || !_ecH->handle()) return MvObs(nullptr); // Check if the input subset number is vali - if(subset_number > msgSubsetCount()) { + if (subset_number > msgSubsetCount()) { std::cout << "ERROR MvObs::cloneSubset() -> invalid input subset number" << std::endl; return MvObs(nullptr); } @@ -1205,7 +1133,7 @@ MvObs MvObs::cloneSubset(long subset_number) // h2 is a temporary handle; it will be deleted at the end of this function codes_handle* h2 = codes_handle_clone(_ecH->handle()); assert(h2); - codes_set_long(h2, "skipExtraKeyAttributes",1); + codes_set_long(h2, "skipExtraKeyAttributes", 1); codes_set_long(h2, "unpack", 1); codes_set_long(h2, "extractSubset", subset_number); codes_set_long(h2, "doExtractSubsets", 1); @@ -1219,7 +1147,7 @@ MvObs MvObs::cloneSubset(long subset_number) // Delete the temporary codes handle codes_handle_delete(h2); - h2 = 0; + h2 = 0; auto p = std::make_shared(_ecHSS); return MvObs(p, 1); } @@ -1230,16 +1158,14 @@ MvObs MvObs::cloneSubset(long subset_number) // ecCodes always returns the Type of the element: CODES_TYPE_LONG, // CODES_TYPE_DOUBLE or CODES_TYPE_STRING. It does not check if the // value is a missing value or not. -int MvObs::elementValueType(long aDescriptor) -{ +int MvObs::elementValueType(long aDescriptor) { // Build key and get type of the value string skey = this->key(aDescriptor); int itype = elementValueType(skey); return itype; } -int MvObs::elementValueType(const string& skeyi) -{ +int MvObs::elementValueType(const string& skeyi) { // skeyi could be a numerical descriptor coded as a string string skey = keyC(skeyi); @@ -1249,23 +1175,20 @@ int MvObs::elementValueType(const string& skeyi) return itype; } -int MvObs::elementValueType() -{ +int MvObs::elementValueType() { // return elementValueType(_currentKey); int itype = elementValueType(_currentKey); return itype; } //______________________________________________________ numberOfPressureLevels -int MvObs::numberOfPressureLevels() -{ +int MvObs::numberOfPressureLevels() { int npl = numberOfLevels(sPressureCoordinate); return npl; } //______________________________________________________ numberOfLevels -int MvObs::numberOfLevels(long levelDescriptor) -{ +int MvObs::numberOfLevels(long levelDescriptor) { // Build key and get value string skey = this->key(levelDescriptor); int nelems = numberOfLevels(skey); @@ -1273,8 +1196,7 @@ int MvObs::numberOfLevels(long levelDescriptor) } //______________________________________________________ numberOfLevels -int MvObs::numberOfLevels(const string& skey) -{ +int MvObs::numberOfLevels(const string& skey) { // Get number of elements size_t nelems; codes_get_size(_ecH->handle(), skey.c_str(), &nelems); @@ -1285,17 +1207,13 @@ int MvObs::numberOfLevels(const string& skey) } //__________________________________________________________ firstPressureLevel -double -MvObs::firstPressureLevel() -{ +double MvObs::firstPressureLevel() { return pressureLevel(1); } //______________________________________________________________ pressureLevel // Parameter indexValue must start from 1...N -double -MvObs::pressureLevel(int indexValue) -{ +double MvObs::pressureLevel(int indexValue) { _currentLevelKey = sPressureCoordinate; _currentLevelOccurrence = indexValue; double myLevelValue = level(_currentLevelKey, _currentLevelOccurrence); @@ -1304,25 +1222,19 @@ MvObs::pressureLevel(int indexValue) } //___________________________________________________________ nextPressureLevel -double -MvObs::nextPressureLevel() -{ +double MvObs::nextPressureLevel() { double myLevelValue = pressureLevel(_currentLevelOccurrence + 1); return myLevelValue; } //__________________________________________________________ firstLevel -double -MvObs::firstLevel(long levelDescriptor) -{ +double MvObs::firstLevel(long levelDescriptor) { string skey = key(levelDescriptor); double myLevelValue = firstLevel(skey); return myLevelValue; } -double -MvObs::firstLevel(const string& skey) -{ +double MvObs::firstLevel(const string& skey) { _currentLevelOccurrence = 1; _currentLevelKey = skey; @@ -1330,9 +1242,7 @@ MvObs::firstLevel(const string& skey) } //___________________________________________________________ nextLevel -double -MvObs::nextLevel() -{ +double MvObs::nextLevel() { _currentLevelOccurrence++; double myLevelValue = level(_currentLevelKey, _currentLevelOccurrence); return myLevelValue; @@ -1343,9 +1253,7 @@ MvObs::nextLevel() // to update parameters _currentLevelKey and _currentLevelOccurrence . // Parameter indexValue must start from 1...N // -double -MvObs::level(const string& key, int indexValue) -{ +double MvObs::level(const string& key, int indexValue) { // Get value double myLevelValue = value(key, indexValue); @@ -1357,9 +1265,8 @@ MvObs::level(const string& key, int indexValue) // specified by some other data // (e.g. temperature at a certain pressure level) //-------------------------------------------------------------------- -double -MvObs::valueBySpecifier(long aSpecifierDescriptor, double aSpecifierValue, long aDescriptor, int firstIndexValue) -{ +double MvObs::valueBySpecifier(long aSpecifierDescriptor, double aSpecifierValue, long aDescriptor, + int firstIndexValue) { // Get the correspondent keys string s1key = key(aSpecifierDescriptor); string s2key = key(aDescriptor); @@ -1368,13 +1275,11 @@ MvObs::valueBySpecifier(long aSpecifierDescriptor, double aSpecifierValue, long return value; } -double -MvObs::valueBySpecifier(const string& coordinateKey, double coordinateValue, const string& paramKey) -{ +double MvObs::valueBySpecifier(const string& coordinateKey, double coordinateValue, const string& paramKey) { // This is a temporary solution while the above code is not available // Find a coordinate key whose value matches the input value this->setFirstDescriptor(); // initialise key iterator - double precision = 0.01; //0.000001; // maybe needs to be adjusted + double precision = 0.01; // 0.000001; // maybe needs to be adjusted std::string skey; bool flag = true; while (flag) { @@ -1418,8 +1323,7 @@ MvObs::valueBySpecifier(const string& coordinateKey, double coordinateValue, con } //________________________________________________________ valueByPressureLevel -double -MvObs::valueByPressureLevelC(float aLevelValue, const std::string& aDescriptor) // in 'hPa' +double MvObs::valueByPressureLevelC(float aLevelValue, const std::string& aDescriptor) // in 'hPa' { // Check only positive integer values; otherwise, use "-.0123456789" std::string skey; @@ -1431,24 +1335,20 @@ MvObs::valueByPressureLevelC(float aLevelValue, const std::string& aDescriptor) return valueByPressureLevel(aLevelValue, skey); } -double -MvObs::valueByPressureLevel(float aLevelValue, long aDescriptor) // in 'hPa' +double MvObs::valueByPressureLevel(float aLevelValue, long aDescriptor) // in 'hPa' { string s2key = key(aDescriptor); double value = valueByPressureLevel(aLevelValue, s2key); return value; } -double -MvObs::valueByPressureLevel(float aLevelValue, const string& s2key) // in 'hPa' +double MvObs::valueByPressureLevel(float aLevelValue, const string& s2key) // in 'hPa' { return valueBySpecifier(sPressureCoordinate, aLevelValue * 100., s2key); } //________________________________________________________ valueByLevel -double -MvObs::valueByLevelC(const string& aLevelDescriptor, float aLevelValue, const std::string& aDescriptor) -{ +double MvObs::valueByLevelC(const string& aLevelDescriptor, float aLevelValue, const std::string& aDescriptor) { // Check only positive integer values; otherwise, use "-.0123456789" std::string s1key; if (strspn(aLevelDescriptor.c_str(), "0123456789") == aLevelDescriptor.size()) @@ -1465,27 +1365,22 @@ MvObs::valueByLevelC(const string& aLevelDescriptor, float aLevelValue, const st return valueByLevel(s1key, aLevelValue, s2key); } -double -MvObs::valueByLevel(long aLevelDescriptor, float aLevelValue, long aDescriptor) -{ +double MvObs::valueByLevel(long aLevelDescriptor, float aLevelValue, long aDescriptor) { std::string s1key = key(aLevelDescriptor); std::string s2key = key(aDescriptor); double value = valueByLevel(s1key, aLevelValue, s2key); return value; } -double -MvObs::valueByLevel(const std::string& s1key, float aLevelValue, const std::string& s2key) -{ +double MvObs::valueByLevel(const std::string& s1key, float aLevelValue, const std::string& s2key) { return valueBySpecifier(s1key, aLevelValue, s2key); } //________________________________________________________ valueByRange // Get the first value from aDescriptor whose value from aLevelDescriptor // is within level1 and level2 (both in Pa) -double -MvObs::valueByLevelRangeC(const std::string& aLevelDescriptor, float level1, float level2, const std::string& aDescriptor) -{ +double MvObs::valueByLevelRangeC(const std::string& aLevelDescriptor, float level1, float level2, + const std::string& aDescriptor) { // Check only positive integer values; otherwise, use "-.0123456789" std::string s1key; if (strspn(aLevelDescriptor.c_str(), "0123456789") == aLevelDescriptor.size()) @@ -1502,18 +1397,14 @@ MvObs::valueByLevelRangeC(const std::string& aLevelDescriptor, float level1, flo return valueByLevelRange(s1key, level1, level2, s2key); } -double -MvObs::valueByLevelRange(long aLevelDescriptor, float level1, float level2, long aDescriptor) -{ +double MvObs::valueByLevelRange(long aLevelDescriptor, float level1, float level2, long aDescriptor) { std::string s1key = key(aLevelDescriptor); std::string s2key = key(aDescriptor); double value = valueByLevelRange(s1key, level1, level2, s2key); return value; } -double -MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, const std::string& s2key) -{ +double MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, const std::string& s2key) { // Get number of elements size_t nelems, len; codes_get_size(_ecH->handle(), s1key.c_str(), &nelems); @@ -1543,7 +1434,7 @@ MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, c for (unsigned int i = 0; i < nelems; i++) { if (dlevels[i] >= minv && dlevels[i] <= maxv) { // Get value from the second key - //double myValue = value(s2key,i+1); // can not assume that s1key and + // double myValue = value(s2key,i+1); // can not assume that s1key and // s2key have the same occurrence // number myValue = valueBySpecifier(s1key, dlevels[i], s2key); @@ -1560,33 +1451,29 @@ MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, c } -//e This function is not working +// e This function is not working //________________________________________________________________ valueByLayer -float MvObs::valueByLayerC(float firstLevel, float secondLevel, const std::string& aDescriptor) -{ +float MvObs::valueByLayerC(float firstLevel, float secondLevel, const std::string& aDescriptor) { std::cout << "MvObs::valueByLayerC -> not implemented yet" << std::endl; return kBufrMissingValue; //-- Not Found or Troubled Msg -- } -float MvObs::valueByLayer(float firstLevel, float secondLevel, long aDescriptor) -{ +float MvObs::valueByLayer(float firstLevel, float secondLevel, long aDescriptor) { std::cout << "MvObs :: valueByLayer -> not implemented yet" << std::endl; - //exit(0); + // exit(0); return kBufrMissingValue; //-- Not Found or Troubled Msg -- } //______________________________________________________________ printAllValues -bool MvObs::printAllValues() -{ +bool MvObs::printAllValues() { std::ostream* myStream = &std::cout; return writeAllValues(*myStream); } //_______________________________________________________________ writeAllValues -bool MvObs::writeAllValues(std::ostream& aStream) -{ - //e remove confidence code temporarily +bool MvObs::writeAllValues(std::ostream& aStream) { + // e remove confidence code temporarily // long myEndingIndex = _confidence->hasConfidences() ? _confidence->lastDataIndex()+1 : In_KTDEXL; long myEndingIndex = 100000; writeValues(aStream, 0, myEndingIndex); @@ -1594,8 +1481,7 @@ bool MvObs::writeAllValues(std::ostream& aStream) return true; } -bool MvObs::writeValues(std::ostream& aStream, int firstIndex, int lastIndex) -{ +bool MvObs::writeValues(std::ostream& aStream, int firstIndex, int lastIndex) { double dval; // Main loop @@ -1643,8 +1529,7 @@ bool MvObs::writeValues(std::ostream& aStream, int firstIndex, int lastIndex) } //_______________________________________________________________ writeAllValues -bool MvObs::writeAllValues(const char* aPathName) -{ +bool MvObs::writeAllValues(const char* aPathName) { std::ofstream myStream(aPathName, std::ios::out); if (!myStream) { std::cerr << " >>> MvObs::writeAllValues(char*): error in creating file " << aPathName << std::endl; @@ -1658,29 +1543,24 @@ bool MvObs::writeAllValues(const char* aPathName) } //______________________________________________________________ WmoIdentNumber -long MvObs::WmoIdentNumber() -{ +long MvObs::WmoIdentNumber() { return WmoBlockNumber() * 1000 + WmoStationNumber(); } //______________________________________________________________ WmoBlockNumber -int MvObs::WmoBlockNumber() -{ +int MvObs::WmoBlockNumber() { long myValue = intValue("blockNumber"); return myValue == kBufrMissingIntValue ? 0 : (int)myValue; } //____________________________________________________________ WmoStationNumber -int MvObs::WmoStationNumber() -{ +int MvObs::WmoStationNumber() { long myValue = intValue("stationNumber"); return myValue == kBufrMissingIntValue ? 0 : (int)myValue; } //____________________________________________________________ findSomeIdent -string -MvObs::findSomeIdent() -{ +string MvObs::findSomeIdent() { //-- 5-digit WMO identifier available? long lid = WmoIdentNumber(); if (lid > 0) { @@ -1691,18 +1571,17 @@ MvObs::findSomeIdent() //-- No WMO id found, thus look for other candidates, //-- this is a list of known identifier candidates. - const string idList[] = - { - "shipOrMobileLandStationIdentifier", // 1011 - "buoyOrPlatformIdentifier", // 1005 - "aircraftFlightNumber", // 1006 - "satelliteIdentifier", // 1007 - "aircraftRegistrationNumberOrOtherIdentification", // 1008 - "stationaryBuoyPlatformIdentifierEGCManBuoys", // 1010 - "stormIdentifier", // 1025 - "stormName", // 1026 - "longStormName" // 1027 - }; + const string idList[] = { + "shipOrMobileLandStationIdentifier", // 1011 + "buoyOrPlatformIdentifier", // 1005 + "aircraftFlightNumber", // 1006 + "satelliteIdentifier", // 1007 + "aircraftRegistrationNumberOrOtherIdentification", // 1008 + "stationaryBuoyPlatformIdentifierEGCManBuoys", // 1010 + "stormIdentifier", // 1025 + "stormName", // 1026 + "longStormName" // 1027 + }; int idVals = sizeof(idList) / sizeof(idList[0]); for (int i = 0; i < idVals; ++i) { @@ -1719,10 +1598,8 @@ MvObs::findSomeIdent() } //____________________________________________________________________ location -MvLocation -MvObs::location() -{ - //F NEW CODE +MvLocation MvObs::location() { + // F NEW CODE // ERROR ERROR ERROR ERROR // THERE IS A PROBLEM HERE. IN THE ORIGINAL CODE (ABOVE) IF "HIGH // ACCURACY" VALUES ARE NOT PRESENTED, IT TRIES TO GET THE "COARSE @@ -1733,12 +1610,11 @@ MvObs::location() // Get latitude/longitude values MvLocation myLocation(value("latitude"), value("longitude")); //-- "high accuracy" - if (myLocation.latitude() == kBufrMissingValue || - myLocation.longitude() == kBufrMissingValue) { - //myLocation.set( value( 5002L ), value( 6002L ) ); //-- "coarse accuracy" + if (myLocation.latitude() == kBufrMissingValue || myLocation.longitude() == kBufrMissingValue) { + // myLocation.set( value( 5002L ), value( 6002L ) ); //-- "coarse accuracy" } //-- hopefully not missing -#if 0 //F add prepBUFR later +#if 0 // F add prepBUFR later // This one is for those quirky NCEP PrepBUFR msgs if( myLocation.latitude() != kBufrMissingValue && myLocation.longitude() == kBufrMissingValue ) @@ -1752,35 +1628,27 @@ MvObs::location() } //____________________________________________________________________ unit -string -MvObs::unit(long aDescriptor) -{ +string MvObs::unit(long aDescriptor) { string skey = key(aDescriptor) + "->units"; string sunit = stringValue(skey); return sunit; } //____________________________________________________________________ unit -string -MvObs::unit() -{ +string MvObs::unit() { string skey = _currentKey + "->units"; string sunit = stringValue(skey); return sunit; } //____________________________________________________________________ name -string -MvObs::name(long aDescriptor) -{ +string MvObs::name(long aDescriptor) { string skey = key(aDescriptor); return skey; } //____________________________________________________________________ name -string -MvObs::name() -{ +string MvObs::name() { return _currentKey; } @@ -1788,8 +1656,7 @@ MvObs::name() //-- APIs for requesting info from the Header, BUFR Section 0,1,2,3 --// //___________________________________________________________________ init -void MvObs::init() -{ +void MvObs::init() { // Read initial variables masterTableVersion(); localTableVersion(); @@ -1800,8 +1667,7 @@ void MvObs::init() } //_________________________________________________________ messageTotalLen() -int MvObs::messageTotalLen() -{ +int MvObs::messageTotalLen() { if (_messageTotalLen == -1) _messageTotalLen = intValue("totalLength"); @@ -1809,8 +1675,7 @@ int MvObs::messageTotalLen() } //___________________________________________________________ editionNumber -int MvObs::editionNumber() -{ +int MvObs::editionNumber() { if (_editionNumber == -1) _editionNumber = intValue("edition"); @@ -1818,8 +1683,7 @@ int MvObs::editionNumber() } //_______________________________________________________________ msgSubsetCount -int MvObs::msgSubsetCount() -{ +int MvObs::msgSubsetCount() { if (_number_of_subsets == -1) _number_of_subsets = intValue("numberOfSubsets"); @@ -1828,8 +1692,7 @@ int MvObs::msgSubsetCount() } //_________________________________________________________________ messageType -int MvObs::messageType() -{ +int MvObs::messageType() { if (_messageType == -1) _messageType = intValue("dataCategory"); @@ -1837,8 +1700,7 @@ int MvObs::messageType() } //______________________________________________________________ messageSubtype -int MvObs::messageSubtype() -{ +int MvObs::messageSubtype() { // FI 20170925: ecCodes does not have a flag to indicate a missing value // indicator as BUFRDC (cOctetMissingIndicator). // Update this code when ecCodes can handle a missing value indicator @@ -1851,8 +1713,7 @@ int MvObs::messageSubtype() } //______________________________________________________________ messageSubtype -int MvObs::messageRdbtype() -{ +int MvObs::messageRdbtype() { if (_rdbType == -1) _rdbType = intValue("rdbType"); @@ -1860,8 +1721,7 @@ int MvObs::messageRdbtype() } //_________________________________________________ messageSubtypeInternational -int MvObs::messageSubtypeInternational() -{ +int MvObs::messageSubtypeInternational() { if (_subTypeInternational == -1) _subTypeInternational = intValue("internationalDataSubCategory"); @@ -1869,8 +1729,7 @@ int MvObs::messageSubtypeInternational() } //_________________________________________________________ messageSubtypeLocal -int MvObs::messageSubtypeLocal() -{ +int MvObs::messageSubtypeLocal() { if (_subTypeLocal == -1) _subTypeLocal = intValue("dataSubCategory"); @@ -1878,16 +1737,14 @@ int MvObs::messageSubtypeLocal() } //___________________________________________________________ originatingCentre -int MvObs::originatingCentre() -{ +int MvObs::originatingCentre() { if (_originatingCentre == -1) _originatingCentre = intValue("bufrHeaderCentre"); return (int)_originatingCentre; } -const std::string& MvObs::originatingCentreAsStr() -{ +const std::string& MvObs::originatingCentreAsStr() { if (_originatingCentreStr.empty()) _originatingCentreStr = stringValue("bufrHeaderCentre"); @@ -1896,8 +1753,7 @@ const std::string& MvObs::originatingCentreAsStr() //___________________________________________________________ originatingSubCentre -int MvObs::originatingSubCentre() -{ +int MvObs::originatingSubCentre() { if (_originatingSubCentre == -1) _originatingSubCentre = intValue("bufrHeaderSubCentre"); @@ -1905,8 +1761,7 @@ int MvObs::originatingSubCentre() } //___________________________________________________________ masterTable -int MvObs::masterTable() -{ +int MvObs::masterTable() { if (_masterTable == -1) _masterTable = intValue("masterTableNumber"); @@ -1914,8 +1769,7 @@ int MvObs::masterTable() } //___________________________________________________________ masterTableVersion -int MvObs::masterTableVersion() -{ +int MvObs::masterTableVersion() { if (_masterTableVersion == -1) _masterTableVersion = intValue("masterTablesVersionNumber"); @@ -1923,16 +1777,14 @@ int MvObs::masterTableVersion() } //___________________________________________________________ localTableVersion -int MvObs::localTableVersion() -{ +int MvObs::localTableVersion() { if (_localTableVersion == -1) _localTableVersion = intValue("localTablesVersionNumber"); return (int)_localTableVersion; } -const std::string& MvObs::headerIdent() -{ +const std::string& MvObs::headerIdent() { if (headerIdent_ == "__UNDEF__") { if (hasSection2() && originatingCentre() == 98) headerIdent_ = stringValue("ident"); @@ -1943,9 +1795,7 @@ const std::string& MvObs::headerIdent() } //_________________________________________________________________ msgTime -TDynamicTime -MvObs::msgTime() -{ +TDynamicTime MvObs::msgTime() { // Get values from the Header if (_lyear == -1) { _lyear = intValue("typicalYear"); @@ -1956,14 +1806,11 @@ MvObs::msgTime() } // Return time - return TDynamicTime((short)_lyear, (short)_lmonth, (short)_lday, - (short)_lhour, (short)_lminute, 0); + return TDynamicTime((short)_lyear, (short)_lmonth, (short)_lday, (short)_lhour, (short)_lminute, 0); } //---------------------------------------------------------------------------- -TDynamicTime -MvObs::obsTime() -{ +TDynamicTime MvObs::obsTime() { // Get values long lyear = intValue("year"); long lmonth = intValue("month"); @@ -1977,20 +1824,14 @@ MvObs::obsTime() lsecond = (lsecond == kBufrMissingIntValue) ? 0 : lsecond; // NCEP PrepBUFR may not contain date/time information - if (lyear == kBufrMissingIntValue || - lmonth == kBufrMissingIntValue || - lday == kBufrMissingIntValue) - return this->msgTime(); //take date from section 1 + if (lyear == kBufrMissingIntValue || lmonth == kBufrMissingIntValue || lday == kBufrMissingIntValue) + return this->msgTime(); // take date from section 1 - return TDynamicTime((short)lyear, (short)lmonth, (short)lday, - (short)lhour, (short)lminute, (short)lsecond); + return TDynamicTime((short)lyear, (short)lmonth, (short)lday, (short)lhour, (short)lminute, (short)lsecond); } - -TDynamicTime -MvObs::obsTime(int occurrence) -{ +TDynamicTime MvObs::obsTime(int occurrence) { // Get values long lyear = intValue("year", occurrence); long lmonth = intValue("month", occurrence); @@ -2004,21 +1845,16 @@ MvObs::obsTime(int occurrence) lsecond = (lsecond == kBufrMissingIntValue) ? 0 : lsecond; // NCEP PrepBUFR may not contain date/time information - if (lyear == kBufrMissingIntValue || - lmonth == kBufrMissingIntValue || - lday == kBufrMissingIntValue) - return this->msgTime(); //take date from section 1 + if (lyear == kBufrMissingIntValue || lmonth == kBufrMissingIntValue || lday == kBufrMissingIntValue) + return this->msgTime(); // take date from section 1 - return TDynamicTime((short)lyear, (short)lmonth, (short)lday, - (short)lhour, (short)lminute, (short)lsecond); + return TDynamicTime((short)lyear, (short)lmonth, (short)lday, (short)lhour, (short)lminute, (short)lsecond); } //---------------------------------------------------------------------------- //-- APIs for converting Descriptors to keys --// -std::string -MvObs::keyC(const std::string& descriptor, const int index) -{ +std::string MvObs::keyC(const std::string& descriptor, const int index) { // Check only positive integer values; otherwise, use "-.0123456789" if (strspn(descriptor.c_str(), "0123456789") == descriptor.size()) return key(atol(descriptor.c_str()), index); @@ -2026,12 +1862,10 @@ MvObs::keyC(const std::string& descriptor, const int index) return descriptor; } -std::string -MvObs::key(const int descriptor, const int index) -{ +std::string MvObs::key(const int descriptor, const int index) { if (!_edition) - _edition = MvBufrEdition::find(_masterTable, _masterTableVersion, _localTableVersion, - _originatingCentre, _originatingSubCentre); + _edition = MvBufrEdition::find(_masterTable, _masterTableVersion, _localTableVersion, _originatingCentre, + _originatingSubCentre); MvBufrElementTable* tbl = MvBufrElementTable::find(_edition); assert(tbl); @@ -2045,8 +1879,7 @@ MvObs::key(const int descriptor, const int index) return skey; } -bool MvObs::descriptorToKey(const long descriptor, string& key) -{ +bool MvObs::descriptorToKey(const long descriptor, string& key) { codes_handle* dkH = NULL; size_t size = 1; char* strVal[1] = { @@ -2080,8 +1913,7 @@ bool MvObs::descriptorToKey(const long descriptor, string& key) return ret; } -bool MvObs::descriptor_to_key(const long descriptor, std::string& key) -{ +bool MvObs::descriptor_to_key(const long descriptor, std::string& key) { // Get BUFR key iterator codes_bufr_keys_iterator* kiter = NULL; kiter = codes_bufr_keys_iterator_new(_ecH->handle(), 0); @@ -2119,9 +1951,7 @@ bool MvObs::descriptor_to_key(const long descriptor, std::string& key) return flag; } -string -MvObs::key(const string& ikey, const int occurrence) -{ +string MvObs::key(const string& ikey, const int occurrence) { // Return original key if (occurrence < 1) return ikey; @@ -2134,9 +1964,7 @@ MvObs::key(const string& ikey, const int occurrence) return key; } -std::string -MvObs::keyWithoutOccurrenceTag(const std::string& key) -{ +std::string MvObs::keyWithoutOccurrenceTag(const std::string& key) { // Remove the prefix #n# if (!key.empty() && key[0] == '#') { std::size_t ipos = key.find('#', 1); @@ -2147,8 +1975,7 @@ MvObs::keyWithoutOccurrenceTag(const std::string& key) return key; } -int MvObs::occurenceFromKey(const std::string& key) -{ +int MvObs::occurenceFromKey(const std::string& key) { if (!key.empty() && key[0] == '#') { std::size_t ipos = key.find('#', 1); if (ipos != std::string::npos) { @@ -2160,48 +1987,41 @@ int MvObs::occurenceFromKey(const std::string& key) } //______________________________________________________________ hasConfidences -bool MvObs::hasConfidences() -{ +bool MvObs::hasConfidences() { std::cout << "MvObs :: hasConfidences() -> not yet implemented" << std::endl; exit(0); return _confidence->hasConfidences(); } //__________________________________________________________________ confidence -int MvObs::confidence() -{ +int MvObs::confidence() { std::cout << "MvObs :: confidence() -> not yet implemented" << std::endl; exit(0); } -void MvBufrSubsetData::addLongData(const std::string& key, long val) -{ +void MvBufrSubsetData::addLongData(const std::string& key, long val) { std::vector vec; vec.push_back(val); longData_[key] = vec; } -void MvBufrSubsetData::addLongData(const std::string& key, long* val, size_t num) -{ +void MvBufrSubsetData::addLongData(const std::string& key, long* val, size_t num) { if (num > 0) longData_[key] = std::vector(val, val + num); } -void MvBufrSubsetData::addDoubleData(const std::string& key, double val) -{ +void MvBufrSubsetData::addDoubleData(const std::string& key, double val) { std::vector vec; vec.push_back(val); doubleData_[key] = vec; } -void MvBufrSubsetData::addDoubleData(const std::string& key, double* val, size_t num) -{ +void MvBufrSubsetData::addDoubleData(const std::string& key, double* val, size_t num) { if (num > 0) doubleData_[key] = std::vector(val, val + num); } -const std::vector& MvBufrSubsetData::longData(const std::string& key) const -{ +const std::vector& MvBufrSubsetData::longData(const std::string& key) const { std::map >::const_iterator it = longData_.find(key); if (it != longData_.end()) return it->second; @@ -2210,8 +2030,7 @@ const std::vector& MvBufrSubsetData::longData(const std::string& key) cons return emptyVec; } -const std::vector& MvBufrSubsetData::doubleData(const std::string& key) const -{ +const std::vector& MvBufrSubsetData::doubleData(const std::string& key) const { std::map >::const_iterator it = doubleData_.find(key); if (it != doubleData_.end()) return it->second; @@ -2228,9 +2047,7 @@ const std::vector& MvBufrSubsetData::doubleData(const std::string& key) //-- //-- ( NOTE: U N F I N I S H E D ! ! ! ) //____________________________________________________________________ OperaRadarImage -unsigned char* -MvObs::OperaRadarImage() -{ +unsigned char* MvObs::OperaRadarImage() { std::cout << " Method MvObs::OperaRadarImage() not implemented yet" << std::endl; exit(0); unsigned char* str = (unsigned char*)' '; @@ -2242,12 +2059,10 @@ MvObs::OperaRadarImage() //-- //-- ( NOTE: U N F I N I S H E D ! ! ! ) //____________________________________________________________________ OperaRadarMetadata -bool - MvObs::OperaRadarMetadata(/* arguments? */) -{ +bool MvObs::OperaRadarMetadata(/* arguments? */) { return false; } -#endif //METVIEW +#endif // METVIEW //============================================================================= @@ -2263,61 +2078,52 @@ bool // * Data Present group is used to define index into Confidence group //____________________________________________________________ MvBufrConfidence -MvBufrConfidence ::MvBufrConfidence(int aSubsetNr) -{ +MvBufrConfidence ::MvBufrConfidence(int aSubsetNr) { std::cout << " Method MvBufrConfidence::MvBufrConfidence() not implemented yet" << std::endl; - //e exit(0); + // e exit(0); } //___________________________________________________________ ~MvBufrConfidence -MvBufrConfidence ::~MvBufrConfidence() -{ -//e std::cout << " Method MvBufrConfidence::~MvBufrConfidence() not implemented yet" << std::endl; -//e exit(0); +MvBufrConfidence ::~MvBufrConfidence() { + // e std::cout << " Method MvBufrConfidence::~MvBufrConfidence() not implemented yet" << std::endl; + // e exit(0); } //______________________________________________________________ hasConfidences -bool MvBufrConfidence ::hasConfidences() -{ +bool MvBufrConfidence ::hasConfidences() { std::cout << " Method MvBufrConfidence::hasConfidences() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ confidence -int MvBufrConfidence ::confidence(long aDescr) -{ +int MvBufrConfidence ::confidence(long aDescr) { std::cout << " Method MvBufrConfidence::confidence() not implemented yet" << std::endl; exit(0); } //___________________________________________________________ confidenceByIndex -int MvBufrConfidence ::confidenceByIndex(int aDataInd) -{ +int MvBufrConfidence ::confidenceByIndex(int aDataInd) { std::cout << " Method MvBufrConfidence::confidenceByIndex() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ lastDataIndex -int MvBufrConfidence ::lastDataIndex() -{ +int MvBufrConfidence ::lastDataIndex() { std::cout << " Method MvBufrConfidence::lastDataIndex() not implemented yet" << std::endl; exit(0); } //__________________________________________________________ startOfDataPresent // Q&D hack !!! -int MvBufrConfidence ::startOfDataPresent() -{ +int MvBufrConfidence ::startOfDataPresent() { std::cout << " Method MvBufrConfidence::startOfDataPresent() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ startOfConfidences // Q&D hack !!! -int MvBufrConfidence ::startOfConfidences() -{ +int MvBufrConfidence ::startOfConfidences() { std::cout << " Method MvBufrConfidence::startOfConfidences() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ delta -int MvBufrConfidence ::delta(int anInd) -{ +int MvBufrConfidence ::delta(int anInd) { std::cout << " Method MvBufrConfidence::delta() not implemented yet" << std::endl; exit(0); } @@ -2326,8 +2132,7 @@ int MvBufrConfidence ::delta(int anInd) //======================================================================== MvBufrParam //________________________________________________________________________ -MvBufrParam ::MvBufrParam(const char* aParamName) -{ +MvBufrParam ::MvBufrParam(const char* aParamName) { std::cout << " Method MvBufrParam::MvBufrParam() not implemented yet" << std::endl; exit(0); @@ -2344,8 +2149,7 @@ MvBufrParam ::MvBufrParam(const char* aParamName) } //_____________________________________________________________ PrintAllKnownParameters -void MvBufrParam ::PrintAllKnownParameters() const -{ +void MvBufrParam ::PrintAllKnownParameters() const { std::cout << " Method MvBufrParam::PrintAllKnownParameters() not implemented yet" << std::endl; exit(0); diff --git a/src/eckit_readers/MvObs.h b/src/eckit_readers/MvObs.h index 9e16c862f..c92c2895b 100644 --- a/src/eckit_readers/MvObs.h +++ b/src/eckit_readers/MvObs.h @@ -17,4 +17,4 @@ #include "MvPrepBufrPrep.h" #endif -#endif // MvObs_DEFINED_ +#endif // MvObs_DEFINED_ diff --git a/src/eckit_readers/MvObsSet.cc b/src/eckit_readers/MvObsSet.cc index 48e310f3e..5b73e0ec0 100644 --- a/src/eckit_readers/MvObsSet.cc +++ b/src/eckit_readers/MvObsSet.cc @@ -25,16 +25,16 @@ #include "MvObsSet.h" -#include #include #include #include +#include #ifdef METVIEW_PREPBUFR #include "MvPrepBufrPrep.h" #endif -int MAX_MESSAGE_LENGTH = 32000; //e maybe delete in the future +int MAX_MESSAGE_LENGTH = 32000; // e maybe delete in the future const int cMSG_TYPE_BUFR_TABLES = 11; @@ -50,8 +50,7 @@ MvObsSet::MvObsSet(const char* aName) : _minTime(2247, 6, 20), _maxTime(1799, 12, 31), useSkipExtraAttributes_(true), - cacheCompressedData_(true) -{ + cacheCompressedData_(true) { _IO_mode = "r"; _init(aName); } @@ -63,8 +62,7 @@ MvObsSet::MvObsSet(const char* aName, const char* aMode) : _minTime(2247, 6, 20), _maxTime(1799, 12, 31), useSkipExtraAttributes_(true), - cacheCompressedData_(true) -{ + cacheCompressedData_(true) { _IO_mode = aMode; _init(aName); } @@ -72,11 +70,7 @@ MvObsSet::MvObsSet(const char* aName, const char* aMode) : //____________________________________________________________________ #ifdef METVIEW MvObsSet::MvObsSet(MvRequest& aRequest, const char* aMode) : - _unpacked(false), - _msgCount(0), - _minTime(2247, 6, 20), - _maxTime(1799, 12, 31) -{ + _unpacked(false), _msgCount(0), _minTime(2247, 6, 20), _maxTime(1799, 12, 31) { _IO_mode = aMode; const char* aName = 0; aRequest.getValue(aName, "PATH"); @@ -85,8 +79,7 @@ MvObsSet::MvObsSet(MvRequest& aRequest, const char* aMode) : #endif //____________________________________________________________________ -MvObsSet::~MvObsSet() -{ +MvObsSet::~MvObsSet() { close(); #ifdef METVIEW_PREPBUFR @@ -98,8 +91,7 @@ MvObsSet::~MvObsSet() } //____________________________________________________________________ -void MvObsSet::_init(const char* aName) -{ +void MvObsSet::_init(const char* aName) { _ecFile = 0; _obsCount = -1; _msgNumber = -1; @@ -118,7 +110,7 @@ void MvObsSet::_init(const char* aName) codes_count_in_file(NULL, _ecFile, &_msgCount); // number of messages // Check if output file is BUFR and if PREPBUFR support is available - if (_IO_mode == WRITE) //should be two classes!!!!!!! (but this a working one...) + if (_IO_mode == WRITE) // should be two classes!!!!!!! (but this a working one...) { _bufrOut = new MvBufrOut(this); } @@ -130,30 +122,28 @@ void MvObsSet::_init(const char* aName) } //____________________________________________________________________ setSubsetMax -void MvObsSet::setSubsetMax(int subsetMax) -{ -// I think ecCodes does not need this function (_maxNrSubsets). -// If this is the case delete it later. +void MvObsSet::setSubsetMax(int subsetMax) { + // I think ecCodes does not need this function (_maxNrSubsets). + // If this is the case delete it later. } //____________________________________________________________________ Open -bool MvObsSet::Open(const char* aFileName) -{ +bool MvObsSet::Open(const char* aFileName) { _msgCount = 0; _msgNumber = 0; // Open bufr file _ecFile = fopen(aFileName, _IO_mode.c_str()); if (!_ecFile) { - std::cerr << " >>> MvObsSet::Open - ERROR opening file \'" << aFileName << "\' - " << std::strerror(errno) << std::endl; + std::cerr << " >>> MvObsSet::Open - ERROR opening file \'" << aFileName << "\' - " << std::strerror(errno) + << std::endl; return false; } return true; } //____________________________________________________________________ close -bool MvObsSet::close() -{ +bool MvObsSet::close() { long myReturnValue = -1; if (_ecFile) { myReturnValue = fclose(_ecFile); @@ -172,8 +162,7 @@ bool MvObsSet::close() } //____________________________________________________________________ rewind -void MvObsSet::rewind() -{ +void MvObsSet::rewind() { _msgNumber = 0; if (_ecFile) { // Clean previous handler @@ -188,9 +177,8 @@ void MvObsSet::rewind() return; } -//msgCnt indexed from one!!!! -MvObs MvObsSet::gotoMessage(long offset, int msgCnt) -{ +// msgCnt indexed from one!!!! +MvObs MvObsSet::gotoMessage(long offset, int msgCnt) { if (!_ecFile) return MvObs(); // nothing if file not ok @@ -208,19 +196,20 @@ MvObs MvObsSet::gotoMessage(long offset, int msgCnt) fseek(_ecFile, offset, SEEK_SET); - int err = 0; + int err = 0; codes_handle* ch = codes_handle_new_from_file(NULL, _ecFile, PRODUCT_BUFR, &err); - _ecH = std::make_shared(ch); + _ecH = std::make_shared(ch); if (ch || err != CODES_SUCCESS) { if (!ch) { - std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber << std::endl; + std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber + << std::endl; _IO_buffer_OK = false; return MvObs(); } // Expand all the descriptors i.e. unpack the data values _unpacked = false; // it is a new message - //if ( unpack ) + // if ( unpack ) // this->expand(); _IO_buffer_OK = true; @@ -234,8 +223,7 @@ MvObs MvObsSet::gotoMessage(long offset, int msgCnt) // Reads next BUFR message and returns an MvObs constructed with it. // An MvObs without a message is returned at EOF. //------------------------------------------------ -MvObs MvObsSet::next(bool unpack) -{ +MvObs MvObsSet::next(bool unpack) { if (!_ecFile) return MvObs(); // nothing if file not ok @@ -252,12 +240,13 @@ MvObs MvObsSet::next(bool unpack) } // Get next message - int err = 0; - codes_handle *ch = codes_handle_new_from_file(NULL, _ecFile, PRODUCT_BUFR, &err); - _ecH = std::make_shared(ch); + int err = 0; + codes_handle* ch = codes_handle_new_from_file(NULL, _ecFile, PRODUCT_BUFR, &err); + _ecH = std::make_shared(ch); if (ch || err != CODES_SUCCESS) { if (!ch) { - std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber << std::endl; + std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber + << std::endl; _IO_buffer_OK = false; return MvObs(); } @@ -279,8 +268,7 @@ MvObs MvObsSet::next(bool unpack) //____________________________________________________________________ add -void MvObsSet::add(MvObs& anObs) -{ +void MvObsSet::add(MvObs& anObs) { if (_IO_mode != WRITE) return; // no add when reading ! @@ -289,8 +277,7 @@ void MvObsSet::add(MvObs& anObs) } //____________________________________________________________________ write -bool MvObsSet::write(const void* aMsg, const size_t aMsgLen) -{ +bool MvObsSet::write(const void* aMsg, const size_t aMsgLen) { if (_IO_mode != WRITE) return false; @@ -304,8 +291,7 @@ bool MvObsSet::write(const void* aMsg, const size_t aMsgLen) return true; } -bool MvObsSet::write(MvObs& anObs) -{ +bool MvObsSet::write(MvObs& anObs) { // Clone the input handle codes_handle* clone_handle = codes_handle_clone(anObs.getHandle()); if (clone_handle == NULL) { @@ -333,8 +319,7 @@ bool MvObsSet::write(MvObs& anObs) return err; } -bool MvObsSet::writeCompressed(MvObs* obs) -{ +bool MvObsSet::writeCompressed(MvObs* obs) { assert(obs); if (!obs->compressData()) @@ -372,8 +357,7 @@ bool MvObsSet::writeCompressed(MvObs* obs) return err; } -bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) -{ +bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) { assert(obs); if (!obs->compressData()) @@ -417,7 +401,7 @@ bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) // Release the clone's handle codes_handle_delete(cloneH); - delete [] subsetArr; + delete[] subsetArr; return err; } @@ -429,9 +413,8 @@ bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) // i.e. the nr of BUFR msgs found <= nr of observation msgs // i.e. messageCount() <= obsCount() //------------------------------------------------------------------ -int MvObsSet::messageCount() -{ -#if 0 //Fec +int MvObsSet::messageCount() { +#if 0 // Fec // old code removed. Counts message using eccodes only. if( _msgCount < 1 ) { @@ -455,8 +438,7 @@ printf("file bufrdc pos %ld\n",myOriginalFilePos); } //____________________________________________________________________ obsCount -int MvObsSet::obsCount() -{ +int MvObsSet::obsCount() { // The number of total messages has been already computed if (_obsCount >= 1) return _obsCount; @@ -492,8 +474,7 @@ int MvObsSet::obsCount() } //_________________________________________________________ searchMinMaxTime -void MvObsSet::searchMinMaxTime() -{ +void MvObsSet::searchMinMaxTime() { std::cout << "MvObsSet::searchMinMaxTime() -> not implemented yet" << std::endl; exit(0); @@ -505,8 +486,7 @@ void MvObsSet::searchMinMaxTime() } //_________________________________________________________ expand -void MvObsSet::expand() -{ +void MvObsSet::expand() { if (_unpacked) return; // nothing to be done, it is already expanded @@ -522,8 +502,7 @@ void MvObsSet::expand() #ifdef METVIEW_PREPBUFR //____________________________________________________________________ prepBufrFile -bool MvObsSet::prepBufrFile() -{ +bool MvObsSet::prepBufrFile() { if (_isPrepBufrFile) { cout << "in MvObsSet::prepBufrFile()" << endl; cout << "BUFR file contains BUFR tables, processing..." << endl; @@ -542,19 +521,19 @@ bool MvObsSet::prepBufrFile() //____________________________________________________________________ minDate #ifdef METVIEW -MvDate -MvObsSet ::minDate() -{ +MvDate MvObsSet ::minDate() { searchMinMaxTime(); - double timfloat = 10000.0L * (double)_minTime.GetYear() + 100.0L * (double)_minTime.GetMonth() + (double)_minTime.GetDay() + (double)_minTime.GetHour() / 24.0L + ((double)_minTime.GetMin() + 0.5L) / 60.0L / 24.0L; //rounded + double timfloat = 10000.0L * (double)_minTime.GetYear() + 100.0L * (double)_minTime.GetMonth() + + (double)_minTime.GetDay() + (double)_minTime.GetHour() / 24.0L + + ((double)_minTime.GetMin() + 0.5L) / 60.0L / 24.0L; // rounded return MvDate(timfloat); } //____________________________________________________________________ maxDate -MvDate -MvObsSet ::maxDate() -{ +MvDate MvObsSet ::maxDate() { searchMinMaxTime(); - double timfloat = 10000.0L * (double)_maxTime.GetYear() + 100.0L * (double)_maxTime.GetMonth() + (double)_maxTime.GetDay() + (double)_maxTime.GetHour() / 24.0L + ((double)_maxTime.GetMin() + 0.5L) / 60.0L / 24.0L; //rounded + double timfloat = 10000.0L * (double)_maxTime.GetYear() + 100.0L * (double)_maxTime.GetMonth() + + (double)_maxTime.GetDay() + (double)_maxTime.GetHour() / 24.0L + + ((double)_maxTime.GetMin() + 0.5L) / 60.0L / 24.0L; // rounded return MvDate(timfloat); } #endif @@ -573,17 +552,12 @@ MvObsSetIterator::MvObsSetIterator(MvObsSet& s) : _SelectState(SF_notSet), ObsSet(&s), observer_(0), - filterProgressStep_(20) -{ -} + filterProgressStep_(20) {} //___________________________________________________________________ -MvObsSetIterator::~MvObsSetIterator() -{ -} +MvObsSetIterator::~MvObsSetIterator() {} -bool MvObsSetIterator::checkOptionSize(std::size_t num, const std::string& functionName) -{ +bool MvObsSetIterator::checkOptionSize(std::size_t num, const std::string& functionName) { if (num >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::" + functionName + " array overflow!!!" << std::endl; return false; @@ -591,13 +565,11 @@ bool MvObsSetIterator::checkOptionSize(std::size_t num, const std::string& funct return true; } -int MvObsSetIterator::currentMessageNumber() const -{ +int MvObsSetIterator::currentMessageNumber() const { return (ObsSet ? (static_cast(ObsSet->_msgNumber)) : -1); } -MvObs MvObsSetIterator::operator()(ENextReturn returnType) -{ +MvObs MvObsSetIterator::operator()(ENextReturn returnType) { if (!current || (returnType == NR_returnMsg) || !current.Advance()) { if (observer_) { observer_->notifyObsIteratorProgress(currentMessageNumber()); @@ -607,7 +579,7 @@ MvObs MvObsSetIterator::operator()(ENextReturn returnType) while (current && !AcceptedObs(current)) { if (!current || (returnType == NR_returnMsg) || !current.Advance()) { - //Notify the observer about the progress + // Notify the observer about the progress if (observer_) { observer_->notifyObsIteratorProgress(currentMessageNumber()); } @@ -618,8 +590,7 @@ MvObs MvObsSetIterator::operator()(ENextReturn returnType) return current; } -void MvObsSetIterator::setFilterProgressStep(int filterProgressStep) -{ +void MvObsSetIterator::setFilterProgressStep(int filterProgressStep) { filterProgressStep_ = filterProgressStep; assert(filterProgressStep_ >= 0); if (filterProgressStep_ == 0) @@ -627,34 +598,29 @@ void MvObsSetIterator::setFilterProgressStep(int filterProgressStep) } -MvObs MvObsSetIterator::gotoMessage(long offset, int msgCnt) -{ +MvObs MvObsSetIterator::gotoMessage(long offset, int msgCnt) { return ObsSet->gotoMessage(offset, msgCnt); } -MvObs MvObsSetIterator::nextMessage() -{ +MvObs MvObsSetIterator::nextMessage() { return ObsSet->next(false); } -void MvObsSetIterator::next() -{ +void MvObsSetIterator::next() { current = ObsSet->next(false); #ifdef METVIEW // static int change_me_with_debugger = 0; -//e if( mars.debug && ( ( ObsSet->messageNumber() == 1 ) || change_me_with_debugger ) ) -//e current.printAllValues(); +// e if( mars.debug && ( ( ObsSet->messageNumber() == 1 ) || change_me_with_debugger ) ) +// e current.printAllValues(); #endif } -void MvObsSetIterator::setTime(const TDynamicTime& anObsTime) -{ +void MvObsSetIterator::setTime(const TDynamicTime& anObsTime) { setTimeRange(anObsTime, anObsTime); } -void MvObsSetIterator::setTimeRange(const TDynamicTime& anObsTime, short deltaInMinutes) -{ +void MvObsSetIterator::setTimeRange(const TDynamicTime& anObsTime, short deltaInMinutes) { fBeginTime = fEndTime = anObsTime; fBeginTime.ChangeByMinutes(-deltaInMinutes); fEndTime.ChangeByMinutes(deltaInMinutes); @@ -662,8 +628,7 @@ void MvObsSetIterator::setTimeRange(const TDynamicTime& anObsTime, short deltaIn _NoFiltersSet = false; } -void MvObsSetIterator::setTimeRange(const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime) -{ +void MvObsSetIterator::setTimeRange(const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime) { fBeginTime = aBeginTime; fEndTime = anEndTime; _TimeFilterState = kTFS_bothSet; @@ -676,8 +641,7 @@ void MvObsSetIterator::setTimeRange(const TDynamicTime& aBeginTime, const TDynam // parameters: in format HHMM, i.e. 1200 == 12.00, 15 == 0.15, i.e. 100*hour+min!!! // values are normalized into range [0000..2400) //_________________________________________ -void MvObsSetIterator::setTimeRangeWithoutDate(int aBegin, int anEnd) -{ +void MvObsSetIterator::setTimeRangeWithoutDate(int aBegin, int anEnd) { TDynamicTime aTime; // date part is not used, so let's use today.. int myBegin = aBegin; int myEnd = anEnd; @@ -696,8 +660,7 @@ void MvObsSetIterator::setTimeRangeWithoutDate(int aBegin, int anEnd) _NoFiltersSet = false; } -void MvObsSetIterator::setTimeRangeInSecWithoutDate(int aBegin, int anEnd) -{ +void MvObsSetIterator::setTimeRangeInSecWithoutDate(int aBegin, int anEnd) { TDynamicTime aTime; // date part is not used, so let's use today.. int myBegin = aBegin; int myEnd = anEnd; @@ -724,8 +687,7 @@ void MvObsSetIterator::setTimeRangeInSecWithoutDate(int aBegin, int anEnd) //____________________________________________________________________ -void MvObsSetIterator::setWmoBlock(int blockNumber) -{ +void MvObsSetIterator::setWmoBlock(int blockNumber) { if (!checkOptionSize(wmoBlock_.size(), "setWmoBlock")) return; @@ -733,8 +695,7 @@ void MvObsSetIterator::setWmoBlock(int blockNumber) _NoFiltersSet = false; } -void MvObsSetIterator::setWmoStation(long wmoStation) -{ +void MvObsSetIterator::setWmoStation(long wmoStation) { if (!checkOptionSize(wmoStation_.size(), "setWmoStation")) return; @@ -742,8 +703,7 @@ void MvObsSetIterator::setWmoStation(long wmoStation) _NoFiltersSet = false; } -void MvObsSetIterator::select(const std::string& aDescriptor, double aValue) -{ +void MvObsSetIterator::select(const std::string& aDescriptor, double aValue) { if (_SelectValueCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::select: array overflow!!!" << std::endl; return; @@ -759,8 +719,7 @@ void MvObsSetIterator::select(const std::string& aDescriptor, double aValue) _NoFiltersSet = false; } -void MvObsSetIterator::selectRange(const std::string& aDescriptor, double firstValue, double secondValue) -{ +void MvObsSetIterator::selectRange(const std::string& aDescriptor, double firstValue, double secondValue) { _SelectDescriptor = aDescriptor; _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; @@ -769,8 +728,7 @@ void MvObsSetIterator::selectRange(const std::string& aDescriptor, double firstV _NoFiltersSet = false; } -void MvObsSetIterator::excludeRange(const std::string& aDescriptor, double firstValue, double secondValue) -{ +void MvObsSetIterator::excludeRange(const std::string& aDescriptor, double firstValue, double secondValue) { _SelectDescriptor = aDescriptor; _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; @@ -779,21 +737,19 @@ void MvObsSetIterator::excludeRange(const std::string& aDescriptor, double first _NoFiltersSet = false; } -void MvObsSetIterator::setXSectionLine(const MvLocation& aStartPoint, const MvLocation& anEndPoint, float aDeltaInMeters) -{ +void MvObsSetIterator::setXSectionLine(const MvLocation& aStartPoint, const MvLocation& anEndPoint, + float aDeltaInMeters) { fXSectionLine.setLine(aStartPoint, anEndPoint); fXSectionLine.setMaxDelta(aDeltaInMeters); _NoFiltersSet = false; } -void MvObsSetIterator::setArea(const MvLocation& aCorner1, const MvLocation& aCorner2) -{ +void MvObsSetIterator::setArea(const MvLocation& aCorner1, const MvLocation& aCorner2) { fArea.set(aCorner1, aCorner2); _NoFiltersSet = false; } -void MvObsSetIterator::setMessageType(int aMsgType) -{ +void MvObsSetIterator::setMessageType(int aMsgType) { if (_MsgTypeCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::setMessageType: array overflow!!!" << std::endl; return; @@ -802,8 +758,7 @@ void MvObsSetIterator::setMessageType(int aMsgType) _NoFiltersSet = false; } -void MvObsSetIterator::setMessageSubtype(int aMsgSubtype) -{ +void MvObsSetIterator::setMessageSubtype(int aMsgSubtype) { if (_MsgSubtypeCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::setMessageSubtype: array overflow!!!" << std::endl; return; @@ -812,8 +767,7 @@ void MvObsSetIterator::setMessageSubtype(int aMsgSubtype) _NoFiltersSet = false; } -void MvObsSetIterator::setMessageNumber(int num) -{ +void MvObsSetIterator::setMessageNumber(int num) { if (!checkOptionSize(messageNumber_.size(), "setMessageNumber")) return; @@ -821,8 +775,7 @@ void MvObsSetIterator::setMessageNumber(int num) _NoFiltersSet = false; } -void MvObsSetIterator::setEditionNumber(int edition) -{ +void MvObsSetIterator::setEditionNumber(int edition) { if (!checkOptionSize(editionNumber_.size(), "setEditionNumber")) return; @@ -830,8 +783,7 @@ void MvObsSetIterator::setEditionNumber(int edition) _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingCentre(int centre) -{ +void MvObsSetIterator::setOriginatingCentre(int centre) { if (!checkOptionSize(originatingCentre_.size(), "setOriginatingCentre")) return; @@ -839,8 +791,7 @@ void MvObsSetIterator::setOriginatingCentre(int centre) _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingCentreAsStr(const std::string& centre) -{ +void MvObsSetIterator::setOriginatingCentreAsStr(const std::string& centre) { if (!checkOptionSize(originatingCentreStr_.size(), "setOriginatingCentreAsStr")) return; @@ -848,8 +799,7 @@ void MvObsSetIterator::setOriginatingCentreAsStr(const std::string& centre) _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingSubCentre(int subCentre) -{ +void MvObsSetIterator::setOriginatingSubCentre(int subCentre) { if (!checkOptionSize(originatingSubCentre_.size(), "setOriginatingSubCentre")) return; @@ -857,8 +807,7 @@ void MvObsSetIterator::setOriginatingSubCentre(int subCentre) _NoFiltersSet = false; } -void MvObsSetIterator::setMasterTableVersion(int masterTable) -{ +void MvObsSetIterator::setMasterTableVersion(int masterTable) { if (!checkOptionSize(masterTableVersion_.size(), "setMasterTableVersion")) return; @@ -866,8 +815,7 @@ void MvObsSetIterator::setMasterTableVersion(int masterTable) _NoFiltersSet = false; } -void MvObsSetIterator::setLocalTableVersion(int localTable) -{ +void MvObsSetIterator::setLocalTableVersion(int localTable) { if (!checkOptionSize(localTableVersion_.size(), "setLocalTableVersion")) return; @@ -875,8 +823,7 @@ void MvObsSetIterator::setLocalTableVersion(int localTable) _NoFiltersSet = false; } -void MvObsSetIterator::setHeaderIdent(const std::string& headerIdent) -{ +void MvObsSetIterator::setHeaderIdent(const std::string& headerIdent) { if (!checkOptionSize(headerIdent_.size(), "setHeaderIdent")) return; @@ -884,14 +831,12 @@ void MvObsSetIterator::setHeaderIdent(const std::string& headerIdent) _NoFiltersSet = false; } -void MvObsSetIterator::setIdentKey(const std::string& identKey) -{ +void MvObsSetIterator::setIdentKey(const std::string& identKey) { identKey_ = simplified(identKey); _NoFiltersSet = false; } -void MvObsSetIterator::setIdentValue(const std::string& identVal) -{ +void MvObsSetIterator::setIdentValue(const std::string& identVal) { if (!checkOptionSize(identValue_.size(), "setIdentValue")) return; @@ -899,8 +844,7 @@ void MvObsSetIterator::setIdentValue(const std::string& identVal) _NoFiltersSet = false; } -void MvObsSetIterator::setMessageRdbtype(int rdbType) -{ +void MvObsSetIterator::setMessageRdbtype(int rdbType) { if (!checkOptionSize(rdbType_.size(), "setMessageRdbtype")) return; @@ -909,8 +853,7 @@ void MvObsSetIterator::setMessageRdbtype(int rdbType) } //____________________________________________________________________ -float MvObsSetIterator::distanceFromXSectionLine(const MvLocation& aPoint) -{ +float MvObsSetIterator::distanceFromXSectionLine(const MvLocation& aPoint) { if (fXSectionLine.startPoint().latitude() == MISSING_LOC_VALUE) return MISSING_LOC_VALUE; @@ -918,8 +861,7 @@ float MvObsSetIterator::distanceFromXSectionLine(const MvLocation& aPoint) } //____________________________________________________________________ -bool MvObsSetIterator::TimeOk(MvObs* anObs) const -{ +bool MvObsSetIterator::TimeOk(MvObs* anObs) const { switch (_TimeFilterState) { case kTFS_notSet: break; @@ -927,7 +869,7 @@ bool MvObsSetIterator::TimeOk(MvObs* anObs) const case kTFS_clockSet: { long obsTime; if (useObsTime_) { - //We need time from the data section so we need to expand the message + // We need time from the data section so we need to expand the message anObs->expand(); obsTime = anObs->obsTime().ClockInSeconds(); //-- need to decode => slow } @@ -952,7 +894,7 @@ bool MvObsSetIterator::TimeOk(MvObs* anObs) const case kTFS_bothSet: { TDynamicTime myTime; if (useObsTime_) { - //We need time from the data section so we need to expand the message + // We need time from the data section so we need to expand the message anObs->expand(); myTime = anObs->obsTime(); //-- time from obs => decode first => slow } @@ -969,10 +911,9 @@ bool MvObsSetIterator::TimeOk(MvObs* anObs) const } //____________________________________________________________________ -bool MvObsSetIterator::WmoBlockOk(MvObs* anObs) const -{ +bool MvObsSetIterator::WmoBlockOk(MvObs* anObs) const { if (!wmoBlock_.empty()) { - //we need to expand the message + // we need to expand the message anObs->expand(); for (std::size_t i = 0; i < wmoBlock_.size(); i++) { if (anObs->WmoBlockNumber() == wmoBlock_[i]) @@ -983,10 +924,9 @@ bool MvObsSetIterator::WmoBlockOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::WmoStationOk(MvObs* anObs) const -{ +bool MvObsSetIterator::WmoStationOk(MvObs* anObs) const { if (!wmoStation_.empty()) { - //we need to expand the message + // we need to expand the message anObs->expand(); for (std::size_t i = 0; i < wmoStation_.size(); i++) { if (anObs->WmoIdentNumber() == wmoStation_[i]) @@ -998,12 +938,11 @@ bool MvObsSetIterator::WmoStationOk(MvObs* anObs) const } //____________________________________________________________________ -bool MvObsSetIterator::WithinXSectionLine(MvObs* anObs) const -{ +bool MvObsSetIterator::WithinXSectionLine(MvObs* anObs) const { if (fXSectionLine.maxDelta() < 0) // not set ? return true; - //We need lat/lon from the data section so we need to expand the message + // We need lat/lon from the data section so we need to expand the message anObs->expand(); if (fXSectionLine.withinDelta(anObs->location())) @@ -1013,20 +952,18 @@ bool MvObsSetIterator::WithinXSectionLine(MvObs* anObs) const } //____________________________________________________________________ -bool MvObsSetIterator::InsideArea(MvObs* anObs) const -{ +bool MvObsSetIterator::InsideArea(MvObs* anObs) const { if (fArea.lowerLeft().latitude() == MISSING_LOC_VALUE) return true; else { - //We need lat/lon from the data section so we need to expand the message + // We need lat/lon from the data section so we need to expand the message anObs->expand(); return fArea.inside(anObs->location()); } } //____________________________________________________________________ -bool MvObsSetIterator::msgTypeOk(MvObs* anObs) const -{ +bool MvObsSetIterator::msgTypeOk(MvObs* anObs) const { if (_MsgTypeCount < 1) return true; @@ -1037,8 +974,7 @@ bool MvObsSetIterator::msgTypeOk(MvObs* anObs) const return false; } -bool MvObsSetIterator::msgSubtypeOk(MvObs* anObs) const -{ +bool MvObsSetIterator::msgSubtypeOk(MvObs* anObs) const { if (_MsgSubtypeCount < 1) return true; @@ -1049,8 +985,7 @@ bool MvObsSetIterator::msgSubtypeOk(MvObs* anObs) const return false; } -bool MvObsSetIterator::messageNumberOk(MvObs* anObs) const -{ +bool MvObsSetIterator::messageNumberOk(MvObs* anObs) const { if (!messageNumber_.empty()) { for (std::size_t i = 0; i < messageNumber_.size(); i++) { if (currentMessageNumber() == messageNumber_[i]) @@ -1061,8 +996,7 @@ bool MvObsSetIterator::messageNumberOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::editionNumberOk(MvObs* anObs) const -{ +bool MvObsSetIterator::editionNumberOk(MvObs* anObs) const { if (!editionNumber_.empty()) { for (std::size_t i = 0; i < editionNumber_.size(); i++) { if (anObs->editionNumber() == editionNumber_[i]) @@ -1073,8 +1007,7 @@ bool MvObsSetIterator::editionNumberOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::originatingCentreOk(MvObs* anObs) const -{ +bool MvObsSetIterator::originatingCentreOk(MvObs* anObs) const { if (!originatingCentre_.empty()) { for (std::size_t i = 0; i < originatingCentre_.size(); i++) { if (anObs->originatingCentre() == originatingCentre_[i]) @@ -1085,8 +1018,7 @@ bool MvObsSetIterator::originatingCentreOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::originatingCentreAsStrOk(MvObs* anObs) const -{ +bool MvObsSetIterator::originatingCentreAsStrOk(MvObs* anObs) const { if (!originatingCentreStr_.empty()) { for (std::size_t i = 0; i < originatingCentreStr_.size(); i++) { if (anObs->originatingCentreAsStr() == originatingCentreStr_[i]) @@ -1097,8 +1029,7 @@ bool MvObsSetIterator::originatingCentreAsStrOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::originatingSubCentreOk(MvObs* anObs) const -{ +bool MvObsSetIterator::originatingSubCentreOk(MvObs* anObs) const { if (!originatingSubCentre_.empty()) { for (std::size_t i = 0; i < originatingSubCentre_.size(); i++) { if (anObs->originatingSubCentre() == originatingSubCentre_[i]) @@ -1109,8 +1040,7 @@ bool MvObsSetIterator::originatingSubCentreOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::masterTableVersionOk(MvObs* anObs) const -{ +bool MvObsSetIterator::masterTableVersionOk(MvObs* anObs) const { if (!masterTableVersion_.empty()) { for (std::size_t i = 0; i < masterTableVersion_.size(); i++) { if (anObs->masterTableVersion() == masterTableVersion_[i]) @@ -1121,8 +1051,7 @@ bool MvObsSetIterator::masterTableVersionOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::localTableVersionOk(MvObs* anObs) const -{ +bool MvObsSetIterator::localTableVersionOk(MvObs* anObs) const { if (!localTableVersion_.empty()) { for (std::size_t i = 0; i < localTableVersion_.size(); i++) { if (anObs->localTableVersion() == localTableVersion_[i]) @@ -1133,8 +1062,7 @@ bool MvObsSetIterator::localTableVersionOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::headerIdentOk(MvObs* anObs) const -{ +bool MvObsSetIterator::headerIdentOk(MvObs* anObs) const { if (!headerIdent_.empty()) { for (std::size_t i = 0; i < headerIdent_.size(); i++) { if (simplified(anObs->headerIdent()) == headerIdent_[i]) @@ -1145,10 +1073,9 @@ bool MvObsSetIterator::headerIdentOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::identValueOk(MvObs* anObs) const -{ +bool MvObsSetIterator::identValueOk(MvObs* anObs) const { if (!identValue_.empty()) { - //We need this key from the data section so we need to expand the message + // We need this key from the data section so we need to expand the message anObs->expand(); for (std::size_t i = 0; i < identValue_.size(); i++) { if (anObs->stringValue(identKey_, 1) == identValue_[i]) @@ -1159,8 +1086,7 @@ bool MvObsSetIterator::identValueOk(MvObs* anObs) const return true; } -bool MvObsSetIterator::msgRdbtypeOk(MvObs* anObs) const -{ +bool MvObsSetIterator::msgRdbtypeOk(MvObs* anObs) const { if (!rdbType_.empty()) { for (std::size_t i = 0; i < rdbType_.size(); i++) { if (anObs->messageRdbtype() == rdbType_[i]) @@ -1172,12 +1098,11 @@ bool MvObsSetIterator::msgRdbtypeOk(MvObs* anObs) const } //____________________________________________________________________ -bool MvObsSetIterator::selectOk(MvObs* anObs) const -{ +bool MvObsSetIterator::selectOk(MvObs* anObs) const { if (_SelectState == SF_notSet) return true; - //We can assume that this key is from the data section so we need to expand the message + // We can assume that this key is from the data section so we need to expand the message anObs->expand(); double myValue = anObs->valueC(_SelectDescriptor); @@ -1210,25 +1135,24 @@ bool MvObsSetIterator::selectOk(MvObs* anObs) const } //____________________________________________________________________ -bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const -{ +bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const { if (!anObs) return false; if (_NoFiltersSet) return true; - //Prefilter conditions are fully based on the BUFR header + // Prefilter conditions are fully based on the BUFR header if (!skipPreFilterCond) { - //Index of the message within the bufr file + // Index of the message within the bufr file if (!messageNumberOk(&anObs)) return false; - //BUFR edition + // BUFR edition if (!editionNumberOk(&anObs)) return false; - //Edition parameters + // Edition parameters if (!originatingCentreOk(&anObs)) return false; @@ -1244,7 +1168,7 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const if (!localTableVersionOk(&anObs)) return false; - //Type parameters - fully based on the BUFR header + // Type parameters - fully based on the BUFR header if (!msgTypeOk(&anObs)) return false; @@ -1259,7 +1183,7 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const if (!headerIdentOk(&anObs)) return false; - //User defined identifier from the data section + // User defined identifier from the data section if (!identValueOk(&anObs)) return false; @@ -1284,8 +1208,7 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const } -bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool &headerDidNotMatch) const -{ +bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool& headerDidNotMatch) const { headerDidNotMatch = false; if (!anObs) @@ -1294,21 +1217,21 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool &h if (_NoFiltersSet) return true; - //Prefilter conditions are fully based on the BUFR header + // Prefilter conditions are fully based on the BUFR header if (!skipPreFilterCond) { - //Index of the message within the bufr file + // Index of the message within the bufr file if (!messageNumberOk(&anObs)) { headerDidNotMatch = true; return false; } - //BUFR edition + // BUFR edition if (!editionNumberOk(&anObs)) { headerDidNotMatch = true; return false; } - //Edition parameters + // Edition parameters if (!originatingCentreOk(&anObs)) { headerDidNotMatch = true; return false; @@ -1334,7 +1257,7 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool &h return false; } - //Type parameters - fully based on the BUFR header + // Type parameters - fully based on the BUFR header if (!msgTypeOk(&anObs)) { headerDidNotMatch = true; return false; @@ -1357,7 +1280,7 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool &h return false; } - //User defined identifier from the data section + // User defined identifier from the data section if (!identValueOk(&anObs)) return false; @@ -1385,10 +1308,8 @@ bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool &h } - //_____________________________________________________________ operator<< -std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& aFilter) -{ +std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& aFilter) { int i; aStream << "Observation Filter values set:\n"; @@ -1495,8 +1416,7 @@ std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& aFilter) } //________________________________________________________ simplified -std::string simplified(const std::string& str) -{ +std::string simplified(const std::string& str) { std::size_t pos1 = str.find_first_not_of(" "); std::size_t pos2 = str.find_last_not_of(" "); diff --git a/src/eckit_readers/MvObsSet.h b/src/eckit_readers/MvObsSet.h index 0872face9..9fdaec477 100644 --- a/src/eckit_readers/MvObsSet.h +++ b/src/eckit_readers/MvObsSet.h @@ -11,7 +11,7 @@ #define MvObsSet_DEFINED //-- temporarily for testing only; should be done via 'configure' -//e #define METVIEW_PREPBUFR +// e #define METVIEW_PREPBUFR #include #include "MvBufrObs.h" @@ -19,7 +19,7 @@ #include #include -//namespace mvObs { +// namespace mvObs { std::string simplified(const std::string&); //} @@ -30,8 +30,7 @@ class MvPrepBufrPrep; /*! This class is used to handle a file containing several * observation reports stored as BUFR messages. */ -class MvObsSet -{ +class MvObsSet { friend class MvObsSetIterator; friend class MvBufrOut; @@ -46,8 +45,8 @@ class MvObsSet //! Constructor with a BUFR file name and access mode as arguments /*! This constructor can be used for writing to a file, use - * access mode "w" or "a". - */ + * access mode "w" or "a". + */ MvObsSet(const char*, const char*); #ifdef METVIEW @@ -64,7 +63,7 @@ class MvObsSet //! Destructor ~MvObsSet(); - //I think ecCodes does not need this function (_maxNrSubsets). + // I think ecCodes does not need this function (_maxNrSubsets). // If this is the case delete it later. //! Set max subset count for a new file void setSubsetMax(int); @@ -78,14 +77,14 @@ class MvObsSet //! Returns the number of BUFR messages in the input file /*! This number is smaller than returned by method obsCount() - * if the input file contains multisubset BUFR messages. - */ + * if the input file contains multisubset BUFR messages. + */ int messageCount(); // nr of BUFR-messages in a file //! Returns the number of observation reports in the input file /*! This number is bigger than returned by method messageCount() - * if the input file contains multisubset BUFR messages. - */ + * if the input file contains multisubset BUFR messages. + */ int obsCount(); // nr of observation messages in a BUFR-file //! Returns the (running) number of the current BUFR message @@ -103,10 +102,7 @@ class MvObsSet bool writeCompressed(MvObs* obs, const std::vector& subsetVec); bool write(const void*, const size_t); - MvObs& firstObs() - { - return _firstObs; - } + MvObs& firstObs() { return _firstObs; } // Expand message void expand(); @@ -121,7 +117,7 @@ class MvObsSet bool Open(const char*); //, char* aMode = "r" ); void searchMinMaxTime(); - //Logical currentInputBufferOK() {return _IO_buffer_OK;} + // Logical currentInputBufferOK() {return _IO_buffer_OK;} protected: FILE* _ecFile; @@ -146,8 +142,8 @@ class MvObsSet MvBufrOut* _bufrOut; - bool useSkipExtraAttributes_; //enables optimisation option for eccodes - bool cacheCompressedData_; //flag for MvObs + bool useSkipExtraAttributes_; // enables optimisation option for eccodes + bool cacheCompressedData_; // flag for MvObs }; //------------------------------------------------------------------------------ @@ -188,8 +184,7 @@ enum ETimeFilterState }; -class MvObsSetIteratorObserver -{ +class MvObsSetIteratorObserver { public: MvObsSetIteratorObserver() {} virtual void notifyObsIteratorProgress(int) = 0; @@ -204,8 +199,7 @@ class MvObsSetIteratorObserver * filtering criteria are set the resulting filter will use * logical AND to combine different criteria. */ -class MvObsSetIterator -{ +class MvObsSetIterator { //! Writes the current filtering options of 'anIter' into stream 'aStream' friend std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& anIter); @@ -218,13 +212,13 @@ class MvObsSetIterator //! Operator that returns the next available valid observation report /*! Subset structure is hidden from the calling application. - */ + */ MvObs operator()() { return operator()(NR_returnObs); } //! Operator that returns the next valid observation report /*! Using mnemonic argument 'NR_returnMsg' accesses only first - * subsets in multisubset BUFR messages. See enum ENextReturn. - */ + * subsets in multisubset BUFR messages. See enum ENextReturn. + */ MvObs operator()(ENextReturn returnType); //! Returns the sequence number of the current BUFR message @@ -235,14 +229,14 @@ class MvObsSetIterator //! Defines where the date/time for filtering should be taken from /*! Date and time information is always available as metadata in - * BUFR section 1, and normally also in the data (observation report) - * itself. In single subset messages these times should be the same, - * but for some multisubset messages observation reports may come from - * different times. \n \n - * The default is to use date/time from the metadata in section 1 (faster), - * but by calling this method it is possible to change to use date/time - * from the data. - */ + * BUFR section 1, and normally also in the data (observation report) + * itself. In single subset messages these times should be the same, + * but for some multisubset messages observation reports may come from + * different times. \n \n + * The default is to use date/time from the metadata in section 1 (faster), + * but by calling this method it is possible to change to use date/time + * from the data. + */ void useObsTime(bool b = true) { useObsTime_ = b; } //! Set the filtering criteria for a single date/time @@ -250,9 +244,9 @@ class MvObsSetIterator //! Set the filtering criteria for a date/time range /*! Observation reports that have their data/time within the range - * 'anObsTime'-'deltaInMinutes' and 'anObsTime'+'deltaInMinutes' - * will be selected. - */ + * 'anObsTime'-'deltaInMinutes' and 'anObsTime'+'deltaInMinutes' + * will be selected. + */ void setTimeRange(const TDynamicTime&, short); //! Set the filtering criteria for a date/time range @@ -260,30 +254,30 @@ class MvObsSetIterator //! Set the filtering criteria for time range only (date ignored) /*! Observation reports that have their time stamp between 'aBeginTime' - * and 'anEndTime' will be selected. \n \n - * Time format is HHMM, i.e. 100*hours+minutes. Thus the value 1500 - * signifies 3PM, and the value 15 signifies 15 mins past midnight. - */ + * and 'anEndTime' will be selected. \n \n + * Time format is HHMM, i.e. 100*hours+minutes. Thus the value 1500 + * signifies 3PM, and the value 15 signifies 15 mins past midnight. + */ void setTimeRangeWithoutDate(int, int); void setTimeRangeInSecWithoutDate(int, int); //! Set the filtering criteria for accepted WMO block numbers /*! This method can be called several times in order to set - * more than one accepted WMO block, i.e. WMO blocks are - * combined with logical OR operator. - */ + * more than one accepted WMO block, i.e. WMO blocks are + * combined with logical OR operator. + */ void setWmoBlock(int); //! Set the filtering criteria for accepted WMO station numbers /*! This method can be called several times in order to set - * more than one accepted WMO station, i.e. WMO stations are - * combined with logical OR operator. - */ + * more than one accepted WMO station, i.e. WMO stations are + * combined with logical OR operator. + */ void setWmoStation(long); //! Set the filtering criteria for an accepted area /*! Observation report locations must be within the given area. - */ + */ void setArea(const MvLocation&, const MvLocation&); //! Set filtering criteria for a proximity of a cross section line @@ -291,16 +285,16 @@ class MvObsSetIterator //! Set the filtering criteria for accepted BUFR message types /*! This method can be called several times in order to set - * more than one accepted BUFR message type, i.e. message types are - * combined with logical OR operator. - */ + * more than one accepted BUFR message type, i.e. message types are + * combined with logical OR operator. + */ void setMessageType(int); //! Set the filtering criteria for accepted BUFR message local subtypes /*! This method can be called several times in order to set - * more than one accepted BUFR message local subtype, i.e. message subtypes - * are combined with logical OR operator. - */ + * more than one accepted BUFR message local subtype, i.e. message subtypes + * are combined with logical OR operator. + */ void setMessageSubtype(int); void setMessageRdbtype(int); @@ -318,23 +312,23 @@ class MvObsSetIterator //! Set the filtering criteria for data 'aDescriptor' having value 'aValue' /*! Observation reports where the data corresponding to descriptor 'aDescriptor' - * has value 'aValue' will be selected.\n \n - * This method can be called several times in order to set more than one - * accepted value for the same 'aDescriptor', i.e. values are - * combined with logical OR operator. - */ + * has value 'aValue' will be selected.\n \n + * This method can be called several times in order to set more than one + * accepted value for the same 'aDescriptor', i.e. values are + * combined with logical OR operator. + */ void select(const std::string&, double); //! Set the filtering criteria for the given data having its value within a range /*! Observation reports where the data corresponding to descriptor 'aDescriptor' - * has its value in the range 'firstValue'...'secondValue' will be selected. - */ + * has its value in the range 'firstValue'...'secondValue' will be selected. + */ void selectRange(const std::string&, double, double); //! Set the filtering criteria for the given data having its value outside a range /*! Observation reports where the data corresponding to descriptor 'aDescriptor' - * has its value outside the range 'firstValue'...'secondValue' will be selected. - */ + * has its value outside the range 'firstValue'...'secondValue' will be selected. + */ void excludeRange(const std::string&, double, double); MvObs nextMessage(); @@ -344,7 +338,7 @@ class MvObsSetIterator MvObs gotoMessage(long offset, int msgCnt); - //Set the observer + // Set the observer void setObserver(MvObsSetIteratorObserver* observer) { observer_ = observer; } void removeObserver() { observer_ = 0; } void setFilterProgressStep(int filterProgressStep); @@ -383,7 +377,7 @@ class MvObsSetIterator int _MsgSubtype[MAX_FILTER_LIST_ARRAY_SIZE]; double _SelectValue[MAX_FILTER_LIST_ARRAY_SIZE]; std::string _SelectDescriptor; - std::vector messageNumber_; //starts at 1 + std::vector messageNumber_; // starts at 1 std::vector editionNumber_; std::vector originatingCentre_; std::vector originatingCentreStr_; diff --git a/src/visualisers/Filter.cc b/src/visualisers/Filter.cc index dfab9d3d9..5e73a3d34 100644 --- a/src/visualisers/Filter.cc +++ b/src/visualisers/Filter.cc @@ -145,7 +145,7 @@ bool MinMaxFilter::Process() { // Initialize input buffer if (this->InitBuffer() == false) { - //FMagLog::debug() << " InitBuffer Error" << "\n"; + // FMagLog::debug() << " InitBuffer Error" << "\n"; return false; } @@ -176,7 +176,7 @@ bool MinMaxFilter::Process() { if (found) // minimum found { - //FMagLog::debug() << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; + // FMagLog::debug() << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; lo = lo + 1; push_back(UserPoint(this->matrix_.column(lin + fcr, col + fcc), this->matrix_.row(lin + fcr, col + fcc), val)); @@ -204,7 +204,7 @@ bool MinMaxFilter::Process() { if (found) // minimum found { - //FMagLog::debug() << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; + // FMagLog::debug() << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n"; hi = hi + 1; push_back(UserPoint(this->matrix_.column(lin + fcr, col + fcc), this->matrix_.row(lin + fcr, col + fcc), val)); @@ -218,8 +218,8 @@ bool MinMaxFilter::Process() { break; } - //FMagLog::debug() << "TOTAL POINTS LOW = " << lo << "\n" - //F << "TOTAL POINTS HI = " << hi << "\n"; + // FMagLog::debug() << "TOTAL POINTS LOW = " << lo << "\n" + // F << "TOTAL POINTS HI = " << hi << "\n"; return true; } @@ -241,7 +241,7 @@ void MinMaxFilter::test_build_data() { // Initialize input buffer if (this->InitBuffer() == false) { - //FMagLog::debug() << " InitBuffer Error" << "\n"; + // FMagLog::debug() << " InitBuffer Error" << "\n"; return; } @@ -250,11 +250,11 @@ void MinMaxFilter::test_build_data() { // Processing for (lin = 0; lin <= this->matrix_.rows() - this->nrows_; lin++) { printf("\n"); - //Ffor (i = 0; i < this->nrows_; i++) { - //F for (j = 0; j < this->matrix_.columns(); j++) - //FMagLog::debug() << this->fbuf_[i][j] << " "; - //F printf("\n"); - //F} + // Ffor (i = 0; i < this->nrows_; i++) { + // F for (j = 0; j < this->matrix_.columns(); j++) + // FMagLog::debug() << this->fbuf_[i][j] << " "; + // F printf("\n"); + // F} for (col = 0; col <= this->matrix_.columns() - this->ncols_; col++) { // check min value @@ -276,8 +276,8 @@ void MinMaxFilter::test_build_data() { if (found) // minimum found { - //FMagLog::debug() << "\n" - //F << "Min " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; + // FMagLog::debug() << "\n" + // F << "Min " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; lo = lo + 1; } } @@ -301,8 +301,8 @@ void MinMaxFilter::test_build_data() { if (found) // minimum found { - //FMagLog::debug() << "\n" - //F << "Max " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; + // FMagLog::debug() << "\n" + // F << "Max " << lin + fcr + 1 << " " << col + fcc + 1 << " " << val << "\n"; hi = hi + 1; } } @@ -312,8 +312,8 @@ void MinMaxFilter::test_build_data() { break; } - //FMagLog::debug() << "TOTAL POINTS LOW=" << lo << "\n"; - //FMagLog::debug() << "TOTAL POINTS HI =" << hi << "\n"; + // FMagLog::debug() << "TOTAL POINTS LOW=" << lo << "\n"; + // FMagLog::debug() << "TOTAL POINTS HI =" << hi << "\n"; printf("\n\nEND TEST\n"); } diff --git a/src/visualisers/ObsItemFamily.cc b/src/visualisers/ObsItemFamily.cc index 7cd5642cd..39bdff703 100644 --- a/src/visualisers/ObsItemFamily.cc +++ b/src/visualisers/ObsItemFamily.cc @@ -60,9 +60,9 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { map::iterator it = point.begin(); map::iterator en = point.end(); - //for (; it != en; ++it) { - //F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - //F} + // for (; it != en; ++it) { + // F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; + // F} Colour colour = owner_->wind_colour_->automatic() ? *owner_->colour_ : *owner_->wind_colour_; CustomisedPoint::const_iterator speed = point.find(speed_); @@ -79,9 +79,9 @@ void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { const string origin = "circle"; - //FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - //F << "\n\twind_speed: " << point[speed_] << "\n\twind_direction: " << point[direction_] - //F << "\n\tcloud amount: " << point["total_cloud"] << " -> " << origin << std::endl; + // FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() + // F << "\n\twind_speed: " << point[speed_] << "\n\twind_direction: " << point[direction_] + // F << "\n\tcloud amount: " << point["total_cloud"] << " -> " << origin << std::endl; flag->setOriginHeight(owner_->ring_size_); @@ -129,13 +129,13 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) map::iterator it = point.begin(); map::iterator en = point.end(); - //Ffor (; it != en; ++it) { - //F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; - //F} + // Ffor (; it != en; ++it) { + // F MagLog::debug() << " >>> " << it->first << " -> " << it->second << endl; + // F} symbol.setHeight(owner_->size_); int total_cloud = maground((point["total_cloud"] / 100.) * 8); - //FMagLog::debug() << "total_cloud-->" << point["total_cloud"] << "--->" << total_cloud << endl; + // FMagLog::debug() << "total_cloud-->" << point["total_cloud"] << "--->" << total_cloud << endl; map::const_iterator marker = origins_.find(total_cloud); string origin; @@ -176,11 +176,11 @@ void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) flag->thickness(1.5); - //FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() - //F << "\n\twind_speed: " << point["wind_speed"] - //F << "\n\twind_direction: " << point["wind_direction"] - //F << "\n\tcloud amount: " << point["total_cloud"] << "--->" << total_cloud << "--->" << origin - //F << std::endl; + // FMagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: " << point.longitude() << " / " << point.latitude() + // F << "\n\twind_speed: " << point["wind_speed"] + // F << "\n\twind_direction: " << point["wind_direction"] + // F << "\n\tcloud amount: " << point["total_cloud"] << "--->" << total_cloud << "--->" << origin + // F << std::endl; flag->setOriginHeight(owner_->ring_size_ * 1.75); flag->setOriginMarker(origin); @@ -234,7 +234,7 @@ void ObsPressure::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons object->text(os.str()); - //FMagLog::debug() << "\tPressure: " << value->second << " = " << pressure << " -> " << os.str() << "\n"; + // FMagLog::debug() << "\tPressure: " << value->second << " = " << pressure << " -> " << os.str() << "\n"; object->font(font); symbol.add(object); @@ -264,7 +264,7 @@ void ObsPressureLevel::operator()(CustomisedPoint& point, ComplexSymbol& symbol) object->text(tostring(pressure)); - //FMagLog::debug() << "\tPressureLevel: " << value->second << " = " << pressure << "\n"; + // FMagLog::debug() << "\tPressureLevel: " << value->second << " = " << pressure << "\n"; font.size(owner_->size_); object->font(font); symbol.add(object); @@ -319,7 +319,7 @@ void ObsPressureTendency::operator()(CustomisedPoint& point, ComplexSymbol& symb oss << "a_" << value->second; tendancy->symbol(oss.str()); - //FMagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n"; + // FMagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n"; tendancy->height(owner_->size_ * 0.8); // A bit too big ! symbol.add(tendancy); @@ -349,7 +349,7 @@ void ObsDewPoint::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons // The temperature is displayed in Celsius. const double tempe = maground(value->second - 273.15); - //FMagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n"; + // FMagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n"; object->text(tostring(tempe)); object->font(font); @@ -395,7 +395,7 @@ void ObsVisibility::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co object->text(val); - //FMagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n"; + // FMagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n"; font.size(owner_->size_); object->font(font); @@ -483,7 +483,7 @@ void ObsPresentWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol object->symbol(ww); - //FMagLog::debug() << "\tPresent Weather--->" << ww << " in " << colour << "\n"; + // FMagLog::debug() << "\tPresent Weather--->" << ww << " in " << colour << "\n"; // time->setJustification(MRIGHT); object->height(owner_->size_); symbol.add(object); @@ -510,7 +510,7 @@ void ObsTemperature::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c // The temperature is displayed in Celsius. double tempe = maground(value->second - 273.15); - //FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; + // FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; object->text(tostring(tempe)); // object->setJustification(MCENTRE); @@ -532,7 +532,7 @@ void ObsTimePlot::operator()(CustomisedPoint& point, ComplexSymbol& symbol) cons if (value == point.end()) return; - //FMagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl; + // FMagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->time_plot_colour_->automatic() ? *owner_->colour_ : *owner_->time_plot_colour_; @@ -566,7 +566,7 @@ void ObsHeight::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const return; double geop = maground(value->second / 98.1); - //FMagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl; + // FMagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl; Colour colour = owner_->height_colour_->automatic() ? *owner_->colour_ : *owner_->height_colour_; TextItem* height = new TextItem(); MagFont font("sansserif"); @@ -598,7 +598,7 @@ void ObsThickness::operator()(CustomisedPoint& point, ComplexSymbol& symbol) con return; const double thickness = maground(value->second / 98.1); #ifdef OBS_DEBUG_ - //FMagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl; + // FMagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl; #endif Colour colour = owner_->thickness_colour_->automatic() ? *owner_->colour_ : *owner_->thickness_colour_; TextItem* object = new TextItem(); @@ -627,7 +627,8 @@ void ObsIdentifier::operator()(CustomisedPoint& point, ComplexSymbol& symbol) co return; TextItem* time = new TextItem(); #ifdef OBS_DEBUG_ - //FMagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << endl; + // FMagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << + // endl; #endif Colour colour = owner_->identifier_colour_->automatic() ? *owner_->colour_ : *owner_->identifier_colour_; MagFont font("sansserif"); @@ -716,7 +717,7 @@ void ObsPastWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c object->symbol(ww->second); - //FMagLog::debug() << "\tPast Weather 1-> " << ww->second << "\n"; + // FMagLog::debug() << "\tPast Weather 1-> " << ww->second << "\n"; object->height(owner_->size_ * .75); symbol.add(object); @@ -734,7 +735,7 @@ void ObsPastWeather::operator()(CustomisedPoint& point, ComplexSymbol& symbol) c object2->symbol(ww->second); - //FMagLog::debug() << "\tPast Weather 2-> " << ww->second << "\n"; + // FMagLog::debug() << "\tPast Weather 2-> " << ww->second << "\n"; object2->height(owner_->size_ * .75); symbol.add(object2); @@ -876,7 +877,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { font.colour(*owner_->low_colour_); font.size(owner_->size_ * 0.9); - //FMagLog::debug() << "\tLow Cloud--->" << nh.str() << "\n"; + // FMagLog::debug() << "\tLow Cloud--->" << nh.str() << "\n"; object->text(nh.str()); object->font(font); symbol.add(object); @@ -893,7 +894,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->symbol(low->second); - //FMagLog::debug() << "\tLow Cloud--->" << value->second << "-->" << low->second << "\n"; + // FMagLog::debug() << "\tLow Cloud--->" << value->second << "-->" << low->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -911,7 +912,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->medium_colour_); cloud->symbol(medium->second); - //FMagLog::debug() << "\tMedium Cloud--->" << value->second << " --> " << medium->second << "\n"; + // FMagLog::debug() << "\tMedium Cloud--->" << value->second << " --> " << medium->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -929,7 +930,7 @@ void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { cloud->colour(*owner_->high_colour_); cloud->symbol(high->second); - //FMagLog::debug() << "\tHigh Cloud--->" << value->second << "-->" << high->second << "\n"; + // FMagLog::debug() << "\tHigh Cloud--->" << value->second << "-->" << high->second << "\n"; cloud->height(owner_->size_); symbol.add(cloud); @@ -956,7 +957,7 @@ void ObsDemoItem1::visit(std::set& tokens) { void ObsDemoItem1::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (point.find("temperature") == point.end()) { - //FMagLog::debug() << "No info for temperature given!" << endl; + // FMagLog::debug() << "No info for temperature given!" << endl; return; } @@ -1108,7 +1109,7 @@ void ObsSeaTemperature::operator()(CustomisedPoint& point, ComplexSymbol& symbol // The temperature is displayed in Celsius. double tempe = maground(value->second - 273.15); - //FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; + // FMagLog::debug() << "\tTemperature: " << tempe << " from " << value->second << "\n"; object->text(tostring(tempe)); @@ -1143,7 +1144,7 @@ void ObsWave::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const { if (period == point.end() || height == point.end()) return; - //FMagLog::debug() << "\theight: " << height->second << " period " << period->second << "\n"; + // FMagLog::debug() << "\theight: " << height->second << " period " << period->second << "\n"; // height of waves in units of 0.5 double h = maground(height->second / 0.5); double p = maground(period->second); diff --git a/src/visualisers/ObsTable.cc b/src/visualisers/ObsTable.cc index df4dd3c86..2e8851a0a 100644 --- a/src/visualisers/ObsTable.cc +++ b/src/visualisers/ObsTable.cc @@ -56,7 +56,7 @@ ObsTable::ObsTable() { XML_SetUserData(parser, this); XML_SetElementHandler(parser, startElement, endElement); - //FMagLog::dev() << "Load observation templates --->" << filename << endl; + // FMagLog::dev() << "Load observation templates --->" << filename << endl; FILE* in = fopen(filename.c_str(), "r"); if (!in) @@ -107,7 +107,7 @@ void ObsTable::add(const string& tag, const map& def) { current_->push_back(obs); } catch (NoFactoryException&) { - //FMagLog::dev() << "can not find ObsItem for : " << tag << "\n"; + // FMagLog::dev() << "can not find ObsItem for : " << tag << "\n"; cout << "can not find ObsItem for : " << tag << "\n"; } } From 54c2500d2f304d2f2bd91b5e34c4c3d000f66e40 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 11:09:10 +0100 Subject: [PATCH 03/24] Ignoring formatting check for now .. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f77aaf5c8..96ce7e6d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,8 @@ before_install: if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo $(clang-format --version) echo $(bash --version) - bash check_formatting.sh + echo "No check for now" + #bash check_formatting.sh fi # prepare install dir - mkdir ${INSTALL_DIR} From 34534f4cc31eefe2973358b3654da395b62a31a0 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 13:15:34 +0100 Subject: [PATCH 04/24] CI: fixing tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 96ce7e6d7..fd29f8885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ env: global: - MAGICS_SRC=${TRAVIS_BUILD_DIR} - MAGICS_PYTHON_SRC=${MAGICS_SRC}/../magics-python - - MAGICS_TEST_SRC=${MAGICS_SRC}/../magics-test + - MAGICS_TEST_SRC=${MAGICS_SRC}/../magics-test/test - MAGICS_PYTHON_TESTS=${MAGICS_SRC}/test/python - ECBUILD_SRC=${MAGICS_SRC}/../ecbuild - BUILD_DIR=${MAGICS_SRC}/build From 057d8f4d9d8472f350eb4c660609121c0178dda0 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 14:12:15 +0100 Subject: [PATCH 05/24] CI : working on test --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd29f8885..b272a5b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,8 +38,8 @@ env: global: - MAGICS_SRC=${TRAVIS_BUILD_DIR} - MAGICS_PYTHON_SRC=${MAGICS_SRC}/../magics-python - - MAGICS_TEST_SRC=${MAGICS_SRC}/../magics-test/test - - MAGICS_PYTHON_TESTS=${MAGICS_SRC}/test/python + - MAGICS_TEST_SRC=${MAGICS_SRC}/../magics-test + - MAGICS_PYTHON_TESTS=${MAGICS_SRC}/../magics-test/test/gallery - ECBUILD_SRC=${MAGICS_SRC}/../ecbuild - BUILD_DIR=${MAGICS_SRC}/build - INSTALL_DIR=/tmp/install @@ -108,7 +108,8 @@ script: # test # - cd ${MAGICS_PYTHON_SRC} # - pytest - - cd ${MAGICS_TEST_SRC} + - cd ${MAGICS_PYTHON_SRC} + - set PYTHONPATH=%PYTHONPATH%;%MAGICS_PYTHON_SRC% - pytest after_success: From 9d91aa52e24f58af9984cd01ad8ea40636952fd5 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 14:35:53 +0100 Subject: [PATCH 06/24] CI : More in tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b272a5b8f..5f324d66d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,7 +109,7 @@ script: # - cd ${MAGICS_PYTHON_SRC} # - pytest - cd ${MAGICS_PYTHON_SRC} - - set PYTHONPATH=%PYTHONPATH%;%MAGICS_PYTHON_SRC% + - set PYTHONPATH=$PYTHONPATH;$MAGICS_PYTHON_SRC - pytest after_success: From 027885b0b18f7f3e928e540dbaa623184cf12f56 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 15:35:33 +0100 Subject: [PATCH 07/24] CI: Fixing test --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f324d66d..fa2f44c05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -106,8 +106,6 @@ script: - ctest -j2 --output-on-failure - make install > /dev/null # test - # - cd ${MAGICS_PYTHON_SRC} - # - pytest - cd ${MAGICS_PYTHON_SRC} - set PYTHONPATH=$PYTHONPATH;$MAGICS_PYTHON_SRC - pytest From eab9909f69e5699b1025baaa1ab620302215a9be Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 17:20:00 +0100 Subject: [PATCH 08/24] CI : work on test --- .appveyor.yml | 3 +++ .travis.yml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 695581cba..85bea6224 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,6 +17,8 @@ environment: GIT_CLONE_DIR: $(ECMWF)\git INSTALL_DIR: $(ECMWF)\install MAGICS_SRC: $(GIT_CLONE_DIR)\magics + MAGICS_TEST_SRC: ${MAGICS_SRC}/../magics-test + MAGICS_PYTHON_TEST: ${MAGICS_TEST_SRC}/test/gallery MAGICS_PYTHON_TESTS: $(MAGICS_SRC)\test\python MAGPLUS_HOME: $(INSTALL_DIR) MAGICS_PYTHON_SRC: $(GIT_CLONE_DIR)\magics_python @@ -53,6 +55,7 @@ install: # install magics-python src - cmd: git clone -b master --depth 1 https://github.com/ecmwf/magics-python.git %MAGICS_PYTHON_SRC% + - cmd: git clone --depth 1 https://github.com/ecmwf/magics-test.git %MAGICS_TESTS_SRC% # install linux utils - cmd: conda install -c msys2 m2-bash ^ diff --git a/.travis.yml b/.travis.yml index fa2f44c05..0bdf7cd5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ env: - MAGICS_SRC=${TRAVIS_BUILD_DIR} - MAGICS_PYTHON_SRC=${MAGICS_SRC}/../magics-python - MAGICS_TEST_SRC=${MAGICS_SRC}/../magics-test - - MAGICS_PYTHON_TESTS=${MAGICS_SRC}/../magics-test/test/gallery + - MAGICS_PYTHON_TESTS=${MAGICS_TEST_SRC}/test/gallery - ECBUILD_SRC=${MAGICS_SRC}/../ecbuild - BUILD_DIR=${MAGICS_SRC}/build - INSTALL_DIR=/tmp/install @@ -107,7 +107,7 @@ script: - make install > /dev/null # test - cd ${MAGICS_PYTHON_SRC} - - set PYTHONPATH=$PYTHONPATH;$MAGICS_PYTHON_SRC + - PYTHONPATH=${PYTHONPATH};${MAGICS_PYTHON_SRC} - pytest after_success: From 8b34b81fa9618df054dc3f39bd3bb5a02f18ed7b Mon Sep 17 00:00:00 2001 From: Sylvie Date: Wed, 22 Jul 2020 18:23:13 +0100 Subject: [PATCH 09/24] CI : tests --- .appveyor.yml | 3 +-- .travis.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 85bea6224..d0a8906e6 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -18,8 +18,7 @@ environment: INSTALL_DIR: $(ECMWF)\install MAGICS_SRC: $(GIT_CLONE_DIR)\magics MAGICS_TEST_SRC: ${MAGICS_SRC}/../magics-test - MAGICS_PYTHON_TEST: ${MAGICS_TEST_SRC}/test/gallery - MAGICS_PYTHON_TESTS: $(MAGICS_SRC)\test\python + MAGICS_PYTHON_TESTS: $(MAGICS_TESTS_SRC)\test\gallery MAGPLUS_HOME: $(INSTALL_DIR) MAGICS_PYTHON_SRC: $(GIT_CLONE_DIR)\magics_python ECBUILD_SRC: $(GIT_CLONE_DIR)\ecbuild diff --git a/.travis.yml b/.travis.yml index 0bdf7cd5e..08c108e6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,7 +107,6 @@ script: - make install > /dev/null # test - cd ${MAGICS_PYTHON_SRC} - - PYTHONPATH=${PYTHONPATH};${MAGICS_PYTHON_SRC} - pytest after_success: From 951339702a9db59860e9f178f2c308622d4b2455 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 09:18:08 +0100 Subject: [PATCH 10/24] CI : fixing test path --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index d0a8906e6..3a7c1ca65 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,7 +17,7 @@ environment: GIT_CLONE_DIR: $(ECMWF)\git INSTALL_DIR: $(ECMWF)\install MAGICS_SRC: $(GIT_CLONE_DIR)\magics - MAGICS_TEST_SRC: ${MAGICS_SRC}/../magics-test + MAGICS_TESTS_SRC: ${MAGICS_SRC}/../magics-test MAGICS_PYTHON_TESTS: $(MAGICS_TESTS_SRC)\test\gallery MAGPLUS_HOME: $(INSTALL_DIR) MAGICS_PYTHON_SRC: $(GIT_CLONE_DIR)\magics_python From 7785f104a20069790dcedad6d25903eb55bf6399 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 09:27:55 +0100 Subject: [PATCH 11/24] CI: osx not working --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 08c108e6e..4b898b1cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ matrix: homebrew: packages: - pango + - cairo env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" From 16651936fca2b1843db406fdb2f64974b4219ceb Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 11:25:14 +0100 Subject: [PATCH 12/24] CI : looking for pangocairo on osx --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b898b1cd..bc6317252 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,12 +26,6 @@ matrix: - os: osx osx_image: xcode10.1 - addons: - homebrew: - packages: - - pango - - cairo - env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" From 62720d5ed3fd7ad7c31a36a0f90ccac0b4c72eab Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 11:41:34 +0100 Subject: [PATCH 13/24] CI : osx --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc6317252..35fc1cab6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,12 @@ matrix: - os: osx osx_image: xcode10.1 + addons: + homebrew: + packages: + - pango + - cairo + env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" @@ -82,10 +88,8 @@ install: - conda install boost libnetcdf expat jinja2 xarray scipy cftime - conda install -c conda-forge proj4=6 eccodes pytest cairo pango pip # search for conda-installed libraries - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - export LDFLAGS="$LDFLAGS -L${CONDA_PREFIX}/lib -Wl,-rpath,${CONDA_PREFIX}/lib" - fi + - export LDFLAGS="$LDFLAGS -L${CONDA_PREFIX}/lib -Wl,-rpath,${CONDA_PREFIX}/lib" + #---------------------------------# # build configuration # From db7bbc419a5217417b277e6804268d18d0d85113 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 11:51:41 +0100 Subject: [PATCH 14/24] CI : osx --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 35fc1cab6..8998377f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,11 +26,6 @@ matrix: - os: osx osx_image: xcode10.1 - addons: - homebrew: - packages: - - pango - - cairo env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" From 84a5ae29e477f3d060a8c7af1938a366e80d890a Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 16:01:34 +0100 Subject: [PATCH 15/24] CI : disabling cairo for osx for now --- .travis.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8998377f1..56f68d623 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,15 +93,26 @@ install: script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 ${MAGICS_SRC} + fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + # No Cairo for osx .. + cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} + -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 + ${MAGICS_SRC} + fi + - make -j2 - ctest -j2 --output-on-failure - make install > /dev/null - # test - - cd ${MAGICS_PYTHON_SRC} - - pytest + # test only on linux for now + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + cd ${MAGICS_PYTHON_SRC} + pytest + fi after_success: # Run script to generate PNGs and push result to magics-tests From 3657757a607081cd4f354fd9335c35dd8fe94f7b Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 17:23:31 +0100 Subject: [PATCH 16/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56f68d623..600860a40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -104,7 +104,6 @@ script: -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 ${MAGICS_SRC} fi - - make -j2 - ctest -j2 --output-on-failure - make install > /dev/null From 783a09cf2ed2ec6527ea1c96c760f54d5698cbb2 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 17:27:29 +0100 Subject: [PATCH 17/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 600860a40..4f8dba8c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,6 @@ matrix: - os: osx osx_image: xcode10.1 - env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" @@ -93,12 +92,14 @@ install: script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 ${MAGICS_SRC} fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then # No Cairo for osx .. cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 @@ -108,7 +109,8 @@ script: - ctest -j2 --output-on-failure - make install > /dev/null # test only on linux for now - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd ${MAGICS_PYTHON_SRC} pytest fi From 8d1cda62fab705f950fb92818040ac4c8e29b9e9 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 17:42:39 +0100 Subject: [PATCH 18/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f8dba8c1..37a30212e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,14 +92,12 @@ install: script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 ${MAGICS_SRC} fi - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then # No Cairo for osx .. cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 @@ -109,8 +107,7 @@ script: - ctest -j2 --output-on-failure - make install > /dev/null # test only on linux for now - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd ${MAGICS_PYTHON_SRC} pytest fi From 62e3e98d426ca6bc77d02ce7ffe797f8701c8578 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 17:45:43 +0100 Subject: [PATCH 19/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37a30212e..771eaaf28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,12 +92,15 @@ install: script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - echo "In build dir" + - | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 ${MAGICS_SRC} fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then # No Cairo for osx .. cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 @@ -107,7 +110,8 @@ script: - ctest -j2 --output-on-failure - make install > /dev/null # test only on linux for now - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd ${MAGICS_PYTHON_SRC} pytest fi From e97740603cbcd46799f6e617c5120b336cac1add Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 17:54:13 +0100 Subject: [PATCH 20/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 771eaaf28..b0f9ee00f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,7 @@ install: script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - echo "In build dir" + - echo "In build dir--> ${MAGICS_SRC}" - | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} From 012da74e4c93059311a7d58dcbb0d0560da9cb91 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Thu, 23 Jul 2020 18:01:26 +0100 Subject: [PATCH 21/24] CI : osx failingCI : disabling cairo for osx for now --- .travis.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0f9ee00f..6d72f60ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,11 +23,13 @@ matrix: env: MINICONDA_FILE="Miniconda3-latest-Linux-x86_64.sh" PROJ4_PATH=~/miniconda3 + CAIRO="" - os: osx osx_image: xcode10.1 env: MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh" + CAIRO="-D ENABLE_CAIRO=0" env: global: @@ -93,25 +95,16 @@ script: # build - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - echo "In build dir--> ${MAGICS_SRC}" - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} + - cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D ENABLE_FORTRAN=0 - ${MAGICS_SRC} - fi - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - # No Cairo for osx .. - cmake -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} - -D ENABLE_FORTRAN=0 -D ENABLE_CAIRO=0 - ${MAGICS_SRC} - fi + ${MAGICS_SRC} ${CAIRO} - make -j2 - ctest -j2 --output-on-failure - make install > /dev/null # test only on linux for now - | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + echo "In build dir--> ${MAGICS_PYTHON_SRC}" cd ${MAGICS_PYTHON_SRC} pytest fi From 554a8b76f3db5ecb803f5a8888f8eb3d405f3fe4 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Fri, 24 Jul 2020 08:42:56 +0100 Subject: [PATCH 22/24] CI : osx failingCI : disabling cairo for osx for now --- test/contour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/contour.c b/test/contour.c index 5c15589a9..0b1a80238 100644 --- a/test/contour.c +++ b/test/contour.c @@ -11,7 +11,7 @@ #include #include "magics_api.h" -#define NUM_FORMATS 3 +#define NUM_FORMATS 1 void myprint_error(void* data, const char* msg) { @@ -63,7 +63,7 @@ int main() { mag_setc("contour", "on"); mag_setc("contour_line_colour", "sky"); mag_setc("CONTOUR_HIGHLIGHT_COLOUR", "GREEN"); - mag_setc("cjgskljdfkljdontour_label", "on"); + mag_setc("dontour_label", "on"); mag_cont(); From 7d01c49b36b791854620329ce4395cddcd289956 Mon Sep 17 00:00:00 2001 From: Sylvie Date: Fri, 24 Jul 2020 09:37:59 +0100 Subject: [PATCH 23/24] CI: fixing test --- test/contour.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/contour.c b/test/contour.c index 0b1a80238..18bb01e7e 100644 --- a/test/contour.c +++ b/test/contour.c @@ -40,11 +40,12 @@ int main() { mag_add_warning_listener(&data, myprint_warning); mag_add_error_listener(&data, myprint_error); mag_open(); - const char* formats[NUM_FORMATS]; + const char* formats[3]; formats[0] = "ps"; formats[1] = "png"; formats[2] = "pdf"; + mag_set1c("output_formats", formats, NUM_FORMATS); @@ -63,7 +64,7 @@ int main() { mag_setc("contour", "on"); mag_setc("contour_line_colour", "sky"); mag_setc("CONTOUR_HIGHLIGHT_COLOUR", "GREEN"); - mag_setc("dontour_label", "on"); + mag_setc("contour_label", "on"); mag_cont(); From 269728248e32bfc130514f8ea80b98836c83c38d Mon Sep 17 00:00:00 2001 From: Sylvie Date: Fri, 24 Jul 2020 11:02:41 +0100 Subject: [PATCH 24/24] Updating version develop to 4.4.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c727dcf5..6362c289d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ cmake_minimum_required( VERSION 3.6.0 FATAL_ERROR ) -project( magics VERSION 4.4.1 LANGUAGES CXX ) +project( magics VERSION 4.4.3 LANGUAGES CXX ) # make sure that the header files are installed into include/magics # note that this needs to be done before ecbuild_declare_project()