Load R packages
library(data.table)
library(dplyr)
library(ggplot2)
library(tidyr)
Set up data cache directory
cache.dir <- "Cache"
if (!dir.exists(cache.dir)) {
dir.create(cache.dir)
}
Get stars to observe for today either from cache or from AAVSO site
# Cache file.
cache.file = sprintf("%s/Stars to Observe %s.csv", cache.dir, strftime(now,"%Y-%m-%d"))
# URL to resource on AAVSO web site.
resource.url <- "https://www.aavso.org/sites/default/files/legacy/program_nmo.csv"
if (file.exists(cache.file)) {
raw <- read.csv(cache.file, as.is=T)
} else {
raw <- read.csv(url(resource.url), as.is=T)
if (nrow(raw) > 0) write.csv(raw, cache.file)
}
nrow(raw)
## [1] 267
Process raw data
stars.all <- raw %>%
# Star name.
mutate(name = Star.name) %>%
# When to observe the star.
mutate(night.half = factor(night.half)) %>%
# Star magnitude range.
mutate(range = Range) %>%
# Variable star type.
mutate(type = factor(Var.Type)) %>%
# Star right ascension in sexagesimal form.
mutate(ra2000.sexagesimal = RA.J2000.) %>%
# Star declination in sexagesimal form.
mutate(de2000.sexagesimal = Dec.J2000.) %>%
# Observing programs the star is in.
unnest(program = strsplit(Program.s., "/")) %>%
mutate(program = factor(program)) %>%
# Hour angle from Sun.
mutate(distance = hours.from.Sun) %>%
# Columns to use.
select(name, range, type, ra2000.sexagesimal, de2000.sexagesimal, program, distance, night.half)
nrow(stars.all)
## [1] 292
Reformat right ascension
stars.all <- stars.all %>%
# Split sexagesimal value.
separate(ra2000.sexagesimal, into=c("h","m","s"), sep=":", convert=T) %>%
# Compose value for printing.
mutate(ra2000.sexagesimal = sprintf("%+03d:%02d:%02.0f", h, m , s)) %>%
# Create value for sorting and filtering.
mutate(ra2000.time = h + m / 60 * s / 3600) %>%
# Clean up temporary columns.
select(-h, -m, -s)
Reformat declination
stars.all <- stars.all %>%
# Split sexagesimal value.
separate(de2000.sexagesimal, into=c("d","m","s"), sep=":", convert=T, remove=F) %>%
# Compose value for printing.
mutate(de2000.sexagesimal = sprintf("%+03d:%02d:%04.1f", d, m , s)) %>%
# Create value for sorting and filtering.
mutate(de2000.degree = d + sign(d) * m / 60 + sign(d) * s / 3600) %>%
# Clean up temporary columns.
select(-d, -m, -s)
Remove stars to narrow to the Sun
stars.visible <- stars.all %>%
filter(!startsWith(name,"***"))
nrow(stars.visible)
## [1] 196
p <- ggplot(subset(stars.visible,!duplicated(name))) +
geom_bar(aes(x=type,fill=night.half)) +
labs(title="AAVSO Stars to Observe by Type", x="Variable Star Type", y="Count") +
scale_fill_discrete(name="Observe best") +
theme_bw()+
theme(axis.text.x=element_text(angle=90, vjust=0.5, hjust=1))
print(p)
p <- ggplot(stars.visible) +
geom_bar(aes(x=program, fill=night.half)) +
labs(title="Stars to Observe by Program", x="Observing Program", y="Count") +
scale_fill_discrete(name="Observe best") +
theme_bw()+
theme(axis.text.x=element_text(angle=90, vjust=0.5, hjust=1))
print(p)
p <- ggplot(subset(stars.visible,!duplicated(name))) +
geom_histogram(aes(x=ra2000.time),binwidth=1) +
labs(title="AAVSO Stars to Observe by Right Ascension", x="Right Ascension", y="Count") +
theme_bw()
print(p)
p <- ggplot(subset(stars.visible,!duplicated(name))) +
geom_histogram(aes(x=de2000.degree),binwidth=10) +
labs(title="AAVSO Stars to Observe by Declination", x="Declination", y="Count") +
theme_bw()
print(p)
Filter criteria for observing programs using observing program codes
observing.programs = c("LB", "LP")
print(observing.programs)
## [1] "LB" "LP"
Filter criterion for declination limits
limits.de2000 <- c(-10, 90)
Filter stars to observe by the criteria defined
stars.to.observe <- stars.visible %>%
# Filter stars in selected observing programs.
filter(program %in% observing.programs) %>%
# Allow stars within some declination limits.
filter(de2000.degree >= limits.de2000[1]) %>%
filter(de2000.degree <= limits.de2000[2]) %>%
# Sort.
arrange(ra2000.time, de2000.degree) %>%
# Columns to show.
select(name, program, range, type, RA2000=ra2000.sexagesimal, DE2000=de2000.sexagesimal, night.half)
nrow(stars.to.observe)
## [1] 107
df <- stars.to.observe %>%
filter(night.half == "evening") %>%
select(Name=name, Range=range, Type=type, RA2000, DE2000) %>%
unique()
nrow(df)
## [1] 49
print(as.data.table(df))
## Name Range Type RA2000 DE2000
## 1: S Cet <7.600:14.700(V)> M +00:24:04 -09:19:40.6
## 2: T And <7.700:14.500(V)> M +00:22:23 +26:59:45.8
## 3: FR Cas <12.700:13.900(B)> LB +00:22:27 +59:11:33.8
## 4: Y Cep <8.100:16.000(V)> M +00:38:23 +80:21:25.8
## 5: VX And <7.500:9.700(V)> SRA +00:19:54 +44:42:33.9
## 6: RR And <8.400:15.600(V)> M +00:51:23 +34:22:36.8
## 7: IZ Cas <11.500:13.100(p)> LB +00:52:40 +47:28:15.5
## 8: Z Psc <6.370:7.490(V)> SRB +01:16:05 +25:46:09.6
## 9: UZ And <9.100:15.600(V)> M +01:16:11 +41:44:58.3
## 10: U And <9.000:15.000(V)> M +01:15:30 +40:43:08.4
## 11: S Cas <7.900:16.100(V)> M +01:19:42 +72:36:40.7
## 12: X Cas <9.450:13.200(V)> M +01:56:38 +59:15:33.6
## 13: RR Per <8.100:15.100(V)> M +02:28:29 +51:16:17.1
## 14: SS Cep <6.500:7.700(V)> SRB +03:49:30 +80:19:20.8
## 15: U Cam <11.000:12.800(p)> SRB +03:41:48 +62:38:54.3
## 16: S Sct <6.600:7.300(V)> SRB +18:50:20 -07:54:27.3
## 17: SV Dra <9.100:15.000(V)> M +18:33:38 +49:22:19.8
## 18: HK Lyr <7.500:8.400(V)> SR +18:42:50 +36:57:30.8
## 19: Z Lyr <9.200:15.300(V)> M +18:59:37 +34:57:16.3
## 20: V0398 Lyr <7.300:7.570(V)> LB +19:08:13 +39:09:17.6
## 21: S Lyr <9.300:16.000(V)> M +19:13:12 +26:00:28.1
## 22: U Lyr <8.300:13.500(V)> M +19:20:09 +37:52:36.0
## 23: W Aql <7.300:14.300(V)> M +19:15:23 -07:02:50.3
## 24: AW Cyg <8.170:9.150(V)> SRB +19:28:48 +46:02:38.1
## 25: R Cyg <6.100:14.400(V)> M +19:36:49 +50:11:59.4
## 26: T Cyg <4.910:4.960(V)> LB: +20:47:11 +34:22:26.7
## 27: WX Cyg <8.800:13.200(V)> M +20:18:33 +37:26:59.1
## 28: U Cyg <5.900:12.100(V)> M +20:19:37 +47:53:39.0
## 29: T Del <8.500:15.200(V)> M +20:45:21 +16:23:55.8
## 30: Z Del <8.300:15.300(V)> M +20:32:39 +17:27:03.3
## 31: RU Vul <8.300:11.000(V)> SRB +20:38:53 +23:15:31.2
## 32: V Del <8.100:17.000(V)> M +20:47:46 +19:20:06.7
## 33: V Aqr <7.600:10.100(V)> SRB +20:46:49 +02:26:15.2
## 34: FI Vul <6.970:8.300(V)> SR +20:48:51 +22:59:39.0
## 35: DY Vul <8.400:9.700(p)> LB +21:03:30 +23:59:46.4
## 36: R Vul <7.000:14.300(V)> M +21:04:22 +23:49:18.0
## 37: R Equ <8.400:15.000(V)> M +21:13:11 +12:48:06.1
## 38: RV Cyg <10.800:12.400(p)> SRB +21:43:16 +38:01:02.9
## 39: GO Peg <7.140:7.910(V)> SRB +22:55:01 +19:33:34.9
## 40: DM Cep <6.950:7.400(V)> LB +22:08:16 +72:46:06.7
## 41: TV And <8.300:11.500(V)> SRB +22:58:03 +42:44:11.1
## 42: RZ Peg <7.600:13.600(V)> M +22:05:53 +33:30:24.8
## 43: R Lac <8.500:14.800(V)> M +22:43:16 +42:22:11.2
## 44: PV Peg <6.600:7.700(V)> SRB +22:23:56 +31:15:42.2
## 45: SZ And <9.500:15.800(V)> M +22:59:34 +42:50:30.2
## 46: bet Peg <2.310:2.740(V)> SR +23:03:46 +28:04:56.7
## 47: W Peg <7.600:13.000(V)> M +23:19:50 +26:16:43.6
## 48: Z Cas <8.500:15.400(V)> M +23:44:32 +56:34:52.3
## 49: RR Cas <9.500:14.700(V)> M +23:55:49 +53:43:29.3
## Name Range Type RA2000 DE2000
df <- stars.to.observe %>%
filter(night.half == "morning") %>%
select(Name=name, Range=range, Type=type, RA2000, DE2000) %>%
unique()
nrow(df)
## [1] 51
print(as.data.table(df))
## Name Range Type RA2000 DE2000
## 1: ST Cam <9.200:12.000(p)> SRB +04:51:13 +68:10:07.6
## 2: X Cam <7.400:14.200(V)> M +04:45:42 +75:06:03.4
## 3: U Aur <7.500:15.500(V)> M +05:42:09 +32:02:23.3
## 4: BQ Ori <7.100:9.000(V)> SRB +05:57:07 +22:50:20.1
## 5: RR Aur <8.200:15.000(V)> M +06:12:08 +43:09:51.5
## 6: SV Aur <10.800:11.600(p)> LB +06:03:40 +46:26:08.0
## 7: RS Aur <10.800:12.500(p)> SRA +06:03:54 +46:17:34.7
## 8: X Gem <7.500:13.800(V)> M +06:47:07 +30:16:34.2
## 9: RV Mon <6.880:7.700(V)> SRB +06:58:21 +06:10:01.5
## 10: SW Gem <8.600:10.500(V)> SRA +06:59:30 +26:02:39.5
## 11: Y Mon <8.600:14.900(V)> M +06:56:52 +11:14:32.3
## 12: SX Mon <7.430:8.210(V)> SRB +06:51:57 +04:45:52.4
## 13: RS Gem <9.100:12.000(V)> SRB +07:01:37 +30:31:24.7
## 14: S Gem <8.000:14.700(V)> M +07:43:03 +23:26:58.2
## 15: VZ Cam <4.800:4.960(V)> SR +07:31:04 +82:24:41.6
## 16: V Gem <7.800:14.900(V)> M +07:23:09 +13:06:04.7
## 17: Y Lyn <6.580:8.250(V)> SRC +07:28:12 +45:59:26.1
## 18: R CMi <7.250:11.600(V)> M +07:08:43 +10:01:26.5
## 19: CE Lyn <7.300:8.020(V)> SRB +07:44:09 +38:50:16.1
## 20: U CMi <8.000:14.000(V)> M +07:41:20 +08:22:49.1
## 21: T Gem <7.980:15.000(V)> M +07:49:18 +23:44:03.8
## 22: SV Lyn <6.700:7.600(V)> SRB +08:03:40 +36:20:41.4
## 23: RT Cnc <7.050:8.100(V)> SRB +08:58:16 +10:50:42.6
## 24: X Cnc <5.690:6.940(V)> SRB +08:55:23 +17:13:52.6
## 25: U Cnc <8.500:15.500(V)> M +08:35:46 +18:53:44.6
## 26: S Hya <7.200:13.300(V)> M +08:53:34 +03:04:06.4
## 27: V UMa <9.500:11.500(V)> SRB +09:08:14 +51:06:49.3
## 28: RS Cnc <5.330:6.940(V)> SRB +09:10:39 +30:57:47.3
## 29: AB Leo <10.700:13.200(p)> SRD +09:33:22 +19:52:17.1
## 30: Y Dra <7.500:14.900(V)> M +09:42:23 +77:51:07.4
## 31: R LMi <6.300:13.200(V)> M +09:45:34 +34:30:42.8
## 32: S LMi <7.500:14.300(V)> M +09:53:43 +34:55:35.3
## 33: RY Leo <9.000:11.800(V)> SRB +10:04:16 +13:58:57.6
## 34: W Leo <8.900:14.800(V)> M +10:53:37 +13:42:54.2
## 35: S Leo <9.500:14.900(V)> M +11:10:51 +05:27:34.8
## 36: TV UMa <6.720:7.450(V)> SRB +11:45:35 +35:53:39.5
## 37: RW Vir <6.710:7.500(V)> SRB +12:07:15 -06:45:56.0
## 38: U Vir <7.400:13.500(V)> M +12:51:06 +05:33:11.5
## 39: SS Vir <6.000:9.600(V)> SRA +12:25:14 +00:46:10.9
## 40: T CVn <8.900:11.700(V)> SRA +12:30:12 +31:30:11.9
## 41: BK Vir <7.280:8.800(V)> SRB +12:30:21 +04:24:59.1
## 42: Y UMa <7.700:9.200(V)> SRB +12:40:21 +55:50:47.6
## 43: RU Vir <8.100:14.200(V)> M +12:47:18 +04:08:41.3
## 44: TU CVn <5.500:6.200(V)> SRB +12:54:57 +47:11:48.1
## 45: S Vir <6.300:13.200(V)> M +13:33:00 -07:11:40.9
## 46: SW Vir <6.200:8.000(V)> SRB +13:14:04 -02:48:25.1
## 47: RT Vir <7.410:9.000(V)> SRB +13:02:38 +05:11:08.4
## 48: FP Vir <6.550:7.690(V)> SRB +13:35:52 +08:17:34.1
## 49: Z Boo <8.200:15.000(V)> M +14:06:30 +13:29:05.7
## 50: RX Boo <7.000:8.300(V)> SRB +14:24:12 +25:42:13.3
## 51: RS Vir <7.000:14.600(V)> M +14:27:16 +04:40:41.0
## Name Range Type RA2000 DE2000