Skip to content

Commit

Permalink
add confidence angle to spicy processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachHoppinen authored Sep 6, 2023
1 parent e646a4c commit d798a36
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spicy_snow/processing/s1_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,28 @@ def merge_s1_subsets(dataset_dictionary: Dict[str, xr.Dataset]) -> xr.Dataset:

return dataset

def add_confidence_angle(dataset: xr.Dataset, inplace: bool = False):
"""
Function to add confidence angle to dataset.
Confidence Angle = angle[ abs(dVH/dt / mean(dVH/dt)), abs(dVV/dt / mean(dVV/dt)) ]
Args:
dataset: Xarray Dataset of sentinel images to add confidence angle to
inplace: boolean flag to modify original Dataset or return a new Dataset
Returns:
dataset: Xarray dataset of sentinel image with confidence interval in
"""
ds_amp = s1_dB_to_power(dataset).copy()
ds_amp['deltaVH_amp'] = ds_amp['s1'].sel(band = 'VH').diff(1)
ds_amp['deltaVV_amp'] = ds_amp['s1'].sel(band = 'VV').diff(1)

ds_amp['deltaVH_norm'] = np.abs(ds_amp['deltaVH_amp'] / ds_amp['deltaVH_amp'].mean())
ds_amp['deltaVV_norm'] = np.abs(ds_amp['deltaVV_amp'] / ds_amp['deltaVV_amp'].mean())

ds_amp['confidence'] = (ds_amp['deltaVH_norm'].dims, np.angle(ds_amp['deltaVV_norm'].values + ds_amp['deltaVH_norm'].values * 1j))
dataset['confidence'] = ds_amp['confidence'].mean('time')

if not inplace:
return dataset

0 comments on commit d798a36

Please sign in to comment.