Skip to content

Commit

Permalink
new implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoalopez committed May 21, 2024
1 parent 5505c3e commit 0cbb4f3
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
84 changes: 84 additions & 0 deletions grain_size_tools/new_piezometers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from dataclasses import dataclass
from typing import Dict, ClassVar, Any
import yaml

@dataclass
class Piezometer:
name: str
year: int
reference: str
B: float
m: float
warn: str
linear_intercepts: bool
correction_factor: Any
notes: str

def summary(self):
print(
f"Piezometer: {self.name}\n"
f"Year: {self.year}\n"
f"Reference: {self.reference}\n"
f"B: {self.B}\n"
f"m: {self.m}\n"
f"Warning: {self.warn}\n"
f"Linear Intercepts: {self.linear_intercepts}\n"
f"Correction Factor: {self.correction_factor}\n"
f"Notes: {self.notes}\n"
)

return None


@dataclass
class quartz(Piezometer):
piezometers: ClassVar[Dict[str, "Quartz"]] = {}


@dataclass
class olivine(Piezometer):
piezometers: ClassVar[Dict[str, "Olivine"]] = {}


@dataclass
class calcite(Piezometer):
piezometers: ClassVar[Dict[str, "Calcite"]] = {}


@dataclass
class feldspar(Piezometer):
piezometers: ClassVar[Dict[str, "Feldspar"]] = {}


def load_piezometers_from_yaml(filepath):
with open(filepath, "r") as file:
data = yaml.safe_load(file)

for mineral, piezos in data.items():
for piezo_data in piezos:
name = piezo_data.pop("piezometer")

if mineral == "quartz":
piezo = quartz(name=name, **piezo_data)
quartz.piezometers[name] = piezo
setattr(quartz, name, piezo)

elif mineral == "olivine":
piezo = olivine(name=name, **piezo_data)
olivine.piezometers[name] = piezo
setattr(olivine, name, piezo)

elif mineral == "calcite":
piezo = calcite(name=name, **piezo_data)
calcite.piezometers[name] = piezo
setattr(calcite, name, piezo)

elif mineral == "feldspar":
piezo = feldspar(name=name, **piezo_data)
feldspar.piezometers[name] = piezo
setattr(feldspar, name, piezo)


if __name__ == "__main__":
load_piezometers_from_yaml("piezometers.yaml")
print("database loaded")
41 changes: 41 additions & 0 deletions grain_size_tools/piezometers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
quartz:
- piezometer: Stipp_Tullis
year: 2003
reference: https://doi.org/10.1029/2003GL018444
B: 669.0
m: 0.79
warn: Ensure that you entered the apparent grain size as the root mean square (RMS)
linear_intercepts: false
correction_factor: false
notes: Only applies to recrystallization regimes 2 and 3 (SGR, GBM)

- piezometer: Holyoke
year: 2010
reference: https://doi.org/10.1016/j.tecto.2010.08.001
B: 490.3
m: 0.79
warn: Ensure that you entered the apparent grain size as the root mean square (RMS)
linear_intercepts: true
correction_factor: true
notes: None

olivine:
- piezometer: VanderWal_wet
year: 1993
reference: https://doi.org/10.1029/93GL01382
B: 1355.4
m: 0.75
warn: Ensure that you entered the apparent grain size as the root mean square (RMS)
linear_intercepts: true
correction_factor: 1.5
notes: The Van de Wal (1993) piezometer was calibrated using the linear intercept (LI) grain size multiplied by 1.5 (correction factor). ECDs without stereological correction are converted to LIs using the empirical equation of De Hoff and Rhines (1968) LI = (1.5 / sqrt(4/pi)) * ECD

- piezometer: Jung_Karato
year: 2001
reference: https://doi.org/10.1016/S0191-8141(01)00005-0
B: 5461.03
m: 0.85
warn: Ensure that you entered the apparent grain size as the root mean square (RMS)
linear_intercepts: true
correction_factor: 1.5
notes: The Jung & Karato (2001) piezometer was calibrated using the linear intercept (LI) grain size multiplied by 1.5 (correction factor). If equivalent circular diameters (ECD) without stereological correction are used, they must be converted to LIs using the empirical equation of De Hoff and Rhines (1968) as follows LI = (1.5 / sqrt(4/pi)) * ECD

0 comments on commit 0cbb4f3

Please sign in to comment.