Skip to content

Optimization with Time Flag#60

Open
Eesha-Jain wants to merge 20 commits intomainfrom
optimization-with-time-flag
Open

Optimization with Time Flag#60
Eesha-Jain wants to merge 20 commits intomainfrom
optimization-with-time-flag

Conversation

@Eesha-Jain
Copy link
Copy Markdown

@Eesha-Jain Eesha-Jain commented Nov 15, 2025

Description

Resolves #44

Adds a time flag request to found's distance command that marks when the image was taken (in nanoseconds). This allows for a more accurate understanding of the satellite's latitude and longitude. Currently outputs time into the outputted .found file.

This PR also modifies the output of output.cpp's GetEarthCoordinates function to be ECEF coordinates. This is the standard set for representing position by NASA (example: https://ntrs.nasa.gov/api/citations/20190002515/downloads/20190002515.pdf) and other space grade receivers.

Note that the nanoseconds since epoch is being stored as an unsigned 64-bit integer throughout the code. This can reliably store up until the year 2557.

Artifacts for PR #60 (DO NOT CHANGE)

@Eesha-Jain Eesha-Jain linked an issue Nov 15, 2025 that may be closed by this pull request
Comment thread test/integration/integration-test.cpp
Comment thread README.md Outdated
Copilot AI review requested due to automatic review settings December 14, 2025 23:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a --image-time flag to the distance command that records when an image was captured, enabling more accurate satellite position calculations by using the actual image capture time instead of the current system time. The timestamp is stored in the output .found file.

  • Adds new strtodatetime converter function to parse datetime strings in YYYY-MM-DD HH:MM:SS format
  • Replaces automatic timestamp generation with user-provided image capture time in position records
  • Updates all distance command tests and README documentation to include the new time parameter

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/providers/converters.hpp Adds strtodatetime function to convert string timestamps to DateTime structures
src/command-line/parsing/options.hpp Adds image-time option definition for the distance command
src/command-line/execution/executors.cpp Modifies OutputResults to use provided imageTime instead of calling getUT1Time()
test/integration/integration-test.cpp Updates integration tests to include the new --image-time parameter and removes obsolete test
test/command-line/parsing/parser-test.cpp Adds parser tests for the new imageTime field
test/command-line/execution/executors-test.cpp Updates executor test to include sample imageTime data
README.md Updates documentation and examples to show usage of the new --image-time flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread README.md
Comment thread README.md
Comment thread src/providers/converters.hpp
Comment thread README.md Outdated
Copy link
Copy Markdown
Collaborator

@nguy8tri nguy8tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is by no means comprehensive, but great job, just left some comments!

Comment thread src/common/spatial/attitude-utils.hpp Outdated
Comment thread src/common/time/time.cpp Outdated
Comment thread src/common/time/time.hpp Outdated
Comment thread src/common/decimal.hpp Outdated
Comment thread src/distance/output.cpp
Comment thread src/providers/converters.hpp Outdated
Copy link
Copy Markdown
Collaborator

@nguy8tri nguy8tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on the fixes. This time, my comments are more towards having you think critically about some code changes you've made. Please respond to my comments as appropriate. Also if it takes a long time for me to review your code, ping me on slack so I can make time for it.

Comment thread src/common/spatial/attitude-utils.hpp
Comment thread src/common/time/time.cpp Outdated
Comment thread src/common/time/time.cpp Outdated
Comment thread src/common/time/time.cpp Outdated
Comment thread src/common/time/time.cpp Outdated
Comment thread src/distance/output.cpp Outdated
Comment thread src/distance/output.hpp Outdated
Comment thread test/providers/converters-test.cpp Outdated
Comment thread test/providers/converters-test.cpp
Comment thread README.md Outdated
@j4lando
Copy link
Copy Markdown
Contributor

j4lando commented Mar 3, 2026

It might be better to replace celestial coordinate with equatorial coordinate since equatorial coordinates are a specific definition of celestial coordinates.

@Eesha-Jain
Copy link
Copy Markdown
Author

It seems that you changed celestial to equatorial in your PR, so I won't implement that here to prevent merge conflicts in the future

@Eesha-Jain Eesha-Jain force-pushed the optimization-with-time-flag branch from 385ce43 to 1d8013f Compare March 24, 2026 20:44
@Eesha-Jain Eesha-Jain requested a review from nguy8tri March 26, 2026 18:34
Copy link
Copy Markdown
Collaborator

@nguy8tri nguy8tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, just a few more minor comments.

Comment thread src/common/time/time.cpp
decimal getGreenwichMeanSiderealTime(std::time_t epochs) {
return 15 * (DECIMAL(18.697374558) + DECIMAL(24.06570982441908) * (getJulianDateTime(epochs) - DECIMAL(2451545.0)));
decimal getGreenwichMeanSiderealTime(uint64_t epochs) {
return 15 * (DECIMAL(18.697374558) + DECIMAL(24.06570982441908) *
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have constants for these 3

// This is preferable than continuing with invalid data and outputting an unintended
// result.

constexpr int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope to the namespace

// Convert to nanoseconds: seconds * NS_PER_SEC + nanoseconds
uint64_t epochs_ns = static_cast<uint64_t>(t) * NS_PER_SEC + nanosecond;

return {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure there isn't a library function that will do this for us? Please look into that

FOUND_CLI_OPTION("isdda-radius-loss-order" , int , ISDDARadLossOrd , 4 , atoi(optarg) , kNoDefaultArgument, REQ_ASSIGN, "The Radius Loss Order ISSDA (even int)" ) \
FOUND_CLI_OPTION("output-file" , std::string , outputFile , "" , optarg , kNoDefaultArgument, REQ_ASSIGN, "The output file (*.found)" ) \
FOUND_CLI_OPTION("image" , found::Image , image , {} , found::strtoimage(optarg) , kNoDefaultArgument, REQ_ASSIGN, "The image to process (JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC)") \
FOUND_CLI_OPTION("image-time" , found::DateTime , imageTime , {} , found::strtodatetime(optarg), kNoDefaultArgument, REQ_ASSIGN, "Image capture time (in UT1 in format YYYY-MM-DD HH:MM:SS.NS)" ) \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its unclear how many nano seconds, or if its required. It may add value to be flexible about the format, maybe not. Usually libraries will parse a string into a date.


// Test Time (epochs in nanoseconds: 1762889400 seconds * NS_PER_SEC)
DateTime expectedImageTime{1762889400000000000ULL, 2025, 11, 11, 19, 30, 0};
ASSERT_EQ(expectedImageTime.epochs, options.imageTime.epochs);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a helper macro that will assert over an entire Date time so we can do something like ASSET_TIME(expected, actual)

Comment thread test/common/common.hpp
ASSERT_GE(num, lo) << "Value " << num << " is less than lower bound " << lo; \
ASSERT_LE(num, hi) << "Value " << num << " is greater than upper bound " << hi;

#define ASSERT_DATETIME_EQ(expected, actual) \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah here it is

Comment thread README.md
--camera-focal-length 85e-3 \
--camera-pixel-size 20e-6 \
--reference-orientation 110,0,0
--reference-orientation 110,0,0 \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, there should not have a line continuation at the last one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement/Optimization: Time Flag

4 participants