Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Moon phase on historical events

by Aldebaran (Curate)
on Oct 09, 2021 at 08:15 UTC ( [id://11137380]=note: print w/replies, xml ) Need Help??


in reply to Moon phase on historical events

I found this understandable once I went through it with the debugger. A person can get caught up in the geometry of it. This comes at it with strings. I changed the events to my locality and then switched the location to a point somewhere in bliako's neighborhood:

{ "name" => "Current Moon in the 'Ho", "date" => "2021-10-09", "time" => "01:00:00", "timezone" => "America/Boise", }, { "name" => "Scylla and Charybdis", "date" => "2021-10-09", "time" => "01:00:00", "location" => {lon=>38.245833, lat=>15.6325}, },
Current Moon in the 'Ho on 2021-10-09T01:00:00 (1633762800 seconds uni +x-epoch) timezone: America/Boise Moon age: 3.16929659167535 days Moon phase: 10.7 % of cycle (birth-to-death) Moon's illuminated fraction: 10.9 % of full disc important moon phases around the event: New Moon = Wed Oct 6 05:05:44 2021 First quarter = Tue Oct 12 21:27:35 2021 Full moon = Wed Oct 20 08:57:41 2021 Last quarter = Thu Oct 28 14:06:44 2021 New Moon = Thu Nov 4 15:15:26 2021 end event. Scylla and Charybdis on 2021-10-09T01:00:00 (1633730400 seconds unix-e +poch) timezone: Africa/Nairobi (lat: 15.6325, lon: 38.245833) Moon age: 2.74601783357238 days Moon phase: 9.3 % of cycle (birth-to-death) Moon's illuminated fraction: 8.3 % of full disc important moon phases around the event: New Moon = Wed Oct 6 05:05:44 2021 First quarter = Tue Oct 12 21:27:35 2021 Full moon = Wed Oct 20 08:57:41 2021 Last quarter = Thu Oct 28 14:06:44 2021 New Moon = Thu Nov 4 15:15:26 2021 end event.

These data seem plausible. I don't know why I needed Geo::Location::TimeZone to get this done and also Math::Polygon, but it works as advertised.

In starting this I was not aware that Moon phase for a specific time is more-or-less the same for anywhere on the surface of our planet, irrespective of standpoint. With the caveat that our antipodean fellows will see it, well ... , antipodeanly.

Yeah, so if you freeze time, we all see the same moon, barring obstructions like walls, trees, mountains, clouds, or the earth itself. If you wonder what it was like for someone at one a.m. at the antipode, the answer will differ as the above. The comparison of phase to fraction illuminated is also interesting.

Fun stuff. Thanks for posting.

Replies are listed 'Best First'.
Re^2: Moon phase on historical events
by bliako (Monsignor) on Oct 09, 2021 at 10:11 UTC

    Thanks Aldebaran for doing that very insightful test of different place, "same" time. The unix-epoch seconds of the output show: 1633762800-1633730400=324000, a 9 hour difference. So, yes plausible results as you said.

    bw from atop the Scylla

      bw from atop the Scylla

      Likewise and always good to hear from you. I extended your script to attempt to determine what this moon might look like from the points we have defined and their antipodes. Any observation also needs a height which I have set at the height of Boise. I threw in the planets Venus, Saturn, and Jupiter too, as they seem to be part of the big celestial show for the next few days.

      I also use Log::Log4perl, because these data would overwhelm STDOUT. The .conf files are from the examples.

      My first question is how the azimuth is defined. Astro::Coord is suuuper complicated. Looks like there's even fortran in there. Physicists and mathematicians do things differently in a lot of settings. I can't tell if my results are wrong or untransformed.

      The same time is used for 4 different places. (Not that they're gleichzeitig.) I'll put the log and then the source between readmore tags:

      One thing I noticed is that these data are very sensitive to altitude of the defined observer. A person at 817 meters above the Scylla would have a much better view of rising and setting planets. Is there any way to figure out what a reasonable guesstimate is of altitude given latitude and longitude?

      How long does the moon's transit from Venus to Jupiter take?

      How can I determine that a priori? I know that I can bound the value in DateTime with output from the original post. Can one loop over this interval with the methods of DateTime adding the duration of a second and then checking values. A month isn't a lot of seconds for a computer.

        Great additions Aldebaran!

        DateTime can do date arithmetic as simply as:

        my $dt = DateTime->new( year => 2021, month => 4, day => 5, hour => 2, time_zone => 'Africa/Nairobi', ); # or, create a DateTime object from an ISO timestring my $isostr = '2021-10-11T11:13:57'; my $dt = DateTime::Format::ISO8601->parse_datetime($isostr); # add a second to what $dt currently holds $dt->add(seconds => 1);

        Regarding your other questions, I have no clue about celestial mechanics. Nonetheless I have whipped up a Perl sub to get you the elevation given coordinates. It uses a site which I am not sure if they would like people using their services in this way. So with that in mind:

        # usage: # my $elevation = get_elevation_from_coordinates(15.6325, 38.245833, 0 +); sub get_elevation_from_coordinates { my ($lat, $lon, $debug) = @_; $debug //= 0; my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100 +101 Firefox/78.0', ); my $response; my $payload = 'latitude='.$lat .'&longitude='.$lon .'&application_max_assets_mtime=1559625591' ; my $payloadlen = length($payload); # this request was translated from Curl command-line # by [Corion]'s https://corion.net/curl2lwp.psgi my $req = HTTP::Request->new( 'POST' => 'https://www.mapcoordinates.net/admin/component/edit +/Vpc_MapCoordinates_Advanced_GoogleMapCoords_Component/Component/json +-get-elevation', [ 'Connection' => 'keep-alive', 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, x-gzip, deflate, x-bzip2, bzip2', 'Accept-Language' => 'en-US,en;q=0.5', # 'Host' => 'www.mapcoordinates.net:443', 'Referer' => 'https://www.mapcoordinates.net/en', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) +Gecko/20100101 Firefox/78.0', 'Content-Length' => $payloadlen, 'Content-Type' => 'application/x-www-form-urlencoded; charse +t=UTF-8', 'DNT' => '1', 'Origin' => 'https://www.mapcoordinates.net', 'X-Requested-With' => 'XMLHttpRequest' ], $payload ); die "call to HTTP::Request has failed" unless $req; if( $debug > 0 ){ print "$0 : $payload\n$0 : sending above payload +, of $payloadlen bytes...\n" } $response = $ua->request($req); die "Error fetching: ".$response->status_line unless $response->is_success; my $content = $response->decoded_content; my $data = Data::Roundtrip::json2perl($content); die "failed to parse received data:\n$content\n" unless exists $data->{'elevation'}; return $data->{'elevation'}; }

        bw, bliako

        Is there any way to figure out what a reasonable guesstimate is of altitude given latitude and longitude?

        Geo::WebService::Elevation::USGS - Elevation queries against USGS web services.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found