astrocalc 0.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 48

AstroCalc

This library is a Dart port of the awesome Vladimir Agafonkin (@mourner)'s JavaScript library for calculating sun and moon positions and phases for a given location and time.

Calculations for other solar system bodies are also in the works.

Usage

AstroCalc is available on Pub.

See the examples folder for usage examples.

Reference

BaseCalc

// Latitude and longitude in degrees
BaseCalc baseCalcChild = BaseCalcChild({ DateTime date, num longitude, num latitude })

All celestial body classes inherit from the abstract class BaseCalc. On instantiation, they all calculate and expose the following properties of the body for the provided location and time (each is a Map):

PropertyDescription
eclipticCoordsEarth-based ecliptic coordinates: latitude (eclipticCoords['lat']) and longitude (eclipticCoords['lng'])
equatorialCoordsEquatorial coordinates: right ascension (equatorialCoords['ra'] and declination equatorialCoords['dec'])
positionEarth-based horizontal coordinates: azimuth (position['azimuth']) and altitude (position['altitude'])
timesTimes of astronomical interest (body-specific)

The coordinate systems are returned in radians. For more information on each, see the following links:

SunCalc

SunCalc sunCalc = new SunCalc({ DateTime date, num longitude, num latitude })

In addition to the coordinate systems, SunCalc calculates the following times (accessible as properties of the Map sunCalc.times)

PropertyDescription
nightEndnight ends (morning astronomical dawn starts)
nauticalDawnnautical dawn (morning nautical dawn starts)
dawndawn (morning nautical dawn ends, morning civil dawn starts)
sunrisesunrise (top edge of the sun appears on the horizon)
sunriseEndsunrise ends (bottom edge of the sun touches the horizon)
goldenHourEndmorning golden hour (soft light, best time for photography) ends
solarNoonsolar noon (sun is in the highest position)
goldenHourevening golden hour starts
sunsetStartsunset starts (bottom edge of the sun touches the horizon)
sunsetsunset (sun disappears below the horizon, evening civil twilight starts)
duskdusk (evening nautical twilight starts)
nauticalDusknautical dusk (evening astronomical twilight starts)
nightnight starts (dark enough for astronomical observations)
nadirnadir (darkest moment of the night, sun is in the lowest position)

Changelog

All notable changes to this project will be documented in this file.

28/09/2017 (0.0.1)

Added

  • Base, extendable calc class with calculations for:

    • Ecliptic coordinates (latitude and longitude)
    • Equatorial coordinates (right ascension and declination)
    • Horizonatal coordinates (azimuth and altitude)
  • Times calculations for the Sun

    • nightEnd
    • nauticalDawn
    • dawn
    • sunrise
    • sunriseEnd
    • goldenHourEnd
    • solarNoon
    • goldenHour
    • sunsetStart
    • sunset
    • dusk
    • nauticalDusk
    • night
    • nadir

example/astrocalc_example.dart

import 'package:astrocalc/astrocalc.dart';

main() {
  SunCalc sunCalc = new SunCalc(
    date: new DateTime.now(),
    longitude: 3.3839178,
    latitude: 6.5069113
  );
  print(sunCalc.position);
  print(sunCalc.times);
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  astrocalc: "^0.0.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:astrocalc/astrocalc.dart';
        
Version Uploaded Documentation Archive
0.0.1 Sep 29, 2017 Go to the documentation of astrocalc 0.0.1 Download astrocalc 0.0.1 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
48
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:astrocalc/astrocalc.dart.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 9 hints.

    Run dartfmt to format lib/astrocalc.dart.

    Run dartfmt to format lib/src/base_calc.dart.

    Similar analysis of the following files failed:

    • lib/src/constants.dart (hint)
    • lib/src/sun_calc.dart (hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0