knitr::opts_chunk$set(
  comment = "#>", 
  echo = TRUE,
  message = FALSE,
  warning = FALSE,
  error = FALSE
)
#####################################################
###                                               ###
###   File created automatically. Do not change!  ###
###   Changes will be overwritten!                ###
###                                               ###
#####################################################

Load custom functions

source(here::here("R/custom_functions.R"))

Load packages

library(tidyverse)
library(lubridate)
library(patchwork)

Read and wrangle data

Cr/Au

files <- list.files(
  here::here("data-raw/gatebreak/mock/cr_au_US100")
)

data_crau_US100 <-
  tibble(
    filename = files,
    type = rep(c("blind", "sample"), each = 3, times = 4),
    chip = rep(1:4, each = 6),
    rep = rep(1:3, times = 8)
  ) |>
  mutate(
    measurement = map(
      filename,
      ~read_csv(
        here::here("data-raw/gatebreak/mock/cr_au_US100", .),
        skip = 8
      )
    ),
    us = 100
  ) |>
  select(-filename)

head(data_crau_US100)
files <- 
  list.files(
    here::here("data-raw/gatebreak/mock/cr_au_US130"),
    full.name = TRUE
  )

data_crau_US130 <- 
  tibble(files) |> 
  mutate(
    measurement = map(files, read_csv, skip = 8)
  ) |> 
  mutate(
    type = case_when(
      str_detect(files, "blind") ~ "blind",
      str_detect(files, "real") ~ "sample"
    ),
    chip = case_when(
      str_detect(files, "sample-01") ~ 1,
      str_detect(files, "sample-02") ~ 2,
      str_detect(files, "sample-03") ~ 3,
      str_detect(files, "sample-04") ~ 4
    ),
    rep = case_when(
      str_detect(files, "01.csv") ~ 1,
      str_detect(files, "02.csv") ~ 2,
      str_detect(files, "03.csv") ~ 3
    ),
    us = 130
  ) |> 
  select(-files)

head(data_crau_US130)
data_mock <-
  full_join(
    data_crau_US100, 
    data_crau_US130
  ) |> 
  unnest(measurement) |> 
  select(
    type,
    chip,
    rep,
    us,
    amps = Reading, 
    volts = Value
  ) |> 
  mutate(volts = round(volts, digits = 1))

data_mock |> head()
data_mock |> head()

Plot kennlinie

create_kennlinie <- function(data, us) {

  p <- 
    data |>
    filter(
      us == {{ us }},
      type == "sample"
    ) |> 
    mutate(
      amps = case_when(
        amps > 0.05 * 10^(-6) ~ 0.05 * 10^(-6),
        amps <= 0.05 * 10^(-6) ~ amps
      )
    ) |> 
    group_by(chip, rep, volts) |> 
    summarise(amps = mean(amps)) |> 
    ggplot() +
    aes(
      x = volts,
      y = amps * 10^6,
      color = as.factor(rep)
    ) +
    geom_line() +
    scale_colour_brewer(palette = "Set1") +
    labs(
      subtitle = glue::glue("Ultraschallleistung: {us}"),
      colour = "Rep.",
      x = "Spannung in V",
      y = "Stromstärke in µA"
    ) +
    facet_wrap(facets = vars(chip)) +
    theme(legend.title = element_blank())

  return(p)

}

plot_crau_kennlinie <- 
  create_kennlinie(data_mock, 100) / create_kennlinie(data_mock, 130) &
  plot_annotation(
    title = "Kennlinie"
  )
plot_crau_kennlinie

Cr/Pd/Au

Save data

fs::dir_create(
  path = here::here("data/gatebreak"),
  recurse = TRUE
)

write_rds(
  x = data_mock,
  file = here::here("data/gatebreak/gb_mock.rds")
)

save(
  plot_crau_kennlinie,
  file = here::here("data/gatebreak/gb_mock_plots.rda")
)


kdschneider/tpt-goldbonder documentation built on Feb. 5, 2022, 5:24 p.m.