Coder Social home page Coder Social logo

suncalcpy's Introduction

SunCalcPy

A Python library for calculating sun/moon times, positions and phases. Includes methods for getting:

  • sunrise
  • sunset
  • moonrise
  • moonset
  • golden hour
  • sun position
  • moon position
  • moon illumination
  • and more!

Installing

pip install suncalcPy

Usage examples:

Get sunrise, sunset, golden hour and other times for San Francisco:
>>> import suncalc
>>> suncalc.getTimes(datetime.now(), 37.7749, -122.4194)
{
   'sunriseEnd': '2017-09-06 06:48:24', 
   'goldenHourEnd': '2017-09-06 07:20:27', 
   'dusk': '2017-09-06 19:59:44', 
   'nightEnd': '2017-09-06 05:15:09', 
   'night': '2017-09-06 21:03:39', 
   'goldenHour': '2017-09-06 18:58:21', 
   'sunset': '2017-09-06 19:33:08', 
   'nauticalDawn': '2017-09-06 05:47:35', 
   'sunsetStart': '2017-09-06 19:30:24', 
   'dawn': '2017-09-06 06:19:04', 
   'nauticalDusk': '2017-09-06 20:31:13', 
   'sunrise': '2017-09-06 06:45:40'
}
Get moon illumination information:
>>> import suncalc
>>> suncalc.getMoonIllumination(datetime.now())
{
   'phase': 0.5198419002220316, 
   'angle': 1.574687975565145, 
   'fraction': 0.9961193570459752
}
Get moonrise/moonset times for San Francisco:
>>> import suncalc
>>> suncalc.getMoonTimes(datetime.now(), 37.7749, -122.4194)
{
   'rise': datetime.datetime(2017, 9, 6, 20, 4, 29, 213367), 
   'set': datetime.datetime(2017, 9, 6, 6, 56, 30, 536332)
}

suncalcpy's People

Contributors

broham avatar mrharcombe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

suncalcpy's Issues

"ImportError: No module named suncalc" ... although installed via "pip install suncalcPy"

Short:
I get "ImportError: No module named suncalc" ... although installed via "pip install suncalcPy"

Tips how to solve?

Long:

sander@sammie:~$ pip install suncalcPy
Collecting suncalcPy
Installing collected packages: suncalcPy
Successfully installed suncalcPy-0.1

but I get:

sander@sammie:~$ python -c "import suncalc"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named suncalc
sander@sammie:~$ 

It is really installed:

sander@sammie:~$ pip uninstall suncalcPy
Uninstalling suncalcPy-0.1:
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/DESCRIPTION.rst
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/INSTALLER
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/METADATA
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/RECORD
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/WHEEL
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/metadata.json
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy-0.1.dist-info/top_level.txt
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy/suncalc.py
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy/suncalc.pyc
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy/test.py
  /home/sander/.local/lib/python2.7/site-packages/suncalcPy/test.pyc
Proceed (y/n)? y
  Successfully uninstalled suncalcPy-0.1

and the uninstall works too:

sander@sammie:~$ pip uninstall suncalcPy
Cannot uninstall requirement suncalcPy, not installed
sander@sammie:~$ 

Development status?

Hi, this library is perfect for a project I have in mind, it's lightweight and small.

However, there are a few open issues and pull requests, plus a variety of other minor problems I've seen. What do you think about fixing them up? If not, I am prepared to fork and continue development with the assistance of other coders.

Thanks

wrong results when daylight time

hello

now that we have daylight savings time, sunrise, sunset, moonrise, moonset are all -1 hour.
How to fix this ?
thanks in advance
frank

Azimuth Error

As I attempt get azimuth, the result is more different than SunCalc.org. Suncalc.org says 298.54° but suncalcPy says 2.0824 radians or 119.31° for intersection of Greenwich and Equator(0,0)

Moonset if Hour is 0 then it should be the next day

First of all thank you for this cool and short routine to determine sun and moon data. I noticed, that the moon-set date remains on the same day if it is after midnight. I think the date should be one day later (add 1 day to date). I added following to the getMoonTimes method almost at the end (where if (sett): is):
def getMoonTimes(date, lat, lng):

   if (sett):

       if int(sett) == 0:

           sett +=24

   result["set"] = hoursLater(t, sett)

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.