Skip to content

Commit

Permalink
Adjust method for cloud detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmarke committed Jan 24, 2024
1 parent ae6e779 commit 82d5627
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mwrpy/atmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def find_lwcl_free(lev1: dict) -> tuple[np.ndarray, np.ndarray]:

tb_wv = np.squeeze(lev1["tb"][:, freq_22])
tb_rat = pd.DataFrame({"Tb": tb_wv / tb}, index=ind)
tb_max = tb_rat.rolling(
tb_rat = tb_rat.rolling(
pd.tseries.frequencies.to_offset("20min"), center=True, min_periods=100
).max()
index[tb_mx["Tb"] < (0.1 * tb_max["Tb"])] = 0
index[tb_mx["Tb"] < np.median(tb_rat["Tb"]) * 0.1] = 0

df = pd.DataFrame({"index": index}, index=ind)
df = df.bfill(limit=120)
Expand Down
17 changes: 15 additions & 2 deletions mwrpy/level2/lwp_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,35 @@ def correct_lwp_offset(
).max()
freq_31 = np.where(np.round(lev1["frequency"][:], 1) == 31.4)[0]
freq_22 = np.where(np.round(lev1["frequency"][:], 1) == 22.2)[0]
tb = lev1["tb"][index, :]
tb[lev1["elevation_angle"][index] < 89.0] = np.nan
tb_rat = pd.DataFrame(
{"Tb": np.squeeze(lev1["tb"][index, freq_22] / lev1["tb"][index, freq_31])},
{"Tb": np.squeeze(tb[:, freq_22] / tb[:, freq_31])},
index=ind,
)
tb_max = tb_rat.rolling(
pd.tseries.frequencies.to_offset("20min"), center=True, min_periods=100
).max()

lwp[
(lwcl_i != 0) | (lwp > 0.06) | (lwp_max["Lwp"] > (tb_max["Tb"] * 0.002))
(lwcl_i != 0) | (lwp > 0.06) | (lwp_max["Lwp"] > (tb_max["Tb"] * 0.0025))
] = np.nan
lwp_df = pd.DataFrame({"Lwp": lwp}, index=ind)
lwp_offset = lwp_df.rolling(
pd.tseries.frequencies.to_offset("20min"), center=True, min_periods=100
).mean()
lwp_offset = lwp_offset.interpolate(method="linear")
lwp_offset = lwp_offset.bfill()

lwp_mx = lwp_offset.rolling(
pd.tseries.frequencies.to_offset("60min"), center=True, min_periods=100
).max()
lwp_mn = lwp_offset.rolling(
pd.tseries.frequencies.to_offset("60min"), center=True, min_periods=100
).min()
lwp_offset["Lwp"][
(lwp_mx["Lwp"][:] - lwp_mn["Lwp"][:]) / tb_max["Tb"] > (tb_max["Tb"] * 0.002)
] = np.nan
lwp_offset = lwp_offset.interpolate(method="linear")
lwp_offset = lwp_offset.bfill()
lwp_offset["Lwp"][(np.isnan(lwp_offset["Lwp"])) | (lwp_org == -999.0)] = 0.0
Expand Down

0 comments on commit 82d5627

Please sign in to comment.