Skip to content

Commit

Permalink
atl03 and atl06 endpoint support for ancillary data
Browse files Browse the repository at this point in the history
  • Loading branch information
jpswinski committed Nov 14, 2022
1 parent 2351606 commit a0a2a96
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion plugins/icesat2/endpoints/atl06.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ local atl06_algo = icesat2.atl06(rspq, parms)
local atl06_disp = core.dispatcher(recq)
atl06_disp:attach(atl06_algo, "atl03rec")
atl06_disp:attach(except_pub, "exceptrec") -- exception records
atl06_disp:attach(except_pub, "ga3rec") -- ancillary records
atl06_disp:attach(except_pub, "extrec") -- ancillary records
atl06_disp:run()

-- Post Initial Status Progress --
Expand Down
30 changes: 15 additions & 15 deletions plugins/icesat2/plugin/Atl03Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ const RecordObject::fieldDef_t Atl03Reader::exRecDef[] = {
{"data", RecordObject::USER, offsetof(extent_t, photons), 0, phRecType, NATIVE_FLAGS} // variable length
};

const char* Atl03Reader::geoAncRecType = "ga3rec"; // geo ancillary atl03 record
const RecordObject::fieldDef_t Atl03Reader::geoAncRecDef[] = {
{"extent_id", RecordObject::UINT64, offsetof(geo_anc_t, extent_id), 1, NULL, NATIVE_FLAGS},
{"field_index", RecordObject::UINT8, offsetof(geo_anc_t, field_index), 1, NULL, NATIVE_FLAGS},
{"data_type", RecordObject::UINT8, offsetof(geo_anc_t, data_type), 1, NULL, NATIVE_FLAGS},
{"data", RecordObject::UINT8, offsetof(geo_anc_t, data), 0, NULL, NATIVE_FLAGS} // variable length
const char* Atl03Reader::extAncRecType = "extrec"; // extent ancillary atl03 record
const RecordObject::fieldDef_t Atl03Reader::extAncRecDef[] = {
{"extent_id", RecordObject::UINT64, offsetof(ext_anc_t, extent_id), 1, NULL, NATIVE_FLAGS},
{"field_index", RecordObject::UINT8, offsetof(ext_anc_t, field_index), 1, NULL, NATIVE_FLAGS},
{"data_type", RecordObject::UINT8, offsetof(ext_anc_t, data_type), 1, NULL, NATIVE_FLAGS},
{"data", RecordObject::UINT8, offsetof(ext_anc_t, data), 0, NULL, NATIVE_FLAGS} // variable length
};

const char* Atl03Reader::phAncRecType = "pa3rec"; // photon ancillary atl03 record
const char* Atl03Reader::phAncRecType = "phrec"; // photon ancillary atl03 record
const RecordObject::fieldDef_t Atl03Reader::phAncRecDef[] = {
{"extent_id", RecordObject::UINT64, offsetof(ph_anc_t, extent_id), 1, NULL, NATIVE_FLAGS},
{"field_index", RecordObject::UINT8, offsetof(ph_anc_t, field_index), 1, NULL, NATIVE_FLAGS},
Expand Down Expand Up @@ -156,10 +156,10 @@ void Atl03Reader::init (void)
mlog(CRITICAL, "Failed to define %s: %d", phRecType, rc);
}

rc = RecordObject::defineRecord(geoAncRecType, NULL, sizeof(geo_anc_t), geoAncRecDef, sizeof(geoAncRecDef) / sizeof(RecordObject::fieldDef_t));
rc = RecordObject::defineRecord(extAncRecType, NULL, sizeof(ext_anc_t), extAncRecDef, sizeof(extAncRecDef) / sizeof(RecordObject::fieldDef_t));
if(rc != RecordObject::SUCCESS_DEF)
{
mlog(CRITICAL, "Failed to define %s: %d", geoAncRecType, rc);
mlog(CRITICAL, "Failed to define %s: %d", extAncRecType, rc);
}

rc = RecordObject::defineRecord(phAncRecType, NULL, sizeof(ph_anc_t), phAncRecDef, sizeof(phAncRecDef) / sizeof(RecordObject::fieldDef_t));
Expand Down Expand Up @@ -567,7 +567,7 @@ Atl03Reader::Atl03Data::Atl03Data (info_t* info, Region* region):
anc_photon_data (EXPECTED_NUM_ANC_FIELDS)
{
ancillary_list_t* geo_fields = info->reader->parms->atl03_geo_fields;
ancillary_list_t* photon_fields = info->reader->parms->atl03_photon_fields;
ancillary_list_t* photon_fields = info->reader->parms->atl03_ph_fields;

/* Read Ancillary Geolocation Fields */
if(geo_fields)
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void* Atl03Reader::subsettingThread (void* parm)

/* Ancillary Photon Fields */
bool index_photons = false;
if(reader->parms->atl03_photon_fields)
if(reader->parms->atl03_ph_fields)
{
photon_indices[PRT_LEFT] = new List<int32_t>;
photon_indices[PRT_RIGHT] = new List<int32_t>;
Expand Down Expand Up @@ -1464,7 +1464,7 @@ void* Atl03Reader::subsettingThread (void* parm)

/* Send Ancillary Records */
reader->sendAncillaryGeoRecords(extent->extent_id, info->reader->parms->atl03_geo_fields, &atl03.anc_geo_data, extent_segment, &local_stats);
reader->sendAncillaryPhRecords(extent->extent_id, info->reader->parms->atl03_photon_fields, &atl03.anc_photon_data, &photon_indices[0], &local_stats);
reader->sendAncillaryPhRecords(extent->extent_id, info->reader->parms->atl03_ph_fields, &atl03.anc_photon_data, &photon_indices[0], &local_stats);
}
else // neither pair in extent valid
{
Expand Down Expand Up @@ -1558,9 +1558,9 @@ bool Atl03Reader::sendAncillaryGeoRecords (uint64_t extent_id, ancillary_list_t*
GTDArray* array = field_dict->get((*field_list)[i].getString());

/* Create Ancillary Record */
int record_size = offsetof(geo_anc_t, data) + array->gt[PRT_LEFT].elementSize() + array->gt[PRT_RIGHT].elementSize();
RecordObject record(geoAncRecType, record_size);
geo_anc_t* data = (geo_anc_t*)record.getRecordData();
int record_size = offsetof(ext_anc_t, data) + array->gt[PRT_LEFT].elementSize() + array->gt[PRT_RIGHT].elementSize();
RecordObject record(extAncRecType, record_size);
ext_anc_t* data = (ext_anc_t*)record.getRecordData();

/* Populate Ancillary Record */
data->extent_id = extent_id;
Expand Down
12 changes: 4 additions & 8 deletions plugins/icesat2/plugin/Atl03Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Atl03Reader: public LuaObject
static const char* exRecType;
static const RecordObject::fieldDef_t exRecDef[];

static const char* geoAncRecType;
static const RecordObject::fieldDef_t geoAncRecDef[];
static const char* extAncRecType;
static const RecordObject::fieldDef_t extAncRecDef[];

static const char* phAncRecType;
static const RecordObject::fieldDef_t phAncRecDef[];
Expand Down Expand Up @@ -116,17 +116,13 @@ class Atl03Reader: public LuaObject
photon_t photons[]; // zero length field
} extent_t;

/* Ancillary Extent Record */
typedef struct {
} extent_anc_t;

/* Geo Ancillary Record */
/* Extent Ancillary Record */
typedef struct {
uint64_t extent_id;
uint8_t field_index; // position in request parameter list
uint8_t data_type; // RecordObject::fieldType_t
uint8_t data[];
} geo_anc_t;
} ext_anc_t;

/* Photon Ancillary Record */
typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions plugins/icesat2/plugin/lua_parms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const icesat2_parms_t DefaultParms = {
.extent_length = ATL06_DEFAULT_EXTENT_LENGTH,
.extent_step = ATL06_DEFAULT_EXTENT_STEP,
.atl03_geo_fields = NULL,
.atl03_photon_fields = NULL
.atl03_ph_fields = NULL
};

/******************************************************************************
Expand Down Expand Up @@ -715,8 +715,8 @@ icesat2_parms_t* getLuaIcesat2Parms (lua_State* L, int index)
if(provided) mlog(DEBUG, "ATL03 geo field array detected");
lua_pop(L, 1);

lua_getfield(L, index, LUA_PARM_ATL03_PHOTON_FIELDS);
get_lua_field_list (L, -1, &parms->atl03_photon_fields, &provided);
lua_getfield(L, index, LUA_PARM_ATL03_PH_FIELDS);
get_lua_field_list (L, -1, &parms->atl03_ph_fields, &provided);
if(provided) mlog(DEBUG, "ATL03 photon field array detected");
lua_pop(L, 1);
}
Expand All @@ -737,6 +737,6 @@ void freeLuaIcesat2Parms (const icesat2_parms_t* parms)
{
if(parms->raster) delete parms->raster;
if(parms->atl03_geo_fields) delete parms->atl03_geo_fields;
if(parms->atl03_photon_fields) delete parms->atl03_photon_fields;
if(parms->atl03_ph_fields) delete parms->atl03_ph_fields;
delete parms;
}
4 changes: 2 additions & 2 deletions plugins/icesat2/plugin/lua_parms.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#define LUA_PARM_QUALITY_IMPULSE_RESPONSE "atl03_quality_impulse_response"
#define LUA_PARM_QUALITY_TEP "atl03_quality_tep"
#define LUA_PARM_ATL03_GEO_FIELDS "atl03_geo_fields"
#define LUA_PARM_ATL03_PHOTON_FIELDS "atl03_photon_fields"
#define LUA_PARM_ATL03_PH_FIELDS "atl03_ph_fields"

#define PAIR_TRACKS_PER_GROUND_TRACK 2
#define PRT_LEFT 0
Expand Down Expand Up @@ -227,7 +227,7 @@ typedef struct {
double extent_length; // length of ATL06 extent (meters or segments if dist_in_seg is true)
double extent_step; // resolution of the ATL06 extent (meters or segments if dist_in_seg is true)
ancillary_list_t* atl03_geo_fields; // list of geolocation and geophys_corr fields to associate with an extent
ancillary_list_t* atl03_photon_fields; // list of per-photon fields to associate with an extent
ancillary_list_t* atl03_ph_fields; // list of per-photon fields to associate with an extent
} icesat2_parms_t;

/******************************************************************************
Expand Down

0 comments on commit a0a2a96

Please sign in to comment.