Hello and happy perlukkah (why not),

It's nice to be able to roll in here with perl syntax that can calculate the coming conjunction of jupiter and saturn. Having a grown-up logging capability made the data so clear, so quick. I'll begin with output followed by source.

2020/12/11 00:28:28 INFO ./4.wm_fermi.pl 2020/12/11 00:28:33 INFO right ascension of jupiter 20h 11m 7s 2020/12/11 00:28:33 INFO right ascension of saturn 20h 11m 3s 2020/12/11 00:28:33 INFO jup seconds is 72667 2020/12/11 00:28:33 INFO sat seconds is 72663 2020/12/11 00:28:38 INFO right ascension of jupiter 20h 10m 16s 2020/12/11 00:28:38 INFO right ascension of saturn 20h 10m 38s 2020/12/11 00:28:38 INFO jup seconds is 72616 2020/12/11 00:28:38 INFO sat seconds is 72638 2020/12/11 00:28:42 INFO right ascension of jupiter 20h 10m 38s 2020/12/11 00:28:42 INFO right ascension of saturn 20h 10m 49s 2020/12/11 00:28:42 INFO jup seconds is 72638 2020/12/11 00:28:42 INFO sat seconds is 72649 2020/12/11 00:28:47 INFO right ascension of jupiter 20h 10m 53s 2020/12/11 00:28:47 INFO right ascension of saturn 20h 10m 56s 2020/12/11 00:28:47 INFO jup seconds is 72653 2020/12/11 00:28:47 INFO sat seconds is 72656 2020/12/11 00:28:51 INFO right ascension of jupiter 20h 11m 0s 2020/12/11 00:28:51 INFO right ascension of saturn 20h 11m 0s 2020/12/11 00:28:51 INFO jup seconds is 72660 2020/12/11 00:28:51 INFO sat seconds is 72660 2020/12/11 00:28:51 INFO equal, while condition fails at julian day 24 +59205.07717792 2020/12/11 00:28:51 INFO equal seconds is 72660

Source:

#!/usr/bin/env perl use warnings; use strict; use 5.010; use WWW::Mechanize; use HTML::TableExtract qw(tree); use open ':std', OUT => ':utf8'; use Prompt::Timeout; use constant TIMEOUT => 3; use constant MAXTRIES => 30; use Log::Log4perl; ## redesign for jupiter/saturn conjunction 2020 my $log_conf3 = "/home/hogan/Documents/hogan/logs/conf_files/3.conf"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/4.conf"; #Log::Log4perl::init($log_conf3); #debug Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info($0); my $site = 'http://www.fourmilab.ch/yoursky/cities.html'; my $mech = WWW::Mechanize->new; $mech->get($site); $mech->follow_link( text => 'Portland OR' ); my $before_bound = 2459203.5; #before conjunction my $after_bound = 2459206.5; #after conjunction $mech->set_fields(qw'date 2'); my ( $moon_seconds, $sun_seconds ) = ( 5, 3 ); # unequal values to start script c +hugging my $upper = $after_bound; my $lower = $before_bound; my ( $equal, $equal_sec ); my $attempts = 1; while ( ( $sun_seconds != $moon_seconds ) ) { my $default = ( ( $attempts >= MAXTRIES ) ) ? 'N' : 'Y'; my $answer = prompt( "Make query number $attempts?", $default, TIME +OUT ); exit if $answer =~ /^N/i; my $guess = closetohalf( $upper, $lower ); $mech->set_fields( jd => $guess ); $mech->click_button( value => "Update" ); my $te = 'HTML::TableExtract'->new; $te->parse( $mech->content ); my $table = ( $te->tables )[3]; my $table_tree = $table->tree; my $moon = $table_tree->cell( 7, 1 )->as_text; $logger->info("right ascension of jupiter $moon"); my $sun = $table_tree->cell( 8, 1 )->as_text; $logger->info("right ascension of saturn $sun"); $moon_seconds = string_to_second($moon); $logger->info("jup seconds is $moon_seconds"); $sun_seconds = string_to_second($sun); $logger->info("sat seconds is $sun_seconds"); if ( $sun_seconds < $moon_seconds ) { $upper = $guess; } elsif ( $moon_seconds < $sun_seconds ) { $lower = $guess; } else { $equal = $guess; $logger->info("equal, while condition fails at julian day $equal") +; $equal_sec = $moon_seconds; } $te->delete; $attempts++; } $logger->info("equal seconds is $equal_sec"); sub string_to_second { my $string = shift; my $return = 9000; if ( my $success = $string =~ /^(\d*)h\s+(\d*)m\s+(\d*)s$/ ) { $return = 3600 * $1 + 60 * $2 + $3; } else { # log the error $logger->error("string was misformed $string"); die "string was misformed $!"; } return $return; } sub closetohalf { my ( $up, $low ) = @_; $low + ( $up - $low ) * ( 0.4 + rand 0.2 ); }

There's any number of things I'd like to accomplish with this thread; some are more perl-related than others. Comment on what you will but leave the rest for those of us who are captured by this moment. A little physics won't hurt us, will it?

Goal 1: I've had versions of this that calculate the endpoints precisely and then a mean. I'd like to reconstitute this capability.

Goal 2: Determine whether it's mathematically-possible that Jupiter occludes the earth from the point of view of Saturn or his rings, whatever they are.

Goal 3: Build a front end for this script with Mojolicious and perl standard toolkits. "Welcome to Conjunction Junction". It should have the planets, moon and sun in two different pull downs. Order should not matter. The choices should be constrained to be different. Then the script comes up with its output as the next conjunction of these objects. I'm presenting with 'Jupiter' and 'Saturn' hard-coded. A button should begin the calculation. Extra points if we can populate the solar system by the table we already have your sky.

Goal 4: Update variable names so that they don't become physically-wrong for the next version of this script.

Goal 5: Deploy onto server and be able to use from a browser.

I've tried to do this before and failed. The sticky wicket had been a shared host where I couldn't install perl modules at all. I have successes, however humble, with mojo

fred@fourth:~/mojo$ ls 1.button.pl 2.1.mojo_hello.pl 5.3.elev.debug.pl 1.myapp.pl 5.2.elev.pl 5.3.elev.pl fred@fourth:~/mojo$

I do have a working button, if invoked with a daemon. Thanks for comments,


In reply to calculating planet conjunction with mojo front end by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.