adapted g12 for any ndim
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "scgenerator"
|
name = "scgenerator"
|
||||||
version = "0.3.5"
|
version = "0.3.6"
|
||||||
description = "Simulate nonlinear pulse propagation in optical fibers"
|
description = "Simulate nonlinear pulse propagation in optical fibers"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "Benoit Sierro", email = "benoit.sierro@iap.unibe.ch" }]
|
authors = [{ name = "Benoit Sierro", email = "benoit.sierro@iap.unibe.ch" }]
|
||||||
|
|||||||
@@ -672,18 +672,19 @@ def g12(values):
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
values : 2D array
|
values : np.ndarray, shape (..., m, n)
|
||||||
complex values following sc-ordering
|
complex values following sc-ordering
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
g12_arr : coherence function as a n-D array
|
np.ndarray, shape (..., n)
|
||||||
|
coherence function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Create all the possible pairs of values
|
# Create all the possible pairs of values
|
||||||
n = len(values)
|
n = len(values)
|
||||||
field_pairs = itertools.combinations(values, 2)
|
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()
|
mask = mean_spec > 1e-15 * mean_spec.max()
|
||||||
corr = np.zeros_like(values[0])
|
corr = np.zeros_like(values[0])
|
||||||
for pair in field_pairs:
|
for pair in field_pairs:
|
||||||
|
|||||||
Reference in New Issue
Block a user