Added tests for rot_elements_at_epoch function #602
Conversation
Hi @amsuhane, thanks for this pull request! I will need some more time to read the tests because they are a bit long, but in the meanwhile could you please fix the import order? The "quality" step is failing because of that reason. You can apply isort yourself using |
Codecov Report
@@ Coverage Diff @@
## master #602 +/- ##
==========================================
+ Coverage 85.03% 87.51% +2.47%
==========================================
Files 51 51
Lines 2386 2386
Branches 183 183
==========================================
+ Hits 2029 2088 +59
+ Misses 308 249 -59
Partials 49 49
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #602 +/- ##
==========================================
+ Coverage 84.87% 87.28% +2.41%
==========================================
Files 51 51
Lines 2446 2446
Branches 191 191
==========================================
+ Hits 2076 2135 +59
+ Misses 319 260 -59
Partials 51 51
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, but the tests are so long that in general from a quick overview it's difficult to understand what are we testing. It is only the values of the constants? I'm not sure where does all that logic come from, but it's essential to document it and find out if we can simplify it.
ra = (281.01 - 0.033 * T) * u.deg | ||
dec = (61.45 - 0.005 * T) * u.deg | ||
W = (329.548 + 6.1385025 * d) * u.deg | ||
ra = (281.0097 - 0.0328 * T) * u.deg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please write a link at the top of the file to see where can we get these values from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was not done yet? We should have this information in the code, not only in the tests. Just a line in the top docstring stating where do they come from, as it's done in other modules.
Orientation models to calculate the rotational elements (ICRF right ascension and declination and prime meridian location) are given in the kernel file "pck00010.tpc", provided by Nasa. These models have been used to calculate the rotational elements. The kernel file provides the coefficients of polynomials and trigonometric terms of the models. Hence, in the tests, coefficients are taken from the kernel file and plugged into the polynomial/trigonometric terms. Url for kernel file is https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00010.tpc |
@Juanlu001 I am not sure how to correct the error |
Perhaps because you already created the directory? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left only one comment.
@@ -90,9 +91,23 @@ def test_from_relative(): | |||
|
|||
|
|||
class TestRotElements: | |||
|
|||
"""Orientation models to calculate the rotational elements (ICRF right ascension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
May I request that the only two SPICE experts that I know, @AndrewAnnex and @marcsit, take a look at this pull request when they have the time and will to do so? 😊 It would be great to confirm that we are following the right approach here. |
I just discovered https://github.com/esaSPICEservice/spiops by the way, in case it's any useful. |
I'll look into spiops. Thanks for the link! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some extra comments. Also, this will need a git rebase
on current master
.
ra = (281.01 - 0.033 * T) * u.deg | ||
dec = (61.45 - 0.005 * T) * u.deg | ||
W = (329.548 + 6.1385025 * d) * u.deg | ||
ra = (281.0097 - 0.0328 * T) * u.deg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was not done yet? We should have this information in the code, not only in the tests. Just a line in the top docstring stating where do they come from, as it's done in other modules.
BODY599_NUT_PREC_RA = spice.gdpool("BODY599_NUT_PREC_RA", 0, 15) | ||
BODY599_NUT_PREC_DEC = spice.gdpool("BODY599_NUT_PREC_DEC", 0, 15) | ||
|
||
Ja = BODY5_NUT_PREC_ANGLES[20] + BODY5_NUT_PREC_ANGLES[21] * T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was shocked when I saw the code the first time some days ago, but then I realized it's exactly the same logic we're applying in bodies.py
. Perhaps it would be better to have functions that can be reused, so they just receive appropriate numerical values? That would make these tests shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll start working on the functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to write functions that would help in reducing the length of the tests. The problem is that the big tests are unique and there isn't a generalized way of calculating them. So, I'll just end up passing all the coefficients in the functions, which won't really make the tests shorter Instead, I was thinking I could just write them in a more compact like:
instead of
Changes to improve code-quality
Minor code-quality changes
Added documentation for added test
d0c34b0
to
2d731d7
Compare
Validating against SPICE (using SpiceyPy for example) is something we would also move to https://github.com/poliastro/validation/, so I am closing this. Thanks again @amsuhane for the massive effort in building this pull request. |
Added tests for rot_elements_at_epoch function