foscat 3.6.1__py3-none-any.whl → 3.7.1__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.
foscat/scat_cov2D.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import foscat.scat_cov as scat
2
-
2
+ import numpy as np
3
3
 
4
4
  class scat_cov2D:
5
5
  def __init__(self, s0, s2, s3, s4, s1=None, s3p=None, backend=None):
@@ -11,8 +11,108 @@ class scat_cov2D:
11
11
  def fill(self, im, nullval=0):
12
12
  return self.fill_2d(im, nullval=nullval)
13
13
 
14
-
15
14
  class funct(scat.funct):
16
15
  def __init__(self, *args, **kwargs):
17
16
  # Impose que use_2D=True pour la classe scat
18
17
  super().__init__(use_2D=True, *args, **kwargs)
18
+
19
+ def spectrum(self,image):
20
+ """
21
+ Compute the 1D power spectrum of a 2D image by averaging the 2D power spectrum
22
+ over concentric frequency rings (radial averaging), using np.bincount for efficiency.
23
+
24
+ Parameters:
25
+ - image : ndarray (2D), input image
26
+
27
+ Returns:
28
+ - freq : radial frequencies
29
+ - spectrum_1d : corresponding 1D power spectrum
30
+ """
31
+ import numpy as np
32
+
33
+ # Compute the 2D Fourier Transform and shift the zero frequency to the center
34
+ F = np.fft.fftshift(np.fft.fft2(image))
35
+ power_spectrum = np.abs(F) ** 2
36
+
37
+ # Create coordinate grids and compute the radial distance from the center
38
+ y, x = np.indices(power_spectrum.shape)
39
+ center = np.array(power_spectrum.shape) // 2
40
+ r = np.sqrt((x - center[1])**2 + (y - center[0])**2).astype(int)
41
+
42
+ # Use np.bincount for fast summation and counting
43
+ sum_power = np.bincount(r.ravel(), weights=power_spectrum.ravel())
44
+ counts = np.bincount(r.ravel())
45
+
46
+ # Compute the mean power for each radial bin
47
+ spectrum_1d = sum_power / counts
48
+
49
+ return spectrum_1d
50
+
51
+ def plot_results(self,in_image,out_image,vmin=None,vmax=None,cmap='coolwarm',spec_range=None):
52
+ import matplotlib.pyplot as plt
53
+
54
+ if len(out_image.shape)>2:
55
+ nimage=out_image.shape[0]
56
+ ndraw=np.min([3,nimage])
57
+ plt.figure(figsize=(16,12))
58
+ plt.subplot(2,ndraw+1,1)
59
+ plt.title('Original field')
60
+ plt.imshow(in_image,cmap=cmap,vmin=vmin,vmax=vmax,origin='lower')
61
+ plt.xticks([])
62
+ plt.yticks([])
63
+ for k in range(ndraw):
64
+ plt.subplot(2,ndraw+1,2+k)
65
+ plt.title('Modeled field #%d'%(k))
66
+ plt.imshow(out_image[k],cmap=cmap,vmin=vmin,vmax=vmax,origin='lower')
67
+ plt.xticks([])
68
+ plt.yticks([])
69
+ plt.subplot(2,2,3)
70
+ plt.title('Histogram')
71
+ for k in range(nimage):
72
+ if k==0:
73
+ plt.hist(out_image[k].flatten(),bins=100,label='modeled',color='b',histtype='step',log=True,alpha=0.5)
74
+ else:
75
+ plt.hist(out_image[k].flatten(),bins=100,color='b',histtype='step',log=True,alpha=0.5)
76
+ plt.hist(in_image.flatten(),bins=100,label='original',color='r',histtype='step',log=True)
77
+ plt.legend(frameon=0)
78
+ plt.subplot(2,2,4)
79
+ plt.title('Powerspectra')
80
+ for k in range(nimage):
81
+ if k==0:
82
+ plt.plot(self.spectrum(out_image[k]),color='b',label='modeled',alpha=0.5)
83
+ else:
84
+ plt.plot(self.spectrum(out_image[k]),color='b',alpha=0.5)
85
+ plt.plot(self.spectrum(in_image),color='r',label='original')
86
+ plt.xscale('log')
87
+ plt.yscale('log')
88
+ plt.legend(frameon=0)
89
+ if spec_range is not None:
90
+ plt.ylim(spec_range[0],spec_range[1])
91
+ else:
92
+ plt.figure(figsize=(16,3))
93
+ plt.subplot(1,4,1)
94
+ plt.title('Original field')
95
+ plt.imshow(in_image,cmap=cmap,vmin=vmin,vmax=vmax,origin='lower')
96
+ plt.xticks([])
97
+ plt.yticks([])
98
+ plt.subplot(1,4,2)
99
+ plt.title('Modeled field')
100
+ plt.imshow(out_image,cmap=cmap,vmin=vmin,vmax=vmax,origin='lower')
101
+ plt.xticks([])
102
+ plt.yticks([])
103
+ plt.subplot(1,4,3)
104
+ plt.title('Histogram')
105
+ plt.hist(in_image.flatten(),bins=100,label='original',color='r',histtype='step',log=True)
106
+ plt.hist(out_image.flatten(),bins=100,label='modeled',color='b',histtype='step',log=True)
107
+ plt.legend(frameon=0)
108
+ plt.subplot(1,4,4)
109
+ plt.title('Powerspectra')
110
+ plt.plot(self.spectrum(in_image),color='b',label='original')
111
+ plt.plot(self.spectrum(out_image),color='r',label='modeled')
112
+ plt.xscale('log')
113
+ plt.yscale('log')
114
+ if spec_range is not None:
115
+ plt.ylim(spec_range[0],spec_range[1])
116
+ plt.legend(frameon=0)
117
+
118
+
foscat/scat_cov_map.py CHANGED
@@ -24,10 +24,23 @@ class funct(scat.funct):
24
24
  super().__init__(return_data=True, *args, **kwargs)
25
25
 
26
26
  def eval(
27
- self, image1, image2=None, mask=None, norm=None, Auto=True, calc_var=False,out_nside=None
27
+ self,
28
+ image1,
29
+ image2=None,
30
+ mask=None,
31
+ norm=None,
32
+ Auto=True,
33
+ calc_var=False,
34
+ out_nside=None,
28
35
  ):
29
36
  r = super().eval(
30
- image1, image2=image2, mask=mask, norm=norm, Auto=Auto, calc_var=calc_var,out_nside=out_nside
37
+ image1,
38
+ image2=image2,
39
+ mask=mask,
40
+ norm=norm,
41
+ Auto=Auto,
42
+ calc_var=calc_var,
43
+ out_nside=out_nside,
31
44
  )
32
45
  return scat_cov_map(
33
46
  r.S2, r.S0, r.S3, r.S4, S1=r.S1, S3P=r.S3P, backend=r.backend
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: foscat
3
- Version: 3.6.1
3
+ Version: 3.7.1
4
4
  Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
5
5
  Author-email: Jean-Marc DELOUIS <jean.marc.delouis@ifremer.fr>
6
6
  Maintainer-email: Theo Foulquier <theo.foulquier@ifremer.fr>
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Requires-Python: >=3.9
20
20
  Description-Content-Type: text/markdown
21
- License-File: LICENCE
21
+ License-File: LICENSE
22
22
  Requires-Dist: imageio
23
23
  Requires-Dist: imagecodecs
24
24
  Requires-Dist: matplotlib
@@ -0,0 +1,26 @@
1
+ foscat/CNN.py,sha256=j0F2a4Xf3LijhyD_WVZ6Eg_IjGuXw3ddH6Iudj1xVaw,4874
2
+ foscat/CircSpline.py,sha256=CXi49FxF8ZoeZ17Ua8c1AZXe2B5ICEC9aCXb97atB3s,4028
3
+ foscat/FoCUS.py,sha256=bYQctBoTiKyJd9xtIuPgcroek4XxIEnUmdirkSxdcmQ,102659
4
+ foscat/GCNN.py,sha256=5RV-FKuvqbD-k99TwiM4CttM2LMZE21WD0IK0j5Mkko,7599
5
+ foscat/Softmax.py,sha256=aBLQauoG0q2SJYPotV6U-cxAhsJcspWHNRWdnA_nAiQ,2854
6
+ foscat/Spline1D.py,sha256=rKzzenduaZZ-yBDJd35it6Gyrj1spqb7hoIaUgISPzY,2983
7
+ foscat/Synthesis.py,sha256=3oL-WIwOzjO6jYn-7J3TfAQSiPaQTqGtrmxcGBh1Gvs,13787
8
+ foscat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ foscat/alm.py,sha256=PaAaq82CH3JzH520eQpqTCivxE4VeJmmc6I_9HXIhcA,32480
10
+ foscat/backend.py,sha256=b7c6nL4vaolypzcmhzsZm7vzsJhjrkd--l5DjtESXEA,44851
11
+ foscat/backend_tens.py,sha256=9Dp136m9frkclkwifJQLLbIpl3ETI3_txdPUZcKfuMw,1618
12
+ foscat/loss_backend_tens.py,sha256=dCOVN6faDtIpN3VO78HTmYP2i5fnFAf-Ddy5qVBlGrM,1783
13
+ foscat/loss_backend_torch.py,sha256=k3z18Dj3SaLKK6ZIKcm7GO4U_YKYVP6LtHG1aIbxkYk,1627
14
+ foscat/scat.py,sha256=qGYiBIysPt65MdmF07WWA4piVlTfA9-lFDTaicnqC2w,72822
15
+ foscat/scat1D.py,sha256=W5Uu6wdQ4ZsFKXpof0f1OBl-1wjJmW7ruvddRWxe7uM,53726
16
+ foscat/scat2D.py,sha256=boKj0ASqMMSy7uQLK6hPniG87m3hZGJBYBiq5v8F9IQ,532
17
+ foscat/scat_cov.py,sha256=mHGOFa6ZnmGksOSa_zQQ-92FlRs2D1Z1zmkA-22X0Tg,232476
18
+ foscat/scat_cov1D.py,sha256=XOxsZZ5TYq8f34i2tUgIfzyaqaTDlICB3HzD2l_puro,531
19
+ foscat/scat_cov2D.py,sha256=HVYBNtpZgRlz6OOm0LwG_w8Q4Kld4Qc1n6XYeGoxIug,4802
20
+ foscat/scat_cov_map.py,sha256=Swt39-nYEaQkBzyX4EOAQBvUuYQpERzJ-uVxSWS2b-Y,2911
21
+ foscat/scat_cov_map2D.py,sha256=FqF45FBcoiQbvuVsrLWUIPRUc95GsKsrnH6fKzB3GlE,2841
22
+ foscat-3.7.1.dist-info/LICENSE,sha256=i0ukIr8ZUpkSY2sZaE9XZK-6vuSU5iG6IgX_3pjatP8,1505
23
+ foscat-3.7.1.dist-info/METADATA,sha256=Jgds24vLXVaJ2W3FaBHysyu19qY2hrywOpn4ggy46rA,7216
24
+ foscat-3.7.1.dist-info/WHEEL,sha256=EaM1zKIUYa7rQnxGiOCGhzJABRwy4WO57rWMR3_tj4I,91
25
+ foscat-3.7.1.dist-info/top_level.txt,sha256=AGySXBBAlJgb8Tj8af6m_F-aiNg2zNTcybCUPVOKjAg,7
26
+ foscat-3.7.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (75.9.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
foscat/alm_tools.py DELETED
@@ -1,11 +0,0 @@
1
- import numpy as np
2
-
3
- #====================================================================================================================
4
- # This class is an automatic traduction of the fortran healpix software
5
- #====================================================================================================================
6
-
7
-
8
- class alm_tools():
9
- def __init__(self):
10
- pass
11
-
@@ -1,27 +0,0 @@
1
- foscat/CNN.py,sha256=j0F2a4Xf3LijhyD_WVZ6Eg_IjGuXw3ddH6Iudj1xVaw,4874
2
- foscat/CircSpline.py,sha256=DjP1gy88cnXu2O21ww_lNnsHAHXc3OAWk_8ey84yicg,4053
3
- foscat/FoCUS.py,sha256=YoZqPiDLQanUXGgN4RyN6S4_F2rHn273P6QQjq0hlBU,101774
4
- foscat/GCNN.py,sha256=5RV-FKuvqbD-k99TwiM4CttM2LMZE21WD0IK0j5Mkko,7599
5
- foscat/Softmax.py,sha256=aBLQauoG0q2SJYPotV6U-cxAhsJcspWHNRWdnA_nAiQ,2854
6
- foscat/Spline1D.py,sha256=a5Jb8I9tb8y20iM8W-z6iZsIqDFByRp6eZdChpmuI5k,3010
7
- foscat/Synthesis.py,sha256=3_Lq5-gUM-WmO2h15kajMES8XjRo2BGseoxvTLW_xEc,13626
8
- foscat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- foscat/alm.py,sha256=IIvYOz0kAtufhlBzS_QOx891-Y30ARmofyqomOFmJDY,29335
10
- foscat/alm_tools.py,sha256=BMObyIMF3_v04JdvMWBMMaF2F8s2emvDKmirKDnHWDA,387
11
- foscat/backend.py,sha256=bN-b0CWcJXVsLCyqMhJACom0JlSStgrMWyD0uB6HqoU,40218
12
- foscat/backend_tens.py,sha256=9Dp136m9frkclkwifJQLLbIpl3ETI3_txdPUZcKfuMw,1618
13
- foscat/loss_backend_tens.py,sha256=dCOVN6faDtIpN3VO78HTmYP2i5fnFAf-Ddy5qVBlGrM,1783
14
- foscat/loss_backend_torch.py,sha256=k3z18Dj3SaLKK6ZIKcm7GO4U_YKYVP6LtHG1aIbxkYk,1627
15
- foscat/scat.py,sha256=qGYiBIysPt65MdmF07WWA4piVlTfA9-lFDTaicnqC2w,72822
16
- foscat/scat1D.py,sha256=W5Uu6wdQ4ZsFKXpof0f1OBl-1wjJmW7ruvddRWxe7uM,53726
17
- foscat/scat2D.py,sha256=boKj0ASqMMSy7uQLK6hPniG87m3hZGJBYBiq5v8F9IQ,532
18
- foscat/scat_cov.py,sha256=gQvGC2s93oDurBDW0A6mGyzzMETjYAuBsBsDOI-ZqUY,150642
19
- foscat/scat_cov1D.py,sha256=XOxsZZ5TYq8f34i2tUgIfzyaqaTDlICB3HzD2l_puro,531
20
- foscat/scat_cov2D.py,sha256=3gn6xjKvfKsyHJoPfYIu8q9LLVAbU3tsiS2l1LAJ0XM,531
21
- foscat/scat_cov_map.py,sha256=9Yymbr1MxUNY5nJd9kIEEHt1x2IoOjc0EW4kkJVtmQ4,2783
22
- foscat/scat_cov_map2D.py,sha256=FqF45FBcoiQbvuVsrLWUIPRUc95GsKsrnH6fKzB3GlE,2841
23
- foscat-3.6.1.dist-info/LICENCE,sha256=i0ukIr8ZUpkSY2sZaE9XZK-6vuSU5iG6IgX_3pjatP8,1505
24
- foscat-3.6.1.dist-info/METADATA,sha256=6t347EDYxBbM5qhlC5T6pwbJDBwvAnJ5VJnNppblC6A,7216
25
- foscat-3.6.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
26
- foscat-3.6.1.dist-info/top_level.txt,sha256=AGySXBBAlJgb8Tj8af6m_F-aiNg2zNTcybCUPVOKjAg,7
27
- foscat-3.6.1.dist-info/RECORD,,