MenoData / Time4J

Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
GNU Lesser General Public License v2.1
424 stars 62 forks source link

Question about the use of altitude in solar calculations #977

Closed z3bi closed 1 year ago

z3bi commented 1 year ago

I see that altitude value is used in SolarTime to do two things:

1 - Correct the default atmospheric refraction to better reflect the pressure and temperature of that altitude 2 - Adjust the zenith angle which would be considered sunrise or sunset

For the second part, it seems like this is only valid if the observed sunrise/sunset is at sea level, is that assumption correct? If you are at a high altitude but the horizon is also at the same altitude then it seems like we should not be adjusting the geodetic angle (for example in the city of Denver, Colorado the elevation is around 5,000 ft but thats consistent all the way to the horizon).

MenoData commented 1 year ago

Sorry for my late reply. About your statements about the usage of altitude parameter, yes, that is right.

ad 1) Keep in mind that the used calculations for a standard atmospheric model are still approximations and can easily change with the weather.

ad 2) Your special situation with an observer located inside a mountain area (as the observer is in a kind of valley or deeper area between mountains at the horizon) would probably need a calculation without geodetic correction. Normally, the geodetic correction is fine for single high mountains like Kilimanjaro in East Africa. Time4J delivers at least four different calculators, one of them is StdSolarCalculator.NOAA which does not use any geodetic correction but also without a special correction for altitude-dependent atmosperic refraction.

If you want to keep the special efforts of StdSolarCalculator.TIME4J with altitude-dependent atmosperic refraction but with no geodetic correction then you might try something like:

    SolarTime.Calculator calculator = StdSolarCalculator.TIME4J;
    PlainDate date = PlainDate.of(2023, Month.MARCH, 10);

    // example: Hamburg / North Germany
    double latitude = 53.0;
    double longitude = 10.0;
    int altitude = 10;

    double zenith = 
        calculator.getZenithAngle(latitude, altitude) - calculator.getGeodeticAngle(latitude, altitude);

    Optional<Moment> sunrise = calculator.sunrise(date, latitude, longitude, zenith);

    if (sunrise.isPresent()) { // always true for Hamburg or Denver
        System.out.println(sunrise.get().toLocalTimestamp());
        // output for Hamburg: 2023-03-10T06:47:10
    }
MenoData commented 1 year ago

I have now enhanced the documentation of the altitude parameter in solar calculations.