Skip to content

Commit

Permalink
Merge pull request #30 from hgloeckner/int_p_log
Browse files Browse the repository at this point in the history
option to interp p in log space
  • Loading branch information
hgloeckner authored Sep 3, 2024
2 parents c6fcfd8 + 98e6c3c commit 396a3be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pydropsonde/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ def interpolate_alt(
interp_stop=14515,
interp_step=10,
max_gap_fill: int = 50,
p_log=True,
method: str = "bin",
):
"""
Expand All @@ -1092,7 +1093,8 @@ def interpolate_alt(
f"your altitude for sonde {self._prep_l3_ds.sonde_id.values} is not sorted."
)
ds = self._prep_l3_ds.swap_dims({"time": alt_var}).load()

if p_log:
ds = ds.assign(p=(ds.p.dims, np.log(ds.p.values)))
if method == "linear_interpolate":
interp_ds = ds.interp({alt_var: interpolation_grid})
elif method == "bin":
Expand Down Expand Up @@ -1131,6 +1133,9 @@ def interpolate_alt(
.rename({f"{alt_var}_bins": alt_var, "time": "interpolated_time"})
)

if p_log:
interp_ds = ds.assign(p=(ds.p.dims, np.exp(ds.p.values)))

object.__setattr__(self, "_prep_l3_ds", interp_ds)

return self
Expand Down

0 comments on commit 396a3be

Please sign in to comment.