Initial Pecan Data Format
This commit is contained in:
commit
42b3a9cf12
|
@ -0,0 +1,40 @@
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import List, Any
|
||||||
|
|
||||||
|
Interval = tuple[float, float] | None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Measurement:
|
||||||
|
"""These are the fields that represent the outputs of the experiment."""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
unit: str
|
||||||
|
interval: Interval = None
|
||||||
|
values: List[float] = field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Variable:
|
||||||
|
"""These are the fields that represent the inputs of the experiment."""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
unit: str
|
||||||
|
interval: Interval = None
|
||||||
|
value: Any = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Experiment:
|
||||||
|
"""This is the data class that represents the experiment."""
|
||||||
|
|
||||||
|
experiment: str
|
||||||
|
date: str
|
||||||
|
measurements: List[Measurement] = field(default_factory=list)
|
||||||
|
variables: List[Variable] = field(default_factory=list)
|
||||||
|
|
||||||
|
def to_json(self):
|
||||||
|
# Convert the data class to a dictionary, which can be easily converted to JSON.
|
||||||
|
import json
|
||||||
|
|
||||||
|
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
|
|
@ -0,0 +1,19 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from experiment import Experiment, Measurement, Variable
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class MoistureExperiment(Experiment):
|
||||||
|
def __init__(self, date: str):
|
||||||
|
super().__init__(
|
||||||
|
experiment="Moisture Analysis",
|
||||||
|
date=date,
|
||||||
|
variables=[
|
||||||
|
Variable("cold-soak-time", "hour", (5, 45)),
|
||||||
|
Variable("cold-soak-temp", "degF", (69, 72)),
|
||||||
|
Variable("hot-soak-time", "minute", (5, 20)),
|
||||||
|
Variable("hot-soak-temp", "degF", (180, 200)),
|
||||||
|
],
|
||||||
|
measurements=[Measurement("moisture-content", "%", (0.06, 0.08))],
|
||||||
|
)
|
|
@ -0,0 +1,31 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from experiment import Experiment, Measurement, Variable
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ShellingExperiment(Experiment):
|
||||||
|
def __init__(self, date: str):
|
||||||
|
super().__init__(
|
||||||
|
experiment="Shelling Analysis",
|
||||||
|
date=date,
|
||||||
|
variables=[
|
||||||
|
Variable("drum-rpm", "rpm", (30, 40)),
|
||||||
|
Variable("paddle-shaft-rpm", "rpm", (400, 800)),
|
||||||
|
Variable("ring-gap", "in"),
|
||||||
|
Variable("tilt-angle", "deg", (2, 5)),
|
||||||
|
Variable("feed-rate", "lb/hr", (300, 500), 500),
|
||||||
|
Variable("moisture-content", "%", (5, 9)),
|
||||||
|
Variable("pecan-variety", "", None, "desirable"),
|
||||||
|
],
|
||||||
|
measurements=[
|
||||||
|
Measurement("bin1-weight", "lb"),
|
||||||
|
Measurement("bin2-weight", "lb"),
|
||||||
|
Measurement("bin3-weight", "lb"),
|
||||||
|
Measurement("recirculated-weight", "lb"),
|
||||||
|
Measurement("final-discharge-weight", "lb"),
|
||||||
|
Measurement("bin1-half-yield", "%"),
|
||||||
|
Measurement("bin2-half-yield", "%"),
|
||||||
|
Measurement("bin3-half-yield", "%"),
|
||||||
|
],
|
||||||
|
)
|
Loading…
Reference in New Issue