Compare commits
6 Commits
08659faea9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d2451ff42 | |||
| 7c851c1d4a | |||
| 4b4cf9aae8 | |||
| 1b9848d14f | |||
| da6bc2a4f7 | |||
| 5e636e082c |
10
README.md
10
README.md
@@ -86,12 +86,14 @@ material codes); copy the template to create your own:
|
|||||||
cp samples.example.txt samples.txt
|
cp samples.example.txt samples.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
Lines starting with `#` are ignored. Material names can be any codes.
|
Lines starting with `#` are comments. Lines starting with `note:` are
|
||||||
Append ` > REF` to measure that sample's `dE00` against another sample; a
|
metadata shown above the table in `averaged.html` (not samples). Material
|
||||||
bare name (no `>`) is itself a **reference**. Mix samples use the pattern
|
names can be any codes. Append ` > REF` to measure that sample's `dE00`
|
||||||
`NAME_A+NAME_B[w1 to w2 mix]`, e.g.:
|
against another sample; a bare name (no `>`) is itself a **reference**.
|
||||||
|
Mix samples use the pattern `NAME_A+NAME_B[w1 to w2 mix]`, e.g.:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
note: Glaze: CPO1192
|
||||||
INK_A
|
INK_A
|
||||||
INK_B > INK_A
|
INK_B > INK_A
|
||||||
INK_A+INK_B[75 to 15 mix] > INK_A
|
INK_A+INK_B[75 to 15 mix] > INK_A
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ scan_samples() {
|
|||||||
SAMPLES=()
|
SAMPLES=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
SAMPLES+=("$line")
|
SAMPLES+=("$line")
|
||||||
done < <(grep -v '^#' "$SAMPLES_FILE" | grep -v '^[[:space:]]*$' \
|
done < <(grep -v '^#' "$SAMPLES_FILE" | grep -iv '^[[:space:]]*note:' \
|
||||||
| sed -E 's/[[:space:]]*>.*$//')
|
| grep -v '^[[:space:]]*$' | sed -E 's/[[:space:]]*>.*$//')
|
||||||
local count="${#SAMPLES[@]}"
|
local count="${#SAMPLES[@]}"
|
||||||
[[ "$count" -gt 0 ]] || fail "No sample names found in $SAMPLES_FILE"
|
[[ "$count" -gt 0 ]] || fail "No sample names found in $SAMPLES_FILE"
|
||||||
|
|
||||||
@@ -190,7 +190,8 @@ update_average() {
|
|||||||
info "Step 5/5: Updating $AVERAGED_CSV"
|
info "Step 5/5: Updating $AVERAGED_CSV"
|
||||||
|
|
||||||
local expected
|
local expected
|
||||||
expected="$(grep -v '^#' "$SAMPLES_FILE" | grep -cv '^[[:space:]]*$' || true)"
|
expected="$(grep -v '^#' "$SAMPLES_FILE" | grep -iv '^[[:space:]]*note:' \
|
||||||
|
| grep -cv '^[[:space:]]*$' || true)"
|
||||||
|
|
||||||
# Collect scan CSVs (timestamped files only) with the expected reading count
|
# Collect scan CSVs (timestamped files only) with the expected reading count
|
||||||
local -a scans=()
|
local -a scans=()
|
||||||
|
|||||||
@@ -20,11 +20,15 @@ WHITE_POINT = (96.422, 100.0, 82.521)
|
|||||||
# (no ">") are references themselves. The " > REF" suffix is stripped to
|
# (no ">") are references themselves. The " > REF" suffix is stripped to
|
||||||
# recover the real sample name used as sample_id.
|
# recover the real sample name used as sample_id.
|
||||||
REF_SEP = ">"
|
REF_SEP = ">"
|
||||||
NOTE_PREFIX = "# note:"
|
NOTE_PREFIX = "note:"
|
||||||
|
|
||||||
|
|
||||||
|
def _is_note_line(line: str) -> bool:
|
||||||
|
return line.strip().lower().startswith(NOTE_PREFIX)
|
||||||
|
|
||||||
|
|
||||||
def load_notes(path: Path) -> list[str]:
|
def load_notes(path: Path) -> list[str]:
|
||||||
"""Read display notes from '# note: ...' comment lines in the samples file."""
|
"""Read display notes from 'note: ...' lines in the samples file."""
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return []
|
return []
|
||||||
notes = []
|
notes = []
|
||||||
@@ -48,7 +52,9 @@ def _sample_lines(path: Path) -> list[str]:
|
|||||||
return [
|
return [
|
||||||
line.strip()
|
line.strip()
|
||||||
for line in path.read_text(encoding="utf-8").splitlines()
|
for line in path.read_text(encoding="utf-8").splitlines()
|
||||||
if line.strip() and not line.strip().startswith("#")
|
if line.strip()
|
||||||
|
and not line.strip().startswith("#")
|
||||||
|
and not _is_note_line(line)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -117,10 +123,11 @@ def de2000(lab1, lab2) -> float:
|
|||||||
def add_delta_e(rows: list[dict], references: dict[str, str]) -> bool:
|
def add_delta_e(rows: list[dict], references: dict[str, str]) -> bool:
|
||||||
"""Add a CIEDE2000 column to each averaged row vs that sample's reference.
|
"""Add a CIEDE2000 column to each averaged row vs that sample's reference.
|
||||||
|
|
||||||
Samples absent from `references` are references themselves (dE00 = 0).
|
Samples absent from `references` are references themselves (dE00 left
|
||||||
Returns True if the column was written (only when at least one sample
|
empty — they have no external comparison). Returns True if the column
|
||||||
names a reference). Never raises so the scan pipeline can continue even
|
was written (only when at least one sample names a reference). Never
|
||||||
when a named reference is missing.
|
raises so the scan pipeline can continue even when a named reference
|
||||||
|
is missing.
|
||||||
"""
|
"""
|
||||||
if not rows or not references:
|
if not rows or not references:
|
||||||
return False
|
return False
|
||||||
@@ -131,7 +138,7 @@ def add_delta_e(rows: list[dict], references: dict[str, str]) -> bool:
|
|||||||
sid = row["sample_id"]
|
sid = row["sample_id"]
|
||||||
ref_id = references.get(sid)
|
ref_id = references.get(sid)
|
||||||
if ref_id is None:
|
if ref_id is None:
|
||||||
row[DE_COL] = 0.0
|
row[DE_COL] = ""
|
||||||
wrote = True
|
wrote = True
|
||||||
continue
|
continue
|
||||||
ref_row = by_id.get(ref_id)
|
ref_row = by_id.get(ref_id)
|
||||||
@@ -221,10 +228,10 @@ def write_html(
|
|||||||
if has_de:
|
if has_de:
|
||||||
raw = r.get(DE_COL, "")
|
raw = r.get(DE_COL, "")
|
||||||
if raw == "" or raw is None:
|
if raw == "" or raw is None:
|
||||||
cells.append('<td class="de">—</td>')
|
cells.append("<td>—</td>")
|
||||||
else:
|
else:
|
||||||
d = float(raw)
|
d = float(raw)
|
||||||
de_cls = "de win" if is_ref else ("de bad" if d >= 3.5 else "de")
|
de_cls = "de bad" if d >= 3.5 else "de"
|
||||||
cells.append(
|
cells.append(
|
||||||
f'<td class="{de_cls}" title="{esc(de_bucket(d))}">{d:.2f}</td>'
|
f'<td class="{de_cls}" title="{esc(de_bucket(d))}">{d:.2f}</td>'
|
||||||
)
|
)
|
||||||
@@ -232,7 +239,7 @@ def write_html(
|
|||||||
|
|
||||||
ref_note = (
|
ref_note = (
|
||||||
"ΔE00 is CIEDE2000 against each sample's named reference "
|
"ΔE00 is CIEDE2000 against each sample's named reference "
|
||||||
"(<code>NAME > REF</code> in samples.txt); tagged "
|
"; tagged "
|
||||||
"<b>reference</b> rows have no external reference. Lower is a closer match."
|
"<b>reference</b> rows have no external reference. Lower is a closer match."
|
||||||
if has_de else
|
if has_de else
|
||||||
"No Delta-E column (add <code>NAME > REF</code> lines in samples.txt)."
|
"No Delta-E column (add <code>NAME > REF</code> lines in samples.txt)."
|
||||||
@@ -252,7 +259,7 @@ def write_html(
|
|||||||
<title>Averaged color measurements</title>
|
<title>Averaged color measurements</title>
|
||||||
<style>
|
<style>
|
||||||
:root {{ --text:#1f2328; --text2:#57606a; --text3:#8b949e; --stroke:#d0d7de;
|
:root {{ --text:#1f2328; --text2:#57606a; --text3:#8b949e; --stroke:#d0d7de;
|
||||||
--bg:#fff; --fill:#f6f8fa; --good:#1a7f37; --bad:#bc4c00; }}
|
--bg:#fff; --fill:#f6f8fa; --bad:#bc4c00; }}
|
||||||
* {{ box-sizing:border-box; }}
|
* {{ box-sizing:border-box; }}
|
||||||
body {{ margin:0; padding:32px 24px 48px; background:var(--bg); color:var(--text);
|
body {{ margin:0; padding:32px 24px 48px; background:var(--bg); color:var(--text);
|
||||||
font:14px/1.5 -apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; }}
|
font:14px/1.5 -apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; }}
|
||||||
@@ -278,7 +285,6 @@ def write_html(
|
|||||||
.tag {{ font-size:11px; color:var(--text3); border:1px solid var(--stroke);
|
.tag {{ font-size:11px; color:var(--text3); border:1px solid var(--stroke);
|
||||||
border-radius:4px; padding:0 5px; margin-left:6px; }}
|
border-radius:4px; padding:0 5px; margin-left:6px; }}
|
||||||
.de {{ font-weight:600; }}
|
.de {{ font-weight:600; }}
|
||||||
.win {{ color:var(--good); }}
|
|
||||||
.bad {{ color:var(--bad); }}
|
.bad {{ color:var(--bad); }}
|
||||||
.faint {{ color:var(--text3); font-size:12px; margin-top:14px; }}
|
.faint {{ color:var(--text3); font-size:12px; margin-top:14px; }}
|
||||||
@media print {{ body {{ padding:0; }} }}
|
@media print {{ body {{ padding:0; }} }}
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ esac
|
|||||||
|
|
||||||
SAMPLE_COUNT=0
|
SAMPLE_COUNT=0
|
||||||
if [[ -f samples.txt ]]; then
|
if [[ -f samples.txt ]]; then
|
||||||
SAMPLE_COUNT="$(grep -cv '^#\|^$' samples.txt || true)"
|
SAMPLE_COUNT="$(grep -v '^#' samples.txt | grep -iv '^[[:space:]]*note:' \
|
||||||
|
| grep -cv '^[[:space:]]*$' || true)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ RESET = "\033[0m"
|
|||||||
|
|
||||||
def load_sample_names(path: Path) -> list[str]:
|
def load_sample_names(path: Path) -> list[str]:
|
||||||
# Optional "NAME > REF": keep only the sample name (before ">").
|
# Optional "NAME > REF": keep only the sample name (before ">").
|
||||||
|
# Skip "#" comments and "note: ..." metadata lines.
|
||||||
names = []
|
names = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line and not line.startswith("#"):
|
if not line or line.startswith("#") or line.lower().startswith("note:"):
|
||||||
|
continue
|
||||||
if ">" in line:
|
if ">" in line:
|
||||||
line = line.split(">", 1)[0].strip()
|
line = line.split(">", 1)[0].strip()
|
||||||
names.append(line)
|
names.append(line)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ if [[ -z "$LATEST" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -qv '^#' samples.txt 2>/dev/null && grep -q '[^[:space:]]' samples.txt; then
|
if grep -v '^#' samples.txt 2>/dev/null | grep -iv '^[[:space:]]*note:' \
|
||||||
|
| grep -q '[^[:space:]]'; then
|
||||||
./tsv-to-csv.py "$LATEST" -s samples.txt
|
./tsv-to-csv.py "$LATEST" -s samples.txt
|
||||||
else
|
else
|
||||||
./tsv-to-csv.py "$LATEST"
|
./tsv-to-csv.py "$LATEST"
|
||||||
@@ -24,7 +25,8 @@ fi
|
|||||||
|
|
||||||
CSV="${LATEST%.tsv}.csv"
|
CSV="${LATEST%.tsv}.csv"
|
||||||
READING_COUNT="$(($(wc -l < "$LATEST") - 1))"
|
READING_COUNT="$(($(wc -l < "$LATEST") - 1))"
|
||||||
EXPECTED="$(grep -cv '^#\|^$' samples.txt 2>/dev/null || echo 0)"
|
EXPECTED="$(grep -v '^#' samples.txt 2>/dev/null | grep -iv '^[[:space:]]*note:' \
|
||||||
|
| grep -cv '^[[:space:]]*$' || echo 0)"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# One sample name per line, in measurement order.
|
# One sample name per line, in measurement order.
|
||||||
# Lines starting with # are ignored.
|
# Lines starting with # are comments (ignored). Lines starting with "note:"
|
||||||
|
# are HTML report metadata (not samples).
|
||||||
#
|
#
|
||||||
# Name a Delta-E reference with "NAME > REF": that sample's dE00 (CIEDE2000
|
# Name a Delta-E reference with "NAME > REF": that sample's dE00 (CIEDE2000
|
||||||
# in averaged.csv) is measured against REF. A bare name (no ">") is itself a
|
# in averaged.csv) is measured against REF. A bare name (no ">") is itself a
|
||||||
@@ -7,9 +8,11 @@
|
|||||||
# INK_A
|
# INK_A
|
||||||
# INK_B > INK_A
|
# INK_B > INK_A
|
||||||
#
|
#
|
||||||
# Optional notes for averaged.html (one per line, shown above the results table):
|
# Optional notes for averaged.html (one per line, NOT starting with #):
|
||||||
# note: Glaze: CPO1192
|
# note: Print Surface: A4 Paper
|
||||||
# note: Firing Temperature: 1150 C
|
# note: Temperature: 30 C
|
||||||
|
#
|
||||||
|
# Lines starting with "note:" are metadata for the HTML report, not samples.
|
||||||
#
|
#
|
||||||
# Single materials: just the material name/code, e.g.
|
# Single materials: just the material name/code, e.g.
|
||||||
# INK_A
|
# INK_A
|
||||||
@@ -20,6 +23,8 @@
|
|||||||
#
|
#
|
||||||
# Copy this file to samples.txt and replace with your own materials:
|
# Copy this file to samples.txt and replace with your own materials:
|
||||||
# cp samples.example.txt samples.txt
|
# cp samples.example.txt samples.txt
|
||||||
|
note: Print Surface: A4 Paper
|
||||||
|
note: Temperature: 30 ℃
|
||||||
INK_A
|
INK_A
|
||||||
INK_B > INK_A
|
INK_B > INK_A
|
||||||
INK_C > INK_A
|
INK_C > INK_A
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ from pathlib import Path
|
|||||||
|
|
||||||
def load_sample_names(path: Path) -> list[str]:
|
def load_sample_names(path: Path) -> list[str]:
|
||||||
# Optional "NAME > REF": keep only the sample name (before ">").
|
# Optional "NAME > REF": keep only the sample name (before ">").
|
||||||
|
# Skip "#" comments and "note: ..." metadata lines.
|
||||||
names = []
|
names = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line and not line.startswith("#"):
|
if not line or line.startswith("#") or line.lower().startswith("note:"):
|
||||||
|
continue
|
||||||
if ">" in line:
|
if ">" in line:
|
||||||
line = line.split(">", 1)[0].strip()
|
line = line.split(">", 1)[0].strip()
|
||||||
names.append(line)
|
names.append(line)
|
||||||
|
|||||||
Reference in New Issue
Block a user