Skip to content

Instantly share code, notes, and snippets.

@timmc
Last active April 11, 2022 12:47
Show Gist options
  • Select an option

  • Save timmc/7081c40c3a504b9c0138988b8ce62a4b to your computer and use it in GitHub Desktop.

Select an option

Save timmc/7081c40c3a504b9c0138988b8ce62a4b to your computer and use it in GitHub Desktop.

Revisions

  1. timmc revised this gist Apr 11, 2022. No changes.
  2. timmc revised this gist Feb 27, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions suffolk covid-19 wastewater plot.sh
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ xwindow = as.Date(c('2020-01-01', '2022-03-01'))
    # Log y axis
    png("${png_path_prefix}.log.png", height=800, width=1200, units='px')
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$normalized_concentration_rolling_average,
    d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    type='l',
    log='y',
    xlim=xwindow,
    @@ -30,10 +30,10 @@ dev.off()
    # Linear y axis
    png("${png_path_prefix}.lin.png", height=800, width=1200, units='px')
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$normalized_concentration_rolling_average,
    d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    type='l',
    xlim=xwindow,
    ylim=c(0, max(d.Suffolk\$normalized_concentration_rolling_average) * 1.1),
    ylim=c(0, max(d.Suffolk\$effective_concentration_rolling_average) * 1.1),
    )
    abline(h=0) # draw y=0 line since origin does not start at 0
    dev.off()
  3. timmc revised this gist Feb 18, 2022. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions suffolk covid-19 wastewater plot.sh
    Original file line number Diff line number Diff line change
    @@ -40,4 +40,8 @@ dev.off()
    EOF
    ;;
    *)
    >&2 echo "Usage: $0 <fetch|plot>"
    exit 1
    ;;
    esac
  4. timmc revised this gist Feb 18, 2022. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions suffolk covid-19 wastewater plot.sh
    Original file line number Diff line number Diff line change
    @@ -2,42 +2,42 @@
    set -eu -o pipefail

    data_path="/home/timmc/warehouse/biobot-data.csv"
    png_path="/home/timmc/warehouse/biobot-data.Suffolk.png"
    png_path_prefix="/home/timmc/warehouse/biobot-data.Suffolk"

    case "$1" in
    fetch)
    curl -sS https://raw.githubusercontent.com/biobotanalytics/covid19-wastewater-data/master/wastewater_by_county.csv > "$data_path"
    ;;

    plot)
    echo "pending"
    Rscript - <<EOF
    d = read.csv("$data_path", header=T, sep=',')
    d.Suffolk=subset(d, d\$name=='Suffolk County, MA')
    d.Suffolk\$timestamp=as.Date(d.Suffolk\$sampling_week)
    xwindow = as.Date(c('2020-01-01', '2022-03-01'))
    png("$png_path", height=800, width=1200, units='px')
    # Log y axis
    png("${png_path_prefix}.log.png", height=800, width=1200, units='px')
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    d.Suffolk\$timestamp, d.Suffolk\$normalized_concentration_rolling_average,
    type='l',
    log='y',
    xlim=xwindow,
    )
    dev.off()
    # Linear y axis
    # plot(
    # d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    # type='l',
    # xlim=xwindow,
    # ylim=c(0, max(d.Suffolk\$effective_concentration_rolling_average) * 1.1),
    # )
    # abline(h=0) # draw y=0 line since origin does not start at 0
    png("${png_path_prefix}.lin.png", height=800, width=1200, units='px')
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$normalized_concentration_rolling_average,
    type='l',
    xlim=xwindow,
    ylim=c(0, max(d.Suffolk\$normalized_concentration_rolling_average) * 1.1),
    )
    abline(h=0) # draw y=0 line since origin does not start at 0
    dev.off()
    EOF
    ;;
    esac
  5. timmc revised this gist Feb 13, 2022. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion suffolk covid-19 wastewater plot.sh
    Original file line number Diff line number Diff line change
    @@ -16,12 +16,27 @@ d = read.csv("$data_path", header=T, sep=',')
    d.Suffolk=subset(d, d\$name=='Suffolk County, MA')
    d.Suffolk\$timestamp=as.Date(d.Suffolk\$sampling_week)
    xwindow = as.Date(c('2020-01-01', '2022-03-01'))
    png("$png_path", height=800, width=1200, units='px')
    # Log y axis
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    type='l', log='y', xlim=as.Date(c('2020-01-01', '2022-03-01'))
    type='l',
    log='y',
    xlim=xwindow,
    )
    # Linear y axis
    # plot(
    # d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    # type='l',
    # xlim=xwindow,
    # ylim=c(0, max(d.Suffolk\$effective_concentration_rolling_average) * 1.1),
    # )
    # abline(h=0) # draw y=0 line since origin does not start at 0
    dev.off()
    EOF
    ;;
  6. timmc created this gist Feb 13, 2022.
    28 changes: 28 additions & 0 deletions suffolk covid-19 wastewater plot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/usr/bin/env bash
    set -eu -o pipefail

    data_path="/home/timmc/warehouse/biobot-data.csv"
    png_path="/home/timmc/warehouse/biobot-data.Suffolk.png"

    case "$1" in
    fetch)
    curl -sS https://raw.githubusercontent.com/biobotanalytics/covid19-wastewater-data/master/wastewater_by_county.csv > "$data_path"
    ;;

    plot)
    echo "pending"
    Rscript - <<EOF
    d = read.csv("$data_path", header=T, sep=',')
    d.Suffolk=subset(d, d\$name=='Suffolk County, MA')
    d.Suffolk\$timestamp=as.Date(d.Suffolk\$sampling_week)
    png("$png_path", height=800, width=1200, units='px')
    plot(
    d.Suffolk\$timestamp, d.Suffolk\$effective_concentration_rolling_average,
    type='l', log='y', xlim=as.Date(c('2020-01-01', '2022-03-01'))
    )
    dev.off()
    EOF
    ;;
    esac