# A home brewer's notebook: each file in brews/ is one brew. The data is
# invented for SampleKit's documentation.

schema_version = 1

# The brews are in brews/: read from here too, so that `samplekit` in this
# folder shows them. This README is no brew.
[collection]
recursive = true
exclude = ["README.md"]

# ---------------------------------------------------------------- model
# What derives from what: alcohol, attenuation and efficiency, computed from
# the gravities read with a hydrometer.

[model]
path = "../shared/brew.py"
class = "Brew"

# ---------------------------------------------------------------- render
# Figures label their axes with the "figure" forms below. The "math" forms are
# for tables written into a LaTeX report: samplekit brews --style math.

[render]
figure_style = "figure"

[style.math]
separator = '\pm'

[style.figure]       # matplotlib's mathtext: $…$

# ----------------------------------------------------------------- units
# The key is the unit as the files write it; `plain` is how a table shows it.

[unit."degC"]
plain = "°C"
math = '^\circ\mathrm{C}'
# The character itself: mathtext's `^\circ` on nothing leaves a gap before it.
figure = '°C'

[unit."L"]
math = '\mathrm{L}'
figure = '$\mathrm{L}$'

[unit."kg"]
math = '\mathrm{kg}'
figure = '$\mathrm{kg}$'

[unit."%"]
math = '\%'
figure = '$\%$'

[unit."d"]
figure = 'd'

[unit."pt/d"]
plain = "pt/day"
math = '\mathrm{pt\,d^{-1}}'
figure = 'points per day'

# ------------------------------------------------------------ quantities
# Each quantity: its unit, which `samplekit set` and `samplekit new` write for
# you; its precision (the value's, then the uncertainty's); and its symbol,
# which labels a figure's axis.

[property.og]
symbol = "OG"
precision = [".3f", ".4f"]
symbol_math = '\mathrm{OG}'
symbol_figure = 'Original gravity'

[property.fg]
symbol = "FG"
precision = [".3f", ".4f"]
symbol_math = '\mathrm{FG}'
symbol_figure = 'Final gravity'

[property.volume]
unit = "L"
symbol = "V"
precision = ".1f"
symbol_math = 'V'
symbol_figure = '$V$'

[property.grain_mass]
unit = "kg"
symbol = "m_grain"
precision = ".2f"
symbol_math = 'm_\mathrm{grain}'
symbol_figure = '$m_\mathrm{grain}$'

[property.mash_temperature]
unit = "degC"
symbol = "T_mash"
precision = ".0f"
symbol_math = 'T_\mathrm{mash}'
symbol_figure = '$T_\mathrm{mash}$'

# Attributes have no unit, but a figure's legend names them by their symbol.
[property.style]
symbol_figure = 'Style'

[property.yeast]
symbol_figure = 'Yeast'

[property.abv]
symbol = "ABV"
precision = ".1f"
symbol_math = '\mathrm{ABV}'
symbol_figure = 'Alcohol by volume'

[property.attenuation]
symbol = "AA"
precision = ".0f"
symbol_math = '\mathrm{AA}'
symbol_figure = 'Apparent attenuation'

[property.efficiency]
symbol = "eff"
precision = ".0f"
symbol_math = '\eta'
symbol_figure = 'Brewhouse efficiency'

[property."fermentation.day"]
symbol = "t"
symbol_figure = 'Day'

[property."fermentation.gravity"]
symbol = "SG"
precision = ".3f"
symbol_math = '\mathrm{SG}'
symbol_figure = 'Specific gravity'

[property."fermentation.temperature"]
symbol = "T"
precision = ".1f"
symbol_figure = 'Temperature'

[property."fermentation.rate"]
symbol = "r_t"
precision = ".1f"
symbol_figure = 'Gravity drop'

[property."fermentation.apparent"]
symbol = "AA_t"
precision = ".0f"
symbol_figure = 'Apparent attenuation'

[property.drop]
symbol = "r"
precision = [".1f", ".1f"]
symbol_math = 'r'
symbol_figure = 'Gravity drop, first three days'

[property.score]
symbol = "S"
precision = [".1f", ".1f"]
symbol_figure = 'Tasting score'

# --------------------------------------------------------------- queries
# samplekit brews/ --query ipas

[query.ipas]
filter = 'style == ipa'

[query.strong]
filter = 'og > 1.060'

[query.medals]
filter = 'tags has medal'

[query.ana]
filter = 'brewer == ana'

[query.still_fermenting]
filter = 'fg is missing'

[query.never_computed]
filter = 'abv is missing'

[query.dry]
filter = 'attenuation > 80'

[query.best]
filter = 'score > 42'

[query.slow]
filter = 'drop < 5'

# -------------------------------------------------------------- profiles
# samplekit brews/ --profile overview

[profile.overview]
columns = [
  { field = "name", label = "Brew" },
  { field = "style", label = "Style" },
  { field = "yeast", label = "Yeast" },
  { field = "og", label = "Original gravity" },
  { field = "fg", label = "Final gravity" },
  { field = "volume", label = "Volume" },
]
sort = ["style", "-og"]

[profile.mash]
columns = [
  { field = "name", label = "Brew" },
  { field = "grain_mass", label = "Grain" },
  { field = "mash_temperature", label = "Mash" },
  { field = "brewed", label = "Brewed" },
]
sort = ["brewed"]

[profile.alcohol]
columns = [
  { field = "name", label = "Brew" },
  { field = "style", label = "Style" },
  { field = "og", label = "Original gravity" },
  { field = "fg", label = "Final gravity" },
  { field = "abv", label = "Alcohol" },
  { field = "attenuation", label = "Attenuation" },
]
sort = ["-abv"]

[profile.readings]
columns = [
  { field = "name", label = "Brew" },
  { field = "og", label = "Original gravity" },
  { field = "og.stats.count", label = "n" },
  { field = "og.stats.sample_stdev", label = "s", precision = ".4f" },
]

[profile.fermentation]
columns = [
  { field = "name", label = "Brew" },
  { field = "yeast", label = "Yeast" },
  { field = "og", label = "Original gravity" },
  { field = "fermentation.gravity[1]", label = "Day 1", header = "SG_1" },
  { field = "fermentation.gravity[3]", label = "Day 3", header = "SG_3" },
  { field = "fermentation.apparent[3]", label = "Attenuation, day 3", header = "AA_3" },
  { field = "drop", label = "Drop" },
]
sort = ["-drop"]

[profile.tasting]
columns = [
  { field = "name", label = "Brew" },
  { field = "style", label = "Style" },
  { field = "score", label = "Score" },
  { field = "tasting.score[Lea]", label = "Lea", header = "Lea" },
  { field = "abv", label = "Alcohol" },
]
sort = ["-score"]

# --------------------------------------------------------------- exports
# samplekit export overview brews/ --write

[export.overview]
profile = "overview"
format = "csv"
output = "out/overview.csv"

[export.mash]
profile = "mash"
format = "json"
output = "out/mash.json"

[export.tasting]
profile = "tasting"
format = "csv"
output = "out/tasting.csv"

# --------------------------------------------------------------- figures
# samplekit plot NAME brews/ opens one; -o fig.pdf --write writes it.

[figure.fermentation]
kind = "line"
x = "fermentation.day"
y = "fermentation.gravity"
group = "yeast"
title = "Fermentation, a curve per brew"

[figure.alcohol_by_style]
kind = "box"
x = "style"
y = "abv"
title = "Alcohol by style"

[figure.efficiency]
kind = "scatter"
x = "grain_mass"
y = "efficiency"
group = "style"
title = "Efficiency against the grain bill"

[figure.score]
kind = "scatter"
x = "abv"
y = "score"
group = "style"
title = "Do stronger beers taste better?"
legend = "outside"

# matplotlib's own settings, by their names: every figure the project draws.
[matplotlib]
"figure.figsize" = [15, 10]     # centimetres, as every size SampleKit takes
"axes.grid" = true
"grid.alpha" = 0.3
