in reply to calculate length of day as function of space at onset of fall
Hi Datz_cozee75,
When did fall begin? Is there only one answer to that question?
A quick reading of Wikipedia leads me to believe that there are plenty of different definitions of the beginnings and ends of the seasons, depending on region and culture. But apparently in North America (aside from the simpler meteorological definitions based on calendar months), it's the March & September equinoxes and the June & December solstices. That also seems to match with your definition, "fall occurs exactly when the sun sets in the west".
how long was the day today?
A bit more research, and CPAN comes to the rescue. First, the output:
At 21.3N 157.816667W: In 2016: Spring begins on the March equinox at 2016-03-19 18:29:48 HST. Sunrise is at 06:32:58 HST, sunset is at 18:40:50 HST, and the day is 12 hours, 7 minutes, and 52 seconds long. Summer begins on the June solstice at 2016-06-20 12:33:55 HST. Sunrise is at 05:48:34 HST, sunset is at 19:14:27 HST, and the day is 13 hours, 25 minutes, and 53 seconds long. Fall begins on the September equinox at 2016-09-22 04:20:41 HST. Sunrise is at 06:18:46 HST, sunset is at 18:24:11 HST, and the day is 12 hours, 5 minutes, and 25 seconds long. Winter begins on the December solstice at 2016-12-21 00:44:00 HST. Sunrise is at 07:03:22 HST, sunset is at 17:53:41 HST, and the day is 10 hours, 50 minutes, and 19 seconds long. In 2017: Spring begins on the March equinox at 2017-03-20 00:28:31 HST. Sunrise is at 06:32:16 HST, sunset is at 18:41:04 HST, and the day is 12 hours, 8 minutes, and 48 seconds long. Summer begins on the June solstice at 2017-06-20 18:23:42 HST. Sunrise is at 05:48:31 HST, sunset is at 19:14:24 HST, and the day is 13 hours, 25 minutes, and 53 seconds long. Fall begins on the September equinox at 2017-09-22 10:01:07 HST. Sunrise is at 06:18:43 HST, sunset is at 18:24:25 HST, and the day is 12 hours, 5 minutes, and 42 seconds long. Winter begins on the December solstice at 2017-12-21 06:27:50 HST. Sunrise is at 07:03:15 HST, sunset is at 17:53:33 HST, and the day is 10 hours, 50 minutes, and 18 seconds long.
And the code:
#!/usr/bin/env perl use warnings; use strict; use Astro::Utils; use DateTime; use DateTime::Event::Sunrise; use DateTime::Format::Strptime; use DateTime::Format::Human::Duration; my $LONG = -157.816667; # E = +, W = - my $LAT = 21.3; # N = +, S = - my $ZONE = 'Pacific/Honolulu'; my $sun = DateTime::Event::Sunrise->new( precise=>1, longitude => $LONG, latitude => $LAT ); my $strp = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S', time_zone=>'UTC', on_error=>'croak'); my $durfmt = DateTime::Format::Human::Duration->new(); print "At ".abs($LAT).($LAT>0?"N":"S") ." ".abs($LONG).($LONG>0?"E":"W").":\n"; my $now_year = DateTime->now->year; for my $year ($now_year, $now_year+1) { print " In $year:\n"; my @seas = ( [ 'Spring', 'March equinox', calculate_equinox ('mar', 'utc', $year) ], [ 'Summer', 'June solstice', calculate_solstice('jun', 'utc', $year) ], [ 'Fall', 'September equinox', calculate_equinox ('sep', 'utc', $year) ], [ 'Winter', 'December solstice', calculate_solstice('dec', 'utc', $year) ], ); for my $seas (@seas) { my ($sname,$when,$start) = @$seas; $start = $strp->parse_datetime($start); $start->set_time_zone($ZONE); my $rise = $sun->sunrise_datetime($start); my $set = $sun->sunset_datetime($start); my $dur = $durfmt->format_duration_between($rise, $set); print " $sname begins on the $when at ", $start->strftime('%Y-%m-%d %H:%M:%S %Z'),".\n"; print " Sunrise is at ",$rise->strftime('%H:%M:%S %Z'), ", sunset is at ",$set->strftime('%H:%M:%S %Z'),",\n"; print " and the day is $dur long.\n"; } }
I know this doesn't address the "as function of space" part of the question, but still, a fun little weekend project :-)
Update: Perhaps Astro::Coord::ECI::Sun could be useful?
Regards,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: calculate length of day as function of space at onset of fall
by Aldebaran (Curate) on Sep 28, 2016 at 08:01 UTC |