Skip to content

TheNephilim88/solarpositioning

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solarpositioning

This is a Java library containing algorithms for finding the sun’s position on the sky for a given date and latitude and longitude (and other parameters). Currently, the PSA algorithm by Blanco-Muriel et al. and the SPA algorithm by Reda and Andreas are included.

Usage

import net.e175.klaus.solarpositioning.*;

public class App {
  public static void main(String[] args) {
    final GregorianCalendar dateTime = new GregorianCalendar();
    final double latitude = 48.21;
    final double longitude = 16.37;

    AzimuthZenithAngle position = PSA.calculateSolarPosition(dateTime,
                                                             latitude,
                                                             longitude);
    System.out.println("PSA: " + position);


    position = SPA.calculateSolarPosition(dateTime,
                                          latitude,
                                          longitude,
                                          190, // elevation
                                          67, // delta T
                                          1010, // avg. air pressure
                                          11); // avg. air temperature
    System.out.println("SPA: " + position);
  }
}

Which algorithm should I use?

When in doubt, use SPA. It's widely considered the reference algorithm for solar positioning, being very accurate and usable in a very large time window. Its only downside is that it's relatively slow.

If speed is critical (e.g. you need to calculate lots of positions), consider using PSA. Note however that it's highly optimised for its specified time window (1999-2015), and will be drastically less accurate outside of it.

A fast, yet still accurate alternative would be the Grena/ENEA algorithm, but that's not implemented yet.

How do I get the time of sunrise/sunset?

Not implemented yet. (Of course you could just search for the time when the zenith angle is 90° by calculating for several times, but that's neither efficient nor elegant.)

About

Java solar positioning code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published