Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/glide/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def l3(
"""
Generate L3 data from L2 data.
"""
conf = config.load_config(config_file)

l2 = process_l2.parse_l2(l2_file)

out = process_l2.bin_l2(l2, bin_size, depth)
out = process_l2.bin_l2(l2, bin_size, depth, conf)

if q_netcdf is not None:
conf = config.load_config(config_file)

q = ancillery.parse_q(q_netcdf)

out = process_l3.bin_q(out, q, bin_size, conf)
Expand Down
15 changes: 14 additions & 1 deletion src/glide/process_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def parse_l2(file: str) -> xr.Dataset:


def bin_l2(
ds: xr.Dataset, bin_size: float = 10.0, depth: float | None = None
ds: xr.Dataset,
bin_size: float = 10.0,
depth: float | None = None,
config: dict | None = None,
) -> xr.Dataset:
"""Depth bin size specified in meters."""

Expand All @@ -80,6 +83,16 @@ def bin_l2(
# treat them after binning. We may want to define new QC variables in the future.
qc_variables = [v for v in ds.variables if "_qc" in str(v)]
drop_variables = qc_variables + ["dive_id", "climb_id", "state", "z"]

# Drop variables flagged with drop_from_l3 in the config
if config is not None:
for v in list(ds.variables):
try:
if config["variables"][v].get("drop_from_l3", False):
_log.info("Not binning %s due to drop_from_l3 flag in config", v)
drop_variables.append(v)
except KeyError:
pass
_log.warning("Binning QC flags is not supported, dropping %s", drop_variables)
for var in ds.variables:
if "ancillary_variables" not in ds[var].attrs:
Expand Down
Loading