Download the PHP package andrmoel/astronomy-bundle without Composer

On this page you can find all versions of the php package andrmoel/astronomy-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package astronomy-bundle

Table of Contents

  1. Introduction
  2. Installation
  3. Example data
  4. Angle Util
  5. Time of Interest
    1. Create TOI
    2. Julian Day, Centuries & Millennia
    3. GMST, GAST & Equation of Time
  6. Location
  7. Coordinate Systems (and transformations)
  8. Astronomical Objects
    1. Sun
      1. Position
      2. Distance to earth
      3. Sunrise, Sunset & Culmination
    2. Moon
      1. Position
      2. Distance to earth
      3. Moonrise, Moonset & Culmination
      4. Phases
    3. Planets
      1. Heliocentric position of a planet
      2. Geocentric position of a planet
      3. Rise, Set & Culmination
  9. Events
    1. Solar Eclipse
      1. Create a Solar Eclipse
      2. Type, Obscuration, Magnitude, Duration
      3. Contacts (C1, C2, MAX, C3, C4)
    2. Lunar Eclipse
  10. Other calculations
    1. Distance between two locations
    2. Nutatation of earth

Introduction

This library provides tools and methods for astronomical calculations. With this bundle it is possible to calculate the position of moon, sun and planets and several coordinate systems. For a higher accuracy, several corrections, like nutation and precision, were taken into account. It is also possible to calculate rise, set and culmination events for celestial objects. For a detailed see the table of contents.

Most of the calculations are based on Jean Meeus 'Astronomical Algorithms' book and the VSOP87 theory.

Installation

Use composer to install this package.

Example data

Some example calculations are provided inside the /examples folder of the project dir. Usage:

Angle Util

The angle util provides helper methods to convert an angle into different formats.

Example 1: Convert decimal angle

The result of the calculation should be:\ Angle: 132°36'10.542"\ Time: 8h50m24.703s

Example 2: Convert time into decimal format

The result of the calculation should be:\ Angle: 132.60292916667°

Time of Interest

The TimeOfInterest (TOI) object represents the time for which all of the astronomical calculations are done. For that reason it is the most important object in this library.

:information_source: Why can't we simply use PHP's DateTime object?

The problem with PHP's own DateTime object is, that its supported range is '1000-01-01' to '9999-12-31'. So we cannot process calculations for dates before year 1000.

Create the TimeOfInterest object

There are several ways how to initialize the TOi object.

Example 1: Initialize the TimeOfInterest object for the date 02 July 2017 at 15:30:00 UTC

The Result will be always: 2017-07-02 15:30:00

Example 2: Create the TOI object for the current date and time in UTC

The TimeOfInterest provides some methods to modify the time:

Example 3: Create the TOI object for the current time and change the time to 2017-07-02 15:30:00 UTC

The Result will be always: 2017-07-02 12:00:00

Julian Day, Julian Centuries from J2000 and Julian Millennia from J2000

Example: Create TOI for 02 July 2017 at 13:37 UTC

The result of the calculation should be:\ Julian Day: 2457937.0673611\ Julian Day 0: 2457936.5\ Julian Centuries J2000: 0.1750052665602\ Julian Millennia J2000: 0.01750052665602

Greenwich Mean Sidereal Time (GMST), Greenwich Apparent Sidereal Time (GAST) and Equation of Time

With the help of the TOI-Object it is possible to calculate the GMST, GAST and the equation in time (units of all values are degrees). The following example explains how to get these values for 20 December 1992 at 00:00 UTC.

The result of the calculation should be:\ GMST: 88.82536°\ GAST: 88.829629°\ Equation of Time: 0.619485°

You may convert this values into the more common angle format by using AngleUtil::dec2time($value). The result will be:\ GMST: 5h55m18.086s\ GAST: 5h55m19.111s\ Equation of Time: 0h2m28.676s

Location

The location object represents the location of the observer on the earth's surface.

Coordinate systems and transformations

The bundle provides the common astronomical coordinate systems for calculations.

Each class provides methods to transform one coordinate system into another.

Example 1: Convert Geocentric Equatorial Spherical Coordinates into Geocentric Ecliptical Spherical Coordinates

Example 2: Convert Geocentric Equatorial Spherical Coordinates to Local Horizontal Coordinates

Astronomical Objects

An astronomical object must be initialized with the TOI. If you don't pass the TOI in the constructor, the current time is chosen.

Sun

Position of the sun

Example 1: Calculate the position of the sun for 17 May 2019 at 17:50 UTC

The result of the calculation should be:\ Longitude: 56.544°\ Latitude: 0.0001°

Example 2: Calculate azimuth and altitude of the sun observed in Berlin, Germany for 17 May 2019 at 17:50 UTC

The result of the calculation should be:\ Azimuth: 291.0°\ Altitude: 8.49°

The result of the altitude is corrected by atmospheric refraction. To obtain the local horizontal coordinates without correction of refraction, pass false as second parameter:

$locHorCoord = $sun->getLocalHorizontalCoordinates($location, false);

Distance of the sun to earth

Example 1: The current distance of the sun in kilometers can be calculated as follow:

The result should be between 147.1 mio and 152.1 mio kilometers.

Example 2: Get the distance of the sun on 05 June 2017 at 20:50 UTC

The result should be 151797703km.

Sunrise, sunset and upper culmination

Calculate sunrise, sunset and upper culmination of the sun on 17 May 2019 in Berlin:

The result of the calculation should be:\ Sunrise: 03:08 UTC\ Sunset: 18:59 UTC\ Upper culmination: 13:03 UTC

Moon

Position of the moon

Example 1: Calculate the geocentric position of the moon for 12 April 1992 at 00:00 UTC.

The result of the calculation should be:\ Right ascension: 134.69°\ Declination: 13.77°

Example 2: Calculate azimuth and altitude of the moon observed in Berlin, Germany for 20 May 2019 at 23:00 UTC

The result of the calculation should be:\ Azimuth: 153.3°\ Altitude: 12.28°

The result of the altitude is corrected by atmospheric refraction. To obtain the local horizontal coordinates without correction of refraction, pass false as second parameter:

$locHorCoord = $moon->getLocalHorizontalCoordinates($location, false);

Distance of the moon to earth

Example 1: The current distance of the moon in kimometers can be calculated as follow:

The result should be between 363300km and 405500km.

Example 2: Get the distance of the moon on 05 June 2017 at 20:50 UTC

The result should be 402970km.

Moonrise, moonset and upper culmination

Phases of the moon

The following code sniped explains how to calculate all important parameters which belong to the moons phase for an specific date. In this example it is 13 May 2019 at 21:30 UTC.

The result of the calculation should be:\ Is waxing moon: yes\ Illumination: 0.709 (70.9%)\ Position angle of bright limb: 293.54°

Planets

Like Sun and Moon-Objects, the Planets can be created by passing the TimeOfInterest. If no TimeOfInteressed is passed, the current date and time are used for further calculations.

Example: Create some planets

Heliocentric position of a planet

The calculations use the VSOP87 theory to obtain the heliocentric position of a planet.

Example: Calculate the heliocentric position of Venus for 20. December 1992 at 00:00 UTC.

The result of the calculation should be:\ Longitude: 26.11412°\ Latitude: -2.62063°\ Radius vector: 0.72460\ X: 0.64995327095595\ Y: 0.31860745636351\ Z: -0.033130385747949

Geocentric position of a planet

All solutions for the geocentric calculations give the apparent position of a planet. That means the position of the planet is corrected by light time and aberration.

Example 1: Calculate the apparent geocentric position of Venus on 25 October 2018 at 07:15 UTC

The result of the calculation should be:\ Longitude: 213.898092° (213°53'53.131")\ Latitude: -6.476359° (-6°28'34.891")\ Right ascension: 209.340427° (13h57m21.702s)\ Declination: -18.898191° (-18°53'53.487")

Example 2: Calculate the azimuth and altitude of Venus on 25 October 2018 at 07:15 UTC in Berlin

The result of the calculation should be:\ Azimuth: 130.202°\ Altitude: 5.038°

The result of the altitude is corrected by atmospheric refraction. To obtain the local horizontal coordinates without correction of refraction, pass false as second parameter:

$locHorCoord = $venus->getLocalHorizontalCoordinates($location, false);

Rise, set and upper culmination

Calculate rise, set and upper culmination of Venus on 25 October 2018 at 07:15 UTC in Berlin:

The result of the calculation should be:\ Rise: 06:31 UTC\ Set: 15:06 UTC\ Upper culmination: 10:49 UTC

Events

Solar eclipse

Create a Solar Eclipse object

Example: Create a solar eclipse for 21 August 2017 for the location Madrads in Oregon (USA)

Note: If the date of the eclipse is invalid, an exception will be thrown.

Eclipse type, Obscuration, Magnitude, Duration, etc.

To obtain the eclipse circumstances of the maximum eclipse for a given location, see the following examples.

The type of an eclipse (for the given location) is expressed in a string. But it is better to use the following constants: SolarEclipse:TYPE_NONE, SolarEclipse:TYPE_PARTIAL, SolarEclipse:TYPE_ANNULAR or SolarEclipse:TYPE_TOTAL.

Example 1: Local circumstances for the total solar eclipse of 21 August 2017 for Madras, OR

The result of the calculation should be:\ Type: total\ Duration of eclipse: 9257s\ Duration of totality: 120s\ Obscuration: 1 (100%)\ Magnitude: 1.01\ Moon-sun-ratio: 1.03

Example 2: Local circumstances for the partial solar eclipse of 20 March 2015 in Berlin

The result of the calculation should be:\ Type: partial\ Duration of eclipse: 8386s\ Duration of totality: 0s\ Obscuration: 0.74 (74%)\ Magnitude: 0.79\ Moon-sun-ratio: 1.05

Contacts (C1, C2, MAX, C3, C4)

It is possible to obtains the current circumstances for each contact type (C1, C2, MAX, C3 and X4) for an eclipse.

Example: Obtain the exact time of the second contact (C2) and the position of the sun. The solar eclipse happens on 21 August 2017 in Madras, Oregon.

The result of the calculation for the second contact (C2) should be:\ Time of Interest: 2017-06-21 17:19:24 UTC\ Azimuth of sun: 118.9°\ Altitude of sun: 41.4°

The result of the altitude is corrected by atmospheric refraction. To obtain the local horizontal coordinates without correction of refraction, pass false as parameter:

$locHorCoord = $c2->getLocalHorizontalCoordinates(false);

Lunar eclipse

Other calculations

Distance between two locations

The result of the calculation should be 6436km.

Nutation of earth

The result of the calculation should be:\ Nutation in longitude: -0°0'3.788"\ Nutation in obliquity: 0°0'9.442"


All versions of astronomy-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andrmoel/astronomy-bundle contains the following files

Loading the files please wait ....