On Saturday, November 26, 2016 at 8:53:24 AM UTC-5, WindnFog wrote:
>
> Is there a better way (from a Linux bash script, not Python) than parsing
> /home/weewx/public_html/index_html to obtain these values? I'm looking for
> the simplest solution.
>
this is what it looks like in perl, using the DateTime::Event module:
my $loc = "xxx, yyy";
my $skip = 0; # should we skip this image?
my $buffer = 45; # sunset/sunrise buffer in minutes
my($lat,$lon) = split(',', $loc);
my $dt = DateTime->now();
$dt->set_time_zone('local');
my $s = DateTime::Event::Sunrise->new(longitude => $lon, latitude => $lat);
my $span = $s->sunrise_sunset_span($dt);
my($y,$m,$d,$H,$M,$S) = $span->start->datetime =~
/(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)/;
my $sr = DateTime->new(
year => $y, month => $m, day => $d,
hour => $H, minute => $M, second => $S,
time_zone => 'local'
);
$sr->add(minutes => -$buffer);
($y,$m,$d,$H,$M,$S) = $span->end->datetime =~
/(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)/;
my $ss = DateTime->new(
year => $y, month => $m, day => $d,
hour => $H, minute => $M, second => $S,
time_zone => 'local'
);
$ss->add(minutes => $buffer);
$span = DateTime::Span->from_datetimes(start => $sr, end => $ss);
if (! $span->contains($dt)) {
print "skipping due to darkness (now=$dt sr=$sr ss=$ss)\n";
$skip = 1;
}
this is code we use when grabbing still images from network cameras for use
in timelapse videos:
http://sailing.mit.edu/weather
the implementation is called 'eyesee':
http://lancet.mit.edu/mwall/projects/eyesee
it is not terribly difficult to set up if you know linux, but it is harder
to set up that weewx.
m
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.