From a4e9dc4b9bfde27322a815d048b5fcf46a4a1468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Sierro?= Date: Wed, 9 Aug 2023 13:55:08 +0200 Subject: [PATCH] adapted g12 for any ndim --- pyproject.toml | 2 +- src/scgenerator/physics/pulse.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3c710eb..abf2491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" }] diff --git a/src/scgenerator/physics/pulse.py b/src/scgenerator/physics/pulse.py index 4ece788..0a1733a 100644 --- a/src/scgenerator/physics/pulse.py +++ b/src/scgenerator/physics/pulse.py @@ -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: