Code Monkey home page Code Monkey logo

ephemeris's Introduction

ephemeris - forked from singulariti-tech (https://github.com/singulariti-tech/ephemeris)

A Java port of Ephemeris calculations by Peter Hayes. Since the original JavaScript version of the code could not be found, we are unable to link to it. There are a few versions available on github and a few hosted versions too. This version is more or less an exact port of the original (specifically the calculations which are based on Jean Meeus' calculations). This version is being provided only as a library and so does not include a front-end.

The code provides calculators for determining the positions of the Sun, Moon, Planets and several stars as viewed from a particular position on Earth.

Github repo of the JS version

clicktrend/ephemeris

Hosted versions

Stargazing

Building the code

mvn clean package

Usage

Sample code below shows how you can use each of the calculators to generate the Ephemeris.

Observatory

The location on Earth from where you want to view the astronomical body


// Create an instance of the observatory
double latitude = 13.0068;
double longitude = 76.0996;

ZonedDateTime time = ZonedDateTime.of(2017, 11, 7, 0, 0, 0, 0, ZoneId.of("UTC")); //Date and time in UTC

Place place = new Place("Hassan", latitude, Pole.NORTH, longitude, Pole.EAST, TimeZone.getTimeZone("Asia/Calcutta"), "", "");
Observatory hassan = new Observatory(place, time); //observatory is a place at a specific time

Sun Position

Calculating position of the sun as viewed from the Observatory


// Create an instance of the Sun position calculator
SunPositionCalculator solarCalc = new SunPositionCalculator();
SunPosition sunPosition = solarCalc.getPosition(hassan);

sunPosition.getRiseTime(); //Rise time
sunPosition.getSetTime(); //Set time
sunPosition.getAzimuth(); //Azimuth
sunPosition.getAltitude(); //Elevation

There's a convenience method to generate the Ephemeris for a period.


int timeIntervalInMinutes = 10; //Positions to be calculated every 10 minutes from the start time
ZonedDateTime anotherTime = ZonedDateTime.of(2017, 11, 8, 0, 0, 0, 0, ZoneId.of("UTC")); //Date and time in UTC
List<SunPosition> ephemerides = sun.getEphemeris(obs, time, anotherTime, timeIntervalInMinutes);

Moon Position

Calculating position of the moon as viewed from the Observatory


MoonPositionCalculator lunarCalc = new MoonPositionCalculator();
MoonPosition moonPosition = lunarCalc.getPosition(hassan);

You can generate the Ephemeris with a specified interval as with the SunCalculator.

Planet Position

Calculating position of a planet as viewed from the Observatory


PlanetPositionCalculator planetCalc = new PlanetPositionCalculator();
Planet mars = PlanetCatalog.byName("Mars");
PlanetPosition marsPosition = planetCalc.getPosition(mars, hassan);

The Ephemeris can be generated as with the SunCalculator.

Star Position

Calculating the position of a Star as viewed from the Observatory


StarCalculator starCalculator = new StarCalculator();
Star casA = StarCatalog.byIdAndConstellation("a", "cas");
StarPosition casAPosition = starCalc.getPosition(casA, hassan);

The Ephemeris can be generated as with the SunCalculator.

License

This project is licensed under the terms of the Apache 2 license.

ephemeris's People

Contributors

johnemmanuel avatar esspecialmkb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.