Skip to content

Commit

Permalink
scattering: add vectorize_scattering_coefficients_xarray
Browse files Browse the repository at this point in the history
  • Loading branch information
zerafachris committed May 28, 2024
1 parent 2a0366c commit 6e34ea6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scatcluster/processing/scattering.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,17 +550,8 @@ def process_vectorized_scattering_coefficients(self) -> None:
coefficients = self.normalize(coefficients)
print(coefficients)

# Extract design matrix
n_samples = coefficients.time.shape[0]
x1 = coefficients.order_1.data.reshape(n_samples, -1)
x2 = coefficients.order_2.data.reshape(n_samples, -1)
x = np.hstack((x1, x2))

# Remove NaNs
x[np.isnan(x)] = 0

self.data_times = coefficients.time.values
self.data_scat_coef_vectorized = x
self.data_scat_coef_vectorized = self.vectorize_scattering_coefficients_xarray(coefficients)

# Display statistics from the vectorization
print(f'Number of valid time windows of size {self.network_segment}s: {int(self.data_times.shape[0])}')
Expand All @@ -579,6 +570,17 @@ def process_vectorized_scattering_coefficients(self) -> None:
f'{self.network_name}_scat_coef_xarray.nc')

return coefficients

def vectorize_scattering_coefficients_xarray(self, coefficients):
n_samples = coefficients.time.shape[0]
x1 = coefficients.order_1.data.reshape(n_samples, -1)
x2 = coefficients.order_2.data.reshape(n_samples, -1)
x = np.hstack((x1, x2))

x[np.isnan(x)] = 0

return x


def load_scattering_coefficients_xarray(self):
"""
Expand Down

0 comments on commit 6e34ea6

Please sign in to comment.