in reply to calculating planet conjunction with mojo front end

For Goals 1+2, can you start with describing the physics of the problem? I can see you make a guess which lies in the centre of a range with a 10% random deviation. Then you enter that guess into a remote web-based service and you get back two values which you compare until they are equal. If they are not you make a new guess within a new range which becomes smaller and smaller. There must be some equations governing these phenomena and perhaps you can solve them to get the answer analytically rather than with iterating? I am a complete newbie when it comes to the stars.

Goal 3: I would start with the HTML (re: pulldowns etc), you probably require a form in order to sumbit user input to your back-end script. The back-end script can do the calculations and present them back to the webpage. Perhaps you can also present results by constructing an image on-the-fly via Perl (e.g. GD). I can see a bit of a problem when back-end processing takes some time to complete while the webpage says "waiting ...": timeouts, connection failures, exceeding web-host's CPU quota etc. can waste the backend processing and users retrying and clogging the system. I am not sure what a good system for that is: perhaps users submit jobs and when a job is completed an email/pdf is sent to them? Another idea is to add a database caching user requests. You may be able to save some processing this way (on the expense of setting+working a db).

bw, bliako

  • Comment on Re: calculating planet conjunction with mojo front end

Replies are listed 'Best First'.
Re^2: calculating planet conjunction with mojo front end
by Anonymous Monk on Dec 11, 2020 at 16:41 UTC
    There must be some equations governing these phenomena and perhaps you can solve them to get the answer analytically rather than with iterating?

    Astro::Coords - Class for handling astronomical coordinates

    #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coords; print qq/Planet\tRight Ascension\t\tDeclination\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); my $ra = $planet->ra(format => q/deg/); my $dec = $planet->dec(format => q/deg/); print qq/$name\t$ra\t$dec\n/ }
    Output:
    Planet	Right Ascension		Declination
    Jupiter	300.231916167496	-21.0148733591416
    Saturn	301.371438440471	-20.6884105467964
    
    One-liner:
    perl -MAstro::Coords -MTime::Piece -Mstrict -e 'print qq/Planet\tRight + Ascension\t\tDeclination\n/; for my $name (qw/Jupiter Saturn/) { my +$planet = Astro::Coords->new(planet => $name); $planet->datetime(Time +::Piece->new); my $ra = $planet->ra(format => q/deg/); my $dec = $pla +net->dec(format => q/deg/); print qq/$name\t$ra\t$dec\n/}'
      Use Astro::Telescope to calculate the position in the sky from your location:
      #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coords; use Astro::Telescope; print qq/Planet\tAzimuth\t\t\tElevation\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); $planet->telescope(Astro::Telescope->new( Name => q/1600 Pennsylvania Ave, Washington DC/, Long => -77, Lat => 38.9, Alt => 16.7)); my $az = $planet->az(format => 'deg'); my $el = $planet->el(format => 'deg'); print qq/$name\t$az\t $el\n/ }
      Output:
      Planet	Azimuth			Elevation
      Jupiter	132.670727106298	 -7.05306603251409
      Saturn	131.551952092501	 -7.04332546770451
      
        Oops forgot that Astro::Telescope requires Lat and Long in radians:
        #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coord::ECI::Utils 'deg2rad'; use Astro::Coords; use Astro::Telescope; print qq/Planet\tAzimuth\t\t\tElevation\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); $planet->telescope(Astro::Telescope->new( Name => '1600 Pennsylvania Ave, Washington DC', Long => deg2rad(-77), Lat => deg2rad(38.9), Alt => 16.7)); my $az = $planet->az(format => 'deg'); my $el = $planet->el(format => 'deg'); print qq/$name\t$az\t $el\n/ }
      For sexagesimal notation omit the format parameter:
      #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coords; print qq/Planet\tRight Ascension\t\tDeclination\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); my $ra = $planet->ra; my $dec = $planet->dec; print qq/$name\t$ra\t$dec\n/ }
      Output:
      Planet	Right Ascension		Declination
      Jupiter	20:00:56.326	-21:00:51.63
      Saturn	20:05:29.464	-20:41:17.35
      

      Very nice. Notice that we got different results. When I took Stellar Evolution, we were doing well to get within an order of magnitude with many first order approximations./p>

      $ ./1.astro.pl Planet Right Ascension Declination Jupiter 300.371015239225 -20.9886573993409 Saturn 301.438145819967 -20.6756490862067 $ cat 1.astro.pl #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coords; print qq/Planet\tRight Ascension\t\tDeclination\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); my $ra = $planet->ra(format => q/deg/); my $dec = $planet->dec(format => q/deg/); print qq/$name\t$ra\t$dec\n/ } sleep 2; __END__ $

      We'll see where this folds into the ultimate product. Thanks for yor comments.

        Notice that we got different results. When I took Stellar Evolution...

        Unlike the minuscule proper motion of stars, the planets constantly move relatively rapidly across the sky, so the coordinates will be different each time they are calculated.

        #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Astro::Coords; while () { system 'clear'; print qq/Planet\tRight Ascension\t\tDeclination\n/; for my $name (qw/Jupiter Saturn/) { my $planet = Astro::Coords->new(planet => $name); $planet->datetime(Time::Piece->new); my $ra = sprintf('%.12f', $planet->ra(format => 'deg')); my $dec = sprintf('%.12f', $planet->dec(format => 'deg')); print qq/$name\t$ra\t$dec\n/; } sleep 1 }
Re^2: calculating planet conjunction with mojo front end
by karlgoethebier (Abbot) on Dec 11, 2020 at 16:59 UTC
Re^2: calculating planet conjunction with mojo front end
by Aldebaran (Curate) on Dec 14, 2020 at 19:13 UTC
    Goal 3: I would start with the HTML (re: pulldowns etc), you probably require a form in order to sumbit user input to your back-end script. The back-end script can do the calculations and present them back to the webpage. Perhaps you can also present results by constructing an image on-the-fly via Perl (e.g. GD). I can see a bit of a problem when back-end processing takes some time to complete while the webpage says "waiting ...": timeouts, connection failures, exceeding web-host's CPU quota etc. can waste the backend processing and users retrying and clogging the system. I am not sure what a good system for that is: perhaps users submit jobs and when a job is completed an email/pdf is sent to them? Another idea is to add a database caching user requests. You may be able to save some processing this way (on the expense of setting+working a db).

    Can you, (or anyone), come up with with a mock-up of this?

    Also, I don't know how yet to have mojo projects that live longer than the terminal I have open with a daemon. How do I have a static url like mpj.com/perlmonks/conjunctions or mpj.com/perlmonks/conjunctions.html?