Skip to content

Commit

Permalink
Off-zenith merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmarke committed Sep 27, 2024
2 parents 8c0b27a + 1d28a84 commit 5cd37b6
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 272 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11"]
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]

runs-on: ${{ matrix.os }}
steps:
Expand Down
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
hooks:
- id: toml-sort-fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
rev: v0.6.3
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -39,3 +39,8 @@ repos:
language: system
types: [python]
require_serial: true
- repo: https://github.com/crate-ci/typos
rev: v1.24.1
hooks:
- id: typos
args: ["--force-exclude"]
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 1.0.4 – 2024-08-30

- Handle missing MET files

## 1.0.3 – 2024-08-30

- Handle missing HKD files

## 1.0.2 – 2024-08-26

- Relax min periods for standard deviation

## 1.0.1 – 2024-07-26

- Fix NumPy 2.0 issues
Expand Down
5 changes: 5 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[default]
extend-ignore-identifiers-re = ["ND"]

[files]
extend-exclude = ["mwrpy/site_config/", "tests/data/"]
18 changes: 6 additions & 12 deletions mwrpy/atmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,11 @@ def calc_p_baro(
Tv = mpcalc.virtual_temperature(
masked_array(T, data_units="K"), masked_array(q, data_units="")
).magnitude
p_baro = ma.masked_all(T.shape)
p_baro[(~ma.getmaskarray(q).any(axis=1)) & (~ma.getmaskarray(T).any(axis=1)), 0] = (
p[(~ma.getmaskarray(q).any(axis=1)) & (~ma.getmaskarray(T).any(axis=1))]
)
for ialt in np.arange(len(z) - 1) + 1:
p_baro[:, ialt] = p_baro[:, ialt - 1] * ma.exp(
-scipy.constants.g
* (z[ialt] - z[ialt - 1])
/ (con.RS * (Tv[:, ialt] + Tv[:, ialt - 1]) / 2.0)
)

Tv_half = (Tv[:, :-1] + Tv[:, 1:]) / 2
dz = np.diff(z)
dp = ma.exp(-scipy.constants.g * dz / (con.RS * Tv_half))
tmp = np.insert(dp, 0, p, axis=1)
p_baro = np.cumprod(tmp, axis=1)
return p_baro


Expand Down Expand Up @@ -171,7 +165,7 @@ def find_lwcl_free(lev1: dict) -> tuple[np.ndarray, np.ndarray]:
ind = utils.time_to_datetime_index(lev1["time"][:])
tb_df = pd.DataFrame({"Tb": tb}, index=ind)
tb_std = tb_df.rolling(
pd.tseries.frequencies.to_offset("2min"), center=True, min_periods=60
pd.tseries.frequencies.to_offset("2min"), center=True, min_periods=40
).std()
tb_mx = tb_std.rolling(
pd.tseries.frequencies.to_offset("20min"), center=True, min_periods=100
Expand Down
5 changes: 5 additions & 0 deletions mwrpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def _parse_args(args):
metavar="YYYY-MM-DD",
help="Single date to be processed.",
)
group.add_argument(
"--no-plot",
action="store_true",
help="Process without plotting.",
)
return parser.parse_args(args)


Expand Down
34 changes: 11 additions & 23 deletions mwrpy/level1/met_quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,14 @@ def apply_met_qc(data: dict, params: dict) -> None:
]

for bit, name in enumerate(var_name):
if name in data:
if name == "air_pressure":
threshold_low = (
mpcalc.height_to_pressure_std(
masked_array(params["altitude"], data_units="m")
).magnitude
* 100.0
- 10000.0
)
threshold_high = (
mpcalc.height_to_pressure_std(
masked_array(params["altitude"], data_units="m")
).magnitude
* 100.0
+ 10000.0
)
else:
threshold_low = params["met_thresholds"][bit][0]
threshold_high = params["met_thresholds"][bit][1]
ind = np.where(
(data[name][:] < threshold_low) | (data[name][:] > threshold_high)
)
data["met_quality_flag"][ind] = setbit(data["met_quality_flag"][ind], bit)
if name not in data:
continue
if name == "air_pressure":
altitude = masked_array(params["altitude"], data_units="m")
pressure = mpcalc.height_to_pressure_std(altitude).to("pascal").magnitude
threshold_low = pressure - 10000
threshold_high = pressure + 10000
else:
threshold_low, threshold_high = params["met_thresholds"][bit]
ind = (data[name][:] < threshold_low) | (data[name][:] > threshold_high)
data["met_quality_flag"][ind] = setbit(data["met_quality_flag"][ind], bit)
Loading

0 comments on commit 5cd37b6

Please sign in to comment.