Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -19,21 +19,21 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.2
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.15.9
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
rev: v0.25
hooks:
- id: validate-pyproject

Expand Down
6 changes: 2 additions & 4 deletions aok/core/kd_utils/Kd_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import logging

import numpy as np
import pandas as pd

Check failure on line 7 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Stub file not found for "pandas" (reportMissingTypeStubs)
from scipy.optimize import curve_fit

Check failure on line 8 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type of "curve_fit" is partially unknown   Type of "curve_fit" is "(f: Unknown, xdata: Unknown, ydata: Unknown, p0: Unknown | None = None, sigma: Unknown | None = None, absolute_sigma: bool = False, check_finite: Unknown | None = None, bounds: Unknown = (-np.inf, np.inf), method: Unknown | None = None, jac: Unknown | None = None, *, full_output: bool = False, nan_policy: Unknown | None = None, **kwargs: Unknown) -> Unknown" (reportUnknownVariableType)

Check failure on line 8 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Stub file not found for "scipy.optimize" (reportMissingTypeStubs)
from sklearn.linear_model import LinearRegression

Check failure on line 9 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Stub file not found for "sklearn.linear_model" (reportMissingTypeStubs)

# def log_model(z, kd, e0):
# return np.log(e0) - kd * z
Expand Down Expand Up @@ -172,7 +172,7 @@
# })


def find_exponential_decay_zone(hist_df, decay_threshold=0.0):

Check failure on line 175 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type annotation is missing for parameter "decay_threshold" (reportMissingParameterType)

Check failure on line 175 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type annotation is missing for parameter "hist_df" (reportMissingParameterType)

Check failure on line 175 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type of parameter "hist_df" is unknown (reportUnknownParameterType)

Check failure on line 175 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Return type is unknown (reportUnknownParameterType)
"""
Identify the depth bins that lie within the exponential decay zone.

Expand All @@ -196,7 +196,7 @@
Filtered rows with a 'log_photon_counts' column added; only bins inside
the exponential decay zone are kept (photon_counts > 0 and log finite).
"""
df = hist_df.copy()

Check failure on line 199 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type of "copy" is unknown (reportUnknownMemberType)

Check failure on line 199 in aok/core/kd_utils/Kd_analysis.py

View workflow job for this annotation

GitHub Actions / test

Type of "df" is unknown (reportUnknownVariableType)

# Apply decay threshold: exclude bins below threshold fraction of peak signal
if decay_threshold > 0.0:
Expand Down Expand Up @@ -612,9 +612,7 @@
)
return kd, e0, nf

raise ValueError(
f"Unknown kd_fit_method: {method!r}. " f"Choose from {KD_FIT_METHODS}"
)
raise ValueError(f"Unknown kd_fit_method: {method!r}. Choose from {KD_FIT_METHODS}")


# another solution is to calculate kd without hist
Expand Down Expand Up @@ -849,7 +847,7 @@
else:
expected_nf_per_bin = None
logging.info(
"Hybrid: insufficient noise floor estimates (%d), " "skipping pass 2",
"Hybrid: insufficient noise floor estimates (%d), skipping pass 2",
len(valid_nf_all),
)

Expand Down
6 changes: 3 additions & 3 deletions aok/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def run_pipeline(args):
["relative_AT_dist", "lat_bins", "photon_height"]
].drop_duplicates()
unique_photon_dataset["relative_AT_dist_center"] = (
unique_photon_dataset.groupby(
"lat_bins", observed=False
)["relative_AT_dist"].transform("mean")
unique_photon_dataset.groupby("lat_bins", observed=False)[
"relative_AT_dist"
].transform("mean")
)

_closest_rows = []
Expand Down
Loading