adapted g12 for any ndim

This commit is contained in:
Benoît Sierro
2023-08-09 13:55:08 +02:00
parent 057a65d15e
commit a4e9dc4b9b
2 changed files with 5 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "scgenerator"
version = "0.3.5"
version = "0.3.6"
description = "Simulate nonlinear pulse propagation in optical fibers"
readme = "README.md"
authors = [{ name = "Benoit Sierro", email = "benoit.sierro@iap.unibe.ch" }]

View File

@@ -672,18 +672,19 @@ def g12(values):
Parameters
----------
values : 2D array
values : np.ndarray, shape (..., m, n)
complex values following sc-ordering
Returns
-------
g12_arr : coherence function as a n-D array
np.ndarray, shape (..., n)
coherence function
"""
# Create all the possible pairs of values
n = len(values)
field_pairs = itertools.combinations(values, 2)
mean_spec = np.mean(math.abs2(values), axis=0)
mean_spec = np.mean(math.abs2(values), axis=-2)
mask = mean_spec > 1e-15 * mean_spec.max()
corr = np.zeros_like(values[0])
for pair in field_pairs: