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

I walked out the home depot last night to a brilliant celestial display, as the moon, aldebaran and mars made a nearly symmetric triangle. I thought, "it looks like the moon has conjoined with mars and is within a day of doing so with aldebaran."

The next day, the moon surprised me by seeming to pass between aldebaran and mars. I would like to use the Astro:: modules to verify that this did indeed happen and when, according to some criterion. What a person thinks he sees can be quite unreliable.

As I begin this, I will note that this project will never be an SSCCE. For one, it's not a contrived example, so the shoe doesn't fit right there. I will take the length I need to represent what I have and what I want. It may be short; it may not be. If that doesn't suit you, do not click the readmore tags expecting otherwise.

I wrote several different versions of an Astro:: script, adding Log4perl in the final one and stepping through with the debugger. That was kind of trip, and I'll list that at the end.

One thing I lack now is a representation for where Aldebaran is. Wiki has it at 4 hr 35 min right ascension and +16 and change for what I assume is degrees above the ecliptic. When I was installing the software, I saw:

WYANT/Astro-satpass-0.117.tar.gz ./Build test -- OK Running Build install for WYANT/Astro-satpass-0.117.tar.gz Building Astro-satpass Installing /usr/local/share/perl/5.30.0/Astro/Coord/ECI.pm Installing /usr/local/share/perl/5.30.0/Astro/Coord/ECI/Star.pm

I don't know what that is yet, but that might be the ticket right there.

What I do have is some gutshot data with Mars and the Moon, with an amalgam script 5.astro.pl:

#!/usr/bin/perl use Time::Piece; use Astro::Coord::ECI::Utils 'deg2rad'; use Astro::Coords; use Astro::Telescope; use Log::Log4perl; my $file = '/home/hogan/Documents/hogan/logs/3.log4perl.txt'; # unlink $file or warn "Could not unlink $file: $!"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/3.conf"; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); $logger->info("Object\tAzimuth\tElevation"); $logger->info("Right Ascension\tDeclination "); for my $name (qw/Mars Moon/) { my $planet = Astro::Coords->new( planet => $name ); $planet->datetime( Time::Piece->new ); $planet->telescope( Astro::Telescope->new( Name => 'boise', Long => deg2rad(-116.2), #43.615833, -116.201667 Lat => deg2rad(43.61), Alt => 8321, #meters above sea level boise ) ); my $az = $planet->az( format => 'deg' ); my $el = $planet->el( format => 'deg' ); $logger->info("$name\t$az\t $el"); my $planet2 = Astro::Coords->new( planet => $name ); $planet2->datetime( Time::Piece->new ); my $ra = $planet2->ra( format => q/deg/ ); my $dec = $planet2->dec( format => q/deg/ ); $logger->info("$name\t$ra\t$dec"); } my $t = localtime; my $jd = $t->julian_day; $logger->info("Time is $t"); $logger->info("Julian day is $jd"); __END__

This is the conf file for Log4perl. If you get the proper form for the output, then it makes a huge difference for looking at a time series:

###################################################################### +######### # Log::Log4perl Conf + # ###################################################################### +######### log4perl.rootLogger = DEBUG, LOG1, SCREEN log4perl.appender.SCREEN = Log::Log4perl::Appender::Screen log4perl.appender.SCREEN.stderr = 0 log4perl.appender.SCREEN.layout = Log::Log4perl::Layout::PatternLayou +t log4perl.appender.SCREEN.layout.ConversionPattern = %m %n log4perl.appender.LOG1 = Log::Log4perl::Appender::File log4perl.appender.LOG1.filename = /home/hogan/Documents/hogan/logs/3. +log4perl.txt log4perl.appender.LOG1.mode = append log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayou +t log4perl.appender.LOG1.layout.ConversionPattern = %d %p %m %n

If you would like to replicate this, you will have to change the .filename, unless you happen to be hogan. As far as output, I was very pleased as I went about writing this today, with the log building. Another component of this is going outside and looking every couple hours. That's a way this is not self-contained. We need all kinds of sanity checks with this stuff including peer review and wondering, "did you see it too?" Here's 3.log4perl.txt:

2021/03/19 19:31:51 INFO ./4.astro.pl 2021/03/19 19:31:51 INFO Object Azimuth Elevation 2021/03/19 19:31:51 INFO Mars 220.365443728883 65.2689423230543 + 2021/03/19 19:31:51 INFO Moon 211.599830034082 65.5618916858789 + 2021/03/19 19:31:51 INFO Time is Fri Mar 19 19:31:51 2021 2021/03/19 19:31:51 INFO Julian day is 2459293.56378472 2021/03/19 22:40:06 INFO ./4.astro.pl 2021/03/19 22:40:06 INFO Object Azimuth Elevation 2021/03/19 22:40:06 INFO Mars 270.806033806743 34.1750013710903 + 2021/03/19 22:40:06 INFO Moon 266.284000787558 36.8694401304625 + 2021/03/19 22:40:06 INFO Time is Fri Mar 19 22:40:06 2021 2021/03/19 22:40:06 INFO Julian day is 2459293.69451389 2021/03/19 23:35:35 INFO ./5.astro.pl 2021/03/19 23:35:35 INFO Object Azimuth Elevation 2021/03/19 23:35:35 INFO Right Ascension Declination 2021/03/19 23:35:35 INFO Mars 279.88665284031 24.1792258156848 2021/03/19 23:35:35 INFO 67.2076668140408 23.2786995609773 2021/03/19 23:35:35 INFO Moon 275.550366714117 27.1395270284972 + 2021/03/19 23:35:35 INFO 73.1915415734555 22.2734334102247 2021/03/19 23:35:35 INFO Time is Fri Mar 19 23:35:35 2021 2021/03/19 23:35:35 INFO Julian day is 2459293.73304398 2021/03/19 23:39:06 INFO ./5.astro.pl 2021/03/19 23:39:06 INFO Object Azimuth Elevation 2021/03/19 23:39:06 INFO Right Ascension Declination 2021/03/19 23:39:06 INFO Mars 280.444080455657 23.5521856680493 + 2021/03/19 23:39:06 INFO Mars 67.2092465053295 23.2789265197005 2021/03/19 23:39:06 INFO Moon 276.109507072202 26.5260435839715 + 2021/03/19 23:39:06 INFO Moon 73.2365988210088 22.280059131584 2021/03/19 23:39:06 INFO Time is Fri Mar 19 23:39:06 2021 2021/03/19 23:39:06 INFO Julian day is 2459293.73548611 2021/03/20 00:27:38 INFO 5.astro.pl 2021/03/20 00:27:38 INFO Object Azimuth Elevation 2021/03/20 00:28:10 INFO Right Ascension Declination 2021/03/20 00:30:06 INFO Mars 288.303956397801 14.794085544023 2021/03/20 00:32:59 DEBUG This is debug 2021/03/20 00:33:58 INFO Mars 67.2338800886927 23.2824828016645 2021/03/20 00:59:03 INFO Moon 284.638027927888 17.0850686583167 + 2021/03/20 01:00:14 INFO Moon 74.2622910906381 22.4512455528347 2021/03/20 01:00:14 INFO Time is Sat Mar 20 01:00:14 2021 2021/03/20 01:00:14 INFO Julian day is 2459293.7918287

The ultimate run was done with the debugger, which I'm tapping my way around with:

$ perl -d 5.astro.pl Loading DB routines from perl5db.pl version 1.55 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(5.astro.pl:9): my $file = '/home/hogan/Documents/hogan/logs/ +3.log4perl.txt'; DB<1> n + main::(5.astro.pl:12): my $log_conf4 = "/home/hogan/Documents/hogan +/logs/conf_files/3.conf"; DB<1> v + 9: my $file = '/home/hogan/Documents/hogan/logs/3.log4perl.txt'; 10 11 # unlink $file or warn "Could not unlink $file: $!"; 12==> my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/ +3.conf"; 13: Log::Log4perl::init($log_conf4); #info 14: my $logger = Log::Log4perl->get_logger(); ... main::(5.astro.pl:39): my $planet2 = Astro::Coords->new( planet = +> $name ); DB<6> $logger->debug( "This is debug"); + This is debug ... DB<8> . + main::(5.astro.pl:26): $planet->telescope( main::(5.astro.pl:27): Astro::Telescope->new( main::(5.astro.pl:28): Name => 'boise', main::(5.astro.pl:29): Long => deg2rad(-116.2), #43.615833 +, -116.201667 main::(5.astro.pl:30): Lat => deg2rad(43.61), main::(5.astro.pl:31): Alt => 8321, #meters ab +ove sea level boise main::(5.astro.pl:32): ) main::(5.astro.pl:33): ); DB<8> s + Astro::Coord::ECI::Utils::deg2rad(/usr/local/share/perl/5.30.0/Astro/C +oord/ECI/Utils.pm:545): 545: sub deg2rad { return defined $_[0] ? $_[0] * PI / 180 : undef +} ... DB<8> n + Astro::Telescope::new(/usr/local/share/perl/5.30.0/Astro/Telescope.pm: +182): 182: my $proto = shift; DB<8> n + Astro::Telescope::new(/usr/local/share/perl/5.30.0/Astro/Telescope.pm: +183): 183: my $class = ref($proto) || $proto; DB<8> v + 180 181 sub new { 182: my $proto = shift; 183==> my $class = ref($proto) || $proto; 184 185: return undef unless @_; 186 187 # Create the new object 188: my $tel = bless {}, $class; 189 DB<8> b 188 + DB<9> c + Astro::Telescope::new(/usr/local/share/perl/5.30.0/Astro/Telescope.pm: +188): 188: my $tel = bless {}, $class; DB<9> n + Astro::Telescope::new(/usr/local/share/perl/5.30.0/Astro/Telescope.pm: +192): 192: $tel->_configure( @_ ) or return undef; DB<9> v + 189 190 # Configure it with the supplied telescope name 191 # or other arguments 192==> $tel->_configure( @_ ) or return undef; 193 194: return $tel; 195 } 196 197 =back 198 DB<9> p @_ + NameboiseLong-2.02807259081741Lat0.761138086794727Alt8321 ... DB<10> v + 217 =cut 218 219 sub new { 220==> my $class = shift; 221 222: my %args = @_; 223 224: my $obj; 225 226 # Always try for a planet object first if $args{planet} is u +sed DB<10> b 224 + DB<11> c + Astro::Coords::new(/usr/local/share/perl/5.30.0/Astro/Coords.pm:224): 224: my $obj; DB<11> p @_ + planetMoon DB<12> c + Moon 74.2622910906381 22.4512455528347 Time is Sat Mar 20 01:00:14 2021 Julian day is 2459293.7918287 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<12> q

Anyways, so that's as far as make it tonight.

Thank you for your comments.

Replies are listed 'Best First'.
Re: Deciding when the moon passed between aldebaran and mars
by Aldebaran (Curate) on Mar 21, 2021 at 07:14 UTC
    One thing I lack now is a representation for where Aldebaran is.

    I tried writing a script that used the example in Star.pm. In it, it required me to turn right ascension into radians, and after the script pooped out, I realized that all I needed to start making comparisons was its fixed value in radians.

    $ ./7.astro.pl ./7.astro.pl Name Right Ascension Declination Mars 1.18463017264379 0.407948808088123 Moon 1.51448031651065 0.422740932680421 Aldeb 1.20392811802569 0.288139315093836 Time is Sun Mar 21 00:39:59 2021 Julian day is 2459294.7777662 $ pt 7.astro.pl $ cat 7.astro.pl <-I do this to be correct and use STDOUT to list reli +ably
    #!/usr/bin/perl use Time::Piece; use Astro::Coord::ECI::Utils 'deg2rad'; use Astro::Coords; use Log::Log4perl; my $file = '/home/hogan/Documents/hogan/logs/3.log4perl.txt'; # unlink $file or warn "Could not unlink $file: $!"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/3.conf"; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); $logger->info("Name\tRight Ascension\t\tDeclination"); for my $name (qw/Mars Moon/) { my $planet2 = Astro::Coords->new( planet => $name ); $planet2->datetime( Time::Piece->new ); my $ra = $planet2->ra( format => q/rad/ ); my $dec = $planet2->dec( format => q/rad/ ); $logger->info("$name\t$ra\t$dec"); } my $aldeb_ra_degrees = 68.98; my $aldeb_ra_radians = deg2rad($aldeb_ra_degrees); my $aldeb_declination_degrees = 16.509166666667; my $aldeb_dec_radians = deg2rad($aldeb_declination_degrees); $logger->info("Aldeb\t$aldeb_ra_radians\t$aldeb_dec_radians "); my $t = localtime; my $jd = $t->julian_day; $logger->info("Time is $t"); $logger->info("Julian day is $jd"); __END__

    So, the data is bunching together well, but I'm not completely sure how I'd go about figuring out when something crosses between. For me, it's a tantalizing triangle.

    I would think that we should think of these creatures as two-vectors of radians. Then my question now is this: if these are 3 traveling 2-vectors (one is stationary for this script), how do I write a function to calculate betweenness? It seems clear to me that I would need to invoke a telescope method.

    I also wonder if everyone in the world could have had a chance to see this (less light pollution)?

      I just happen to be making astronomical calculations in perl and noticing that the sun is really near 0 right ascension and declination. Hmm. That would be the vernal equinox, right? I always like to calculate things like this exactly if I happen to have the time and a nearby laptop. I'm getting output I don't understand, so I think I'm in a better place to ask a cohesive question. What's more, I think I can get to it without needing to resort to readmore tags.

      I found an old thread where haukex had helped me figure out some of this: Re: calculate length of day as function of space at onset of fall, and started folding in the old code into the new. I write some really primitive-looking code looking back, but it's my learning on display. Out of this I made a githubpull request, simply to try to understand how github works, and I really don't get it still, which defines me clearly as an intermediate perl user that I am struggling with it. This is what I had some code at github that calculates equinoxes, sunsets, meridians.

      Anyways, so I start chopping that up and am left 3 lines, and then I hardcode the year:

      use Astro::Utils; my $spring = calculate_equinox( 'mar', 'utc', '2021' ); $logger->info("spring begins $spring");

      I'll list output, source and then have a couple questions.

      $ ./3.vernal.pl ./3.vernal.pl Name Right Ascension Declination Mars 1.19220473652282 0.409015700183571 Moon 1.6536783961676 0.442537954264476 Sun 0.0202246733370893 0.00876435085335973 Aldeb 1.20392811802569 0.288139315093836 Time is Sun Mar 21 17:03:18 2021 Julian day is 2459295.460625 Sun set is Mon Mar 22 01:58:54 2021 Astro::Coord::ECI=HASH(0x560eda31aa70) spring begins 2021-03-20 09:37:05 $ cat 3.vernal.pl
      #!/usr/bin/perl use Time::Piece; use Astro::Coord::ECI::Utils 'deg2rad'; use Astro::Coords; use Log::Log4perl; use 5.030; my $file = '/home/hogan/Documents/hogan/logs/3.log4perl.txt'; unlink $file or warn "Could not unlink $file: $!"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/3.conf"; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); $logger->info("Name\tRight Ascension\t\tDeclination"); for my $name (qw/Mars Moon Sun/) { my $planet2 = Astro::Coords->new( planet => $name ); $planet2->datetime( Time::Piece->new ); my $ra = $planet2->ra( format => q/rad/ ); my $dec = $planet2->dec( format => q/rad/ ); $logger->info("$name\t$ra\t$dec"); } ## declare values and tailor to what these routines expect... my $aldeb_ra_degrees = 68.98; my $aldeb_ra_radians = deg2rad($aldeb_ra_degrees); my $aldeb_declination_degrees = 16.509166666667; my $aldeb_dec_radians = deg2rad($aldeb_declination_degrees); my $local_lat = deg2rad(43.6135); # +Radians my $local_long = deg2rad(-116.20345); # +Radians my $local_alt = 8321 / 1000; # +Kilometers $logger->info("Aldeb\t$aldeb_ra_radians\t$aldeb_dec_radians "); my $t = localtime; my $jd = $t->julian_day; $logger->info("Time is $t"); $logger->info("Julian day is $jd"); use Astro::Coord::ECI::Sun; my $sun = Astro::Coord::ECI::Sun->new(); my $sta = Astro::Coord::ECI->universal( time() ) ->geodetic( $local_lat, $local_long, $local_alt ); my ( $time, $rise ) = $sta->next_elevation($sun); my $string = "Sun @{[$rise ? 'rise' : 'set']} is " . scalar gmtime $time . " UT\n +"; $logger->info("$string"); $logger->debug("$sta"); # calculate begin of spring use Astro::Utils; my $spring = calculate_equinox( 'mar', 'utc', '2021' ); $logger->info("spring begins $spring"); __END__ $

      As I look at the data, does it not say that spring has already sprung? Here's question 1: Is the value for $spring correct?

      If $spring is correct, then has spring sprung? If so, why are the values for the sun's declination and right ascension still so unzeroish?

      Thanks for your comments,