diff --git a/plugins/gedi/plugin/FootprintReader.h b/plugins/gedi/plugin/FootprintReader.h index 0592dad09..854a126d6 100644 --- a/plugins/gedi/plugin/FootprintReader.h +++ b/plugins/gedi/plugin/FootprintReader.h @@ -100,12 +100,12 @@ class FootprintReader: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array lat; H5Array lon; @@ -301,7 +301,7 @@ FootprintReader::~FootprintReader (void) * Region::Constructor *----------------------------------------------------------------------------*/ template -FootprintReader::Region::Region (info_t* info): +FootprintReader::Region::Region (const info_t* info): lat (info->reader->asset, info->reader->resource, FString("%s/%s", GediParms::beam2group(info->beam), info->reader->latName).c_str(), &info->reader->context), lon (info->reader->asset, info->reader->resource, FString("%s/%s", GediParms::beam2group(info->beam), info->reader->lonName).c_str(), &info->reader->context), inclusion_mask (NULL), @@ -320,13 +320,13 @@ FootprintReader::Region::Region (info_t* info): { rasterregion(info); } - else if(info->reader->parms->polygon.length() > 0) + else if(!info->reader->parms->polygon.empty()) { polyregion(info); } else { - num_footprints = MIN(lat.size, lon.size); + num_footprints = lat.size; } /* Check If Anything to Process */ @@ -363,7 +363,7 @@ void FootprintReader::Region::cleanup (void) * Region::polyregion *----------------------------------------------------------------------------*/ template -void FootprintReader::Region::polyregion (info_t* info) +void FootprintReader::Region::polyregion (const info_t* info) { /* Find First and Last Footprints in Polygon */ bool first_footprint_found = false; @@ -409,7 +409,7 @@ void FootprintReader::Region::polyregion (info_t* info) * Region::rasterregion *----------------------------------------------------------------------------*/ template -void FootprintReader::Region::rasterregion (info_t* info) +void FootprintReader::Region::rasterregion (const info_t* info) { /* Allocate Inclusion Mask */ if(lat.size <= 0) return; diff --git a/plugins/gedi/plugin/Gedi01bReader.cpp b/plugins/gedi/plugin/Gedi01bReader.cpp index 5ca875c13..31cbcb34e 100644 --- a/plugins/gedi/plugin/Gedi01bReader.cpp +++ b/plugins/gedi/plugin/Gedi01bReader.cpp @@ -128,7 +128,7 @@ Gedi01bReader::~Gedi01bReader (void) = default; /*---------------------------------------------------------------------------- * Gedi01b::Constructor *----------------------------------------------------------------------------*/ -Gedi01bReader::Gedi01b::Gedi01b (info_t* info, Region& region): +Gedi01bReader::Gedi01b::Gedi01b (const info_t* info, const Region& region): shot_number (info->reader->asset, info->reader->resource, FString("%s/shot_number", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), delta_time (info->reader->asset, info->reader->resource, FString("%s/geolocation/delta_time", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), elev_bin0 (info->reader->asset, info->reader->resource, FString("%s/geolocation/elevation_bin0", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), @@ -164,7 +164,7 @@ Gedi01bReader::Gedi01b::~Gedi01b (void) = default; void* Gedi01bReader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Gedi01bReader* reader = reinterpret_cast(info->reader); const GediParms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; @@ -176,7 +176,7 @@ void* Gedi01bReader::subsettingThread (void* parm) try { /* Subset to Region of Interest */ - Region region(info); + const Region region(info); /* Read GEDI Datasets */ const Gedi01b gedi01b(info, region); diff --git a/plugins/gedi/plugin/Gedi01bReader.h b/plugins/gedi/plugin/Gedi01bReader.h index ef3340cf8..86789c405 100644 --- a/plugins/gedi/plugin/Gedi01bReader.h +++ b/plugins/gedi/plugin/Gedi01bReader.h @@ -106,7 +106,7 @@ class Gedi01bReader: public FootprintReader { public: - Gedi01b (info_t* info, Region& region); + Gedi01b (const info_t* info, const Region& region); ~Gedi01b (void); H5Array shot_number; diff --git a/plugins/gedi/plugin/Gedi02aReader.cpp b/plugins/gedi/plugin/Gedi02aReader.cpp index 8c702c137..f9957c17c 100644 --- a/plugins/gedi/plugin/Gedi02aReader.cpp +++ b/plugins/gedi/plugin/Gedi02aReader.cpp @@ -125,7 +125,7 @@ Gedi02aReader::~Gedi02aReader (void) = default; /*---------------------------------------------------------------------------- * Gedi02a::Constructor *----------------------------------------------------------------------------*/ -Gedi02aReader::Gedi02a::Gedi02a (info_t* info, Region& region): +Gedi02aReader::Gedi02a::Gedi02a (const info_t* info, const Region& region): shot_number (info->reader->asset, info->reader->resource, FString("%s/shot_number", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), delta_time (info->reader->asset, info->reader->resource, FString("%s/delta_time", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), elev_lowestmode (info->reader->asset, info->reader->resource, FString("%s/elev_lowestmode", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), @@ -160,7 +160,7 @@ Gedi02aReader::Gedi02a::~Gedi02a (void) = default; void* Gedi02aReader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Gedi02aReader* reader = reinterpret_cast(info->reader); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) const GediParms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; @@ -172,10 +172,10 @@ void* Gedi02aReader::subsettingThread (void* parm) try { /* Subset to Region of Interest */ - Region region(info); + const Region region(info); /* Read GEDI Datasets */ - const Gedi02a Gedi02a(info, region); + const Gedi02a gedi02a(info, region); /* Increment Read Statistics */ local_stats.footprints_read = region.num_footprints; @@ -186,7 +186,7 @@ void* Gedi02aReader::subsettingThread (void* parm) /* Check Degrade Filter */ if(parms->degrade_filter != GediParms::DEGRADE_UNFILTERED) { - if(Gedi02a.degrade_flag[footprint] != parms->degrade_filter) + if(gedi02a.degrade_flag[footprint] != parms->degrade_filter) { local_stats.footprints_filtered++; continue; @@ -196,7 +196,7 @@ void* Gedi02aReader::subsettingThread (void* parm) /* Check L2 Quality Filter */ if(parms->l2_quality_filter != GediParms::L2QLTY_UNFILTERED) { - if(Gedi02a.quality_flag[footprint] != parms->l2_quality_filter) + if(gedi02a.quality_flag[footprint] != parms->l2_quality_filter) { local_stats.footprints_filtered++; continue; @@ -206,7 +206,7 @@ void* Gedi02aReader::subsettingThread (void* parm) /* Check Surface Filter */ if(parms->surface_filter != GediParms::SURFACE_UNFILTERED) { - if(Gedi02a.surface_flag[footprint] != parms->surface_filter) + if(gedi02a.surface_flag[footprint] != parms->surface_filter) { local_stats.footprints_filtered++; continue; @@ -226,19 +226,19 @@ void* Gedi02aReader::subsettingThread (void* parm) { /* Populate Entry in Batch Structure */ g02a_footprint_t* fp = &reader->batchData->footprint[reader->batchIndex]; - fp->shot_number = Gedi02a.shot_number[footprint]; - fp->time_ns = GediParms::deltatime2timestamp(Gedi02a.delta_time[footprint]); + fp->shot_number = gedi02a.shot_number[footprint]; + fp->time_ns = GediParms::deltatime2timestamp(gedi02a.delta_time[footprint]); fp->latitude = region.lat[footprint]; fp->longitude = region.lon[footprint]; - fp->elevation_lowestmode = Gedi02a.elev_lowestmode[footprint]; - fp->elevation_highestreturn = Gedi02a.elev_highestreturn[footprint]; - fp->solar_elevation = Gedi02a.solar_elevation[footprint]; - fp->sensitivity = Gedi02a.sensitivity[footprint]; + fp->elevation_lowestmode = gedi02a.elev_lowestmode[footprint]; + fp->elevation_highestreturn = gedi02a.elev_highestreturn[footprint]; + fp->solar_elevation = gedi02a.solar_elevation[footprint]; + fp->sensitivity = gedi02a.sensitivity[footprint]; fp->beam = info->beam; fp->flags = 0; - if(Gedi02a.degrade_flag[footprint]) fp->flags |= GediParms::DEGRADE_FLAG_MASK; - if(Gedi02a.quality_flag[footprint]) fp->flags |= GediParms::L2_QUALITY_FLAG_MASK; - if(Gedi02a.surface_flag[footprint]) fp->flags |= GediParms::SURFACE_FLAG_MASK; + if(gedi02a.degrade_flag[footprint]) fp->flags |= GediParms::DEGRADE_FLAG_MASK; + if(gedi02a.quality_flag[footprint]) fp->flags |= GediParms::L2_QUALITY_FLAG_MASK; + if(gedi02a.surface_flag[footprint]) fp->flags |= GediParms::SURFACE_FLAG_MASK; /* Send Record */ reader->batchIndex++; diff --git a/plugins/gedi/plugin/Gedi02aReader.h b/plugins/gedi/plugin/Gedi02aReader.h index f660710f5..74f42b320 100644 --- a/plugins/gedi/plugin/Gedi02aReader.h +++ b/plugins/gedi/plugin/Gedi02aReader.h @@ -101,7 +101,7 @@ class Gedi02aReader: public FootprintReader { public: - Gedi02a (info_t* info, Region& region); + Gedi02a (const info_t* info, const Region& region); ~Gedi02a (void); H5Array shot_number; diff --git a/plugins/gedi/plugin/Gedi04aReader.cpp b/plugins/gedi/plugin/Gedi04aReader.cpp index 1cb507633..d300dcf99 100644 --- a/plugins/gedi/plugin/Gedi04aReader.cpp +++ b/plugins/gedi/plugin/Gedi04aReader.cpp @@ -126,7 +126,7 @@ Gedi04aReader::~Gedi04aReader (void) = default; /*---------------------------------------------------------------------------- * Gedi04a::Constructor *----------------------------------------------------------------------------*/ -Gedi04aReader::Gedi04a::Gedi04a (info_t* info, Region& region): +Gedi04aReader::Gedi04a::Gedi04a (const info_t* info, const Region& region): shot_number (info->reader->asset, info->reader->resource, FString("%s/shot_number", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), delta_time (info->reader->asset, info->reader->resource, FString("%s/delta_time", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), agbd (info->reader->asset, info->reader->resource, FString("%s/agbd", GediParms::beam2group(info->beam)).c_str(), &info->reader->context, 0, region.first_footprint, region.num_footprints), @@ -163,7 +163,7 @@ Gedi04aReader::Gedi04a::~Gedi04a (void) = default; void* Gedi04aReader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Gedi04aReader* reader = reinterpret_cast(info->reader); const GediParms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; @@ -175,7 +175,7 @@ void* Gedi04aReader::subsettingThread (void* parm) try { /* Subset to Region of Interest */ - Region region(info); + const Region region(info); /* Read GEDI Datasets */ const Gedi04a gedi04a(info, region); diff --git a/plugins/gedi/plugin/Gedi04aReader.h b/plugins/gedi/plugin/Gedi04aReader.h index eaa7548a7..33a5e2d7c 100644 --- a/plugins/gedi/plugin/Gedi04aReader.h +++ b/plugins/gedi/plugin/Gedi04aReader.h @@ -101,7 +101,7 @@ class Gedi04aReader: public FootprintReader { public: - Gedi04a (info_t* info, Region& region); + Gedi04a (const info_t* info, const Region& region); ~Gedi04a (void); H5Array shot_number; diff --git a/plugins/icesat2/plugin/Atl03BathyReader.cpp b/plugins/icesat2/plugin/Atl03BathyReader.cpp index f9175863d..c942a141f 100644 --- a/plugins/icesat2/plugin/Atl03BathyReader.cpp +++ b/plugins/icesat2/plugin/Atl03BathyReader.cpp @@ -325,7 +325,7 @@ Atl03BathyReader::~Atl03BathyReader (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -Atl03BathyReader::Region::Region (info_t* info): +Atl03BathyReader::Region::Region (const info_t* info): segment_lat (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lat").c_str(), &info->reader->context), segment_lon (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lon").c_str(), &info->reader->context), segment_ph_cnt (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/segment_ph_cnt").c_str(), &info->reader->context), @@ -356,7 +356,12 @@ Atl03BathyReader::Region::Region (info_t* info): } else { - return; // early exit since no subsetting required + num_segments = segment_ph_cnt.size; + num_photons = 0; + for(int i = 0; i < num_segments; i++) + { + num_photons += segment_ph_cnt[i]; + } } /* Check If Anything to Process */ @@ -397,7 +402,7 @@ void Atl03BathyReader::Region::cleanup (void) /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void Atl03BathyReader::Region::polyregion (info_t* info) +void Atl03BathyReader::Region::polyregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -461,7 +466,7 @@ void Atl03BathyReader::Region::polyregion (info_t* info) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void Atl03BathyReader::Region::rasterregion (info_t* info) +void Atl03BathyReader::Region::rasterregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -544,7 +549,7 @@ void Atl03BathyReader::Region::rasterregion (info_t* info) /*---------------------------------------------------------------------------- * Atl03Data::Constructor *----------------------------------------------------------------------------*/ -Atl03BathyReader::Atl03Data::Atl03Data (info_t* info, const Region& region): +Atl03BathyReader::Atl03Data::Atl03Data (const info_t* info, const Region& region): sc_orient (info->reader->asset, info->reader->resource, "/orbit_info/sc_orient", &info->reader->context), velocity_sc (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/velocity_sc").c_str(), &info->reader->context, H5Coro::ALL_COLS, region.first_segment, region.num_segments), segment_delta_time (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/delta_time").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), @@ -597,7 +602,7 @@ Atl03BathyReader::Atl03Data::Atl03Data (info_t* info, const Region& region): /*---------------------------------------------------------------------------- * Atl09Class::Constructor *----------------------------------------------------------------------------*/ -Atl03BathyReader::Atl09Class::Atl09Class (info_t* info): +Atl03BathyReader::Atl09Class::Atl09Class (const info_t* info): valid (false), met_u10m (info->reader->missing09 ? NULL : info->reader->asset09, info->reader->resource09.c_str(), FString("profile_%d/low_rate/met_u10m", info->track).c_str(), &info->reader->context09), met_v10m (info->reader->missing09 ? NULL : info->reader->asset09, info->reader->resource09.c_str(), FString("profile_%d/low_rate/met_v10m", info->track).c_str(), &info->reader->context09), @@ -751,7 +756,7 @@ Atl03BathyReader::OrbitInfo::OrbitInfo (const Asset* asset, const char* resource * OrbitInfo::tojson *----------------------------------------------------------------------------*/ const char* Atl03BathyReader::OrbitInfo::tojson (void) const -{ +{ FString json_contents(R"({)" R"("crossing_time":%lf,)" R"("cycle_number":%d,)" @@ -778,9 +783,9 @@ const char* Atl03BathyReader::OrbitInfo::tojson (void) const void* Atl03BathyReader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Atl03BathyReader* reader = info->reader; - BathyParms* parms = reader->parms; + const BathyParms* parms = reader->parms; RasterObject* ndwiRaster = RasterObject::cppCreate(reader->geoparms); /* Thread Variables */ diff --git a/plugins/icesat2/plugin/Atl03BathyReader.h b/plugins/icesat2/plugin/Atl03BathyReader.h index 07d6cb5a6..df72b5e31 100644 --- a/plugins/icesat2/plugin/Atl03BathyReader.h +++ b/plugins/icesat2/plugin/Atl03BathyReader.h @@ -130,7 +130,7 @@ class Atl03BathyReader: public LuaObject uint8_t cycle; uint8_t utm_zone; uint64_t extent_id; - float surface_h; // orthometric (in meters) + float surface_h; // orthometric (in meters) uint32_t photon_count; photon_t photons[]; // zero length field } extent_t; @@ -161,12 +161,12 @@ class Atl03BathyReader: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array segment_lat; H5Array segment_lon; @@ -186,7 +186,7 @@ class Atl03BathyReader: public LuaObject { public: - Atl03Data (info_t* info, const Region& region); + Atl03Data (const info_t* info, const Region& region); ~Atl03Data (void) = default; /* Read Data */ @@ -220,7 +220,7 @@ class Atl03BathyReader: public LuaObject { public: - explicit Atl09Class (info_t* info); + explicit Atl09Class (const info_t* info); ~Atl09Class (void) = default; /* Generated Data */ @@ -233,7 +233,7 @@ class Atl03BathyReader: public LuaObject }; /* AncillaryData SubClass */ - class AncillaryData + class AncillaryData { public: @@ -267,7 +267,7 @@ class Atl03BathyReader: public LuaObject }; /* OrbitInfo SubClass */ - class OrbitInfo + class OrbitInfo { public: diff --git a/plugins/icesat2/plugin/Atl03Reader.cpp b/plugins/icesat2/plugin/Atl03Reader.cpp index 8b517ce37..f2531742a 100644 --- a/plugins/icesat2/plugin/Atl03Reader.cpp +++ b/plugins/icesat2/plugin/Atl03Reader.cpp @@ -249,7 +249,7 @@ Atl03Reader::~Atl03Reader (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -Atl03Reader::Region::Region (info_t* info): +Atl03Reader::Region::Region (const info_t* info): segment_lat (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lat").c_str(), &info->reader->context), segment_lon (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lon").c_str(), &info->reader->context), segment_ph_cnt (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/segment_ph_cnt").c_str(), &info->reader->context), @@ -280,7 +280,12 @@ Atl03Reader::Region::Region (info_t* info): } else { - return; // early exit since no subsetting required + num_segments = segment_ph_cnt.size; + num_photons = 0; + for(int i = 0; i < num_segments; i++) + { + num_photons += segment_ph_cnt[i]; + } } /* Check If Anything to Process */ @@ -299,7 +304,6 @@ Atl03Reader::Region::Region (info_t* info): cleanup(); throw; } - } /*---------------------------------------------------------------------------- @@ -322,7 +326,7 @@ void Atl03Reader::Region::cleanup (void) /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void Atl03Reader::Region::polyregion (info_t* info) +void Atl03Reader::Region::polyregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -341,6 +345,9 @@ void Atl03Reader::Region::polyregion (info_t* info) inclusion = true; } + /* Segments with zero photon count may contain invalid coordinates, + making them unsuitable for inclusion in polygon tests. */ + /* Check First Segment */ if(!first_segment_found) { @@ -386,7 +393,7 @@ void Atl03Reader::Region::polyregion (info_t* info) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void Atl03Reader::Region::rasterregion (info_t* info) +void Atl03Reader::Region::rasterregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -469,7 +476,7 @@ void Atl03Reader::Region::rasterregion (info_t* info) /*---------------------------------------------------------------------------- * Atl03Data::Constructor *----------------------------------------------------------------------------*/ -Atl03Reader::Atl03Data::Atl03Data (info_t* info, const Region& region): +Atl03Reader::Atl03Data::Atl03Data (const info_t* info, const Region& region): sc_orient (info->reader->asset, info->reader->resource, "/orbit_info/sc_orient", &info->reader->context), velocity_sc (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/velocity_sc").c_str(), &info->reader->context, H5Coro::ALL_COLS, region.first_segment, region.num_segments), segment_delta_time (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/delta_time").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), @@ -573,6 +580,7 @@ Atl03Reader::Atl03Data::Atl03Data (info_t* info, const Region& region): } } + /*---------------------------------------------------------------------------- * Atl03Data::Destructor *----------------------------------------------------------------------------*/ @@ -658,7 +666,7 @@ Atl03Reader::Atl08Class::~Atl08Class (void) void Atl03Reader::Atl08Class::classify (const info_t* info, const Region& region, const Atl03Data& atl03) { /* Do Nothing If Not Enabled */ - if(!info->reader->parms->stages[Icesat2Parms::STAGE_ATL08]) + if(!enabled) { return; } @@ -679,7 +687,7 @@ void Atl03Reader::Atl08Class::classify (const info_t* info, const Region& region } /* Allocate ATL08 Classification Array */ - const int num_photons = atl03.dist_ph_along.size; + const long num_photons = atl03.dist_ph_along.size; classification = new uint8_t [num_photons]; /* Allocate PhoREAL Arrays */ @@ -802,17 +810,23 @@ void Atl03Reader::Atl08Class::classify (const info_t* info, const Region& region *----------------------------------------------------------------------------*/ uint8_t Atl03Reader::Atl08Class::operator[] (int index) const { + // This operator is called only after the classification array has been fully populated. + // clang-tidy is not able to determine that the array is always populated. + // We disable the related warning to avoid false positives. + + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) return classification[index]; } /*---------------------------------------------------------------------------- * YapcScore::Constructor *----------------------------------------------------------------------------*/ -Atl03Reader::YapcScore::YapcScore (info_t* info, const Region& region, const Atl03Data& atl03): +Atl03Reader::YapcScore::YapcScore (const info_t* info, const Region& region, const Atl03Data& atl03): + enabled {info->reader->parms->stages[Icesat2Parms::STAGE_YAPC]}, score {NULL} { /* Do Nothing If Not Enabled */ - if(!info->reader->parms->stages[Icesat2Parms::STAGE_YAPC]) + if(!enabled) { return; } @@ -843,7 +857,7 @@ Atl03Reader::YapcScore::~YapcScore (void) /*---------------------------------------------------------------------------- * yapcV2 *----------------------------------------------------------------------------*/ -void Atl03Reader::YapcScore::yapcV2 (info_t* info, const Region& region, const Atl03Data& atl03) +void Atl03Reader::YapcScore::yapcV2 (const info_t* info, const Region& region, const Atl03Data& atl03) { /* YAPC Hard-Coded Parameters */ const double MAXIMUM_HSPREAD = 15000.0; // meters @@ -859,7 +873,7 @@ void Atl03Reader::YapcScore::yapcV2 (info_t* info, const Region& region, const A * CANNOT THROW BELOW THIS POINT */ - /* Allocate ATL08 Classification Array */ + /* Allocate Yapc Score Array */ const int32_t num_photons = atl03.dist_ph_along.size; score = new uint8_t [num_photons]; memset(score, 0, num_photons); @@ -1014,7 +1028,7 @@ void Atl03Reader::YapcScore::yapcV2 (info_t* info, const Region& region, const A /*---------------------------------------------------------------------------- * yapcV3 *----------------------------------------------------------------------------*/ -void Atl03Reader::YapcScore::yapcV3 (info_t* info, const Region& region, const Atl03Data& atl03) +void Atl03Reader::YapcScore::yapcV3 (const info_t* info, const Region& region, const Atl03Data& atl03) { /* YAPC Parameters */ Icesat2Parms::yapc_t* settings = &info->reader->parms->yapc; @@ -1179,9 +1193,9 @@ Atl03Reader::TrackState::~TrackState (void) = default; void* Atl03Reader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Atl03Reader* reader = info->reader; - Icesat2Parms* parms = reader->parms; + const Icesat2Parms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; List* segment_indices = NULL; // used for ancillary data List* photon_indices = NULL; // used for ancillary data diff --git a/plugins/icesat2/plugin/Atl03Reader.h b/plugins/icesat2/plugin/Atl03Reader.h index 363d7bf58..f1e6ec2b9 100644 --- a/plugins/icesat2/plugin/Atl03Reader.h +++ b/plugins/icesat2/plugin/Atl03Reader.h @@ -150,12 +150,12 @@ class Atl03Reader: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array segment_lat; H5Array segment_lon; @@ -175,7 +175,7 @@ class Atl03Reader: public LuaObject { public: - Atl03Data (info_t* info, const Region& region); + Atl03Data (const info_t* info, const Region& region); ~Atl03Data (void); /* Read Data */ @@ -222,9 +222,9 @@ class Atl03Reader: public LuaObject /* Generated Data */ uint8_t* classification; // [num_photons] - float* relief; // [num_photons] - uint8_t* landcover; // [num_photons] - uint8_t* snowcover; // [num_photons] + float* relief; // [num_photons] + uint8_t* landcover; // [num_photons] + uint8_t* snowcover; // [num_photons] /* Read Data */ H5Array atl08_segment_id; @@ -247,14 +247,17 @@ class Atl03Reader: public LuaObject { public: - YapcScore (info_t* info, const Region& region, const Atl03Data& atl03); + YapcScore (const info_t* info, const Region& region, const Atl03Data& atl03); ~YapcScore (void); - void yapcV2 (info_t* info, const Region& region, const Atl03Data& atl03); - void yapcV3 (info_t* info, const Region& region, const Atl03Data& atl03); + void yapcV2 (const info_t* info, const Region& region, const Atl03Data& atl03); + void yapcV3 (const info_t* info, const Region& region, const Atl03Data& atl03); uint8_t operator[] (int index) const; + /* Class Data */ + bool enabled; + /* Generated Data */ uint8_t* score; // [num_photons] }; diff --git a/plugins/icesat2/plugin/Atl03Viewer.cpp b/plugins/icesat2/plugin/Atl03Viewer.cpp index f9167c5ce..0137066e4 100644 --- a/plugins/icesat2/plugin/Atl03Viewer.cpp +++ b/plugins/icesat2/plugin/Atl03Viewer.cpp @@ -220,7 +220,7 @@ Atl03Viewer::~Atl03Viewer (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -Atl03Viewer::Region::Region (info_t* info): +Atl03Viewer::Region::Region (const info_t* info): segment_lat (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lat").c_str(), &info->reader->context), segment_lon (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/reference_photon_lon").c_str(), &info->reader->context), segment_ph_cnt (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/segment_ph_cnt").c_str(), &info->reader->context), @@ -249,7 +249,7 @@ Atl03Viewer::Region::Region (info_t* info): } else { - return; // early exit since no subsetting required + num_segments = segment_ph_cnt.size; } /* Check If Anything to Process */ @@ -290,7 +290,7 @@ void Atl03Viewer::Region::cleanup (void) /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void Atl03Viewer::Region::polyregion (info_t* info) +void Atl03Viewer::Region::polyregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -310,7 +310,7 @@ void Atl03Viewer::Region::polyregion (info_t* info) } /* Segments with zero photon count may contain invalid coordinates, - making them unsuitable for inclusion in polygon tests. */ + making them unsuitable for inclusion in polygon tests. */ /* Check First Segment */ if(!first_segment_found) @@ -346,7 +346,7 @@ void Atl03Viewer::Region::polyregion (info_t* info) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void Atl03Viewer::Region::rasterregion (info_t* info) +void Atl03Viewer::Region::rasterregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -401,7 +401,7 @@ void Atl03Viewer::Region::rasterregion (info_t* info) /*---------------------------------------------------------------------------- * Atl03Data::Constructor *----------------------------------------------------------------------------*/ -Atl03Viewer::Atl03Data::Atl03Data (info_t* info, const Region& region): +Atl03Viewer::Atl03Data::Atl03Data (const info_t* info, const Region& region): sc_orient (info->reader->asset, info->reader->resource, "/orbit_info/sc_orient", &info->reader->context), segment_delta_time (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/delta_time").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), segment_id (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "geolocation/segment_id").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), @@ -425,7 +425,7 @@ Atl03Viewer::Atl03Data::~Atl03Data (void) = default; void* Atl03Viewer::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Atl03Viewer* reader = info->reader; stats_t local_stats = {0, 0, 0, 0, 0}; @@ -441,18 +441,15 @@ void* Atl03Viewer::subsettingThread (void* parm) /* Read ATL03 Datasets */ const Atl03Data atl03(info, region); - /* Get Number of Segments */ - const long num_segments = region.num_segments != H5Coro::ALL_ROWS ? region.num_segments : atl03.segment_delta_time.size; - /* Increment Read Statistics */ - local_stats.segments_read = num_segments; + local_stats.segments_read = region.num_segments; List segments; const uint32_t max_segments_per_extent = 256; /* Loop Through Each Segment */ - for(long s = 0; reader->active && s < num_segments; s++) + for(long s = 0; reader->active && s < region.num_segments; s++) { /* Skip segments with zero photon count */ if(region.segment_ph_cnt[s] == 0) continue; diff --git a/plugins/icesat2/plugin/Atl03Viewer.h b/plugins/icesat2/plugin/Atl03Viewer.h index 3dfac51e1..ad0d3d5a3 100644 --- a/plugins/icesat2/plugin/Atl03Viewer.h +++ b/plugins/icesat2/plugin/Atl03Viewer.h @@ -134,12 +134,12 @@ class Atl03Viewer: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array segment_lat; H5Array segment_lon; @@ -157,7 +157,7 @@ class Atl03Viewer: public LuaObject { public: - Atl03Data (info_t* info, const Region& region); + Atl03Data (const info_t* info, const Region& region); ~Atl03Data (void); /* Read Data */ diff --git a/plugins/icesat2/plugin/Atl06Reader.cpp b/plugins/icesat2/plugin/Atl06Reader.cpp index aa4f25152..583702d1a 100644 --- a/plugins/icesat2/plugin/Atl06Reader.cpp +++ b/plugins/icesat2/plugin/Atl06Reader.cpp @@ -240,7 +240,7 @@ Atl06Reader::~Atl06Reader (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -Atl06Reader::Region::Region (info_t* info): +Atl06Reader::Region::Region (const info_t* info): latitude (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "land_ice_segments/latitude").c_str(), &info->reader->context), longitude (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "land_ice_segments/longitude").c_str(), &info->reader->context), inclusion_mask {NULL}, @@ -267,7 +267,7 @@ Atl06Reader::Region::Region (info_t* info): } else { - return; // early exit since no subsetting required + num_segments = latitude.size; } /* Check If Anything to Process */ @@ -308,7 +308,7 @@ void Atl06Reader::Region::cleanup (void) /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void Atl06Reader::Region::polyregion (info_t* info) +void Atl06Reader::Region::polyregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -354,7 +354,7 @@ void Atl06Reader::Region::polyregion (info_t* info) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void Atl06Reader::Region::rasterregion (info_t* info) +void Atl06Reader::Region::rasterregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -409,7 +409,7 @@ void Atl06Reader::Region::rasterregion (info_t* info) /*---------------------------------------------------------------------------- * Atl06Data::Constructor *----------------------------------------------------------------------------*/ -Atl06Reader::Atl06Data::Atl06Data (info_t* info, const Region& region): +Atl06Reader::Atl06Data::Atl06Data (const info_t* info, const Region& region): sc_orient (info->reader->asset, info->reader->resource, "/orbit_info/sc_orient", &info->reader->context), delta_time (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "land_ice_segments/delta_time").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), h_li (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "land_ice_segments/h_li").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), @@ -484,9 +484,9 @@ Atl06Reader::Atl06Data::Atl06Data (info_t* info, const Region& region): void* Atl06Reader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Atl06Reader* reader = info->reader; - Icesat2Parms* parms = reader->parms; + const Icesat2Parms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; vector rec_vec; diff --git a/plugins/icesat2/plugin/Atl06Reader.h b/plugins/icesat2/plugin/Atl06Reader.h index e7f7b3f5e..015d3d95f 100644 --- a/plugins/icesat2/plugin/Atl06Reader.h +++ b/plugins/icesat2/plugin/Atl06Reader.h @@ -147,12 +147,12 @@ class Atl06Reader: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array latitude; H5Array longitude; @@ -169,7 +169,7 @@ class Atl06Reader: public LuaObject { public: - Atl06Data (info_t* info, const Region& region); + Atl06Data (const info_t* info, const Region& region); ~Atl06Data (void) = default; /* Read Data */ diff --git a/plugins/icesat2/plugin/Atl13Reader.cpp b/plugins/icesat2/plugin/Atl13Reader.cpp index f54c98f99..901ae96cf 100644 --- a/plugins/icesat2/plugin/Atl13Reader.cpp +++ b/plugins/icesat2/plugin/Atl13Reader.cpp @@ -229,7 +229,7 @@ Atl13Reader::~Atl13Reader (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -Atl13Reader::Region::Region (info_t* info): +Atl13Reader::Region::Region (const info_t* info): latitude (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "segment_lat").c_str(), &info->reader->context), longitude (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "segment_lon").c_str(), &info->reader->context), inclusion_mask {NULL}, @@ -256,7 +256,7 @@ Atl13Reader::Region::Region (info_t* info): } else { - return; // early exit since no subsetting required + num_segments = latitude.size; } /* Check If Anything to Process */ @@ -297,7 +297,7 @@ void Atl13Reader::Region::cleanup (void) /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void Atl13Reader::Region::polyregion (info_t* info) +void Atl13Reader::Region::polyregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -343,7 +343,7 @@ void Atl13Reader::Region::polyregion (info_t* info) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void Atl13Reader::Region::rasterregion (info_t* info) +void Atl13Reader::Region::rasterregion (const info_t* info) { /* Find First Segment In Polygon */ bool first_segment_found = false; @@ -398,7 +398,7 @@ void Atl13Reader::Region::rasterregion (info_t* info) /*---------------------------------------------------------------------------- * Atl13Data::Constructor *----------------------------------------------------------------------------*/ -Atl13Reader::Atl13Data::Atl13Data (info_t* info, const Region& region): +Atl13Reader::Atl13Data::Atl13Data (const info_t* info, const Region& region): sc_orient (info->reader->asset, info->reader->resource, "/orbit_info/sc_orient", &info->reader->context), delta_time (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "delta_time").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), segment_id_beg (info->reader->asset, info->reader->resource, FString("%s/%s", info->prefix, "segment_id_beg").c_str(), &info->reader->context, 0, region.first_segment, region.num_segments), @@ -464,9 +464,9 @@ Atl13Reader::Atl13Data::~Atl13Data (void) = default; void* Atl13Reader::subsettingThread (void* parm) { /* Get Thread Info */ - info_t* info = static_cast(parm); + const info_t* info = static_cast(parm); Atl13Reader* reader = info->reader; - Icesat2Parms* parms = reader->parms; + const Icesat2Parms* parms = reader->parms; stats_t local_stats = {0, 0, 0, 0, 0}; vector rec_vec; @@ -518,7 +518,7 @@ void* Atl13Reader::subsettingThread (void* parm) entry->longitude = region.longitude[segment]; entry->snow_ice_atl09 = atl13.snow_ice_atl09[segment]; entry->cloud_flag_asr_atl09 = atl13.cloud_flag_asr_atl09[segment]; - entry->ht_ortho = atl13.ht_ortho[segment] != numeric_limits::max() ? atl13.ht_ortho[segment] : numeric_limits::quiet_NaN(); + entry->ht_ortho = atl13.ht_ortho[segment] != numeric_limits::max() ? atl13.ht_ortho[segment] : numeric_limits::quiet_NaN(); entry->ht_water_surf = atl13.ht_water_surf[segment] != numeric_limits::max() ? atl13.ht_water_surf[segment] : numeric_limits::quiet_NaN(); entry->segment_azimuth = atl13.segment_azimuth[segment] != numeric_limits::max() ? atl13.segment_azimuth[segment] : numeric_limits::quiet_NaN(); entry->segment_quality = nomial_segment_quality != numeric_limits::max() ? atl13.segment_quality[segment] : 0; diff --git a/plugins/icesat2/plugin/Atl13Reader.h b/plugins/icesat2/plugin/Atl13Reader.h index fd39c43d7..618f298e4 100644 --- a/plugins/icesat2/plugin/Atl13Reader.h +++ b/plugins/icesat2/plugin/Atl13Reader.h @@ -140,12 +140,12 @@ class Atl13Reader: public LuaObject { public: - explicit Region (info_t* info); + explicit Region (const info_t* info); ~Region (void); void cleanup (void); - void polyregion (info_t* info); - void rasterregion (info_t* info); + void polyregion (const info_t* info); + void rasterregion (const info_t* info); H5Array latitude; H5Array longitude; @@ -162,7 +162,7 @@ class Atl13Reader: public LuaObject { public: - Atl13Data (info_t* info, const Region& region); + Atl13Data (const info_t* info, const Region& region); ~Atl13Data (void); /* Read Data */ diff --git a/plugins/icesat2/selftests/atl03_ancillary.lua b/plugins/icesat2/selftests/atl03_ancillary.lua index 021d7d8a5..76176f892 100644 --- a/plugins/icesat2/selftests/atl03_ancillary.lua +++ b/plugins/icesat2/selftests/atl03_ancillary.lua @@ -35,8 +35,8 @@ while true do runner.check(rec:getvalue("count") == 2, rec:getvalue("count")) end -runner.check(cnt >= 16697, "failed to read sufficient number of contaner records") - +local expected_cnt = 21748 +runner.check(cnt == expected_cnt, string.format('failed to read sufficient number of container records, expected: %d, got: %d', expected_cnt, cnt)) -- Clean Up -- recq:destroy() diff --git a/plugins/swot/plugin/SwotL2Reader.cpp b/plugins/swot/plugin/SwotL2Reader.cpp index 97fa57210..ad208c307 100644 --- a/plugins/swot/plugin/SwotL2Reader.cpp +++ b/plugins/swot/plugin/SwotL2Reader.cpp @@ -211,7 +211,7 @@ SwotL2Reader::~SwotL2Reader (void) /*---------------------------------------------------------------------------- * Region::Constructor *----------------------------------------------------------------------------*/ -SwotL2Reader::Region::Region (Asset* asset, const char* resource, SwotParms* _parms, H5Coro::context_t* context): +SwotL2Reader::Region::Region (Asset* asset, const char* resource, const SwotParms* _parms, H5Coro::context_t* context): lat (asset, resource, "latitude_nadir", context), lon (asset, resource, "longitude_nadir", context), inclusion_mask (NULL), @@ -236,7 +236,7 @@ SwotL2Reader::Region::Region (Asset* asset, const char* resource, SwotParms* _pa } else { - num_lines = MIN(lat.size, lon.size); + num_lines = lat.size; } /* Trim Geospatial Datasets Read from File */ @@ -263,7 +263,7 @@ void SwotL2Reader::Region::cleanup (void) const /*---------------------------------------------------------------------------- * Region::polyregion *----------------------------------------------------------------------------*/ -void SwotL2Reader::Region::polyregion (SwotParms* _parms) +void SwotL2Reader::Region::polyregion (const SwotParms* _parms) { /* Find First and Last Lines in Polygon */ bool first_line_found = false; @@ -310,7 +310,7 @@ void SwotL2Reader::Region::polyregion (SwotParms* _parms) /*---------------------------------------------------------------------------- * Region::rasterregion *----------------------------------------------------------------------------*/ -void SwotL2Reader::Region::rasterregion (SwotParms* _parms) +void SwotL2Reader::Region::rasterregion (const SwotParms* _parms) { /* Allocate Inclusion Mask */ if(lat.size <= 0) return; diff --git a/plugins/swot/plugin/SwotL2Reader.h b/plugins/swot/plugin/SwotL2Reader.h index 8c47e4a92..7f16d3087 100644 --- a/plugins/swot/plugin/SwotL2Reader.h +++ b/plugins/swot/plugin/SwotL2Reader.h @@ -130,12 +130,12 @@ class SwotL2Reader: public LuaObject /* Region Subclass */ struct Region { - Region (Asset* asset, const char* resource, SwotParms* _parms, H5Coro::context_t* context); + Region (Asset* asset, const char* resource, const SwotParms* _parms, H5Coro::context_t* context); ~Region (void); void cleanup (void) const; - void polyregion (SwotParms* _parms); - void rasterregion (SwotParms* _parms); + void polyregion (const SwotParms* _parms); + void rasterregion (const SwotParms* _parms); H5Array lat; H5Array lon;