Skip to content

Commit

Permalink
Code review vol. 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kautlenbachs committed Mar 15, 2024
1 parent 6cd3cce commit 2d8e254
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion envisat_format/include/ers_sbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace alus::asar::envformat::ers {

void RegisterPatc(const aux::Patc& patc);
// TODO - Develop mechanism for SBT repeated values timespan.
void AdjustIspSensingTime(mjd& isp_sensing_time, uint32_t sbt, uint32_t sbt_repeat, bool overflow = false);

} // namespace alus::asar::envformat::ers
2 changes: 1 addition & 1 deletion envisat_format/src/envisat_aux_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ std::optional<Patc> GetTimeCorrelation(std::string_view aux_root) {
throw std::runtime_error("The auxiliary folder - " + std::string(aux_root) + " - does not exist.");
}

const auto& patc_listing = util::filesystem::GetFileListingAt(aux_root, patc_reg);
const auto patc_listing = util::filesystem::GetFileListingAt(aux_root, patc_reg);
if (patc_listing.size() > 1) {
throw std::runtime_error("Expected single PATC file in the '" + std::string(aux_root) + "'. There were " +
std::to_string(patc_listing.size()) + " found.");
Expand Down
13 changes: 9 additions & 4 deletions envisat_format/src/ers_im_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ void InitializeDataRecordNo(const uint8_t* packet_start, uint32_t& dr_no) {
}

void FetchSatelliteBinaryTime(const uint8_t* packet_start, uint32_t& sbt) {
/*
* The update of that binary counter shall occur every 4th PRI.
* The time relation to the echo data in the format is as following:
* the transfer of the ICU on-board time to the auxiliary memory
* occurs t2 before the RF transmit pulse as depicted in
* Fig. 4.4.2.4.6-3. The least significant bit is equal to 1/256 sec.
*
* ER-IS-ESA-GS-0002 - pg. 4.4 - 24
*/
FetchUint32(packet_start + alus::asar::envformat::ers::highrate::SBT_OFFSET_BYTES, sbt);
}

Expand Down Expand Up @@ -448,10 +457,6 @@ RawSampleMeasurements ParseErsLevel0ImPackets(const std::vector<char>& file_data
* ER-IS-ESA-GS-0002 - pg. 4.4 - 24
*/
echo_meta.onboard_time = sbt;
// echo_meta.onboard_time |= static_cast<uint64_t>(it[0]) << 24;
// echo_meta.onboard_time |= static_cast<uint64_t>(it[1]) << 16;
// echo_meta.onboard_time |= static_cast<uint64_t>(it[2]) << 8;
// echo_meta.onboard_time |= static_cast<uint64_t>(it[3]) << 0;
it += 4;
/*
* This word shall define the activity task within the mode of
Expand Down
2 changes: 1 addition & 1 deletion envisat_format/src/ers_sbt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void AdjustIspSensingTime(mjd& isp_sensing_time, uint32_t sbt, uint32_t, bool ov
delta_count = parseutil::CounterGap<uint32_t, SBT_MAX>(patc_cor.sbt_counter, sbt);
}
const int64_t nanoseconds_diff = static_cast<int64_t>(patc_cor.sbt_period) * delta_count;
const auto microseconds_val = static_cast<int64_t>(nanoseconds_diff / 1e3);
const auto microseconds_val = static_cast<int64_t>(nanoseconds_diff / 1000);
adjusted_ptime = patc_time_point + boost::posix_time::microseconds(microseconds_val);

isp_sensing_time = PtimeToMjd(adjusted_ptime);
Expand Down
2 changes: 1 addition & 1 deletion envisat_format/unit-test/ers_sbt_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST(ErsSbt, WhenEpochIsNegativeRegisterPatcThrows) {

TEST(ErsSbt, WhenEpochIsEarlierThan1990RegisterPatcThrows) {
Patc p{};
p.epoch_1950 = 14974;
p.epoch_1950 = 14974; // Difference of days between 1950 Jan 1st and 1990 Dec 31st.
EXPECT_THROW(RegisterPatc(p), std::runtime_error);
}

Expand Down

0 comments on commit 2d8e254

Please sign in to comment.