Update charts to account for new datafile/charts folders
This commit is contained in:
@@ -2,12 +2,9 @@ library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
|
||||
# Usage: Rscript combined_instr_fault_correlation.r exp_abspath1 exp_abspath2 ... [faults_file]
|
||||
# Usage: Rscript combined_instr_fault_correlation.r exp1 exp2 ... queries_dir charts_dir [faults_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
stop("Need at least 1 experiment")
|
||||
}
|
||||
|
||||
# TODO: I should probably stop duplicating this each time
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
@@ -15,12 +12,23 @@ csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
} else {
|
||||
"faults.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
tail_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
if (length(tail_args) < 3) {
|
||||
stop(paste(
|
||||
"Usage: combined_instr_fault_correlation.r",
|
||||
"<exp1> <exp2> ... <queries_dir> <charts_dir> [faults_file]"
|
||||
))
|
||||
}
|
||||
|
||||
charts_dir <- tail_args[length(tail_args)]
|
||||
queries_dir <- tail_args[length(tail_args) - 1]
|
||||
exp_args <- tail_args[-c(length(tail_args) - 1, length(tail_args))]
|
||||
|
||||
# Don't use counts from faults.csv, as that would correlate completely
|
||||
# because only mnemonics with faults are listed there
|
||||
# NOTE: Doesn't match selected filters for faults.csv
|
||||
@@ -31,8 +39,8 @@ faults_data <- data.frame()
|
||||
|
||||
# TODO: I should probably stop duplicating this each time
|
||||
for (arg in exp_args) {
|
||||
mnem_path <- file.path(arg, mnemonics_file)
|
||||
faults_path <- file.path(arg, csv_suffix)
|
||||
mnem_path <- file.path(queries_dir, paste0(arg, "_", mnemonics_file))
|
||||
faults_path <- file.path(queries_dir, paste0(arg, "_", csv_suffix))
|
||||
|
||||
if (!file.exists(mnem_path)) {
|
||||
warning(paste("Missing:", mnem_path))
|
||||
@@ -129,6 +137,10 @@ plot <- ggplot(
|
||||
)
|
||||
|
||||
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/instr_fault_correlation", suffix, ".svg")
|
||||
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
|
||||
outfile <- file.path(
|
||||
charts_dir,
|
||||
paste0("instr_fault_correlation", suffix, ".svg")
|
||||
)
|
||||
ggsave(outfile, plot = plot, width = 10, height = 8)
|
||||
print(paste("Saved", outfile))
|
||||
|
||||
Reference in New Issue
Block a user