Plotting the brightest 200 stars

Here we try to replicate what we did in class but with R.

#library(tidyverse) or you really just need to two below
library(magrittr)
library(ggplot2)

We begin by reading in the data,

data <- read.csv('./brightest_200.csv', header=FALSE)
head(data)
                   V1              V2     V3    V4
1 Alpha Canis Majoris          Sirius 06h45m -16.7
2       Alpha Carinae         Canopus 06h24m -52.7
3      Alpha Centauri Rigil Kentaurus 14h40m -60.8
4        Alpha Bo�tis        Arcturus 14h16m  19.2
5         Alpha Lyrae            Vega 18h37m  38.8
6       Alpha Aurigae         Capella 05h17m  46.0

and then attach meaningful column names:

names(data) <- c("formal name", "common name", "RA", "DEC")
head(data)
          formal name     common name     RA   DEC
1 Alpha Canis Majoris          Sirius 06h45m -16.7
2       Alpha Carinae         Canopus 06h24m -52.7
3      Alpha Centauri Rigil Kentaurus 14h40m -60.8
4        Alpha Bo�tis        Arcturus 14h16m  19.2
5         Alpha Lyrae            Vega 18h37m  38.8
6       Alpha Aurigae         Capella 05h17m  46.0

Now we have the same issue we had in class, where the Right Ascension values are not in a format we can easily plot. As such, we need to convert them to decimal form.

ra2decimal <- function(s) {
    hrs <- as.numeric(substr(s, 1, 2))
    mins <- as.numeric(substr(s, 4, 5))
    return (15 * (hrs + mins / 60))
}

data$RA %>% ra2decimal
  [1] 101.25  96.00 220.00 214.00 279.25  79.25  78.75 114.75  24.50  88.75
 [11] 211.00 297.75 186.75  69.00 201.25 247.25 116.25 344.50 192.00 310.25
 [21] 152.00 104.75 113.75 187.75 263.50  81.25  81.50 138.25  84.00 332.00
 [31]  85.25 122.50 193.50  51.00 276.00 166.00 107.00 207.00 125.75 264.25
 [41]  90.00 252.25  99.50 131.25 306.50  38.00  95.75 142.00  31.75 155.00
 [51]  11.00 283.75 211.75   2.00  17.50  87.00 222.75 340.75 263.75  47.00
 [61]  31.00 177.25  14.25 190.50 121.00 139.25 233.75 137.00 201.00 305.50
 [71]  10.25 269.25  83.00   2.25 205.00 240.00 252.50 220.50 219.00 165.50
 [81] 221.25 326.00 265.50   6.50 178.50 257.50 346.00 111.00 319.75 140.50
 [91] 311.50 346.25  45.50 249.25 209.00 168.50 241.25  83.25 182.00 184.00
[101] 285.75 229.25 236.00  28.75 222.75  85.00  90.00 188.50  21.50 208.75
[111] 224.75  74.25 161.75 189.25 262.75 109.25 275.25 296.50 243.50 246.00
[121] 160.75 190.50  83.75 200.25 265.75  77.00 247.50 183.75 262.50 194.00
[131] 233.75  82.00 250.25   6.50 249.00 277.00   3.25 122.00 238.75  58.50
[141] 261.25 263.00  56.75 195.50 326.75  29.75 296.25  95.75 229.75 334.75
[151]  44.50 287.50 111.75 239.75  59.50 245.25 292.75 323.00  46.25 146.75
[161] 340.75 102.50 187.50 331.50  59.50  84.50 146.50 271.50 199.75 267.00
[171] 286.25  32.50 167.50 230.25 253.00 328.50  55.75  95.00 105.75 182.50
[181]  75.50 191.50 218.00 305.25 101.00 155.50 288.25 274.50 133.75 162.50
[191] 174.00 309.50  87.75 134.75 254.75 258.75 224.75 140.25 142.75 258.75

Those look pretty good, so I’ll go ahead and add another table column with those converted values.

data$RA_decimal <- data$RA %>% ra2decimal
head(data)
          formal name     common name     RA   DEC RA_decimal
1 Alpha Canis Majoris          Sirius 06h45m -16.7     101.25
2       Alpha Carinae         Canopus 06h24m -52.7      96.00
3      Alpha Centauri Rigil Kentaurus 14h40m -60.8     220.00
4        Alpha Bo�tis        Arcturus 14h16m  19.2     214.00
5         Alpha Lyrae            Vega 18h37m  38.8     279.25
6       Alpha Aurigae         Capella 05h17m  46.0      79.25

Now we can plot! If we just did a straight Cartesian plane:

ggplot(data=data, aes(x=RA_decimal, y=DEC)) + 
    geom_point()

Or if we want to try to replicate the “aitoff” projection we used in Python:

ggplot(data=data, aes(x=RA_decimal, y=DEC)) + 
    geom_point() + 
    coord_map("aitoff")

which looks great, outside the the gridlines being a bit silly. But that could be tweaked.