Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks and happy new year...

...to prove how boring it would be without the reality of digital computing and space exploration, Ultima Thule was just observed. It is fresh off the press as a 'W' for people who look at Cassiopeia. I'd like to look at it with perl.

I know that the game is that I post the source I have. It's been a while since I've made such calculations. They were for the solar eclipse that started in Neskowin, Oregon:

$ cat 4.triton.pl use warnings; use strict; use 5.010; use WWW::Mechanize::GZip; use HTML::TableExtract; use Prompt::Timeout; use open ':std', OUT => ':utf8'; use constant TIMEOUT => 3; use constant MAXTRIES => 30; use utils1; ## redesign for solar eclipse of aug 21, 2017 # declarations, initializations to precede main control my ( $moon_seconds, $sun_seconds, $equal_sec, $equal ); # set time boundaries my ( $before_bound, $after_bound ) = ( 2458070.47111, 2458071.47111); # hard code 2 objects to look at (rows) my $e1 = 4; #venus my $e2 = 7; #jupiter # hard code column my $column = 1; #right ascension my $filename = '2.jv.txt'; #output file my $now_string = localtime; open( my $jh, '>>', $filename ) or die "Could not open file '$filename +' $!"; say $jh "Script executed at $now_string"; my $attempts = 1; my ( $lower, $upper ) = ( $before_bound, $after_bound ); my $site = 'http://www.fourmilab.ch/yoursky/cities.html'; my $mech = 'WWW::Mechanize::GZip'->new; $mech->get($site); $mech->follow_link( text => 'Portland OR' ); $mech->set_fields(qw'date 2'); #julian date specified my $ref_final; #reference to outlive what follows # determine equality by contracting stochastically while ( ( ( $attempts == 1 ) || ( $sun_seconds != $moon_seconds ) ) ) +{ my $default = ( ( $attempts >= MAXTRIES ) ) ? 'N' : 'Y'; my $answer = prompt( "Make query number $attempts?", $default, TIM +EOUT ); 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]; #ephemeris table # looking to get the whole row my $aoa_ref = $table->rows(); #print_aoa( $aoa_ref ); #my $inverted = invert_aoa( $aoa_ref ); #print_aoa( $inverted ); $ref_final = $aoa_ref; # my $row_ref1 = $table->row($e1); my @row1 = @$row_ref1; my $row_ref2 = $table->row($e2); my @row2 = @$row_ref2; my $moon = $row1[$column]; my $sun = $row2[$column]; $moon_seconds = string_to_second($moon); $sun_seconds = string_to_second($sun); if ( $sun_seconds < $moon_seconds ) { $upper = $guess; } elsif ( $moon_seconds < $sun_seconds ) { $lower = $guess; } else { $equal = $guess; say $jh "equal, while condition fails at julian second $equal" +; $equal_sec = $moon_seconds; } say $jh "$attempts @row1"; say $jh "$attempts @row2"; $attempts++; } say $jh "equal seconds is $equal"; print_aoa( $ref_final ); sub string_to_second { my $string = shift; my $return; if ( my $success = $string =~ /^(\d*)h\s+(\d*)m\s+(\d*)s$/ ) { $return = 3600 * $1 + 60 * $2 + $3; } else { } return $return; } sub closetohalf { my ( $up, $low ) = @_; $low + ( $up - $low ) * ( 0.4 + rand 0.2 ); } $

Venus and Jupiter aren't moving fast enough. Instead, I ask that we focus on the question, when will the moon next conjoin with ultima thule? More specifically, when will they have the same right ascension from the point of view of Portland, Oregon? What other resources exist to determine this?

Thanks for your comment,

Aldebaran

Replies are listed 'Best First'.
Re: locating ultima thule
by atcroft (Abbot) on Jan 04, 2019 at 07:10 UTC

    I saw this post earlier, and my first thought was that the code posted here was not really that applicable to the issue at hand (it was, after all, scraping a Fourmilab page for a table that does not contain the object you seek, but only the "major" solar system objects, which, unless it is staying close to one of those objects, did not seem that applicable).

    I installed several Astro::* modules, thinking one could pull the orbital elements from a source (such as the Wikipedia article on (486958) 2014 MU69 ("1110113Y", "Ultima Thule") to compute the position. While trying to get that to work, I ran across a reference in Astro::Coords::Elements to two sites to obtain orbital elements, http://cfa-www.harvard.edu/iau/Ephemerides/ (although that one no longer allows directory listing, and links you to https://minorplanetcenter.net/iau/mpc.html) and http://ssd.jpl.nasa.gov. When I looked at the latter, I found they provide a web interface (HORIZONS) to look up ephemerides (including the RA and DECL for a location for a particular time) for the object. Not necessarily doing-it-yourself, but sometimes an easier path can be a better one (for certain values of "easier" and "better").

    Hope that helps.

      it was, after all, scraping a Fourmilab page for a table that does not contain the object you seek, but only the "major" solar system objects, which, unless it is staying close to one of those objects, did not seem that applicable

      This is true indeed, and thanks for your comments. I looked at the module you posted and the long and short of it is I don't know how to track a single object in space, even possessing the physical values necessary. Nor did I find a perl way to tap into the services at the national jet lab. The ephemeris is the one way I know how to sort out the solar system. It's why I find this so extraordinary. How often do the Gods throw a Pluto Party, have all the titans show up, and leave only us behind to snap the pictures?

      Ultima Thule is essentially invisible from where we are. Its great fortune was being able to occult a star, allowing for predictions of its morphology, which I think is taken to mean composition and shape in this context. These were verified with the fly-by.

      I've marked where I think Ultima Thule is, but I can't get the page to load now, scratching my head as to why:

      a is /home/bob/2.scripts/pages/2.pp/template_stuff/aimages/a.png b is a.png a is /home/bob/2.scripts/pages/2.pp/template_stuff/aimages/b.png b is b.png Path::Tiny paths require defined, positive-length parts at template_st +uff/html7.pm line 126. $

      I've marked line 126 and don't see how the above could offend:

      sub put_page { use 5.011; use utils1; use Net::SFTP::Foreign; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; use Data::Dumper; my ( $sftp, $rvars ) = (@_); my %vars = %$rvars; #load html file to server my $server_dir = $vars{"server_dir"}; say "server dir is $server_dir"; my $return1 = createDir( $server_dir, $sftp ); say "return1 is $return1"; $sftp->setcwd("/$server_dir") or warn "setcwd1 failed $!\n"; $sftp->put( $vars{html_file} ) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path( $vars{css_path}, $vars{"css_file"} ); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put( "$path3", $remote_css ) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; say "image dir is $image_dir"; my $return2 = createDir( $image_dir, $sftp ); say "return2 is $return2"; $sftp->setcwd("/$image_dir") or warn "setcwd2 failed $!\n"; my $return3 = createDir( $vars{remote_dir}, $sftp ); say "return3 is $return3"; $sftp->setcwd( $vars{remote_dir} ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(), "\n"; print Dumper $rvars; my $ref_content = $vars{refc}; my @AoA = @$ref_content; for my $i ( 0 .. $#AoA ) { my $a = path( $vars{to_images}, $AoA[$i][0] ); say "a is $a"; my $b = $a->basename; #line 126 say "b is $b"; $sftp->put( $a, $b ) or warn "AoA put failed $@\n"; } undef $sftp; return }

      Fishing for tips,

        Path::Tiny paths require defined, positive-length parts

        AFAICT that means that one of the paths involved in the operation was either undef or had zero length. It'd be best if you dump the elements of the paths involved, in this case I guess that'd be $vars{to_images} and $AoA[$i][0], and if you're unsure as to what's causing the problem, show the output here.

Re: locating ultima thule
by bliako (Abbot) on Jan 03, 2019 at 14:48 UTC

    Can you please explain the logic behind those calculations from really really basic and simple first principles?

      Can you please explain the logic behind those calculations from really really basic and simple first principles?

      It's hard to appreciate right ascension this and declination that without pictures. I used a pretty stable version of my html template to capture these screens and then comment on them: pluto page.

      I went through the script and added a bunch of comments. Changed some notation to make it more even. There's no remants of Jupiter and Venus there now.

      I generate a guess somewhere near the midpoint of the interval, ask for the ephemeris for that time, and pull the row data from the elements we want, in this case, the moon and Pluto.

      I lacked the imagination to discuss the main control rigorously tonight. Consider it like this. Each wrong interior guess means you can slide the goalposts in. Eventually you hit a humber where they show both bodies occupying the same second. In this case it is 2458489.99538359. Take a look at 2458489.35, and you see (close to) the same picture from the point of view of the Plutans.

      $ pt 3.ut.pl $ ./3.ut.pl Make query number 1? [Y] :Y row1 is Moon 4h 57m 4s +19° 5.9' 58.6 ER 51.804 &#8722;58.490 Up row2 is Pluto 19h 30m 31s &#8722;21° 56.1' 34.700 &#8722;27.638 85.830 + Set Make query number 2? [Y] :Y row1 is Moon 23h 50m 34s &#8722;5° 55.0' 63.0 ER &#8722;12.242 93.887 +Set row2 is Pluto 19h 33m 27s &#8722;21° 51.7' 34.609 &#8722;64.053 148.38 +2 Set ... row1 is Moon 19h 32m 42s &#8722;21° 14.0' 63.1 ER 22.146 16.263 Up row2 is Pluto 19h 32m 43s &#8722;21° 52.8' 34.644 21.516 16.112 Up Make query number 18? [Y] :Y row1 is Moon 19h 32m 43s &#8722;21° 14.0' 63.1 ER 22.126 16.363 Up row2 is Pluto 19h 32m 43s &#8722;21° 52.8' 34.644 21.495 16.214 Up equal seconds is 2458517.329784 ... $

      Here's my cleaned up version of the script:

        Thanks for the explanation!

        Down with the Plutocrats! Up with the Plutophiles....

        !

Re: locating ultima thule
by Aldebaran (Curate) on Jan 03, 2019 at 18:33 UTC
    when will the moon next conjoin with ultima thule

    I wanted to "get my own rebound here" and post source that produces meaningful output. It isn't too far from the source in the original post. I omitted the shebang line, so this script was, in my opinion, dangerous, because it could create files I didn't request in its own environment. I had that environment trimmed down to what was going to serve this script, but after executing the script with ./ , got:

    $ ./4.triton.pl ./4.triton.pl: line 1: use: command not found ./4.triton.pl: line 2: use: command not found ./4.triton.pl: line 3: use: command not found ./4.triton.pl: line 4: use: command not found ./4.triton.pl: line 5: use: command not found ./4.triton.pl: line 6: use: command not found ./4.triton.pl: line 7: use: command not found ./4.triton.pl: line 8: use: command not found ./4.triton.pl: line 9: use: command not found ./4.triton.pl: line 10: use: command not found ./4.triton.pl: line 14: syntax error near unexpected token `$moon_seco +nds,' ./4.triton.pl: line 14: `my ( $moon_seconds, $sun_seconds, $equal_sec, + $equal );' $ file * 1.manifest: ASCII text 1.oneify.bash: Bourne-Again shell script, ASCII text executable 2.a.pl: Perl script text executable 2.create.bash: Bourne-Again shell script, ASCII text executable 3: empty 30: empty 3.ping3a.pl: Perl script text executable 4.haukex.pl: Perl script text executable 4.ping3a.pl: Perl script text executable 4.triton.pl: ASCII text 5.ping3a.pl: Perl script text executable template_stuff: directory :utf8: empty utils1.pm: Perl5 module source, UTF-8 Unicode text $

    Q1) If this was 4.triton.pl, how did those 3 empty files come into existence?

    use warnings; use strict; use 5.010; use WWW::Mechanize::GZip; use HTML::TableExtract; use Prompt::Timeout; use open ':std', OUT => ':utf8'; use constant TIMEOUT => 3; use constant MAXTRIES => 30; use utils1; ## redesign for solar eclipse of aug 21, 2017 # declarations, initializations to precede main control my ( $moon_seconds, $sun_seconds, $equal_sec, $equal );

    One thing I like about this script is the light load it carries with modules. You'd have to be in a place with pretty low baud rate to make the acquisition of the these 3 take long:

    WWW::Mechanize::GZip HTML::TableExtract Prompt::Timeout

    In the drama that unfolded for New Horizons, they had to reload up to the 'puter from scratch right as they got there. It takes 4.5 hours for data to get there at, what, the speed of light in vacuum?

    Anyways, this script is starting to shows the behaviors I'm looking for. Output then source.

    I don't want to cheat and google for where this thing is before I make a good attempt at it. What I propose is that I reset these values to looking when the moon and pluto conjoin. I would understand the answer to this question relationally to the ephemeris, which I can observe. Others may have others ways to get at the same answer, which I, again, solicit. (or is it elicit: I can barely speak my Muttersprache anymore)

    I'd bet that Ultima Thule is less than "one finger" from Pluto, where that represents the arcdistance of a finger held out at armslength for normally-proportioned homo sapiens. (We need to be specific, in case the Plutans are listening.)

    This and the ushering in of a check on executive power in Congress have me rather optimistic today. I hope you feel it too.

      use open ':std', OUT => ':utf8'; use constant TIMEOUT => 3; use constant MAXTRIES => 30;
      ./4.triton.pl: line 1: use: command not found
      3: empty 30: empty :utf8: empty
      By itself, Linux can only run ELF executables and text files containing a special header with a path to the interpreter (but see also binfmt_misc). When you try to run a file that's neither of there two things, the shell makes one last try to run a text file as a shell script. (If it wasn't a text file, you would get cannot execute binary file: Exec format error instead. I'm not sure how shell discerns between these two, but I think that it looks for null bytes.)

      If you paste use open ':std', OUT => ':utf8'; in the shell, you would, indeed, get use: command not found and a new empty file named :utf8.

      The solution would be to either add a #!/usr/bin/perl (or #!/usr/bin/env perl, whichever is more appropriate for your system) as the first line of the script or to run the script using perl 4.triton.pl instead.