Latest version
Close
May 28, 2015 Kumpulan Website tempat mencari contoh kode program komputer dan web — Internet adalah tempat terbaik untuk belajar bahasa pemograman komputer, karena di Internet tersedia berbagai tutorial, tips dan trik serta contoh-contoh kode program komputer. Hanya dengan menemukan website yang tepat, maka Anda bisa mendapatkan beberapa contoh kode program untuk berbagai keperluan.
Last released:
Use a JPL ephemeris to predict planet positions.
Project description
This package can load and use a Jet Propulsion Laboratory (JPL)ephemeris for predicting the position and velocity of a planet or otherSolar System body. It only needs NumPy,which pip will automatically attempt to install alongsidepyephem when you run:
If you see NumPy compilation errors, then try downloading and installingNumPy directly from its web site or simplyuse a distribution of Python with science tools already installed, likeAnaconda.
Note that jplephem offers only the logic necessary to produce plainthree-dimensional vectors. Most programmers interested in astronomywill want to look at Skyfieldinstead, which uses jplephem but converts the numbers into moretraditional measurements like right ascension and declination.
Most users will use jplephem with the Satellite Planet Kernel (SPK)files that the NAIF facility at NASA JPL offers for use with their ownSPICE toolkit. They have collected their most useful kernels beneaththe directory:
To learn more about SPK files, the official SPK Required Readingdocument is available from the NAIF facility’s web site under the NASAJPL domain.
Command Line Tool
If you have downloaded a .bsp file, you can run jplephem fromthe command line to display the data inside of it:
You can also take a large ephemeris and produce a smaller excerpt bylimiting the range of dates that it covers:
If the input ephemeris is a URL, then
jplephem
will try to savebandwidth by fetching only the blocks of the remote file that arenecessary to cover the dates you have specified. For example, theJupiter satellite ephemeris jup310.bsp
is famously large, weighing ina nearly a gigabyte. But if all you need are Jupiter’s satellites for afew months, you can download considerably less data:In this case only about one-thousandth of the ephemeris’s data needed tobe downloaded, a download which took less than one minute.
Getting Started With DE430
The recent DE430 ephemeris is a useful starting point. It weighs in at115 MB, but provides predictions across the generous range of years1550–2650:
After the kernel has downloaded, you can use jplephem to load thisSPK file and learn about the segments it offers:
Each segment of the file lets you predict the position of an object withrespect to some other reference point. If you want the coordinates ofMars at 2457061.5 (2015 February 8) with respect to the center of thesolar system, this ephemeris only requires you to take a single step:
But learning the position of Mars with respect to the Earth takes threesteps, from Mars to the Solar System barycenter to the Earth-Moonbarycenter and finally to Earth itself:
You can see that the output of this ephemeris is in kilometers. If youuse another ephemeris, check its documentation to be sure of the unitsthat it employs.
If you supply the date as a NumPy array, then each component that isreturned will itself be a vector as long as your date:
Some ephemerides include velocity inline by returning a 6-vector insteadof a 3-vector. For an ephemeris that does not, you can ask for theChebyshev polynomial to be differentiated to produce a velocity, whichis delivered as a second return value:
Details of the API
Here are a few details for people ready to go beyond the high-level APIprovided above and read through the code to learn more.
- Instead of reading an entire ephemeris into memory, jplephemmemory-maps the underlying file so that the operating system canefficiently page into RAM only the data that your code is using.
- Once the metadata has been parsed from the binary SPK file, thepolynomial coefficients themselves are loaded by building a NumPyarray object that has access to the raw binary file contents.Happily, NumPy already knows how to interpret a packed array ofdouble-precision floats. You can learn about the underlying DAF“Double Precision Array File” format, in case you ever need to openother such array files in Python, through the DAF class in themodule jplephem.daf.
- An SPK file is made of segments. When you first create an SPKkernel object k, it examines the file and creates a list ofSegment objects that it keeps in a list under an attribute namedk.segments which you are free to examine in your own code bylooping over it.
- There is more information about each segment beyond the one-linesummary that you get when you print out the SPK file, which you cansee by asking the segment to print itself verbosely:
- Each Segment loaded from the kernel has a number of attributesthat are loaded from the SPK file:
- If you want to access the raw coefficients, use the segmentload_array() method. It returns two floats and a NumPy array:
- The square-bracket lookup mechanism kernel[3,399] is anon-standard convenience that returns only the last matching segmentin the file. While the SPK standard does say that the last segmenttakes precedence, it also says that earlier segments for a particularcenter-target pair should be fallen back upon for dates that the lastsegment does not cover. So, if you ever tackle a complicated kernel,you will need to implement fallback rules that send some dates to thefinal segment for a given center and target, but that send other datesto earlier segments that are qualified to cover them.
- If you are accounting for light travel time and require repeatedcomputation of the position, but then need the velocity at the end,and want to avoid repeating the expensive position calculation, thentry out the segment.generate() method - it will let you ask forthe position, and then only proceed to the velocity once you are surethat the light-time error is now small enough.
High-Precision Dates
Since all modern Julian dates are numbers larger than 2.4 million, astandard 64-bit Python or NumPy float necessarily leaves only a limitednumber of bits available for the fractional part. Technical Note2011-02 from the United States Naval Observatory’s AstronomicalApplications Department suggests that the precision possible with a64-bit floating point Julian date is around 20.1 µs.
If you need to supply times and receive back planetary positions withgreater precision than 20.1 µs, then you have two options.
First, you can supply times using the special float96 NumPy type,which is also aliased to the name longfloat. If you provide eithera float96 scalar or a float96 array as your tdb parameter toany jplephem routine, you should get back a high-precision result.
Second, you can split your date or dates into two pieces, and supplythem as a pair of arguments two tdb and tdb2. One popularapproach for how to split your date is to use the tdb float for theinteger Julian date, and tdb2 for the fraction that specifies thetime of day. Nearly all jplephem routines accept this optionaltdb2 argument if you wish to provide it, thanks to the work ofMarten van Kerkwijk!
Legacy Ephemeris Packages
Back before I learned about SPICE and SPK files, I had run across thetext-file formatted JPL ephemerides at:
I laboriously assembled the data in these text files into native NumPyarray files and wrapped them each in a Python package so that userscould install an ephemeris with a simple command:
If you want to use one of these pip-installable ephemerides, you will beusing a slightly older API, and will lose the benefit of the efficientmemory-mapping that the newer SPK code performs. With the old API, hereis how you would load DE421 and compute a position, given a barycentricdynamical time expressed as a Julian date:
For more information about the legacy API, consult the jplephementry on PyPI for the final release of the 1.x series:
The ephemerides that were made available as Python packages (thefollowing links explain the differences between them) are:
- DE405 (May 1997)— 54 MB covering years 1600 through 2200
- DE406 (May 1997)— 190 MB covering years -3000 through 3000
- DE421 (February 2008)— 27 MB covering years 1900 through 2050
- DE422 (September 2009)— 531 MB covering years -3000 through 3000
- DE423 (February 2010)— 36 MB covering years 1800 through 2200
Reporting issues
You can report any issues, bugs, or problems at the GitHub repository:
Changelog
2019 January 3 — Version 2.9
- Added the load_array() method to the segment class.
2018 July 22 — Version 2.8
- Switched to a making a single memory map of the entire file, to avoidrunning out of file descriptors when users load an ephemeris withhundreds of segments.
2018 February 11 — Version 2.7
- Expanded the command line tool, most notably with the ability to fetchover HTTP only those sections of a large ephemeris that cover aspecific range of dates, producing a smaller .bsp file.
2016 December 19 — Version 2.6
- Fixed the ability to invoke the module from the command line withpython -m jplephem, and added a test to keep it fixed.
2015 November 9 — Version 2.5
- Move fileno() call out of the DAF constructor to supportfetching at least summary information from StringIO objects.
2015 November 1 — Version 2.4
- Add Windows compatibility by switching mmap() from usingPAGESIZE to ALLOCATIONGRANULARITY.
- Avoid a new NumPy deprecation warning by being careful to use onlyintegers in the NumPy shape tuple.
- Add names “TDB” and “TT” to the names database for DE430.
2015 August 16 — Version 2.3
- Added auto-detection and support for old NAIF/DAF kernels likede405.bsp to the main DAF class itself, instead of requiringthe awkward use of an entirely different alternative class.
2015 August 5 — Version 2.2
- You can now invoke jplephem from the command line.
- Fixes an exception that was raised for SPK segments with a coefficientcount of only 2, like the DE421 and DE430 segments that provide theoffset of Mercury from the Mercury barycenter.
- Supports old NAIF/DAF kernels like de405.bsp.
- The SPK() constructor is now simpler, taking a DAF objectinstead of an open file. This is considered an internal API change —the public API is the constructor SPK.open().
2015 February 24 — Version 2.1
- Switched from mapping an entire SPK file into memory at once tomemory-mapping each segment separately on demand.
2015 February 8 — Version 2.0
- Added support for SPICE SPK kernel files downloaded directly fromNASA, and designated old Python-packaged ephemerides as “legacy.”
2013 November 26 — Version 1.2
- Helge Eichhorn fixed the default for the position_and_velocity()argument tdb2 so it defaults to zero days instead of 2.0 days.Tests were added to prevent any future regression.
2013 July 10 — Version 1.1
- Deprecates the old compute() method in favor of separateposition() and position_and_velocity() methods.
- Supports computing position and velocity in two separate phases bysaving a “bundle” of coefficients returned by compute_bundle().
- From Marten van Kerkwijk: a second tdb2 time argument, for userswho want to build higher precision dates out of two 64-bit floats.
2013 January 18 — Version 1.0
- Initial release
References
The Jet Propulsion Laboratory’s “Solar System Dynamics” page introducesthe various options for doing solar system position computations:http://ssd.jpl.nasa.gov/?ephemerides
The plain ASCII format element sets from which the jplephem Pythonephemeris packages are built, along with documentation, can be found at:ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/
Equivalent FORTRAN code for using the ephemerides be found at the sameFTP site: ftp://ssd.jpl.nasa.gov/pub/eph/planets/fortran/
Release historyRelease notifications
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.1
2.0
1.2
1.1
1.0
0.1
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size jplephem-2.9.tar.gz (31.5 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for jplephem-2.9.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | 9dffb9f3d3f6d996ade875102431fe385e8ea422da25c8ba17b0508d9ca1282b |
MD5 | d30bb040b155ce6dcbfa94d5f6abe80b |
BLAKE2-256 | 146f354fd50e625a66c7be3f08095c0e1fa389c75453858acf2689ffa9c4fc54 |
CodeIgniter is an Application Development Framework - a toolkit - for peoplewho build web sites using PHP. Its goal is to enable you to develop projectsmuch faster than you could if you were writing code from scratch, by providinga rich set of libraries for commonly needed tasks, as well as a simpleinterface and logical structure to access these libraries. CodeIgniter letsyou creatively focus on your project by minimizing the amount of code neededfor a given task.
Release Information
This repo contains in-development code for future releases. To download thelatest stable release please visit the CodeIgniter Downloads page.
Changelog and New Features
You can find a list of all changes for each release in the userguide change log.
Server Requirements
PHP version 5.6 or newer is recommended.
It should work on 5.3.7 as well, but we strongly advise you NOT to runsuch old versions of PHP, because of potential security and performanceissues, as well as missing features.
Installation
Please see the installation sectionof the CodeIgniter User Guide.
License
Please see the licenseagreement.
Resources
Report security issues to our Security Panelor via our page on HackerOne, thank you.
Acknowledgement
The CodeIgniter team would like to thank EllisLab, all thecontributors to the CodeIgniter project and you, the CodeIgniter user.