← Về thư mục
skills/mineral_spectra_analysis/kernel.py
- _import_module · function · L56-L62 — def _import_module(name: str, install_hint: str)
- _np · function · L65-L68 — def _np()
- _signal · function · L71-L72 — def _signal()
- _ndimage · function · L75-L76 — def _ndimage()
- _optimize · function · L79-L80 — def _optimize()
- _baseline_cls · function · L83-L85 — def _baseline_cls()
- _plt · function · L88-L94 — def _plt()
- available_dependencies · function · L97-L106 — def available_dependencies() -> dict[str, bool]
- default_config · function · L109-L111 — def default_config() -> dict[str, Any]
- Library · class · L115-L127 — class Library
- index · method · L126-L127 — def index(self, name: str) -> int
- PipelineResult · class · L131-L140 — class PipelineResult
- LoopOutcome · class · L144-L146 — class LoopOutcome
- SynthCase · class · L150-L155 — class SynthCase
- parse_rruff_text · function · L158-L180 — def parse_rruff_text(txt: str)
- mineral_from_filename · function · L183-L185 — def mineral_from_filename(fname: str) -> str
- ensure_rruff_dataset · function · L188-L222 — def ensure_rruff_dataset( dataset: str = "excellent_oriented", cache_dir: str | os.PathLike[str] | None = None, allow_download: bool = True, ) -> str
- common_grid · function · L225-L228 — def common_grid()
- resample · function · L231-L238 — def resample(axis: Any, intensity: Any, grid: Any)
- _grid_coverage · function · L241-L245 — def _grid_coverage(axis: Any, grid: Any) -> float
- build_rruff_library · function · L248-L297 — def build_rruff_library( dataset: str = "excellent_oriented", max_minerals: int | None = None, cache_dir: str | os.PathLike[str] | None = None, zip_path: str | os.PathLike[str] | None = None, allow_download: bool = True, ) -> Library
- score · function · L279-L282 — def score(item)
- load_spectrum_csv · function · L300-L306 — def load_spectrum_csv(path: str | os.PathLike[str])
- save_spectrum_csv · function · L309-L323 — def save_spectrum_csv(path: str | os.PathLike[str], grid: Any, spectrum: Any) -> None
- despike · function · L326-L342 — def despike(y: Any, threshold: float = 7.0, window: int = 5)
- denoise · function · L345-L359 — def denoise(y: Any, method: str = "savgol", window: int = 7, poly: int = 3)
- baseline_correct · function · L362-L384 — def baseline_correct( y: Any, method: str = "asls", lam: float = 1e5, p: float = 0.01, poly_order: int = 5, )
- normalise · function · L387-L397 — def normalise(y: Any, method: str = "area")
- detect_peaks_2nd_deriv · function · L400-L428 — def detect_peaks_2nd_deriv(y: Any, grid: Any, config: dict[str, Any])
- preprocess · function · L431-L448 — def preprocess(y: Any, config: dict[str, Any])
- save_clean_spectrum · function · L451-L453 — def save_clean_spectrum(path: str | os.PathLike[str], grid: Any, y: Any) -> None
- load_clean_spectrum · function · L456-L458 — def load_clean_spectrum(path: str | os.PathLike[str])
- pearson · function · L461-L466 — def pearson(a: Any, b: Any) -> float
- cosine · function · L469-L474 — def cosine(a: Any, b: Any) -> float
- rmse · function · L477-L479 — def rmse(a: Any, b: Any) -> float
- sid · function · L482-L489 — def sid(a: Any, b: Any) -> float
- rank_library · function · L492-L498 — def rank_library(processed: Any, lib: Library, metric: str = "pearson")
- _reference_peaks · function · L501-L517 — def _reference_peaks(lib: Library, config: dict[str, Any]) -> list[Any]
- _peak_prefilter · function · L520-L533 — def _peak_prefilter(peaks: Any, lib: Library, config: dict[str, Any])
- best_next_component · function · L536-L558 — def best_next_component( residual: Any, peaks: Any, lib: Library, config: dict[str, Any], exclude: Iterable[int] = (), )
- unmix · function · L561-L580 — def unmix(processed: Any, lib: Library, candidate_idx: Any, config: dict[str, Any])
- reconstruct · function · L583-L591 — def reconstruct(lib: Library, idx: Any, coef: Any)
- find_significant_peaks · function · L594-L606 — def find_significant_peaks( y: Any, grid: Any, prominence_sigma: float = 4.0, abs_floor: float = 0.0, )
- supporting_peaks · function · L609-L632 — def supporting_peaks( processed_target: Any, lib: Library, name: str, grid: Any, tol_cm: float = 10.0, max_peaks: int = 8, ) -> list[float]
- diagnose · function · L635-L677 — def diagnose(processed_target: Any, recon: Any, grid: Any, config: dict[str, Any])
- run_blind_loop · function · L680-L787 — def run_blind_loop( clean: Any, lib: Library, config: dict[str, Any], log_path: str | os.PathLike[str] | None = None, verbose: bool = True, ) -> LoopOutcome
- make_figures · function · L790-L862 — def make_figures( spectrum: Any, clean: Any, lib: Library, outcome: LoopOutcome, fig_dir )
- build_markdown_report · function · L865-L994 — def build_markdown_report( outcome: LoopOutcome, config: dict[str, Any], truth: dict[str, Any] | None = None, evaluation: dict[str, float] | None = None, include_figures: bool = True, ) -> str
- write_report · function · L997-L999 — def write_report(path: str | os.PathLike[str], report: str) -> None
- analyze_spectrum_file · function · L1002-L1064 — def analyze_spectrum_file( spectrum_csv_path: str | os.PathLike[str], library: Library, output_dir: str | os.PathLike[str], config: dict[str, Any] | None = None, truth_path: str | os.PathLike[str] | None = None, make_figure_files: bool = True, make_figures: bool | None = None, verbose: bool = True, ) -> dict[str, Any]
- component_prf · function · L1067-L1077 — def component_prf( true_names: Iterable[str], pred_names: Iterable[str] ) -> dict[str, float]
- fraction_mae · function · L1080-L1087 — def fraction_mae(true_map: dict[str, float], pred_map: dict[str, float]) -> float
- evaluate_against_truth · function · L1090-L1096 — def evaluate_against_truth( result: PipelineResult, truth: dict[str, Any] ) -> dict[str, float]
- synth_mixture · function · L1099-L1148 — def synth_mixture( lib: Library, rng: Any, n_components: int | None = None, noise_level: float = 0.02, n_spikes: int = 3, baseline_strength: float = 0.5, min_fraction: float = 0.15, ) -> SynthCase
- save_case · function · L1151-L1165 — def save_case(case: SynthCase, case_dir: str | os.PathLike[str]) -> None
- load_truth · function · L1168-L1173 — def load_truth(case_dir_or_path: str | os.PathLike[str]) -> dict[str, Any]
- plot_input · function · L1176-L1187 — def plot_input(case: SynthCase, path: str | os.PathLike[str]) -> None
- generate_synthetic_cases · function · L1190-L1212 — def generate_synthetic_cases( lib: Library, out_dir: str | os.PathLike[str], n: int = 5, seed: int = 0, n_components: int | None = None, noise: float = 0.02, make_input_figures: bool = True, ) -> list[str]
- summarize_outcome · function · L1215-L1224 — def summarize_outcome(outcome: LoopOutcome) -> dict[str, Any]