Skip to content

Commit

Permalink
Add CLI calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
seignovert committed Feb 11, 2019
1 parent ff9ea7f commit f712ce6
Show file tree
Hide file tree
Showing 6 changed files with 511 additions and 20 deletions.
39 changes: 37 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,43 @@ The webgeocalc API can be call directly from the command line interface:
...
- SPICE Class -- Binary PCK Lesson Kernels (Earth): (id: 39)
$ wgc-kernels --kernel Solar
- Solar System Kernels: (id: 1)
$ wgc-instruments 'Cassini Huygens' --name 'ISS'
- CASSINI_ISS_WAC_RAD: (id: -82369)
- CASSINI_ISS_NAC_RAD: (id: -82368)
- CASSINI_ISS_WAC: (id: -82361)
- CASSINI_ISS_NAC: (id: -82360)
$ wgc-state-vector --kernels 5 \
--times '2012-10-19T09:00:00' \
--target 'CASSINI' \
--observer 'SATURN' \
--reference_frame 'IAU_SATURN'
API status:
[Calculation submit] Status: COMPLETE (id: 041bf912-178f-4450-b787-12a49c8a3101)
Results:
DATE:
> 2012-10-19 09:00:00.000000 UTC
DISTANCE:
> 764142.63776247
SPEED:
> 111.54765899
X:
> 298292.85744169
Y:
> -651606.58468976
Z:
> 265224.81187627
D_X_DT:
> -98.8032491
D_Y_DT:
> -51.73211296
D_Z_DT:
> -2.1416539
TIME_AT_TARGET:
> 2012-10-19 08:59:57.451094 UTC
LIGHT_TIME:
> 2.54890548
More examples can be found in here_.

Expand Down
128 changes: 119 additions & 9 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@ Command line interface
======================

Some entry points are available through the command line
interface to get the list of available kernels, the body
objects, the frames and instruments available on the
WebGeoCalc API.

.. note::

For now, calculation can not be submitted directly
through the command line.
interface.


Kernel sets
-----------

List all the available kernel sets:
List all the available kernel sets available on the
WebGeoCalc API:

.. code:: bash
Expand Down Expand Up @@ -106,3 +100,119 @@ List and search instruments for a specific kernel set:
- CASSINI_ISS_NAC_RAD: (id: -82368)
- CASSINI_ISS_WAC: (id: -82361)
- CASSINI_ISS_NAC: (id: -82360)
Calculations
------------

The command line can submit generic and specific calculation directly
with the command line interface:

.. code:: bash
$ wgc-calculation --help
usage: wgc-calculation [-h] [--quiet] [--payload] [--dry-run]
[--KEY [VALUE [VALUE ...]]]
Submit generic calculation to the WebGeoCalc API
optional arguments:
-h, --help show this help message and exit
--quiet, -q Disable verbose output status.
--payload, -p Display payload before the calculation results.
--dry-run, -d Dry run. Show only the payload.
--KEY [VALUE [VALUE ...]]
Key parameter and its value(s).
Example:
.. code:: bash
$ wgc-calculation --payload \
--kernels 1 \
--times '2012-10-19T08:24:00.000' \
--calculation_type 'STATE_VECTOR' \
--target 'CASSINI' \
--observer 'SATURN' \
--reference_frame 'IAU_SATURN' \
--aberration_correction 'NONE' \
--state_representation 'PLANETOGRAPHIC'
Payload:
{
kernels: [{'type': 'KERNEL_SET', 'id': 5}],
times: ['2012-10-19T08:24:00.000'],
calculationType: STATE_VECTOR,
target: CASSINI,
observer: SATURN,
referenceFrame: IAU_SATURN,
aberrationCorrection: NONE,
stateRepresentation: PLANETOGRAPHIC,
timeSystem: UTC,
timeFormat: CALENDAR,
}
API status:
[Calculation submit] Status: COMPLETE (id: 37d10124-a65b-44fa-9489-6c0d28cf25d2)
Results:
DATE:
> 2012-10-19 08:24:00.000000 UTC
LONGITUDE:
> 46.18900522
LATITUDE:
> 21.26337134
ALTITUDE:
> 694259.8921163
D_LONGITUDE_DT:
> 0.00888655
D_LATITUDE_DT:
> -0.00031533
D_ALTITUDE_DT:
> 4.77080305
SPEED:
> 109.34997994
TIME_AT_TARGET:
> 2012-10-19 08:24:00.000000 UTC
LIGHT_TIME:
> 2.51438831
The *key* parameter can be in ``underscore_case`` or ``camelCase``.
Multiple *values* can be inserted after the *key* (with ``<space>`` or ``,`` separator),
as well as duplicated *keys*. Assignation with ``=`` sign can also be used:
.. code:: bash
$ wgc-state-vector --dry-run \
--kernels 1 5 \
--times '2012-10-19T09:00:00' \
--times '2012-10-19T10:00:00' \
--target='CASSINI' \
--observer = 'SATURN' \
--referenceFrame 'IAU_SATURN'
Payload:
{
kernels: [{'type': 'KERNEL_SET', 'id': 1}, {'type': 'KERNEL_SET', 'id': 5}],
times: ['2012-10-19T09:00:00', '2012-10-19T10:00:00'],
target: CASSINI,
observer: SATURN,
referenceFrame: IAU_SATURN,
calculationType: STATE_VECTOR,
aberrationCorrection: CN,
stateRepresentation: RECTANGULAR,
timeSystem: UTC,
timeFormat: CALENDAR,
}
Here is the list of all the calculation entry point available on the CLI:
- ``wgc-calculation``
- ``wgc-state-vector``
- ``wgc-angular-separation``
- ``wgc-angular-size``
- ``wgc-frame-transformation``
- ``wgc-illumination-angles``
- ``wgc-subsolar-point``
- ``wgc-subobserver-point``
- ``wgc-surface-intercept-point``
- ``wgc-osculating-elements``
- ``wgc-time-conversion``
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Python package for NAIF WebGeoCalc API


In december 2018, `JPL/NAIF`_ announced an **experimental**
`API RESTful interface`_ for their new `WebGeocalc server`_
`API RESTful interface`_ for their new `WebGeoCalc server`_
(which make online SPICE calculations).
Documentation_ and `JavaScript examples`_ are already available.

Expand All @@ -47,7 +47,7 @@ calculations through this API.

.. _`JPL/NAIF`: https://naif.jpl.nasa.gov/naif/webgeocalc.html
.. _`API RESTful interface`: https://naif.jpl.nasa.gov/naif/WebGeocalc_announcement.pdf
.. _`WebGeocalc server`: https://wgc2.jpl.nasa.gov:8443/webgeocalc
.. _`WebGeoCalc server`: https://wgc2.jpl.nasa.gov:8443/webgeocalc
.. _Documentation: https://wgc2.jpl.nasa.gov:8443/webgeocalc/documents/api-info.html
.. _`JavaScript examples`: https://wgc2.jpl.nasa.gov:8443/webgeocalc/example/perform-calculation.html

Expand All @@ -58,7 +58,7 @@ calculations through this API.
If you need to make intensive queries, use `Spiceypy`_ or `SpiceMiner`_
package with locally hosted kernels.

.. _`WebGeocalc`: https://wgc.jpl.nasa.gov:8443/webgeocalc
.. _`WebGeoCalc`: https://wgc.jpl.nasa.gov:8443/webgeocalc
.. _`Spiceypy`: https://github.com/AndrewAnnex/Spiceypy
.. _`SpiceMiner`: https://github.com/DaRasch/spiceminer

Expand Down
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ console_scripts =
wgc-bodies = webgeocalc.cli:cli_bodies
wgc-frames = webgeocalc.cli:cli_frames
wgc-instruments = webgeocalc.cli:cli_instruments
wgc-calculation = webgeocalc.cli:cli_calculation
wgc-state-vector = webgeocalc.cli:cli_state_vector
wgc-angular-separation = webgeocalc.cli:cli_angular_separation
wgc-angular-size = webgeocalc.cli:cli_angular_size
wgc-frame-transformation = webgeocalc.cli:cli_frame_transformation
wgc-illumination-angles = webgeocalc.cli:cli_illumination_angles
wgc-subsolar-point = webgeocalc.cli:cli_subsolar_point
wgc-subobserver-point = webgeocalc.cli:cli_subobserver_point
wgc-surface-intercept-point = webgeocalc.cli:cli_surface_intercept_point
wgc-osculating-elements = webgeocalc.cli:cli_osculating_elements
wgc-time-conversion = webgeocalc.cli:cli_time_conversion
Loading

0 comments on commit f712ce6

Please sign in to comment.