{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "**Previous:** Use [WebGeoCalc API](api.ipynb)\n", "\n", "---\n", "\n", "# Make a calculation\n", "\n", "__See:__ [Documentation](https://webgeocalc.readthedocs.io/en/stable/calculation.html) for more details on [optional arguments setup](https://webgeocalc.readthedocs.io/en/stable/calculation.html#inputs-examples-and-payloads) and [job submission](https://webgeocalc.readthedocs.io/en/stable/calculation.html#submit-payload-and-retrieve-results)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generic calculation\n", "Webgeocalc calculation: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#generic-calculation))" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: LOADING_KERNELS (id: 1618ab17-dd1b-40e2-8a02-5ce205c4a7cc)\n", "[Calculation update] Phase: LOADING_KERNELS (id: 1618ab17-dd1b-40e2-8a02-5ce205c4a7cc)\n", "[Calculation update] Phase: COMPLETE (id: 1618ab17-dd1b-40e2-8a02-5ce205c4a7cc)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'LONGITUDE': 46.18900522,\n", " 'LATITUDE': 21.26337134,\n", " 'ALTITUDE': 694259.8921163,\n", " 'D_LONGITUDE_DT': 0.00888655,\n", " 'D_LATITUDE_DT': -0.00031533,\n", " 'D_ALTITUDE_DT': 4.77080305,\n", " 'SPEED': 109.34997994,\n", " 'TIME_AT_TARGET': '2012-10-19 08:24:00.000000 UTC',\n", " 'LIGHT_TIME': 2.51438831}" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import Calculation\n", "\n", "Calculation(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " calculation_type = 'STATE_VECTOR',\n", " target = 'CASSINI',\n", " observer = 'SATURN',\n", " reference_frame = 'IAU_SATURN',\n", " aberration_correction = 'NONE',\n", " state_representation = 'PLANETOGRAPHIC',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, if no `api` option is provided, the query is sent to the `WGC_URL` API (if set in the global environment variables) or `JPL` API (if not).\n", "To query on the ESA WGC API, you need to add the `ESA` key to the any `Calculation` parameters:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: b1c189c8-2824-43a8-a682-24613d6e6dae)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2014-01-01 01:23:45.000000 UTC',\n", " 'LONGITUDE': -4.5904441,\n", " 'LATITUDE': -39.43153956,\n", " 'RADIUS': 10514625.76042228,\n", " 'D_LONGITUDE_DT': -0.00806197,\n", " 'D_LATITUDE_DT': 7.01746089e-08,\n", " 'D_RADIUS_DT': -0.813433,\n", " 'SPEED': 1142.73632133,\n", " 'TIME_AT_TARGET': '2014-01-01 01:23:45.000000 UTC',\n", " 'LIGHT_TIME': 35.07301628}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Calculation(\n", " api = 'ESA',\n", " kernels = 6,\n", " times = '2014-01-01T01:23:45.000',\n", " calculation_type = 'STATE_VECTOR',\n", " target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',\n", " observer = 'ROSETTA ORBITER',\n", " reference_frame = '67P/C-G_CK',\n", " aberration_correction = 'NONE',\n", " state_representation = 'LATITUDINAL',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To query a 3-rd party API, you can either set `WGC_URL` on your system to use it a your main entry point (as mention before), or you can provide directly its `url` to the `api` parameter." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " https://wgc.obspm.fr/webgeocalc/api" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Calculation(\n", " api = 'https://wgc.obspm.fr/webgeocalc/api',\n", " kernels = 6,\n", " times = '2014-01-01T01:23:45.000',\n", " calculation_type = 'STATE_VECTOR',\n", " target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',\n", " observer = 'ROSETTA ORBITER',\n", " reference_frame = '67P/C-G_CK',\n", " aberration_correction = 'NONE',\n", " state_representation = 'LATITUDINAL',\n", ").api" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, the user can also create a custom `Api` object and use it directly:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ " https://wgc.obspm.fr/webgeocalc/api" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import Api\n", "\n", "obs_api = Api('https://wgc.obspm.fr/webgeocalc/api')\n", "\n", "Calculation(\n", " api = obs_api,\n", " kernels = 6,\n", " times = '2014-01-01T01:23:45.000',\n", " calculation_type = 'STATE_VECTOR',\n", " target = '67P/CHURYUMOV-GERASIMENKO (1969 R1)',\n", " observer = 'ROSETTA ORBITER',\n", " reference_frame = '67P/C-G_CK',\n", " aberration_correction = 'NONE',\n", " state_representation = 'LATITUDINAL',\n", ").api" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In each cases, every new API is cached to improve the kernels loading performances." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## State Vector\n", "\n", "Calculates the position of one body relative to another, calculated in a desired reference frame: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#state-vector))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 5f85a881-cd76-4cdc-8291-85eb25a92e3e)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 09:00:00.000000 UTC',\n", " 'DISTANCE': 764142.63776247,\n", " 'SPEED': 111.54765899,\n", " 'X': 298292.85744169,\n", " 'Y': -651606.58468976,\n", " 'Z': 265224.81187627,\n", " 'D_X_DT': -98.8032491,\n", " 'D_Y_DT': -51.73211296,\n", " 'D_Z_DT': -2.1416539,\n", " 'TIME_AT_TARGET': '2012-10-19 08:59:57.451094 UTC',\n", " 'LIGHT_TIME': 2.54890548}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import StateVector\n", "\n", "StateVector(\n", " kernels = 5,\n", " times = '2012-10-19T09:00:00',\n", " target = 'CASSINI',\n", " observer = 'SATURN',\n", " reference_frame = 'IAU_SATURN',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Angular Separation\n", "\n", "Calculates the angular separation of two bodies as seen by an observer body: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#angular-separation))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: d2f28b90-f6de-47d4-b69c-8603e5e090d0)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC', 'ANGULAR_SEPARATION': 175.17072258}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import AngularSeparation\n", "\n", "AngularSeparation(\n", " kernel_paths = ['pds/wgc/kernels/lsk/naif0012.tls', 'pds/wgc/kernels/spk/de430.bsp'],\n", " times = '2012-10-19T08:24:00.000',\n", " target_1 = 'VENUS',\n", " target_2 = 'MERCURY',\n", " observer = 'SUN',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Angular Size\n", "\n", "Calculates the angular size of a target as seen by an observer: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#state-size))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 810fd7c7-635d-45d6-828c-ef24e8942524)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC', 'ANGULAR_SIZE': 0.03037939}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import AngularSize\n", "\n", "AngularSize(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " target = 'ENCELADUS',\n", " observer = 'CASSINI',\n", " aberration_correction = 'CN+S',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Frame Transformation\n", "\n", "Calculate the transformation from one reference frame (Frame 1) to another reference frame (Frame 2): ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#frame-transformation))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: f81aac7c-01d2-4347-97e2-e8934ade1001)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'ANGLE3': -20.58940104,\n", " 'ANGLE2': 0.01874004,\n", " 'ANGLE1': 0.00136319,\n", " 'AV_X': 9.94596495e-07,\n", " 'AV_Y': -7.23492228e-08,\n", " 'AV_Z': -0.00634331,\n", " 'AV_MAG': 0.00634331}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import FrameTransformation\n", "\n", "FrameTransformation(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " frame_1 = 'IAU_SATURN',\n", " frame_2 = 'IAU_ENCELADUS',\n", " aberration_correction = 'NONE',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Illumination Angles\n", "\n", "Calculate the emission, phase and solar incidence angles at a point on a target as seen from an observer: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#illumination-angles))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: a8546482-10c0-43d2-b07c-75ac1132a220)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'INCIDENCE_ANGLE': 24.78527742,\n", " 'EMISSION_ANGLE': 25.56007298,\n", " 'PHASE_ANGLE': 1.00079007,\n", " 'OBSERVER_ALTITUDE': 967668.02765637,\n", " 'TIME_AT_POINT': '2012-10-19 08:23:56.772207 UTC',\n", " 'LIGHT_TIME': 3.2277931,\n", " 'LTST': '13:15:59'}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import IlluminationAngles\n", "\n", "IlluminationAngles(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " target = 'ENCELADUS',\n", " target_frame = 'IAU_ENCELADUS',\n", " observer = 'CASSINI',\n", " aberration_correction = 'CN+S',\n", " latitude = 0.0,\n", " longitude = 0.0,\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sub Solar Point\n", "\n", "Calculates the sub-solar point on a target as seen from an observer: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#sub-solar-point))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 47d473f2-77b9-4fe3-8388-d1c7d54b2e25)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'X': 234.00550655,\n", " 'Y': -77.32612213,\n", " 'Z': 67.42916937,\n", " 'SUB_POINT_RADIUS': 255.50851089,\n", " 'OBSERVER_ALTITUDE': 967644.15493281,\n", " 'INCIDENCE_ANGLE': 4.49798357e-15,\n", " 'EMISSION_ANGLE': 0.99611862,\n", " 'PHASE_ANGLE': 0.99611862,\n", " 'TIME_AT_POINT': '2012-10-19 08:23:56.772287 UTC',\n", " 'LIGHT_TIME': 3.22771347}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import SubSolarPoint\n", "\n", "SubSolarPoint(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " target = 'ENCELADUS',\n", " target_frame = 'IAU_ENCELADUS',\n", " observer = 'CASSINI',\n", " aberration_correction = 'CN+S',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sub Observer Point\n", "\n", "Calculate the sub-observer point on a target as seen from an observer: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#sub-observer-point))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 07e5f27e-7372-4eb7-8405-55bcc6015d10)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'X': 232.5831733,\n", " 'Y': -81.40386728,\n", " 'Z': 67.35505213,\n", " 'SUB_POINT_RADIUS': 255.45689491,\n", " 'OBSERVER_ALTITUDE': 967644.11734179,\n", " 'INCIDENCE_ANGLE': 0.99586304,\n", " 'EMISSION_ANGLE': 1.66981544e-12,\n", " 'PHASE_ANGLE': 0.99586304,\n", " 'TIME_AT_POINT': '2012-10-19 08:23:56.772287 UTC',\n", " 'LIGHT_TIME': 3.22771334,\n", " 'LTST': '11:58:49'}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import SubObserverPoint\n", "\n", "SubObserverPoint(\n", " kernels = 5,\n", " times = '2012-10-19T08:24:00.000',\n", " target = 'ENCELADUS',\n", " target_frame = 'IAU_ENCELADUS',\n", " observer = 'CASSINI',\n", " aberration_correction = 'CN+S',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Surface Intercept Point\n", "\n", "Calculate the intercept point of a vector or vectors on a target as seen from an observer: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#surface-intercept-point))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 5d9566ac-652a-4aa7-b118-42c4dff55285)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-14 00:00:00.000000 UTC',\n", " 'LONGITUDE': 98.7675609,\n", " 'LATITUDE': -38.69027976,\n", " 'INTERCEPT_RADIUS': 57739.95803153,\n", " 'OBSERVER_ALTITUDE': 1831047.67987589,\n", " 'INCIDENCE_ANGLE': 123.05323675,\n", " 'EMISSION_ANGLE': 5.8567773,\n", " 'PHASE_ANGLE': 123.77530312,\n", " 'TIME_AT_POINT': '2012-10-14 00:00:00.000000 UTC',\n", " 'LIGHT_TIME': 6.10771763,\n", " 'LTST': '20:03:06'}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import SurfaceInterceptPoint\n", "\n", "SurfaceInterceptPoint(\n", " kernels = 5,\n", " times = '2012-10-14T00:00:00',\n", " target = 'SATURN',\n", " target_frame = 'IAU_SATURN',\n", " observer = 'CASSINI',\n", " direction_vector_type = 'INSTRUMENT_BORESIGHT',\n", " direction_instrument = 'CASSINI_ISS_NAC',\n", " aberration_correction = 'NONE',\n", " state_representation = 'LATITUDINAL',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Osculating Elements\n", "\n", "Calculate the osculating elements of the orbit of a target body around a central body.\n", "The orbit may be elliptical, parabolic, or hyperbolic: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#osculating-elements))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 883bdd2d-3b7c-4aa2-b91e-f787ee69945f)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:24:00.000000 UTC',\n", " 'PERIFOCAL_DISTANCE': 474789.03917271,\n", " 'ECCENTRICITY': 0.70348463,\n", " 'INCLINATION': 38.18727034,\n", " 'ASCENDING_NODE_LONGITUDE': 223.98123058,\n", " 'ARGUMENT_OF_PERIAPSE': 71.59474487,\n", " 'MEAN_ANOMALY_AT_EPOCH': 14.65461204,\n", " 'ORBITING_BODY_RANGE': 753794.65101401,\n", " 'ORBITING_BODY_SPEED': 8.77222231,\n", " 'PERIOD': 2067101.2236748,\n", " 'CENTER_BODY_GM': 37931207.49865224}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import OsculatingElements\n", "\n", "OsculatingElements(\n", " kernels = [1,5],\n", " times = '2012-10-19T08:24:00.000',\n", " orbiting_body = 'CASSINI',\n", " center_body = 'SATURN',\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Time Conversion\n", "\n", "Convert times from one time system or format to another: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#time-conversion))" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: 0ec03563-002b-4225-9218-6dbc4ff80e8d)\n" ] }, { "data": { "text/plain": [ "{'DATE': '1/1729329441.004', 'DATE2': '2012-10-19 08:24:02.919085 UTC'}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import TimeConversion\n", "\n", "TimeConversion(\n", " kernels = 5,\n", " times = '1/1729329441.04',\n", " time_system = 'SPACECRAFT_CLOCK',\n", " time_format = 'SPACECRAFT_CLOCK_STRING',\n", " sclk_id = -82,\n", ").run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Geometry Finder Coordinate Search\n", "\n", "Find time intervals when a coordinate of an observer-target position vector satisfies a condition: ([docs](https://webgeocalc.readthedocs.io/en/stable/calculation.html#geometry-finder-coordinate-search))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Calculation submit] Phase: COMPLETE (id: e4ceb336-05f8-47b7-9e37-c64d8791e96f)\n" ] }, { "data": { "text/plain": [ "{'DATE': '2012-10-19 08:39:33.812153 UTC', 'DURATION': 3394.10937738}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from webgeocalc import GFCoordinateSearch\n", "\n", "GFCoordinateSearch(\n", " kernels = 5,\n", " intervals = ['2012-10-19T07:00:00', '2012-10-19T09:00:00'],\n", " observer = 'CASSINI',\n", " target = 'ENCELADUS',\n", " reference_frame = 'CASSINI_ISS_NAC',\n", " time_step = 1,\n", " time_step_units = 'MINUTES',\n", " aberration_correction = 'NONE',\n", " interval_adjustment = 'EXPAND_INTERVALS',\n", " interval_adjustment_amount = 1,\n", " interval_adjustment_units = 'SECONDS',\n", " interval_filtering = 'FILTER_INTERVALS',\n", " interval_filtering_threshold = 1,\n", " interval_filtering_threshold_units = 'MINUTES',\n", " coordinate_system = 'SPHERICAL',\n", " coordinate = 'COLATITUDE',\n", " relational_condition = '<',\n", " reference_value = 0.25,\n", ").run()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 2 }