Dependencies

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(data.table)
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:lubridate':
## 
##     hour, isoweek, mday, minute, month, quarter, second, wday, week,
##     yday, year
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose

Functions

Function for aggregation

aggnrmean <- function(df, n = 5, FUN = mean) {
  aggregate(df,
            by = list(gl(ceiling(nrow(df)/n), n)[1:nrow(df)]),
            FUN = FUN)[-1]
}

Download Data

Download HET-I Coincidence Rates A-Stopping H and He

Convert date time

trajv1 <- rtrajv1 %>% mutate(tv1ts = date_decimal(V1) + days(V2))
trajv2 <- rtrajv2 %>% mutate(tv2ts = date_decimal(V1) + days(V2))
asthhev1 <- rasthhev1 %>% mutate(v1ts = as_datetime(V1))
asthhev2 <- rasthhev2 %>% mutate(v2ts = as_datetime(V1))

Select and rename

trajv1 <- trajv1 %>% select(tv1ts, v1hradau = V3, v1seclat = V4, v1seclon = V5, v1hellat = V6, v1hellon = V7, v1hillon = V8)
trajv2 <- trajv2 %>% select(tv2ts, v2hradau = V3, v2seclat = V4, v2seclon = V5, v2hellat = V6, v2hellon = V7, v2hillon = V8)
asthhev1 <- asthhev1 %>% select(v1ts, v1v2 = V2, v1v3 = V3)
asthhev2 <- asthhev2 %>% select(v2ts, v2v2 = V2, v2v3 = V3)

Determine Date Range

trajv1mints <- min(trajv1$tv1ts)
trajv2mints <- min(trajv2$tv2ts)
trajv1maxts <- max(trajv1$tv1ts)
trajv2maxts <- max(trajv2$tv2ts)
asthhev1mints <- min(asthhev1$v1ts)
asthhev2mints <- min(asthhev2$v2ts)
asthhev1maxts <- max(asthhev1$v1ts)
asthhev2maxts <- max(asthhev2$v2ts)
mints <- max(trajv1mints, trajv2mints, asthhev1mints, asthhev2mints)
maxts <- min(trajv1maxts, trajv2maxts, asthhev1maxts, asthhev2maxts)

Filter all data by date range

trajv1 <- trajv1 %>% filter(tv1ts >= mints & tv1ts <= maxts)
trajv2 <- trajv2 %>% filter(tv2ts >= mints & tv2ts <= maxts)
asthhev1 <- asthhev1 %>% filter(v1ts >= mints & v1ts <= maxts)
asthhev2 <- asthhev2 %>% filter(v2ts >= mints & v2ts <= maxts)

Aggregate by Mean

asthhev1 <- aggnrmean(asthhev1, 40)
asthhev2 <- aggnrmean(asthhev2, 40)

Convert to data tables

setDT(trajv1)
setDT(trajv2)
setDT(asthhev1)
setDT(asthhev2)

Combine data

Combine Voyager 1 and 2 Trajectory data into one set

setkey(trajv1, tv1ts)
setkey(trajv2, tv2ts)
traj <- trajv1[trajv2, roll = "nearest"]

Combine Voyager 1 and 2 data into one set

setkey(asthhev1, v1ts)
setkey(asthhev2, v2ts)
asthhe <- asthhev2[ asthhev1, roll = "nearest" ]

Combine Trajectory and Cosmic Ray data into one set for each Voyager

trasthhev1 <- trajv1[ asthhev1, roll = "nearest" ]
trasthhev2 <- trajv2[ asthhev2, roll = "nearest" ]

Combine Trajectory and Cosmic Ray data from Voyager 1 and 2 into one set

setkey(trasthhev1, v1hradau)
setkey(trasthhev2, v2hradau)
trasthhe <- trasthhev1[ trasthhev2, roll = "nearest" ]

Plots

Plot Voyager 1 and 2 Trajectory data

ptraj <- melt(traj %>% select(date = tv1ts, "voyager 1" = v1hradau, "voyager 2" = v2hradau), id = "date")
ggplot(data = ptraj) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 1 and 2 Trajectory", x = "Date", y = "Heliospheric radial distance (AU)")

ptraj <- melt(traj %>% select(date = tv1ts, "voyager 1" = v1seclat, "voyager 2" = v2seclat), id = "date")
ggplot(data = ptraj) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 1 and 2 Trajectory", x = "Date", y = "Solar ecliptic latitude (°)")

ptraj <- melt(traj %>% select(date = tv1ts, "voyager 1" = v1seclon, "voyager 2" = v2seclon), id = "date")
ggplot(data = ptraj) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 1 and 2 Trajectory", x = "Date", y = "Solar ecliptic longitude (°)")

ptraj <- melt(trajv1 %>% select(date = tv1ts, "Latitude" = v1hellat, "Longitude (asc node)" = v1hillon), id = "date")
ggplot(data = ptraj) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 1 Solar heliographic Trajectory", x = "Date", y = "Degrees")

ptraj <- melt(trajv2 %>% select(date = tv2ts, "Latitude" = v2hellat, "Longitude (asc node)" = v2hillon), id = "date")
ggplot(data = ptraj) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 2 Solar heliographic Trajectory", x = "Date", y = "Degrees")

Plot Voyager 1 and 2 Cosmic Ray Data

pasthhe <- melt(asthhe %>% select(date = v2ts, "voyager 1" = v1v2, "voyager 2" = v2v2), id = "date")
ggplot(data = pasthhe) +
  geom_line(aes(x = date, y = value, color = variable)) +
  scale_y_continuous(trans = 'log10') +
  labs(title = "Voyager 1 and 2 Cosmic Ray Subsystem (CRS)", x = "Date", y = "HET-I Coincidence Rates A-Stopping H and He")

pasthhe <- melt(asthhe %>% select(date = v2ts, "voyager 1" = v1v3, "voyager 2" = v2v3), id = "date")
ggplot(data = pasthhe) +
  geom_line(aes(x = date, y = value, color = variable)) +
  labs(title = "Voyager 1 and 2 Cosmic Ray Subsystem (CRS)", x = "Date", y = "HET-I Coincidence Rates A-Stopping H and He")

Plot Trajectory and Cosmic Ray data into one set for each Voyager

ggplot(data = trasthhev1) +
  geom_line(aes(x = v1hradau, y = v1v2), color = 'blue') +
  scale_y_continuous(trans = 'log10') +
  labs(title = "Voyager 1 Trajectory with CRS", x = "Heliospheric radial distance (AU)", y = "HET-I Coincidence Rates A-Stopping H and He")

ggplot(data = trasthhev2) +
  geom_line(aes(x = v2hradau, y = v2v2), color = 'green') +
  scale_y_continuous(trans = 'log10') +
  labs(title = "Voyager 2 Trajectory with CRS", x = "Heliospheric radial distance (AU)", y = "HET-I Coincidence Rates A-Stopping H and He")

Plot Trajectory and Cosmic Ray data from Voyager 1 and 2

ptrasthhe <- melt(trasthhe %>% select(au = v1hradau, "voyager 1" = v1v2, "voyager 2" = v2v2), id = "au")
ggplot(data = ptrasthhe) +
  geom_line(aes(x = au, y = value, color = variable)) +
  scale_y_continuous(trans = 'log10') +
  labs(title = "Voyager 1 and 2 Cosmic Ray Subsystem (CRS)", x = "Heliospheric radial distance (AU)", y = "HET-I Coincidence Rates A-Stopping H and He")

ptrasthhe <- melt(trasthhe %>% select(au = v1hradau, "voyager 1" = v1v3, "voyager 2" = v2v3), id = "au")
ggplot(data = ptrasthhe) +
  geom_line(aes(x = au, y = value, color = variable)) +
  labs(title = "Voyager 1 and 2 Cosmic Ray Subsystem (CRS)", x = "Heliospheric radial distance (AU)", y = "HET-I Coincidence Rates A-Stopping H and He")