Extending tide prediction to Landsat and NISAR & adding S2C#54
Conversation
Code Review FindingsFound several issues that need attention: Critical: UTC hour rollover bug (P1)Affects: Both files compute UTC hours with Impact:
Fix: Build result from Behavioral issue: Tide filtering drops passes (P2)Affects: When
Test runner crashAffects: The Fix: tests = [test_utc_datetime, test_non_utc_datetime, test_naive_datetime, test_datetime_list]
results = []
for test in tests:
try:
test()
results.append(True)
except AssertionError as e:
print(f"FAILED: {test.__name__}: {e}")
results.append(False) |
|
** Issue 1 fixed with d116594 and 1dc5a77. The solution is to use datetime.combine() + timedelta to let the arithmetic naturally roll the date: ** Issue 2: The concern is that if we add tide prediction for all overpasses including those beyond the 60 days filter, the results will be hard to read and interpret. Therefore, we keep the current filtering behavior (hide dates beyond 60 days entirely), but add a summary line at the end to let users know about the hidden future passes. The user can always re-run without -t to check overpasses beyond 60 days if needed. Note that the 60 days filtering applies only to Landsat and NISAR. ** issue 3: Fixed test runner crash by wrapping test function calls in try/except blocks to explicitly track pass/fail status (True/False) instead of relying on implicit None returns that caused TypeError |
|
Here are some recommendations to improve maintainability: 1. Extract duplicate 60-day filtering logicThe same filtering logic appears in both def filter_future_dates(dates, tide_data, max_days=60):
"""Filter dates/tides to only those within max_days from now."""
# Shared implementation
passThis would reduce duplication and make the 60-day limit easier to adjust in the future. 2. Convert magic numbers to named constantsSeveral hardcoded values should be module-level constants: # utils/landsat_pass.py:636
LANDSAT_EQUATORIAL_CROSSING_HOUR = 10.2 # 10:12 AM local solar time
# utils/nisar_pass.py:1041-1044
NISAR_ASCENDING_CROSSING_HOUR = 6.0 # 6:00 AM local solar time
NISAR_DESCENDING_CROSSING_HOUR = 18.0 # 6:00 PM local solar timeThis improves readability and makes the orbital specifications more discoverable. 3. Add accuracy disclaimer to CLI outputThe overpass time estimates have ±15-40 minute accuracy (documented in docstrings), but users don't see this. Consider adding a note to the table output: This sets proper expectations for the tide predictions. 4. Document pass count filtering behaviorWhen
Example help text: |


The tide prediction feature (-t flag) previously worked only for Sentinel-1/2, since ESA provides exact overpass times.
This PR extends the same NOAA tide prediction feature to Landsat 8/9 and NISAR overpasses.
** What's new:
** Usage, unchanged from for only Sentinel :
next-pass -b 43.219 45.15 -124.398 -122.2 -t
In this PR, we also fix an issue with the calculation of the percentage of overlap between the overpass and AOI for Landsat. The problem was that when there are multiple rows that intersect with the AOI for the same path/direction/mission combination, the code was adding the intersection percentages together instead of merging the geometries first. The applied change is moving from overlap_pct += intersection_pct (adding percentages) to calculating the intersection once from the geometry of all rows.