Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and improve tests concerning the TLE file handling #118

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

adybbroe
Copy link
Contributor

@adybbroe adybbroe commented Feb 15, 2023

This PR was originally started to introduce support for NOAA-21.

The PR started out attempting to address an issue found when the user requests TLEs for a name not matching what is in the platforms.txt file and only partially matching what name is written in the TLE files. In particular this was a bit confusing when NOAA-21 was newly introduced and the name was NOAA 21 (JPSS-2)in the TLE files from Space_Track/Celetrak, while for NOAA-20 the name was NOAA 20 in the same files.

Support for NOAA-21 was actually already included in #113 but that PR is about environment variables.

@adybbroe adybbroe self-assigned this Feb 15, 2023
…e automated bots for checking code quality and tests

Signed-off-by: Adam.Dybbroe <[email protected]>
@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Attention: Patch coverage is 93.18182% with 45 lines in your changes missing coverage. Please review.

Project coverage is 88.36%. Comparing base (8d982a9) to head (3499641).
Report is 124 commits behind head on main.

Files with missing lines Patch % Lines
pyorbital/orbital.py 86.00% 14 Missing ⚠️
pyorbital/fetch_tles.py 0.00% 9 Missing ⚠️
pyorbital/tlefile.py 91.66% 7 Missing ⚠️
pyorbital/geoloc_example.py 0.00% 6 Missing ⚠️
pyorbital/astronomy.py 88.57% 4 Missing ⚠️
pyorbital/tests/test_astronomy.py 92.50% 3 Missing ⚠️
pyorbital/check_platform.py 0.00% 1 Missing ⚠️
pyorbital/tests/test_tlefile.py 99.60% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   87.51%   88.36%   +0.85%     
==========================================
  Files          15       16       +1     
  Lines        2211     2373     +162     
==========================================
+ Hits         1935     2097     +162     
  Misses        276      276              
Flag Coverage Δ
unittests 88.36% <93.18%> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@adybbroe
Copy link
Contributor Author

While working with this PR and upgrading our systems for NOAA-21 at SMHI we realized that there seem to be a bug here, standing in the way of updating support for NOAA-21, see #119
So, perhaps this PR should try fix this as well?

# Conflicts:
#	pyorbital/tests/test_tlefile.py
#	pyorbital/tlefile.py
@coveralls
Copy link

coveralls commented Nov 23, 2024

Coverage Status

coverage: 88.326% (+0.4%) from 87.904%
when pulling 3499641 on adybbroe:add-jpss2
into 9700076 on pytroll:main.

@adybbroe
Copy link
Contributor Author

adybbroe commented Nov 23, 2024

I have come to the conclusion that there is really no serious issue easily solved as otherwise suggested in #119
Either the user specify a WMO Oscar based satellite name matching what is in the platforms.txt, so NOAA-21 (already in main) or the user must specify an exact match to what is written in the TLE files. So if the TLE files look like this:

NOAA 21 (JPSS-2)        
1 54234U 22150A   23045.56664999  .00000332  00000+0  17829-3 0  9993
2 54234  98.7059 345.5113 0001226  81.6523 278.4792 14.19543871 13653

The use must use either WMO-Oscar satellite name NOAA-21or specify NOAA 21 (JPSS-2) as the platform name, as in:
tle_jpss2 = tlefile.read('NOAA 21 (JPSS-2)', './jpss2.tle')

The only thing this PR does now is to add a debug message indicating that there might be a match in the TLE file for the the satellite the user is wanting the TLEs for. So, like:

>>> tle_metop = tlefile.read('Metop', '/data/tles/tle-202409060015.txt')
[DEBUG: 2024-11-23 14:30:03 : pyorbital.tlefile] Path to the Pyorbital configuration (where e.g. platforms.txt is found): /home/a000680/usr/src/forks/pyorbital/pyorbital/etc
[DEBUG: 2024-11-23 14:30:03 : pyorbital.tlefile] Found a possible match: METOP-B?
[DEBUG: 2024-11-23 14:30:03 : pyorbital.tlefile] Found a possible match: METOP-C?

And:

>>> tle_n21 = tlefile.read('NOAA 21', './jpss2.tle')
[DEBUG: 2024-11-23 14:38:15 : pyorbital.tlefile] Path to the Pyorbital configuration (where e.g. platforms.txt is found): /home/a000680/usr/src/forks/pyorbital/pyorbital/etc
[DEBUG: 2024-11-23 14:38:15 : pyorbital.tlefile] Found a possible match: NOAA 21 (JPSS-2)?

It means that in case the user gives a name like "NOAA" or "Metop" or even "N" or something far from a real satellite name, there might be several debug messages with more or less useful suggestions. But I think that can be accepted.

Okay?

Comment on lines +382 to +383
elif l_0.startswith(platform) and platform not in SATELLITES:
LOGGER.debug("Found a possible match: %s?", str(l_0.strip()))
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering should there be something other than just the log message here? The tests pass, but 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering should there be something other than just the log message here? The tests pass, but 🤷‍♂️

Did you read my discussion above?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, just wanted to solve the pre-commit complaint and afterwards got confused about the former title and description of the issue 😅

Copy link
Member

@pnuu pnuu Nov 26, 2024

Choose a reason for hiding this comment

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

Should the message say that the possible match isn't used? Something like

Suggested change
elif l_0.startswith(platform) and platform not in SATELLITES:
LOGGER.debug("Found a possible match: %s?", str(l_0.strip()))
elif l_0.startswith(platform) and platform not in SATELLITES:
LOGGER.debug("Found a partial match: %s. TLE not used.", str(l_0.strip()))

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

Umm, this PR currently actually does only do refactoring and not add the mentioned NOAA-21 to the platforms.txt. So git commit missing @adybbroe ?

@adybbroe
Copy link
Contributor Author

Umm, this PR currently actually does only do refactoring and not add the mentioned NOAA-21 to the platforms.txt. So git commit missing @adybbroe ?

Yeah right, after a long discussion (mainly with myself) it ended up differently from what I anticipated when I started. Should we rename it then? I am okay with that!

@adybbroe adybbroe changed the title Add NOAA-21 support Refactor and improve tests concerning the TLE file handling Nov 25, 2024
@adybbroe
Copy link
Contributor Author

Umm, this PR currently actually does only do refactoring and not add the mentioned NOAA-21 to the platforms.txt. So git commit missing @adybbroe ?

Better now @pnuu ?

@pnuu
Copy link
Member

pnuu commented Nov 26, 2024

Better now @pnuu ?

Much better! Now the title and description match what's being changed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for review
Development

Successfully merging this pull request may close these issues.

tlefile.py seem to use satellite name rather than the international designator number
4 participants