"Orekit is an open-source library for a number of space related calculations such as:\n",
"Orekit is an open-source library for astrodynamical calculations such as:\n",
"\n",
"* Orbit Propagation\n",
"* Coordinate system transformations\n",
"* Time systems\n",
"* Orbit Determination\n",
"\n",
"The orekit webpage can be accessed at http://www.orekit.org.\n",
"\n"
"And much more..\n",
"\n",
"The orekit webpage can be accessed at http://www.orekit.org.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The java - pyhon bridge"
"## The Java - Python bridge - \"orekit python wrapper\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The orekit library is written in java. For interactive work a bridge to Python has been made, which will be used in this tutorial."
"The orekit library is written and executing in java. However for interactive work a bridge to Python has been made, the \"orekit python wrapper\" which will be used in this tutorial."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The orekit java library has been wrapped using the open source JCC tool, that enables interaction with java objects from the Python ecosystem. Python has quick and high quality routines for plotting and a easily read code.\n",
"The orekit java library has been wrapped using the open source JCC tool, that enables interaction with java objects from the Python ecosystem.\n",
"The recommended way to install the orekit python wrapper is through the pre-built packages for the Anaconda python distribution. \n",
"\n",
"The Anaconda python distribution can be downloaded at:\n",
"https://www.anaconda.com/distribution/\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Install Orekit Python Wrapper Conda package"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A pre-built orekit package for conda is created in the conda-forge channel, and can be installed in the conda environment by:\n",
"\n",
" conda install orekit -c conda-forge\n",
" \n",
"This should download and install the orekit package into the currently activated conda environment, and install the dependenies (openjdk).\n",
"\n",
"For some usages it is useful to install conda-wrappers, for example if using an IDE like PyCharm. The conda-wrappers are installed in the same way:\n",
"\n",
" conda install conda-wrappers -c conda-forge\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Orekit needs to be initiated before used, partly setting up the Python - both the Java gateway and partly setting up access to the data needed for different orekit functions, such as the shape of the earth, leap time seconds etc."
"### Getting the orekit-data.zip file "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First we need to intitilize the iPython notebook, that we want to use the inline pylab functionality and how large defalt plots should be. This is not orekit specific."
"Some fundamental parameters are not included in the orekit package, and should be provided separately. Such files are earth orientation parameters, time standards etc. An example collection of such parameters are available on the orekit page (no guaratees, this data should be maintained by the user for any professional usage).\n",
"\n",
"The datafile is default accessed in current orekit directory or a path can be supplied. The file can be downloaded from https://gitlab.orekit.org/orekit/orekit-data\n",
"\n",
"A convenience function to download this file is included in the orekit package."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
"Orekit needs to be initiated before used, this starts up the java engine and exposes the orekit classes in python."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To start up the orekit JVM:"
"To start up orekit use the initVM() function:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Java version: 1.8.0_92\n"
"Java version: 1.8.0_152-release\n",
"Orekit version: 10.0\n"
]
}
],
"source": [
"import orekit\n",
"vm = orekit.initVM()\n",
"print ('Java version:',vm.java_version)"
"print ('Java version:',vm.java_version)\n",
"print ('Orekit version:', orekit.VERSION)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The orekit library needs a data file with various information on time and earth rotation parameters. This file, called orekit-data.zip is loaded from current dir. A basic version of this file can be downloaded from the orekit [webpage](https://www.orekit.org/forge/projects/orekit/files).\n",
"The orekit library needs a data file with various information on time and earth rotation parameters. This file, called orekit-data.zip is loaded from current dir as default. \n",
"\n",
"This routine is commonly used in the notebooks, so a python specific function is created for this, setup_orekit_curdir()"
"This routine of setting up these parameters is commonly used in the notebooks, so a python specific function is created for this, setup_orekit_curdir()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -132,12 +187,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we are set up to import and use objects from the orekit library."
"Now we are set up to import and use objects from the orekit library. With the proper initialization, all objects in the orekit java library is exposed to Python and can be imported using normal Python syntax."
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -146,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 12,
"metadata": {},
"outputs": [
{
...
...
@@ -172,14 +227,213 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"*Petrus Hyvönen, SSC, 2014*"
"# Documentation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One of the best sources of knowledge about orekit and the Python wrapper is on the orekit forum, https://forum.orekit.org/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Orekit API "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Python version of orekit is very closely matching the java version and the API documentation from Java can be used. This documentation is available at https://www.orekit.org/site-orekit-10.1/apidocs/index.html\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to the API documentation there are a number of architecture descriptions, based on the Java syntax but highly applicable to the Python side. See https://www.orekit.org/doc-maven.html\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Specifics for the Python version of Orekit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For many users there will be no or little differnce in the usage of Orekit between Java and Python. The following chapter provides additional information for more advanced usage."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Python version, or correctly stated the Python Wrapper (it is a pure java orekit that runs in background) has a few areas where there are specific ways to do things, limitations and some quirks. The wrapper is created with a tool called JCC (https://lucene.apache.org/pylucene/jcc/), which is providing most of these features and the documentation for that is relevant.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Casting of classes "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Java is a more strongly typed language than Python and is indirectly casting classes as part of the syntax. In most cases the Python user does not need to consider this when using orekit in Python, but in some cases it may be neccessary to specify which type or interface of a particular object that is refered to."
"The Java language has a feature of parametric class definitions and orekit uses this in some areas. These can be managed in Python with the _of(Class) method that sets this."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Subclassing Java classes in Python "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In some use cases it is relevant to subclass a java class for an own implementation. For the standard orekit classes this is not possible, but a work-around has been implemented for selected classes that allows Python subclassing. These classes are labeled as their corresponding java classes but with a \"Python\" prefix."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Example:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Implementation of Java Interfaces in Python "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The implementation of orekit interfaces in Python is performed in the same way as subclassing, where all interfaces has a corresponding \"Python\" prefixed version that can be subclassed in python in order to implement that interface."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: It is not possible to implement several interfaces to a Python class"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Petrus Hyvönen, SSC, 2020*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
...
...
@@ -193,7 +447,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.7.6"
},
"toc": {
"base_numbering": 1,
...
...
@@ -214,5 +468,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
%% Cell type:markdown id: tags:
# Orekit in Python - The basics
# Orekit in Python - The Basics
%% Cell type:markdown id: tags:
Orekit is an open-source library for a number of space related calculations such as:
Orekit is an open-source library for astrodynamical calculations such as:
* Orbit Propagation
* Coordinate system transformations
* Time systems
* Orbit Determination
The orekit webpage can be accessed at http://www.orekit.org.
And much more..
The orekit webpage can be accessed at http://www.orekit.org.
%% Cell type:markdown id: tags:
## The java - pyhon bridge
## The Java - Python bridge - "orekit python wrapper"
%% Cell type:markdown id: tags:
The orekit library is written in java. For interactive work a bridge to Python has been made, which will be used in this tutorial.
The orekit library is written and executing in java. However for interactive work a bridge to Python has been made, the "orekit python wrapper" which will be used in this tutorial.
%% Cell type:markdown id: tags:
The orekit java library has been wrapped using the open source JCC tool, that enables interaction with java objects from the Python ecosystem. Python has quick and high quality routines for plotting and a easily read code.
The orekit java library has been wrapped using the open source JCC tool, that enables interaction with java objects from the Python ecosystem.
Orekit needs to be initiated before used, partly setting up the Python - both the Java gateway and partly setting up access to the data needed for different orekit functions, such as the shape of the earth, leap time seconds etc.
The recommended way to install the orekit python wrapper is through the pre-built packages for the Anaconda python distribution.
The Anaconda python distribution can be downloaded at:
https://www.anaconda.com/distribution/
%% Cell type:markdown id: tags:
First we need to intitilize the iPython notebook, that we want to use the inline pylab functionality and how large defalt plots should be. This is not orekit specific.
### Install Orekit Python Wrapper Conda package
%% Cell type:markdown id: tags:
A pre-built orekit package for conda is created in the conda-forge channel, and can be installed in the conda environment by:
conda install orekit -c conda-forge
This should download and install the orekit package into the currently activated conda environment, and install the dependenies (openjdk).
For some usages it is useful to install conda-wrappers, for example if using an IDE like PyCharm. The conda-wrappers are installed in the same way:
conda install conda-wrappers -c conda-forge
%% Cell type:markdown id: tags:
### Getting the orekit-data.zip file
%% Cell type:markdown id: tags:
Some fundamental parameters are not included in the orekit package, and should be provided separately. Such files are earth orientation parameters, time standards etc. An example collection of such parameters are available on the orekit page (no guaratees, this data should be maintained by the user for any professional usage).
The datafile is default accessed in current orekit directory or a path can be supplied. The file can be downloaded from https://gitlab.orekit.org/orekit/orekit-data
A convenience function to download this file is included in the orekit package.
Populating the interactive namespace from numpy and matplotlib
# Initiating Orekit in Python
%% Cell type:markdown id: tags:
To start up the orekit JVM:
Orekit needs to be initiated before used, this starts up the java engine and exposes the orekit classes in python.
%% Cell type:markdown id: tags:
To start up orekit use the initVM() function:
%% Cell type:code id: tags:
``` python
importorekit
vm=orekit.initVM()
print ('Java version:',vm.java_version)
print ('Orekit version:',orekit.VERSION)
```
%% Output
Java version: 1.8.0_92
Java version: 1.8.0_152-release
Orekit version: 10.0
%% Cell type:markdown id: tags:
The orekit library needs a data file with various information on time and earth rotation parameters. This file, called orekit-data.zip is loaded from current dir. A basic version of this file can be downloaded from the orekit [webpage](https://www.orekit.org/forge/projects/orekit/files).
The orekit library needs a data file with various information on time and earth rotation parameters. This file, called orekit-data.zip is loaded from current dir as default.
This routine is commonly used in the notebooks, so a python specific function is created for this, setup_orekit_curdir()
This routine of setting up these parameters is commonly used in the notebooks, so a python specific function is created for this, setup_orekit_curdir()
%% Cell type:code id: tags:
``` python
fromorekit.pyhelpersimportsetup_orekit_curdir
setup_orekit_curdir()
```
%% Cell type:markdown id: tags:
Now we are set up to import and use objects from the orekit library.
Now we are set up to import and use objects from the orekit library. With the proper initialization, all objects in the orekit java library is exposed to Python and can be imported using normal Python syntax.
%% Cell type:code id: tags:
``` python
fromorg.orekit.utilsimportConstants
```
%% Cell type:code id: tags:
``` python
print (Constants.WGS84_EARTH_EQUATORIAL_RADIUS)
```
%% Output
6378137.0
%% Cell type:markdown id: tags:
SI base units are used in the library, such as seconds, meter, m/s
%% Cell type:markdown id: tags:
*Petrus Hyvönen, SSC, 2014*
# Documentation
%% Cell type:markdown id: tags:
One of the best sources of knowledge about orekit and the Python wrapper is on the orekit forum, https://forum.orekit.org/
%% Cell type:markdown id: tags:
## Orekit API
%% Cell type:markdown id: tags:
The Python version of orekit is very closely matching the java version and the API documentation from Java can be used. This documentation is available at https://www.orekit.org/site-orekit-10.1/apidocs/index.html
%% Cell type:markdown id: tags:
In addition to the API documentation there are a number of architecture descriptions, based on the Java syntax but highly applicable to the Python side. See https://www.orekit.org/doc-maven.html
%% Cell type:markdown id: tags:
# Specifics for the Python version of Orekit
%% Cell type:markdown id: tags:
For many users there will be no or little differnce in the usage of Orekit between Java and Python. The following chapter provides additional information for more advanced usage.
%% Cell type:markdown id: tags:
The Python version, or correctly stated the Python Wrapper (it is a pure java orekit that runs in background) has a few areas where there are specific ways to do things, limitations and some quirks. The wrapper is created with a tool called JCC (https://lucene.apache.org/pylucene/jcc/), which is providing most of these features and the documentation for that is relevant.
%% Cell type:markdown id: tags:
### Casting of classes
%% Cell type:markdown id: tags:
Java is a more strongly typed language than Python and is indirectly casting classes as part of the syntax. In most cases the Python user does not need to consider this when using orekit in Python, but in some cases it may be neccessary to specify which type or interface of a particular object that is refered to.
The Java language has a feature of parametric class definitions and orekit uses this in some areas. These can be managed in Python with the _of(Class) method that sets this.