pygeoinf 1.3.3__py3-none-any.whl → 1.3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,7 @@ except ImportError:
41
41
  )
42
42
 
43
43
  from pygeoinf.hilbert_space import (
44
+ EuclideanSpace,
44
45
  HilbertModule,
45
46
  MassWeightedHilbertModule,
46
47
  )
@@ -50,12 +51,14 @@ from .symmetric_space import (
50
51
  AbstractInvariantLebesgueSpace,
51
52
  AbstractInvariantSobolevSpace,
52
53
  )
54
+ from .sh_tools import SHVectorConverter
53
55
 
54
56
 
55
57
  if TYPE_CHECKING:
56
58
  from matplotlib.figure import Figure
57
59
  from cartopy.mpl.geoaxes import GeoAxes
58
60
  from cartopy.crs import Projection
61
+ from pyshtools import SHGrid
59
62
 
60
63
 
61
64
  class SphereHelper:
@@ -528,6 +531,93 @@ class Lebesgue(SphereHelper, HilbertModule, AbstractInvariantLebesgueSpace):
528
531
  f"extend={self.extend}"
529
532
  )
530
533
 
534
+ def to_coefficient_operator(self, lmax: int, lmin: int = 0):
535
+ """
536
+ Returns a LinearOperator that maps an element of the space to
537
+ a vector of its spherical harmonic coefficients within the
538
+ specified range of degrees.
539
+
540
+ The output coefficients are ordered in the following manner:
541
+
542
+ u_{00}, u_{1-1}, u_{10}, u_{11}, u_{2-2}, u_{2-1}, u_{20}, u_{21}, u_{22}, ...
543
+
544
+ in this case assuming lmin = 0.
545
+
546
+ If lmax is larger than the field's lmax, the output will be padded by zeros.
547
+
548
+ Args:
549
+ lmax: The maximum spherical harmonic degree to include in the output.
550
+ lmin: The minimum spherical harmonic degree to include in the output.
551
+ Defaults to 0.
552
+
553
+ Returns:
554
+ A LinearOperator that maps an SHGrid to a NumPy vector of coefficients.
555
+
556
+ Notes:
557
+ This is a left inverse of the from_coefficient_operator so long a the
558
+ values for lmin and lmax are equal.
559
+ """
560
+
561
+ converter = SHVectorConverter(lmax, lmin)
562
+ codomain = EuclideanSpace(converter.vector_size)
563
+
564
+ def mapping(u: SHGrid) -> np.ndarray:
565
+ ulm = self.to_coefficients(u)
566
+ return converter.to_vector(ulm.coeffs)
567
+
568
+ def adjoint_mapping(data: np.ndarray) -> SHGrid:
569
+ coeffs = converter.from_vector(data, output_lmax=self.lmax)
570
+ ulm = sh.SHCoeffs.from_array(
571
+ coeffs,
572
+ normalization=self.normalization,
573
+ csphase=self.csphase,
574
+ )
575
+ return self.from_coefficients(ulm) / self.radius**2
576
+
577
+ return LinearOperator(self, codomain, mapping, adjoint_mapping=adjoint_mapping)
578
+
579
+ def from_coefficient_operator(self, lmax: int, lmin: int = 0):
580
+ """
581
+ Returns a LinearOperator that maps a vector of spherical harmonic coefficients
582
+ to an element of the space.
583
+
584
+ The input coefficients are ordered in the following manner:
585
+
586
+ u_{00}, u_{1-1}, u_{10}, u_{11}, u_{2-2}, u_{2-1}, u_{20}, u_{21}, u_{22}, ...
587
+
588
+ in this case assuming lmin = 0.
589
+
590
+ Args:
591
+ lmax: The maximum spherical harmonic degree to include in the output.
592
+ lmin: The minimum spherical harmonic degree to include in the output.
593
+ Defaults to 0.
594
+
595
+ Returns:
596
+ A LinearOperator that maps a NumPy vector of coefficients to an SHGrid.
597
+
598
+ Notes:
599
+ This is a right inverse of the to_coefficient_operator so long a the
600
+ values for lmin and lmax are equal.
601
+ """
602
+
603
+ converter = SHVectorConverter(lmax, lmin)
604
+ domain = EuclideanSpace(converter.vector_size)
605
+
606
+ def mapping(data: np.ndarray) -> SHGrid:
607
+ coeffs = converter.from_vector(data, output_lmax=self.lmax)
608
+ ulm = sh.SHCoeffs.from_array(
609
+ coeffs,
610
+ normalization=self.normalization,
611
+ csphase=self.csphase,
612
+ )
613
+ return self.from_coefficients(ulm)
614
+
615
+ def adjoint_mapping(u: SHGrid) -> np.ndarray:
616
+ ulm = self.to_coefficients(u)
617
+ return converter.to_vector(ulm.coeffs) * self.radius**2
618
+
619
+ return LinearOperator(domain, self, mapping, adjoint_mapping=adjoint_mapping)
620
+
531
621
 
532
622
  class Sobolev(SphereHelper, MassWeightedHilbertModule, AbstractInvariantSobolevSpace):
533
623
  """
@@ -691,3 +781,64 @@ class Sobolev(SphereHelper, MassWeightedHilbertModule, AbstractInvariantSobolevS
691
781
  f"grid={self.grid}\n"
692
782
  f"extend={self.extend}"
693
783
  )
784
+
785
+ def to_coefficient_operator(self, lmax: int, lmin: int = 0):
786
+ """
787
+ Returns a LinearOperator that maps an element of the space to
788
+ a vector of its spherical harmonic coefficients within the
789
+ specified range of degrees.
790
+
791
+ The output coefficients are ordered in the following manner:
792
+
793
+ u_{00}, u_{1-1}, u_{10}, u_{11}, u_{2-2}, u_{2-1}, u_{20}, u_{21}, u_{22}, ...
794
+
795
+ in this case assuming lmin = 0.
796
+
797
+ If lmax is larger than the field's lmax, the output will be padded by zeros.
798
+
799
+ Args:
800
+ lmax: The maximum spherical harmonic degree to include in the output.
801
+ lmin: The minimum spherical harmonic degree to include in the output.
802
+ Defaults to 0.
803
+
804
+ Returns:
805
+ A LinearOperator that maps an SHGrid to a NumPy vector of coefficients.
806
+
807
+ Notes:
808
+ This is a left inverse of the from_coefficient_operator so long a the
809
+ values for lmin and lmax are equal.
810
+ """
811
+
812
+ l2_operator = self.underlying_space.to_coefficient_operator(lmax, lmin)
813
+
814
+ return LinearOperator.from_formal_adjoint(
815
+ self, l2_operator.codomain, l2_operator
816
+ )
817
+
818
+ def from_coefficient_operator(self, lmax: int, lmin: int = 0):
819
+ """
820
+ Returns a LinearOperator that maps a vector of spherical harmonic coefficients
821
+ to an element of the space.
822
+
823
+ The input coefficients are ordered in the following manner:
824
+
825
+ u_{00}, u_{1-1}, u_{10}, u_{11}, u_{2-2}, u_{2-1}, u_{20}, u_{21}, u_{22}, ...
826
+
827
+ in this case assuming lmin = 0.
828
+
829
+ Args:
830
+ lmax: The maximum spherical harmonic degree to include in the output.
831
+ lmin: The minimum spherical harmonic degree to include in the output.
832
+ Defaults to 0.
833
+
834
+ Returns:
835
+ A LinearOperator that maps a NumPy vector of coefficients to an SHGrid.
836
+
837
+ Notes:
838
+ This is a right inverse of the to_coefficient_operator so long a the
839
+ values for lmin and lmax are equal.
840
+ """
841
+
842
+ l2_operator = self.underlying_space.from_coefficient_operator(lmax, lmin)
843
+
844
+ return LinearOperator.from_formal_adjoint(l2_operator.domain, self, l2_operator)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygeoinf
3
- Version: 1.3.3
3
+ Version: 1.3.5
4
4
  Summary: A package for solving geophysical inference and inverse problems
5
5
  License: BSD-3-Clause
6
6
  License-File: LICENSE
@@ -1,30 +1,33 @@
1
- pygeoinf/__init__.py,sha256=vAoI6Kw2EL5koHn0EP0kbLvhtWV9gxA439PowiqkQHU,3246
1
+ pygeoinf/__init__.py,sha256=IrG0WA80NuoXRJvoKNG7lKcht5ICBEQacjtuqBKQ2fU,3622
2
2
  pygeoinf/auxiliary.py,sha256=lfoTt9ZH4y8SAV8dKZi5EWx1oF_JtxtBMSmlFYqJYfE,1610
3
3
  pygeoinf/backus_gilbert.py,sha256=eFi4blSwOCsg_NuH6WD4gcgjvzvu5g5WpWahGobSBdM,3694
4
- pygeoinf/checks/hilbert_space.py,sha256=07AZ6fx44PgSPjo_bjRJlVWTta1k1hhIX0TTTwMRdm8,8665
5
- pygeoinf/checks/linear_operators.py,sha256=LjC7X3RRimsyoLu062RNdhj1KEau3CBhBTZ4m3ZRmjI,7042
6
- pygeoinf/checks/nonlinear_operators.py,sha256=CoINs_Pm0lzo8nR3H70bo8Osvauiy03CA-b99MnCPjw,7532
4
+ pygeoinf/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pygeoinf/checks/hilbert_space.py,sha256=-4x2G4Byj2lsK5UNM34jWXumjZ8AqeNFSTJu-WEmwVI,8667
6
+ pygeoinf/checks/linear_operators.py,sha256=945ECCM7nEPuE00_5Tb8o2pG5IYbNtDSqwKNhXqnrew,7044
7
+ pygeoinf/checks/nonlinear_operators.py,sha256=pFHQrbQslrbBM9J_p1-4TQoETsupVICKtTtKFSWBfsk,7533
7
8
  pygeoinf/direct_sum.py,sha256=7V0qrwFGj0GN-p_zzffefPrIB0dPu5dshLTxem1mQGE,19274
8
9
  pygeoinf/forward_problem.py,sha256=NnqWp7iMfkhHa9d-jBHzYHClaAfhKmO5D058AcJLLYg,10724
9
10
  pygeoinf/gaussian_measure.py,sha256=bBh64xHgmLFl27krn9hkf8qDQjop_39x69cyhJgUHN8,26219
10
- pygeoinf/hilbert_space.py,sha256=rKF8upjHw7uw3qBKS-bsEo1J9-So0urTcmVsmJJQeog,25875
11
+ pygeoinf/hilbert_space.py,sha256=Yc0Jw0A8Jo12Zpgb_9dhcF7CD77S1IDMrSTDFHpTRB8,27340
11
12
  pygeoinf/inversion.py,sha256=RV0hG2bGnciWdja0oOPKPxnFhYzufqdj-mKYNr4JJ_o,6447
12
- pygeoinf/linear_bayesian.py,sha256=L1cJkeHtba4fPXZ8CmiLRBtuG2fmzG228M_iEar-iP8,9643
13
+ pygeoinf/linear_bayesian.py,sha256=o6m0fYESba8rE-rjxfCqXaV6irPthB1aWf8vhM2v8XQ,11324
13
14
  pygeoinf/linear_forms.py,sha256=mgZeDRegNKo8kviE68KrxkHR4gG9bf1RgsJz1MtDMCk,9181
14
15
  pygeoinf/linear_operators.py,sha256=Bn-uzwUXi2kkWZ7wc9Uhj3vBHtocN17hnzc_r7DAzTk,64530
15
- pygeoinf/linear_optimisation.py,sha256=UbSr6AOPpR2sRYoN1Pvv24-Zu7_XlJk1zE1IhQu83hg,12428
16
+ pygeoinf/linear_optimisation.py,sha256=vF1T3HE9rPOnXy3PU82-46dlvGwdAvsqUNXOx0o-KD8,20431
16
17
  pygeoinf/linear_solvers.py,sha256=v-7yjKsa67Ts5EcyJzCdpj-aF0qBrA-akq0kLe59DS4,16843
17
18
  pygeoinf/nonlinear_forms.py,sha256=t7lk-Bha7Xdk9eiwXMmS0F47oTR6jW6qQ3HkgRGk54A,7012
18
19
  pygeoinf/nonlinear_operators.py,sha256=AtkDTQfGDzAnfFDIgiKfdk7uPEI-j_ZA3CNvY5A3U8w,7144
19
20
  pygeoinf/nonlinear_optimisation.py,sha256=skK1ikn9GrVYherD64Qt9WrEYHA2NAJ48msOu_J8Oig,7431
20
21
  pygeoinf/parallel.py,sha256=VVFvNHszy4wSa9LuErIsch4NAkLaZezhdN9YpRROBJo,2267
21
- pygeoinf/plot.py,sha256=zXY0o5MvgJUiwy3uEwTOwVdKT_5XRBKx_-9qmyalB3A,13654
22
+ pygeoinf/plot.py,sha256=Uw9PCdxymUiAkFF0BS0kUAZBRWL6sh89FJnSIxtp_2s,13664
22
23
  pygeoinf/random_matrix.py,sha256=71l6eAXQ2pRMleaz1lXud6O1F78ugKyp3vHcRBXhdwM,17661
24
+ pygeoinf/subspaces.py,sha256=5Bo1F9if5oEmKJ0YPWMFaajJKec5aGIrYZKvetwWa3c,10454
23
25
  pygeoinf/symmetric_space/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
26
  pygeoinf/symmetric_space/circle.py,sha256=GuwVmLdHGTMxMrZfyXIPP3pz_y971ntlD5pl42lKJZ0,18796
25
- pygeoinf/symmetric_space/sphere.py,sha256=SYeGa70fKzasXxwPoVk3tNBtlP0QwLQe5jwW7o3AmcU,23376
27
+ pygeoinf/symmetric_space/sh_tools.py,sha256=_A_coPElu8DNYwA5udL92X87wiTyBClTbFtf6ch9nXM,3520
28
+ pygeoinf/symmetric_space/sphere.py,sha256=wZlAVG3kKMuPmRURL4r2ZP3sQ8kWOAWRk1G_Lo_TZmo,28983
26
29
  pygeoinf/symmetric_space/symmetric_space.py,sha256=pEIZZYWsdegrYCwUs3bo86JTz3d2LsXFWdRYFa0syFs,17963
27
- pygeoinf-1.3.3.dist-info/METADATA,sha256=qXr6ZBARRYzRbjidXKyJ7bOmrf6tPNWZD4qdHjt6I14,16482
28
- pygeoinf-1.3.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
29
- pygeoinf-1.3.3.dist-info/licenses/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
30
- pygeoinf-1.3.3.dist-info/RECORD,,
30
+ pygeoinf-1.3.5.dist-info/METADATA,sha256=m0YVVuJ1McMBzUG1QYdurV1hB91UGmIiSn-STSq9a0s,16482
31
+ pygeoinf-1.3.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
32
+ pygeoinf-1.3.5.dist-info/licenses/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
33
+ pygeoinf-1.3.5.dist-info/RECORD,,