Skip to content

Commit 66797da

Browse files
Update webgeocal tests (#10)
* Fixed with current `version` and `build_id` for NAIF API instance * Fixed solar_system_kernel_set() fixture * Fixed cli ROSETTA kernel set test * Fixed cli ROSETTA frames test * Fixed cli ROSETTA instruments test * Fixed cli ROSETTA state_vector dry run test * Fixed cli ROSETTA bodies test * Bump .github action.yml python version to 3.11 * Add timeout for CWE-400 compliance * Fix Linter E501 Line too long * Fix Linter E275 missing whitespace after keyword * Remove `no-space-check` since it is removed from pylint since version 2.6. See: https://pylint.pycqa.org/en/latest/whatsnew/2/2.6/summary.html#other-changes * Add timeout to requests.post (pylint W3101) * Add too-many-positional-arguments to disable list * Set language to 'en' in sphinx config * Fixed new ROSETTA kernel set id * Updated WGC API version * Fixed results in docs with new values from API
1 parent d80f656 commit 66797da

10 files changed

Lines changed: 87 additions & 85 deletions

File tree

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Continuous Integration
22

33
env:
44
PACKAGE: webgeocalc
5-
PYTHON: 3.8
5+
PYTHON: 3.11
66

77
on:
88
pull_request:

.pylintrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ disable=
143143
C0103, # UPPER_CASE naming style (invalid-name)
144144
C0301, # Line too long (already handle by flake8)
145145
too-many-arguments,
146+
too-many-positional-arguments,
146147
too-many-public-methods,
147148
too-many-lines,
148149
too-many-instance-attributes,
@@ -344,8 +345,6 @@ max-module-lines=1000
344345
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
345346
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
346347
# `empty-line` allows space-only lines.
347-
no-space-check=trailing-comma,
348-
dict-separator
349348

350349
# Allow the body of a class to be on the same line as the declaration if body
351350
# contains single statement.

docs/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ and can be retrieved directly as items:
3838
'WGC2 -- a WebGeocalc Server with enabled API at NAIF, JPL'
3939

4040
>>> API['version']
41-
'2.2.9'
41+
'2.7.6'
4242

4343

4444
Request kernel sets

docs/calculation.rst

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,16 @@ calculated in a desired reference frame:
306306
... verbose = False,
307307
... ).run()
308308
{'DATE': '2012-10-19 09:00:00.000000 UTC',
309-
'DISTANCE': 764142.63776247,
310-
'SPEED': 111.54765899,
311-
'X': 298292.85744169,
312-
'Y': -651606.58468976,
313-
'Z': 265224.81187627,
314-
'D_X_DT': -98.8032491,
315-
'D_Y_DT': -51.73211296,
316-
'D_Z_DT': -2.1416539,
309+
'DISTANCE': 764142.65053372,
310+
'SPEED': 111.54765158,
311+
'X': 298293.06093747,
312+
'Y': -651606.39373107,
313+
'Z': 265225.08895284,
314+
'D_X_DT': -98.80322113,
315+
'D_Y_DT': -51.73215012,
316+
'D_Z_DT': -2.14166057,
317317
'TIME_AT_TARGET': '2012-10-19 08:59:57.451094 UTC',
318-
'LIGHT_TIME': 2.54890548}
318+
'LIGHT_TIME': 2.54890552}
319319

320320
.. important::
321321

@@ -388,7 +388,7 @@ Calculates the angular size of a target as seen by an observer.
388388
... aberration_correction = 'CN+S',
389389
... verbose = False,
390390
... ).run()
391-
{'DATE': '2012-10-19 08:24:00.000000 UTC', 'ANGULAR_SIZE': 0.03037939}
391+
{'DATE': '2012-10-19 08:24:00.000000 UTC', 'ANGULAR_SIZE': 0.03032491}
392392

393393
.. important::
394394

@@ -425,13 +425,13 @@ another reference frame (Frame 2).
425425
... verbose = False,
426426
... ).run()
427427
{'DATE': '2012-10-19 08:24:00.000000 UTC',
428-
'ANGLE3': -20.58940104,
429-
'ANGLE2': 0.01874004,
430-
'ANGLE1': 0.00136319,
431-
'AV_X': 9.94596495e-07,
432-
'AV_Y': -7.23492228e-08,
433-
'AV_Z': -0.00634331,
434-
'AV_MAG': 0.00634331}
428+
'ANGLE3': -19.59511576,
429+
'ANGLE2': -0.00533619,
430+
'ANGLE1': -0.00345332,
431+
'AV_X': -2.8406831e-07,
432+
'AV_Y': 1.83751477e-07,
433+
'AV_Z': -0.00633942,
434+
'AV_MAG': 0.00633942}
435435

436436
.. important::
437437

@@ -479,13 +479,13 @@ target as seen from an observer.
479479
... verbose = False,
480480
... ).run()
481481
{'DATE': '2012-10-19 08:24:00.000000 UTC',
482-
'INCIDENCE_ANGLE': 24.78527742,
483-
'EMISSION_ANGLE': 25.56007298,
484-
'PHASE_ANGLE': 1.00079007,
485-
'OBSERVER_ALTITUDE': 967668.02765637,
486-
'TIME_AT_POINT': '2012-10-19 08:23:56.772207 UTC',
487-
'LIGHT_TIME': 3.2277931,
488-
'LTST': '13:15:59'}
482+
'INCIDENCE_ANGLE': 25.51886414,
483+
'EMISSION_ANGLE': 26.31058362,
484+
'PHASE_ANGLE': 1.00106425,
485+
'OBSERVER_ALTITUDE': 967670.28784259,
486+
'TIME_AT_POINT': '2012-10-19 08:23:56.772199 UTC',
487+
'LIGHT_TIME': 3.22780064,
488+
'LTST': '13:19:56'}
489489

490490
.. important::
491491

@@ -527,16 +527,16 @@ Calculates the sub-solar point on a target as seen from an observer.
527527
... verbose = False,
528528
... ).run()
529529
{'DATE': '2012-10-19 08:24:00.000000 UTC',
530-
'X': 234.00550655,
531-
'Y': -77.32612213,
532-
'Z': 67.42916937,
533-
'SUB_POINT_RADIUS': 255.50851089,
534-
'OBSERVER_ALTITUDE': 967644.15493281,
535-
'INCIDENCE_ANGLE': 4.49798357e-15,
536-
'EMISSION_ANGLE': 0.99611862,
537-
'PHASE_ANGLE': 0.99611862,
538-
'TIME_AT_POINT': '2012-10-19 08:23:56.772287 UTC',
539-
'LIGHT_TIME': 3.22771347}
530+
'X': 232.15437562,
531+
'Y': -81.18742303,
532+
'Z': 67.66010394,
533+
'SUB_POINT_RADIUS': 255.07830453,
534+
'OBSERVER_ALTITUDE': 967644.95641522,
535+
'INCIDENCE_ANGLE': 1.10177646e-14,
536+
'EMISSION_ANGLE': 0.99615507,
537+
'PHASE_ANGLE': 0.99615507,
538+
'TIME_AT_POINT': '2012-10-19 08:23:56.772284 UTC',
539+
'LIGHT_TIME': 3.22771614}
540540

541541
.. important::
542542

@@ -576,16 +576,16 @@ Calculate the sub-observer point on a target as seen from an observer.
576576
... verbose = False,
577577
... ).run()
578578
{'DATE': '2012-10-19 08:24:00.000000 UTC',
579-
'X': 232.5831733,
580-
'Y': -81.40386728,
581-
'Z': 67.35505213,
582-
'SUB_POINT_RADIUS': 255.45689491,
583-
'OBSERVER_ALTITUDE': 967644.11734179,
584-
'INCIDENCE_ANGLE': 0.99586304,
585-
'EMISSION_ANGLE': 1.66981544e-12,
586-
'PHASE_ANGLE': 0.99586304,
587-
'TIME_AT_POINT': '2012-10-19 08:23:56.772287 UTC',
588-
'LIGHT_TIME': 3.22771334,
579+
'X': 230.66149425,
580+
'Y': -85.24005493,
581+
'Z': 67.58656174,
582+
'SUB_POINT_RADIUS': 255.02653827,
583+
'OBSERVER_ALTITUDE': 967644.91882136,
584+
'INCIDENCE_ANGLE': 0.99589948,
585+
'EMISSION_ANGLE': 3.94425842e-12,
586+
'PHASE_ANGLE': 0.99589948,
587+
'TIME_AT_POINT': '2012-10-19 08:23:56.772284 UTC',
588+
'LIGHT_TIME': 3.22771602,
589589
'LTST': '11:58:49'}
590590

591591
.. important::
@@ -630,15 +630,15 @@ from an observer.
630630
... verbose = False,
631631
... ).run()
632632
{'DATE': '2012-10-14 00:00:00.000000 UTC',
633-
'LONGITUDE': 98.7675609,
634-
'LATITUDE': -38.69027976,
635-
'INTERCEPT_RADIUS': 57739.95803153,
636-
'OBSERVER_ALTITUDE': 1831047.67987589,
637-
'INCIDENCE_ANGLE': 123.05323675,
638-
'EMISSION_ANGLE': 5.8567773,
639-
'PHASE_ANGLE': 123.77530312,
633+
'LONGITUDE': 98.76797447,
634+
'LATITUDE': -38.69300277,
635+
'INTERCEPT_RADIUS': 57739.67660691,
636+
'OBSERVER_ALTITUDE': 1831047.98047459,
637+
'INCIDENCE_ANGLE': 123.05303919,
638+
'EMISSION_ANGLE': 5.8595724,
639+
'PHASE_ANGLE': 123.7753032,
640640
'TIME_AT_POINT': '2012-10-14 00:00:00.000000 UTC',
641-
'LIGHT_TIME': 6.10771763,
641+
'LIGHT_TIME': 6.10771863,
642642
'LTST': '20:03:06'}
643643

644644
.. important::
@@ -679,17 +679,18 @@ central body. The orbit may be elliptical, parabolic, or hyperbolic.
679679
... verbose = False,
680680
... ).run()
681681
{'DATE': '2012-10-19 08:24:00.000000 UTC',
682-
'PERIFOCAL_DISTANCE': 474789.03917271,
683-
'ECCENTRICITY': 0.70348463,
684-
'INCLINATION': 38.18727034,
685-
'ASCENDING_NODE_LONGITUDE': 223.98123058,
686-
'ARGUMENT_OF_PERIAPSE': 71.59474487,
687-
'MEAN_ANOMALY_AT_EPOCH': 14.65461204,
688-
'ORBITING_BODY_RANGE': 753794.65101401,
689-
'ORBITING_BODY_SPEED': 8.77222231,
690-
'PERIOD': 2067101.2236748,
682+
'PERIFOCAL_DISTANCE': 474789.01814487,
683+
'ECCENTRICITY': 0.70348464,
684+
'INCLINATION': 38.18736036,
685+
'ASCENDING_NODE_LONGITUDE': 223.98121958,
686+
'ARGUMENT_OF_PERIAPSE': 71.59475294,
687+
'MEAN_ANOMALY_AT_EPOCH': 14.65461277,
688+
'ORBITING_BODY_RANGE': 753794.66333655,
689+
'ORBITING_BODY_SPEED': 8.77222221,
690+
'PERIOD': 2067101.1993984,
691691
'CENTER_BODY_GM': 37931207.49865224}
692692

693+
693694
.. important::
694695

695696
Calculation required parameters:
@@ -771,7 +772,7 @@ Find time intervals when a coordinate of an observer-target position vector sati
771772
... reference_value = 0.25,
772773
... verbose = False,
773774
... ).run()
774-
{'DATE': '2012-10-19 08:39:33.812153 UTC', 'DURATION': 3394.10937738}
775+
{'DATE': '2012-10-19 08:39:33.814938 UTC', 'DURATION': 3394.11539114}
775776

776777
.. important::
777778

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
source_suffix = '.rst'
2727
master_doc = 'index'
28-
language = None
28+
language = 'en'
2929
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
3030

3131
# -- Options for HTML output -------------------------------------------------

examples/calculation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"source": [
114114
"Calculation(\n",
115115
" api = 'ESA',\n",
116-
" kernels = 6,\n",
116+
" kernels = 13,\n",
117117
" times = '2014-01-01T01:23:45.000',\n",
118118
" calculation_type = 'STATE_VECTOR',\n",
119119
" target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',\n",

tests/test_api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ def solar_system_kernel_set():
1818
return {
1919
'caption': 'Solar System Kernels',
2020
'sclkId': '0',
21-
'description': 'Generic kernels for planets, satellites, and some asteroids '
22-
'covering from 1950-01-01 to 2050-01-01.',
21+
'description': 'Generic kernels for planets, satellites, and some asteroids, '
22+
'covering at least from 1950-01-01 to 2050-01-01, and including '
23+
'the latest generic text PCK and the mars_iau2000_v1.tpc PCK '
24+
'loaded in this order.',
2325
'kernelSetId': '1',
2426
'missionId': 'gen',
2527
}
@@ -138,8 +140,8 @@ def test_api_metadata():
138140
assert API['documentation'] == \
139141
'https://wgc2.jpl.nasa.gov:8443/webgeocalc/documents/api-info.html'
140142
assert API['contact'] == 'Boris Semenov <Boris.Semenov@jpl.nasa.gov>'
141-
assert API['version'] == '2.2.9'
142-
assert API['build_id'] == '5115 N67 14-JAN-2022'
143+
assert API['version'] == '2.7.6'
144+
assert API['build_id'] == '5363 N67 29-JAN-2025'
143145

144146
with raises(KeyError):
145147
_ = API['foo']

tests/test_cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def test_cli_kernel_sets(capsys):
2828
assert ' - Solar System Kernels: (id: 1)' in captured.out
2929
assert 'Too many kernel sets contains \'Cassini\' in their names:' in captured.out
3030

31-
argv = '--api esa --kernel 6'.split()
31+
argv = '--api esa --kernel 13'.split()
3232
cli_kernel_sets(argv)
3333
captured = capsys.readouterr()
34-
assert ' - OPS -- Rosetta -- Operational: (id: 6)' in captured.out
34+
assert ' - OPS -- Rosetta -- Operational: (id: 13)' in captured.out
3535
assert '' in captured.out
3636

3737

@@ -53,7 +53,7 @@ def test_cli_bodies(capsys):
5353
captured = capsys.readouterr()
5454
assert captured.out == ' - TITAN: (id: 606)\n'
5555

56-
argv = '--api esa 6 --name 67P'.split()
56+
argv = '--api esa 13 --name 67P'.split()
5757
cli_bodies(argv)
5858
captured = capsys.readouterr()
5959
assert captured.out == ' - 67P/CHURYUMOV-GERASIMENKO (1969 R1): (id: 1000012)\n'
@@ -78,7 +78,7 @@ def test_cli_frames(capsys):
7878
assert ' - IAU_TITAN: (id: 10044)' in captured.out
7979
assert ' - J2000: (id: 1)' not in captured.out
8080

81-
argv = '--api esa 6 --name 67P'.split()
81+
argv = '--api esa 13 --name 67P'.split()
8282
cli_frames(argv)
8383
captured = capsys.readouterr()
8484
assert '- 67P/C-G_CK: (id: -1000012000)' in captured.out
@@ -104,7 +104,7 @@ def test_cli_instruments(capsys):
104104
assert ' - CASSINI_ISS_WAC: (id: -82361)' in captured.out
105105
assert ' - CASSINI_VIMS_IR: (id: -82370)' not in captured.out
106106

107-
argv = '--api esa 6 --name NAVCAM'.split()
107+
argv = '--api esa 13 --name NAVCAM'.split()
108108
cli_instruments(argv)
109109
captured = capsys.readouterr()
110110
assert ' - ROS_NAVCAM-A: (id: -226170)' in captured.out
@@ -191,7 +191,7 @@ def test_cli_angular_size_run(capsys):
191191
assert "timeSystem: UTC," in captured.out
192192
assert 'API status:\n[Calculation submit] Phase:' in captured.out
193193
assert 'Results:\nDATE:\n> 2012-10-19 08:24:00.000000 UTC' in captured.out
194-
assert 'ANGULAR_SIZE:\n> 0.03037939' in captured.out
194+
assert 'ANGULAR_SIZE:\n> 0.03032491' in captured.out
195195

196196

197197
def test_cli_frame_transformation_dry_run(capsys):
@@ -386,7 +386,7 @@ def test_cli_state_vector_esa(capsys):
386386
captured = capsys.readouterr()
387387
assert 'API: http://spice.esac.esa.int/webgeocalc/api' in captured.out
388388
assert 'Payload:' in captured.out
389-
assert "kernels: [{'type': 'KERNEL_SET', 'id': 6}]" in captured.out
389+
assert "kernels: [{'type': 'KERNEL_SET', 'id': 13}]" in captured.out
390390
assert "times: ['2014-01-01T01:23:45.000']" in captured.out
391391
assert 'target: 67P/CHURYUMOV-GERASIMENKO (1969 R1)' in captured.out
392392
assert 'observer: ROSETTA ORBITER' in captured.out

webgeocalc/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get(self, url):
6262
[<KernelSetDetails> Solar System Kernels (id: 1), ...]
6363
6464
"""
65-
response = requests.get(self.url + url)
65+
response = requests.get(self.url + url, timeout=60)
6666
if response.ok:
6767
return self.read(response.json())
6868

@@ -95,7 +95,7 @@ def post(self, url, payload):
9595
('0788aba2-d4e5-4028-9ef1-4867ad5385e0', 'COMPLETE')
9696
9797
"""
98-
response = requests.post(self.url + url, json=payload)
98+
response = requests.post(self.url + url, json=payload, timeout=60)
9999
if response.ok:
100100
return self.read(response.json())
101101

@@ -226,8 +226,8 @@ def kernel_set_id(self, kernel_set):
226226
if isinstance(kernel_set, KernelSetDetails):
227227
return int(kernel_set)
228228

229-
raise TypeError(f"'kernel_set' must be a 'int', a 'str' of a 'KernelSetDetails' object:\n' + \
230-
'>>> Type({kernel_set}) = {type(kernel_set)}")
229+
raise TypeError(f"'kernel_set' must be a 'int', a 'str' of a 'KernelSetDetails' "
230+
f"object:\n' + '>>> Type({kernel_set}) = {type(kernel_set)}")
231231

232232
def bodies(self, kernel_set):
233233
"""Get list of bodies available in a kernel set.

webgeocalc/calculation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,11 +1455,11 @@ def direction_vector_type(self, val):
14551455

14561456
keys = self.params.keys()
14571457
if val in ['VECTOR_IN_INSTRUMENT_FOV', 'VECTOR_IN_REFERENCE_FRAME']:
1458-
if not(
1458+
if not (
14591459
'direction_vector_x' in keys and # noqa: W504
14601460
'direction_vector_y' in keys and # noqa: W504
14611461
'direction_vector_z' in keys
1462-
) and not(
1462+
) and not (
14631463
'direction_vector_ra' in keys and # noqa: W504
14641464
'direction_vector_dec' in keys
14651465
):

0 commit comments

Comments
 (0)