Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I love this time of year, when I finally get to stow my tools and pay attention to the world of computer scripting. I have a upload project for perl that I started and want to give a proper treatment to, but this is not that. This I might call "fun."
I just went outside and saw Mars, Aldebaran and Betelgeuse in what seemed from my venue to be a right triangle. I would like to see if I can come up with what those angles are right now. The spot of observation isn't material to the matter, so we're not gonna fire up a virtual telescope, except maybe at the end to check results.
I've got a start, so let's trot out some output then source:
2022/12/15 23:38:42 INFO Name Right Ascension Declination
2022/12/15 23:38:42 INFO Mars 1.23928088293942 0.433953921126419
+
2022/12/15 23:38:42 INFO Moon 3.05180035788273 0.114033717122039
+
2022/12/15 23:38:42 INFO Aldeb 1.20392811802569 0.28813931509383
+6
2022/12/15 23:38:42 INFO Time is Thu Dec 15 23:38:42 2022
2022/12/15 23:38:42 INFO Julian day is 2459929.776875
2022/12/16 20:45:44 INFO ./1.betelgeuse.pl
2022/12/16 20:45:44 INFO Name Right Ascension Declination
2022/12/16 20:45:44 INFO Mars 1.23352830004944 0.43369447662583
2022/12/16 20:45:44 INFO Moon 3.23649903846235 0.025070511750444
+2
2022/12/16 20:45:44 INFO Aldeb 1.20392811802569 0.28813931509383
+6
2022/12/16 20:45:44 INFO Time is Fri Dec 16 20:45:44 2022
2022/12/16 20:45:44 INFO Julian day is 2459930.65675926
No frills, behaving nicely. Numbers look about right. Source:
#!/usr/bin/perl
use Time::Piece;
use Astro::Coord::ECI::Utils 'deg2rad';
use Astro::Coords;
use Log::Log4perl;
my $file = '/home/fritz/Documents/perlmonks/1.aldeb.txt';
# unlink $file or warn "Could not unlink $file: $!";
my $log_conf4 = '/home/fritz/Documents/perlmonks/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__
I'm super-duper rusty, so even this much was hard. For something like this, Log::Log4perl is essential to line up the data. I can't do anything with such data unless they are meticulously organized, so I already have a file dependency. What I would like to do is be able to host it on gitlab. I've tried once to create several commands that I would use at the terminal did not succeed. So, Objective 1 is to establish an appropriate web host. Given that I'm not there yet, I'll provide the source for the .conf file, so that I don't miss a base for SSCCE posting considerations:
######################################################################
+#########
# 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/fritz/Documents/perlmonks/1.a
+ldeb.txt
log4perl.appender.LOG1.mode = append
log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayou
+t
log4perl.appender.LOG1.layout.ConversionPattern = %d %p %m %n
Ok, so what now? I'd like to find a way to represent the position of Betelgeuse by querying a computer that thinks it knows where it is. Is anyone aware of an API that gets me there?
Another thing I want to do is host this project on gitlab. I haven't been able to make a proper transfer yet. Regarding gitlab, I seem to be stuck at ssh setup page for gitlab. Which ssh key am I giving them? Do I generate a new key pair for this instance or one that I have already created?
I consider the Golden Days of usenet when we worked up physical problems in discussions in comp.lang.fortran, and then we had to go to comp.lang.perl.misc to be able to go out and get the data so that we could interoperate with it. (I especially prefered the discussions of C that occured in c.l.f. to c.l.c. looking at it as the lingua franca for interop as opposed to the one and only thing.) Lots of NASA and Cal Tech peeps who just have a reach into space like few others do.
Beyond position, I'd like to get measurable sources of as many of the values I can manage of the following.
Edit: I've had some direct comments about the pre tags I used to display this, specifically, that I should have used c tags. I don't want to be bucking the norms, so I will reprise the same data with C-tags. My claim is that there's a bunch of weird symbols in this data set that are problematic one way or the other, and seeing the data with both renderings might help.
Pronunciation /ˈbɛtəldʒuːz, ˈbiːtəl-, -dʒuːs/[1][2]
Right ascension 05h 55m 10.30536s[3]
Declination +07° 24′ 25.4304″[3]
Apparent magnitude (V) +0.50[4] (0.0–1.6[5])
Characteristics
Evolutionary stage Red supergiant
Spectral type M1–M2 Ia–ab[6]
Apparent magnitude (J) −3.00[7]
Apparent magnitude (K) −4.05[7]
U−B color index +2.06[4]
B−V color index +1.85[4]
Variable type SRc[8]
Absolute magnitude (MV) −5.85[12]
Same data with c-tags:
Pronunciation /ˈbɛtəldʒuːz, ˈbiː
+;təl-, -dʒuːs/[1][2]
Right ascension 05h 55m 10.30536s[3]
Declination +07° 24′ 25.4304″[3]
Apparent magnitude (V) +0.50[4] (0.0–1.6[5])
Characteristics
Evolutionary stage Red supergiant
Spectral type M1–M2 Ia–ab[6]
Apparent magnitude (J) −3.00[7]
Apparent magnitude (K) −4.05[7]
U−B color index +2.06[4]
B−V color index +1.85[4]
Variable type SRc[8]
Absolute magnitude (MV) −5.85[12]
For now let's say I've cobbled together three points of (right ascension, declination) in radians, so then we're in the world of geometry. I completely forget what perl modules might address distance, angles and betweenness on the celestial sphere.
There's other things I want to do with this, but I think I'll just post this to get on the proverbial scoreboard. I have to wonder about the pronounciation. Westerners might think we made something up, but we're almost always the last ones to the rodeo, thinking we're first.
fritz@laptop:~/Documents$ trans :ru betelgeuse -p
betelgeuse
бетельгейзе
(betel'geyze)
Translations of betelgeuse
[ English -> Русский ]
betelgeuse
бетельгейзе, Бетельгейзе
fritz@laptop:~/Documents$
Same data with c-tags:
fritz@laptop:~/Documents$ trans :ru betelgeuse -p
betelgeuse
бетельгейз
+е
(betel'geyze)
Translations of betelgeuse
[ English -> Русский ]
betelgeuse
бетельгей
+079;е, Бетельге
+йзе
fritz@laptop:~/Documents$
Does anyone know this star by a different name?
Cheers,
Also, for my german friends, what the hell was your QSource Insurrection about?.
Re: perl in the stars
by hv (Prior) on Dec 17, 2022 at 14:19 UTC
|
Regarding gitlab, I seem to be stuck at ssh setup page for gitlab. Which ssh key am I giving them? Do I generate a new key pair for this instance or one that I have already created?
I have not used gitlab, but I have used github and a variety of non-web remote git servers, the underlying git authentication model will be the same.
I have a single ssh key that I use for authentication, connected to my email address. Github gets the public key (as does the git config on any other remote git server I interact with). After any reboot, the first command I run is ssh-add so that all terminals I open already have my credentials (nobody else has access to this computer), and interaction with github and others is seamless.
| [reply] [d/l] |
|
$ xclip -sel clip < id_rsa.pub
But then...
fritz@laptop:~/.ssh$ ssh -T tallharry66@gitlab.com
The authenticity of host 'gitlab.com (2606:47...:a9b9)' can't be estab
+lished.
ECDSA key fingerprint is SHA256:....w.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
+es
Warning: Permanently added 'gitlab.com,2606:4700:....' (ECDSA) to the
+list of known hosts.
tallharry66@gitlab.com: Permission denied (publickey).
fritz@laptop:~/.ssh$
So I'm not there yet. Was the .pub one the right one to give to gitlab?
(I hope I haven't left my auth key bare here.)
is @gitlab.com right?
Fishing for tips, | [reply] [d/l] [select] |
|
| [reply] [d/l] |
|
|
|
|
I think we are not supposed to use ssh directly to login to gitlab/github/bitbucket/etc, only via git clone/push/pull/... You are supposed to create a repository via the web interface, and they show you the correct git incantation to connect your local repo with the remote. PLUS you might have to select "ssh" instead of "http(s)"...
| [reply] |
Re: perl in the stars
by kcott (Archbishop) on Dec 17, 2022 at 08:34 UTC
|
G'day Aldebaran,
"Does anyone know this star by a different name?"
I'm no astronomer, but I do know a couple of constellations.
Betelgeuse is in the constellation of Orion:
it's his right shoulder, also known as "Alpha Orionis".
There's some other names in "Wikipedia: Betelgeuse".
That article has additional information which might be of interest to you;
however, I'm in no position to vouch for its accuracy.
I'm unable to help with any of your other questions.
[Aside (cosmetic issues with your post):
Using <pre> (block) and <tt> (inline) is absolutely fine for non-ASCII text.
Unlike <code> and <c>, you have to manually handle special characters
(e.g. write '&' as '&').
In particular, you have a number of autogenerated links which shouldn't be there:
please change instances of "[X]" to "[X]".]
| [reply] [d/l] [select] |
Re: perl in the stars
by Anonymous Monk on Dec 18, 2022 at 01:32 UTC
|
#!/usr/bin/perl
use strict;
use warnings;
use Astro::Coords;
use Astro::Telescope;
use Math::Trig 'deg2rad';
use Time::Piece;
# Observer latitude, longitude and altitude
# in decimal degrees and meters:
my ($lat, $lon, $alt) = (38.899, -77.038, 16.68);
my $star = Astro::Coords->new(
name => 'Betelgeuse',
ra => '05h 55m 10.30536s',
dec => '07 24 25.4304',
type => 'j2000',
);
my $scope = Astro::Telescope->new(
Name =>"$lat $lon $alt",
Lat => deg2rad($lat),
Long => deg2rad($lon),
Alt => $alt
);
$star->telescope($scope);
$star->datetime(Time::Piece->new);
print $star->name, "\n",
"RA : ", $star->ra, "\n",
"DEC:", $star->dec, "\n\n",
"NOW: ", scalar localtime, "\n",
"OBS: ", $scope->name, "\n\n",
"AZ: ", $star->az(format=>'deg'), "°\n", # Azimuth
"EL: ", $star->el(format=>'deg'), "°\n"; # Elevation
| [reply] [d/l] |
|
Measure angles with Astro::Coords::Angle or the angle method of Astro::Coord::ECI.
Ok, great, thanks, I had forgotten the critical word ::Coords:: here.
Implement star catalogs with Astro-Catalog
I'm trying to get my head around that. If I gave you:
my $stern = 'aldebaran';
, could this locate it without having to hard code the position?
Locate stars with Astro::Coord::ECI::Star or Astro::Coords/Astro::Telescope:
Yeah, so this looks very nice and clean. I've just lopped it into the beginning of what I had before mixing the sources:
fritz@laptop:~/Documents/gitlab1$ ./2.betelgeuse.pl
Betelgeuse
RA : 05:55:10.305
DEC: 07:24:25.43
NOW: Sun Dec 18 22:39:20 2022
OBS: 43 -116 830
AZ: 131.819209124284°
EL: 44.4163511693206°
./2.betelgeuse.pl
Name Right Ascension Declination
Mars 1.22046550975414 0.432956445569288
Moon 3.66020589860573 -0.191580119364385
Aldeb 1.20392811802569 0.288139315093836
Time is Sun Dec 18 22:39:20 2022
Julian day is 2459932.73564815
fritz@laptop:~/Documents/gitlab1$
Source:
#!/usr/bin/perl
use strict;
use warnings;
use Time::Piece;
use Astro::Coord::ECI::Utils 'deg2rad';
use Astro::Coords;
use Log::Log4perl;
use Astro::Telescope;
# Observer latitude, longitude and altitude
# in decimal degrees and meters:
my ( $lat, $lon, $alt ) = ( 43.0, -116.0, 830 );
my $star = Astro::Coords->new(
name => 'Betelgeuse',
ra => '05h 55m 10.30536s',
dec => '07 24 25.4304',
type => 'j2000',
);
my $scope = Astro::Telescope->new(
Name => "$lat $lon $alt",
Lat => deg2rad($lat),
Long => deg2rad($lon),
Alt => $alt
);
$star->telescope($scope);
$star->datetime( Time::Piece->new );
print $star->name, "\n", "RA : ", $star->ra, "\n", "DEC:", $star->dec,
+ "\n\n",
"NOW: ", scalar localtime, "\n", "OBS: ", $scope->name, "\n\n",
"AZ: ", $star->az( format => 'deg' ), "°\n", # Azimuth
"EL: ", $star->el( format => 'deg' ), "°\n"; # Elevation
my $file = '/home/fritz/Documents/gitlab1/1.aldeb.txt';
# unlink $file or warn "Could not unlink $file: $!";
my $log_conf4 = "/home/fritz/Documents/gitlab1/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__
This is great progress, so I'm really pleased, and thanks for posting. I want to get away from as much hard-coding of values as possible. Let me ask this question:
How might we represent Orion as a perl data structure with as little cooking from scratch as possible? What about the Plieades?
Lots happening tonight, in the vicinity of Aldebaran....
| [reply] [d/l] [select] |
|
perl -MAstro::SIMBAD::Client -le '$s=Astro::SIMBAD::Client->new;@q=spl
+it /\n/, $s->url_query(id => Ident => "$ARGV[0]", NbIdent => 1);@r=gr
+ep/ICRS/,@q;print for @r' aldebaran
Result: Coordinates(ICRS,ep=J2000,eq=2000): 04 35 55.23907 +16 30 33.4885 (Opt ) A [7.38 5.70 90] 2007A&A...474..653V
| [reply] [d/l] |
|
Here's the raw SIMBAD data:
http:// simbad.u-strasbg.fr/simbad/sim-id?output.format=ASCII&Ident=aldebaran
| [reply] |
|
| [reply] |
Re: perl in the stars [pre- vs. c-tags]
by kcott (Archbishop) on Dec 21, 2022 at 00:26 UTC
|
Since considering your OP ("... replace [...] with [...] ...")
I've seen your "Edit:" (just 10 minutes ago).
It's a pity that whoever sent you "direct comments", didn't actually post those comments here:
the issue could have been discussed.
As I said in my reply,
"Using <pre> ... and <tt> ... is absolutely fine for non-ASCII text."
— this has been standard practice for many years.
Thanks for making the effort to provide a fix.
Unfortunately, the autogenerated links still exist in the original,
and the new additions are pretty much unreadable due to the plethora of &#nnnn; entities.
I took the two blocks of "c-tags" text, and ran them through a quick-and-dirty script that I threw together
to convert them to what the two, original <pre> blocks should have looked like.
#!/usr/bin/env perl
use strict;
use warnings;
my $c1 = <<'C1';
Pronunciation /ˈbɛtəldʒuːz, ˈbiː
+;təl-, -dʒuːs/[1][2]
Right ascension 05h 55m 10.30536s[3]
Declination +07° 24′ 25.4304″[3]
Apparent magnitude (V) +0.50[4] (0.0–1.6[5])
Characteristics
Evolutionary stage Red supergiant
Spectral type M1–M2 Ia–ab[6]
Apparent magnitude (J) −3.00[7]
Apparent magnitude (K) −4.05[7]
U−B color index +2.06[4]
B−V color index +1.85[4]
Variable type SRc[8]
Absolute magnitude (MV) −5.85[12]
C1
my $c2 = <<'C2';
fritz@laptop:~/Documents$ trans :ru betelgeuse -p
betelgeuse
бетельгейз
+е
(betel'geyze)
Translations of betelgeuse
[ English -> Русский ]
betelgeuse
бетельгей
+079;е, Бетел&#
1100;гейзе
fritz@laptop:~/Documents$
C2
my %c2pre = ('[' => '[', ']' => ']');
for my $c ($c1, $c2) {
$c =~ s/([\[\]])/$c2pre{$1}/eg;
print "<pre>\n$c</pre>\n";
print '-' x 60, "\n";
}
Here's the output:
<pre>
Pronunciation /ˈbɛtəldʒuːz, ˈbiː
+;təl-, -dʒuːs/[1][2]
Right ascension 05h 55m 10.30536s[3]
Declination +07° 24′ 25.4304″[3]
Apparent magnitude (V) +0.50[4] (0.0–1.6[5])
Characteristics
Evolutionary stage Red supergiant
Spectral type M1–M2 Ia–ab[6]
Apparent magnitude (J) −3.00[7]
Apparent magnitude (K) −4.05[7]
U−B color index +2.06[4]
B−V color index +1.85[4]
Variable type SRc[8]
Absolute magnitude (MV) −5.85[12]
</pre>
------------------------------------------------------------
<pre>
fritz@laptop:~/Documents$ trans :ru betelgeuse -p
betelgeuse
бетельгейз
+е
(betel'geyze)
Translations of betelgeuse
[ English -> Русский 	
+3;
betelgeuse
бетельгей
+079;е, Бетельге
+йзе
fritz@laptop:~/Documents$
</pre>
------------------------------------------------------------
Before wrapping that output in <code>...</code>,
I ran a "Preview": both <pre> blocks look fine,
with the autogenerated links no longer there,
and the Russian translation appearing in Cyrillic.
Please replace your two, original <pre> blocks with those above,
and remove the two "Same data with c-tags: ..." sections.
That should fix up everything and we can get rid of the consideration.
Thankyou.
| [reply] [d/l] [select] |
Re: perl in the stars
by Anonymous Monk on Dec 20, 2022 at 16:13 UTC
|
Disclaimer: though I'm anonymous here, I'm the author of both Astro::Coord::ECI and Astro::SIMBAD::Client.
Astro::Coord::ECI and friends are a bit heavyweight if all you want to do is convert degrees to radians. The actual code to do this is two lines:
use constant PI => atan2 (0, -1);
sub deg2rad { return defined $_[0] ? $_[0] * PI / 180 : undef }
As for computing angles, I will not recommend a specific module. I will say the initial implementation of Astro::Coord::ECI->angle() naively used the law of cosines, but I had to switch to the law of haversines after trying to compute the closest passage of a satellite to a star and having the law of cosines blow up.
All I can say about Astro::SIMBAD::Client is that it is a mess. Sorry. There are a number of ways to get the data, the SIMBAD API changed over time, and, well, what can I say? It badly needs a simpler interface. It takes me 30-some lines of code just to get the position and proper motion of a star. If you decide you want to wrestle with it, you can contact me at wyant at cpan dot org. | [reply] [d/l] [select] |
|
Thank you for all your good work for Perl on CPAN! I use your Astro modules constantly to
power my planetariums and clocks. I'd like to see your 30 lines. Here
is one that puts SIMBAD data in a perl hash:
perl -MAstro::SIMBAD::Client -MData::Dumper -le '$s=Astro::SIMBAD::Cli
+ent->new;@s=split/\n/,$s->url_query(id => Ident => "$ARGV[0]", NbIden
+t => 1);splice(@s,0,7);splice(@s,20,$#s+1);%s=map{/([^:]+\S)\s?:\s+(\
+S.*)/;$1=>$2}@s;@s=grep/^Coord/,keys%s;print"$_: $s{$_}"for@s;print q
+q[\n$s{"Proper motions"}\n];print Dumper\%s;' sirius
Prints coordinates and proper motions and dumps the hash:
Coordinates(Gal,ep=J2000,eq=2000): 227.23029126 -08.89028121
Coordinates(ICRS,ep=J2000,eq=2000): 06 45 08.91728 -16 42 58.0171 (Op
+t ) A [11.70 10.90 90] 2007A&A...474..653V
Coordinates(FK4,ep=B1950,eq=1950): 06 42 56.72452 -16 38 45.4080
-546.01 -1223.07 [1.33 1.24 0] A 2007A&A...474..653V
$VAR1 = {
'Angular size' => '~ ~ ~ (~) ~ ~',
'Coordinates(Gal,ep=J2000,eq=2000)' => '227.23029126 -08.89
+028121 ',
'Spectral type' => 'A0mA1Va C 2003AJ....126.2048G',
'Parallax' => '379.21 [1.58] A 2007A&A...474..653V',
'Flux V' => '-1.46 [~] C 2002yCat.2237....0D',
'Flux I' => '-1.43 [~] C 2002yCat.2237....0D',
'Flux J' => '-1.36 [~] C 2002yCat.2237....0D',
'Flux R' => '-1.46 [~] C 2002yCat.2237....0D',
'Redshift' => '-0.000018 [0.000001] A 2006AstL...32..759G',
'Proper motions' => '-546.01 -1223.07 [1.33 1.24 0] A 2007A&
+A...474..653V',
'Flux K' => '-1.35 [~] C 2002yCat.2237....0D',
'Morphological type' => '~ ~ ~',
'Flux H' => '-1.33 [~] C 2002yCat.2237....0D',
'cz' => '-5.50 [0.40] A 2006AstL...32..759G',
'Flux U' => '-1.51 [~] C 2002yCat.2237....0D',
'Radial Velocity' => '-5.50 [0.4] A 2006AstL...32..759G',
'Flux B' => '-1.46 [~] C 2002yCat.2237....0D',
'Coordinates(ICRS,ep=J2000,eq=2000)' => '06 45 08.91728 -16
+ 42 58.0171 (Opt ) A [11.70 10.90 90] 2007A&A...474..653V',
'Coordinates(FK4,ep=B1950,eq=1950)' => '06 42 56.72452 -16
+38 45.4080',
'hierarchy counts' => '#parents=0, #children=0, #siblings=0'
};
PS - I think the easiest way to get deg2rad (and rad2deg) is a core module:
use Math::Trig 'deg2rad';
| [reply] [d/l] [select] |
|
|