Skip to content

Commit

Permalink
Merge pull request #414 from SlideRuleEarth/allrowsfix
Browse files Browse the repository at this point in the history
h5coro allrows (-1) fix for icesat2 and gedi readers
  • Loading branch information
jpswinski authored Jun 19, 2024
2 parents 95a4301 + fd29a80 commit d0c6358
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 123 deletions.
16 changes: 8 additions & 8 deletions plugins/gedi/plugin/FootprintReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> lat;
H5Array<double> lon;
Expand Down Expand Up @@ -301,7 +301,7 @@ FootprintReader<footprint_t>::~FootprintReader (void)
* Region::Constructor
*----------------------------------------------------------------------------*/
template <class footprint_t>
FootprintReader<footprint_t>::Region::Region (info_t* info):
FootprintReader<footprint_t>::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),
Expand All @@ -320,13 +320,13 @@ FootprintReader<footprint_t>::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 */
Expand Down Expand Up @@ -363,7 +363,7 @@ void FootprintReader<footprint_t>::Region::cleanup (void)
* Region::polyregion
*----------------------------------------------------------------------------*/
template <class footprint_t>
void FootprintReader<footprint_t>::Region::polyregion (info_t* info)
void FootprintReader<footprint_t>::Region::polyregion (const info_t* info)
{
/* Find First and Last Footprints in Polygon */
bool first_footprint_found = false;
Expand Down Expand Up @@ -409,7 +409,7 @@ void FootprintReader<footprint_t>::Region::polyregion (info_t* info)
* Region::rasterregion
*----------------------------------------------------------------------------*/
template <class footprint_t>
void FootprintReader<footprint_t>::Region::rasterregion (info_t* info)
void FootprintReader<footprint_t>::Region::rasterregion (const info_t* info)
{
/* Allocate Inclusion Mask */
if(lat.size <= 0) return;
Expand Down
6 changes: 3 additions & 3 deletions plugins/gedi/plugin/Gedi01bReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -164,7 +164,7 @@ Gedi01bReader::Gedi01b::~Gedi01b (void) = default;
void* Gedi01bReader::subsettingThread (void* parm)
{
/* Get Thread Info */
info_t* info = static_cast<info_t*>(parm);
const info_t* info = static_cast<info_t*>(parm);
Gedi01bReader* reader = reinterpret_cast<Gedi01bReader*>(info->reader);
const GediParms* parms = reader->parms;
stats_t local_stats = {0, 0, 0, 0, 0};
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/gedi/plugin/Gedi01bReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Gedi01bReader: public FootprintReader<g01b_footprint_t>
{
public:

Gedi01b (info_t* info, Region& region);
Gedi01b (const info_t* info, const Region& region);
~Gedi01b (void);

H5Array<uint64_t> shot_number;
Expand Down
32 changes: 16 additions & 16 deletions plugins/gedi/plugin/Gedi02aReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -160,7 +160,7 @@ Gedi02aReader::Gedi02a::~Gedi02a (void) = default;
void* Gedi02aReader::subsettingThread (void* parm)
{
/* Get Thread Info */
info_t* info = static_cast<info_t*>(parm);
const info_t* info = static_cast<info_t*>(parm);
Gedi02aReader* reader = reinterpret_cast<Gedi02aReader*>(info->reader); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
const GediParms* parms = reader->parms;
stats_t local_stats = {0, 0, 0, 0, 0};
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion plugins/gedi/plugin/Gedi02aReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Gedi02aReader: public FootprintReader<g02a_footprint_t>
{
public:

Gedi02a (info_t* info, Region& region);
Gedi02a (const info_t* info, const Region& region);
~Gedi02a (void);

H5Array<uint64_t> shot_number;
Expand Down
6 changes: 3 additions & 3 deletions plugins/gedi/plugin/Gedi04aReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -163,7 +163,7 @@ Gedi04aReader::Gedi04a::~Gedi04a (void) = default;
void* Gedi04aReader::subsettingThread (void* parm)
{
/* Get Thread Info */
info_t* info = static_cast<info_t*>(parm);
const info_t* info = static_cast<info_t*>(parm);
Gedi04aReader* reader = reinterpret_cast<Gedi04aReader*>(info->reader);
const GediParms* parms = reader->parms;
stats_t local_stats = {0, 0, 0, 0, 0};
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/gedi/plugin/Gedi04aReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Gedi04aReader: public FootprintReader<g04a_footprint_t>
{
public:

Gedi04a (info_t* info, Region& region);
Gedi04a (const info_t* info, const Region& region);
~Gedi04a (void);

H5Array<uint64_t> shot_number;
Expand Down
23 changes: 14 additions & 9 deletions plugins/icesat2/plugin/Atl03BathyReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,)"
Expand All @@ -778,9 +783,9 @@ const char* Atl03BathyReader::OrbitInfo::tojson (void) const
void* Atl03BathyReader::subsettingThread (void* parm)
{
/* Get Thread Info */
info_t* info = static_cast<info_t*>(parm);
const info_t* info = static_cast<info_t*>(parm);
Atl03BathyReader* reader = info->reader;
BathyParms* parms = reader->parms;
const BathyParms* parms = reader->parms;
RasterObject* ndwiRaster = RasterObject::cppCreate(reader->geoparms);

/* Thread Variables */
Expand Down
16 changes: 8 additions & 8 deletions plugins/icesat2/plugin/Atl03BathyReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<double> segment_lat;
H5Array<double> segment_lon;
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -233,7 +233,7 @@ class Atl03BathyReader: public LuaObject
};

/* AncillaryData SubClass */
class AncillaryData
class AncillaryData
{
public:

Expand Down Expand Up @@ -267,7 +267,7 @@ class Atl03BathyReader: public LuaObject
};

/* OrbitInfo SubClass */
class OrbitInfo
class OrbitInfo
{
public:

Expand Down
Loading

0 comments on commit d0c6358

Please sign in to comment.