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
11 changes: 8 additions & 3 deletions act/retrievals/cbh.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def generic_sobel_cbh(
ds,
variable=None,
height_dim=None,
height_dim='range',
var_thresh=None,
fill_na=None,
return_thresh=False,
Expand All @@ -35,7 +35,7 @@ def generic_sobel_cbh(
variable : string
Variable on which to process.
height_dim : string
Height variable to use for CBH values.
Height variable to use for CBH values. Default is 'range'.
var_thresh : float
Thresholding for variable if needed.
fill_na : float
Expand Down Expand Up @@ -87,6 +87,11 @@ def generic_sobel_cbh(
"""
if variable is None:
return
if height_dim is None:
raise ValueError(
"height_dim must be specified. Please provide the name of the height "
"dimension (e.g., 'range', 'range_bins')."
)
if fill_na is None:
fill_na = var_thresh

Expand Down Expand Up @@ -119,7 +124,7 @@ def generic_sobel_cbh(
edge_da = edge_da.fillna(fill_na)

# Do a diff along the height dimension to define edge
diff = edge_da.diff(dim=1).values
diff = edge_da.diff(dim=height_dim).values

# Get height variable to use for cbh
height = ds[height_dim].values
Expand Down
4 changes: 2 additions & 2 deletions tests/retrievals/test_cbh.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def test_generic_sobel_cbh():
edge_thresh=5,
)
cbh = ceil['cbh_sobel_backscatter'].values
assert cbh[500] == 615.0
assert cbh[1000] == 555.0
assert cbh[500] == 585.0
assert cbh[1000] == 525.0
ceil.close()
Loading