foscat 2025.7.3__py3-none-any.whl → 2025.8.4__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/CNN.py +1 -0
- foscat/FoCUS.py +379 -139
- foscat/HOrientedConvol.py +546 -0
- foscat/HealSpline.py +8 -5
- foscat/Synthesis.py +27 -18
- foscat/UNET.py +200 -0
- foscat/scat_cov.py +92 -55
- foscat/scat_cov_map2D.py +1 -1
- {foscat-2025.7.3.dist-info → foscat-2025.8.4.dist-info}/METADATA +1 -1
- {foscat-2025.7.3.dist-info → foscat-2025.8.4.dist-info}/RECORD +13 -11
- {foscat-2025.7.3.dist-info → foscat-2025.8.4.dist-info}/WHEEL +0 -0
- {foscat-2025.7.3.dist-info → foscat-2025.8.4.dist-info}/licenses/LICENSE +0 -0
- {foscat-2025.7.3.dist-info → foscat-2025.8.4.dist-info}/top_level.txt +0 -0
foscat/UNET.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
import foscat.scat_cov as sc
|
|
4
|
+
import foscat.HOrientedConvol as hs
|
|
5
|
+
|
|
6
|
+
class UNET:
|
|
7
|
+
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
nparam=1,
|
|
11
|
+
KERNELSZ=3,
|
|
12
|
+
NORIENT=4,
|
|
13
|
+
chanlist=None,
|
|
14
|
+
in_nside=1,
|
|
15
|
+
n_chan_in=1,
|
|
16
|
+
n_chan_out=1,
|
|
17
|
+
cell_ids=None,
|
|
18
|
+
SEED=1234,
|
|
19
|
+
filename=None,
|
|
20
|
+
):
|
|
21
|
+
self.f=sc.funct(KERNELSZ=KERNELSZ)
|
|
22
|
+
|
|
23
|
+
if chanlist is None:
|
|
24
|
+
nlayer=int(np.log2(in_nside))
|
|
25
|
+
chanlist=[4*2**k for k in range(nlayer)]
|
|
26
|
+
else:
|
|
27
|
+
nlayer=len(chanlist)
|
|
28
|
+
print('N_layer ',nlayer)
|
|
29
|
+
|
|
30
|
+
n=0
|
|
31
|
+
wconv={}
|
|
32
|
+
hconv={}
|
|
33
|
+
l_cell_ids={}
|
|
34
|
+
self.KERNELSZ=KERNELSZ
|
|
35
|
+
kernelsz=self.KERNELSZ
|
|
36
|
+
|
|
37
|
+
# create the CNN part
|
|
38
|
+
l_nside=in_nside
|
|
39
|
+
l_cell_ids[0]=cell_ids.copy()
|
|
40
|
+
l_data=self.f.backend.bk_cast(np.ones([1,1,l_cell_ids[0].shape[0]]))
|
|
41
|
+
l_chan=n_chan_in
|
|
42
|
+
print('Initial chan %d Npix=%d'%(l_chan,l_data.shape[2]))
|
|
43
|
+
for l in range(nlayer):
|
|
44
|
+
print('Layer %d Npix=%d'%(l,l_data.shape[2]))
|
|
45
|
+
# init double convol weights
|
|
46
|
+
wconv[2*l]=n
|
|
47
|
+
nw=l_chan*chanlist[l]*kernelsz*kernelsz
|
|
48
|
+
print('Layer %d conv [%d,%d]'%(l,l_chan,chanlist[l]))
|
|
49
|
+
n+=nw
|
|
50
|
+
wconv[2*l+1]=n
|
|
51
|
+
nw=chanlist[l]*chanlist[l]*kernelsz*kernelsz
|
|
52
|
+
print('Layer %d conv [%d,%d]'%(l,chanlist[l],chanlist[l]))
|
|
53
|
+
n+=nw
|
|
54
|
+
|
|
55
|
+
hconvol=hs.HOrientedConvol(l_nside,3,cell_ids=l_cell_ids[l])
|
|
56
|
+
hconvol.make_idx_weights()
|
|
57
|
+
hconv[l]=hconvol
|
|
58
|
+
l_data,n_cell_ids=self.f.ud_grade_2(l_data,cell_ids=l_cell_ids[l],nside=l_nside)
|
|
59
|
+
l_cell_ids[l+1]=self.f.backend.to_numpy(n_cell_ids)
|
|
60
|
+
l_nside//=2
|
|
61
|
+
# plus one to add the input downgrade data
|
|
62
|
+
l_chan=chanlist[l]+n_chan_in
|
|
63
|
+
|
|
64
|
+
self.n_cnn=n
|
|
65
|
+
self.l_cell_ids=l_cell_ids
|
|
66
|
+
self.wconv=wconv
|
|
67
|
+
self.hconv=hconv
|
|
68
|
+
|
|
69
|
+
# create the transpose CNN part
|
|
70
|
+
m_cell_ids={}
|
|
71
|
+
m_cell_ids[0]=l_cell_ids[nlayer]
|
|
72
|
+
t_wconv={}
|
|
73
|
+
t_hconv={}
|
|
74
|
+
|
|
75
|
+
for l in range(nlayer):
|
|
76
|
+
#upgrade data
|
|
77
|
+
l_chan+=n_chan_in
|
|
78
|
+
l_data=self.f.up_grade(l_data,l_nside*2,
|
|
79
|
+
cell_ids=l_cell_ids[nlayer-l],
|
|
80
|
+
o_cell_ids=l_cell_ids[nlayer-1-l],
|
|
81
|
+
nside=l_nside)
|
|
82
|
+
print('Transpose Layer %d Npix=%d'%(l,l_data.shape[2]))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
m_cell_ids[l]=l_cell_ids[nlayer-1-l]
|
|
86
|
+
l_nside*=2
|
|
87
|
+
|
|
88
|
+
# init double convol weights
|
|
89
|
+
t_wconv[2*l]=n
|
|
90
|
+
nw=l_chan*l_chan*kernelsz*kernelsz
|
|
91
|
+
print('Transpose Layer %d conv [%d,%d]'%(l,l_chan,l_chan))
|
|
92
|
+
n+=nw
|
|
93
|
+
t_wconv[2*l+1]=n
|
|
94
|
+
out_chan=n_chan_out
|
|
95
|
+
if nlayer-1-l>0:
|
|
96
|
+
out_chan+=chanlist[nlayer-1-l]
|
|
97
|
+
print('Transpose Layer %d conv [%d,%d]'%(l,l_chan,out_chan))
|
|
98
|
+
nw=l_chan*out_chan*kernelsz*kernelsz
|
|
99
|
+
n+=nw
|
|
100
|
+
|
|
101
|
+
hconvol=hs.HOrientedConvol(l_nside,3,cell_ids=m_cell_ids[l])
|
|
102
|
+
hconvol.make_idx_weights()
|
|
103
|
+
t_hconv[l]=hconvol
|
|
104
|
+
|
|
105
|
+
# plus one to add the input downgrade data
|
|
106
|
+
l_chan=out_chan
|
|
107
|
+
print('Final chan %d Npix=%d'%(out_chan,l_data.shape[2]))
|
|
108
|
+
self.n_cnn=n
|
|
109
|
+
self.m_cell_ids=l_cell_ids
|
|
110
|
+
self.t_wconv=t_wconv
|
|
111
|
+
self.t_hconv=t_hconv
|
|
112
|
+
self.x=self.f.backend.bk_cast((np.random.rand(n)-0.5)/self.KERNELSZ)
|
|
113
|
+
self.nside=in_nside
|
|
114
|
+
self.n_chan_in=n_chan_in
|
|
115
|
+
self.n_chan_out=n_chan_out
|
|
116
|
+
self.chanlist=chanlist
|
|
117
|
+
|
|
118
|
+
def get_param(self):
|
|
119
|
+
return self.x
|
|
120
|
+
|
|
121
|
+
def set_param(self,x):
|
|
122
|
+
self.x=self.f.backend.bk_cast(x)
|
|
123
|
+
|
|
124
|
+
def eval(self,data):
|
|
125
|
+
# create the CNN part
|
|
126
|
+
l_nside=self.nside
|
|
127
|
+
l_chan=self.n_chan_in
|
|
128
|
+
l_data=data
|
|
129
|
+
m_data=data
|
|
130
|
+
nlayer=len(self.chanlist)
|
|
131
|
+
kernelsz=self.KERNELSZ
|
|
132
|
+
ud_data={}
|
|
133
|
+
|
|
134
|
+
for l in range(nlayer):
|
|
135
|
+
# init double convol weights
|
|
136
|
+
nw=l_chan*self.chanlist[l]*kernelsz*kernelsz
|
|
137
|
+
ww=self.x[self.wconv[2*l]:self.wconv[2*l]+nw]
|
|
138
|
+
ww=self.f.backend.bk_reshape(ww,[l_chan,
|
|
139
|
+
self.chanlist[l],
|
|
140
|
+
kernelsz*kernelsz])
|
|
141
|
+
l_data = self.hconv[l].Convol_torch(l_data,ww)
|
|
142
|
+
|
|
143
|
+
nw=self.chanlist[l]*self.chanlist[l]*kernelsz*kernelsz
|
|
144
|
+
ww=self.x[self.wconv[2*l+1]:self.wconv[2*l+1]+nw]
|
|
145
|
+
ww=self.f.backend.bk_reshape(ww,[self.chanlist[l],
|
|
146
|
+
self.chanlist[l],
|
|
147
|
+
kernelsz*kernelsz])
|
|
148
|
+
|
|
149
|
+
l_data = self.hconv[l].Convol_torch(l_data,ww)
|
|
150
|
+
|
|
151
|
+
l_data,_=self.f.ud_grade_2(l_data,
|
|
152
|
+
cell_ids=self.l_cell_ids[l],
|
|
153
|
+
nside=l_nside)
|
|
154
|
+
|
|
155
|
+
ud_data[l]=m_data
|
|
156
|
+
|
|
157
|
+
m_data,_=self.f.ud_grade_2(m_data,
|
|
158
|
+
cell_ids=self.l_cell_ids[l],
|
|
159
|
+
nside=l_nside)
|
|
160
|
+
|
|
161
|
+
l_data = self.f.backend.bk_concat([m_data,l_data],1)
|
|
162
|
+
|
|
163
|
+
l_nside//=2
|
|
164
|
+
# plus one to add the input downgrade data
|
|
165
|
+
l_chan=self.chanlist[l]+self.n_chan_in
|
|
166
|
+
|
|
167
|
+
for l in range(nlayer):
|
|
168
|
+
l_chan+=self.n_chan_in
|
|
169
|
+
l_data=self.f.up_grade(l_data,l_nside*2,
|
|
170
|
+
cell_ids=self.l_cell_ids[nlayer-l],
|
|
171
|
+
o_cell_ids=self.l_cell_ids[nlayer-1-l],
|
|
172
|
+
nside=l_nside)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
l_data = self.f.backend.bk_concat([ud_data[nlayer-1-l],l_data],1)
|
|
176
|
+
l_nside*=2
|
|
177
|
+
|
|
178
|
+
# init double convol weights
|
|
179
|
+
out_chan=self.n_chan_out
|
|
180
|
+
if nlayer-1-l>0:
|
|
181
|
+
out_chan+=self.chanlist[nlayer-1-l]
|
|
182
|
+
nw=l_chan*l_chan*kernelsz*kernelsz
|
|
183
|
+
ww=self.x[self.t_wconv[2*l]:self.t_wconv[2*l]+nw]
|
|
184
|
+
ww=self.f.backend.bk_reshape(ww,[l_chan,
|
|
185
|
+
l_chan,
|
|
186
|
+
kernelsz*kernelsz])
|
|
187
|
+
|
|
188
|
+
c_data = self.t_hconv[l].Convol_torch(l_data,ww)
|
|
189
|
+
|
|
190
|
+
nw=l_chan*out_chan*kernelsz*kernelsz
|
|
191
|
+
ww=self.x[self.t_wconv[2*l+1]:self.t_wconv[2*l+1]+nw]
|
|
192
|
+
ww=self.f.backend.bk_reshape(ww,[l_chan,
|
|
193
|
+
out_chan,
|
|
194
|
+
kernelsz*kernelsz])
|
|
195
|
+
l_data = self.t_hconv[l].Convol_torch(c_data,ww)
|
|
196
|
+
|
|
197
|
+
# plus one to add the input downgrade data
|
|
198
|
+
l_chan=out_chan
|
|
199
|
+
|
|
200
|
+
return l_data
|
foscat/scat_cov.py
CHANGED
|
@@ -33,7 +33,14 @@ testwarn = 0
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class scat_cov:
|
|
36
|
-
def __init__(self,
|
|
36
|
+
def __init__(self,
|
|
37
|
+
s0, s2, s3, s4,
|
|
38
|
+
s1=None,
|
|
39
|
+
s3p=None,
|
|
40
|
+
backend=None,
|
|
41
|
+
use_1D=False,
|
|
42
|
+
return_data=False
|
|
43
|
+
):
|
|
37
44
|
self.S0 = s0
|
|
38
45
|
self.S2 = s2
|
|
39
46
|
self.S3 = s3
|
|
@@ -44,12 +51,13 @@ class scat_cov:
|
|
|
44
51
|
self.idx1 = None
|
|
45
52
|
self.idx2 = None
|
|
46
53
|
self.use_1D = use_1D
|
|
47
|
-
|
|
48
|
-
self.backend.bk_len(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
if not return_data:
|
|
55
|
+
self.numel = self.backend.bk_len(s0)+ \
|
|
56
|
+
self.backend.bk_len(s1)+ \
|
|
57
|
+
self.backend.bk_len(s2)+ \
|
|
58
|
+
self.backend.bk_len(s3)+ \
|
|
59
|
+
self.backend.bk_len(s4)+ \
|
|
60
|
+
self.backend.bk_len(s3p)
|
|
53
61
|
|
|
54
62
|
def numpy(self):
|
|
55
63
|
if self.BACKEND == "numpy":
|
|
@@ -2755,34 +2763,6 @@ class funct(FOC.FoCUS):
|
|
|
2755
2763
|
|
|
2756
2764
|
nside = nside * 2
|
|
2757
2765
|
|
|
2758
|
-
if self.KERNELSZ > 5 and not self.use_2D:
|
|
2759
|
-
# if the kernel size is bigger than 3 increase the binning before smoothing
|
|
2760
|
-
if self.use_2D:
|
|
2761
|
-
vmask = self.up_grade(
|
|
2762
|
-
vmask, I1.shape[-2] * 2, nouty=I1.shape[-1] * 2,axis=-2
|
|
2763
|
-
)
|
|
2764
|
-
I1 = self.up_grade(
|
|
2765
|
-
I1, I1.shape[-2] * 2, nouty=I1.shape[-1] * 2,axis=-2
|
|
2766
|
-
)
|
|
2767
|
-
if cross:
|
|
2768
|
-
I2 = self.up_grade(
|
|
2769
|
-
I2,
|
|
2770
|
-
I2.shape[-2] * 2,
|
|
2771
|
-
nouty=I2.shape[-1] * 2,axis=-2
|
|
2772
|
-
)
|
|
2773
|
-
elif self.use_1D:
|
|
2774
|
-
vmask = self.up_grade(vmask, I1.shape[-1] * 2)
|
|
2775
|
-
I1 = self.up_grade(I1, I1.shape[-1] * 2)
|
|
2776
|
-
if cross:
|
|
2777
|
-
I2 = self.up_grade(I2, I2.shape[-1] * 2)
|
|
2778
|
-
nside = nside * 2
|
|
2779
|
-
else:
|
|
2780
|
-
I1 = self.up_grade(I1, nside * 2)
|
|
2781
|
-
vmask = self.up_grade(vmask, nside * 2)
|
|
2782
|
-
if cross:
|
|
2783
|
-
I2 = self.up_grade(I2, nside * 2)
|
|
2784
|
-
nside = nside * 2
|
|
2785
|
-
|
|
2786
2766
|
# Normalize the masks because they have different pixel numbers
|
|
2787
2767
|
# vmask /= self.backend.bk_reduce_sum(vmask, axis=1)[:, None] # [Nmask, Npix]
|
|
2788
2768
|
|
|
@@ -2825,6 +2805,7 @@ class funct(FOC.FoCUS):
|
|
|
2825
2805
|
P1_dic = {}
|
|
2826
2806
|
if cross:
|
|
2827
2807
|
P2_dic = {}
|
|
2808
|
+
|
|
2828
2809
|
elif (norm == "auto") and (self.P1_dic is not None):
|
|
2829
2810
|
P1_dic = self.P1_dic
|
|
2830
2811
|
if cross:
|
|
@@ -3647,7 +3628,9 @@ class funct(FOC.FoCUS):
|
|
|
3647
3628
|
if calc_var:
|
|
3648
3629
|
if not cross:
|
|
3649
3630
|
return scat_cov(
|
|
3650
|
-
s0, S2, S3, S4, s1=S1, backend=self.backend,
|
|
3631
|
+
s0, S2, S3, S4, s1=S1, backend=self.backend,
|
|
3632
|
+
use_1D=self.use_1D,
|
|
3633
|
+
return_data=self.return_data
|
|
3651
3634
|
), scat_cov(
|
|
3652
3635
|
vs0,
|
|
3653
3636
|
VS2,
|
|
@@ -3656,6 +3639,7 @@ class funct(FOC.FoCUS):
|
|
|
3656
3639
|
s1=VS1,
|
|
3657
3640
|
backend=self.backend,
|
|
3658
3641
|
use_1D=self.use_1D,
|
|
3642
|
+
return_data=self.return_data
|
|
3659
3643
|
)
|
|
3660
3644
|
else:
|
|
3661
3645
|
return scat_cov(
|
|
@@ -3667,6 +3651,7 @@ class funct(FOC.FoCUS):
|
|
|
3667
3651
|
s3p=S3P,
|
|
3668
3652
|
backend=self.backend,
|
|
3669
3653
|
use_1D=self.use_1D,
|
|
3654
|
+
return_data=self.return_data
|
|
3670
3655
|
), scat_cov(
|
|
3671
3656
|
vs0,
|
|
3672
3657
|
VS2,
|
|
@@ -3676,11 +3661,16 @@ class funct(FOC.FoCUS):
|
|
|
3676
3661
|
s3p=VS3P,
|
|
3677
3662
|
backend=self.backend,
|
|
3678
3663
|
use_1D=self.use_1D,
|
|
3664
|
+
return_data=self.return_data
|
|
3679
3665
|
)
|
|
3680
3666
|
else:
|
|
3681
3667
|
if not cross:
|
|
3682
3668
|
return scat_cov(
|
|
3683
|
-
s0, S2, S3, S4,
|
|
3669
|
+
s0, S2, S3, S4,
|
|
3670
|
+
s1=S1,
|
|
3671
|
+
backend=self.backend,
|
|
3672
|
+
use_1D=self.use_1D,
|
|
3673
|
+
return_data=self.return_data
|
|
3684
3674
|
)
|
|
3685
3675
|
else:
|
|
3686
3676
|
return scat_cov(
|
|
@@ -3692,6 +3682,7 @@ class funct(FOC.FoCUS):
|
|
|
3692
3682
|
s3p=S3P,
|
|
3693
3683
|
backend=self.backend,
|
|
3694
3684
|
use_1D=self.use_1D,
|
|
3685
|
+
return_data=self.return_data
|
|
3695
3686
|
)
|
|
3696
3687
|
|
|
3697
3688
|
def clean_norm(self):
|
|
@@ -3769,8 +3760,12 @@ class funct(FOC.FoCUS):
|
|
|
3769
3760
|
# cconv, sconv are [Nbatch, Norient3, Npix_j3]
|
|
3770
3761
|
if self.use_1D:
|
|
3771
3762
|
s3 = conv * self.backend.bk_conjugate(MconvPsi)
|
|
3763
|
+
elif self.use_2D:
|
|
3764
|
+
s3 = self.backend.bk_expand_dims(conv, -4)* self.backend.bk_conjugate(
|
|
3765
|
+
MconvPsi
|
|
3766
|
+
) # [Nbatch, Norient3, Norient2, Npix_j3]
|
|
3772
3767
|
else:
|
|
3773
|
-
s3 = self.backend.bk_expand_dims(conv, -3)
|
|
3768
|
+
s3 = self.backend.bk_expand_dims(conv, -3)* self.backend.bk_conjugate(
|
|
3774
3769
|
MconvPsi
|
|
3775
3770
|
) # [Nbatch, Norient3, Norient2, Npix_j3]
|
|
3776
3771
|
### Apply the mask [Nmask, Npix_j3] and sum over pixels
|
|
@@ -4100,6 +4095,7 @@ class funct(FOC.FoCUS):
|
|
|
4100
4095
|
get_variance=False,
|
|
4101
4096
|
ref_sigma=None,
|
|
4102
4097
|
iso_ang=False,
|
|
4098
|
+
return_table=False,
|
|
4103
4099
|
):
|
|
4104
4100
|
"""
|
|
4105
4101
|
Calculates the scattering correlations for a batch of images, including:
|
|
@@ -4234,7 +4230,7 @@ class funct(FOC.FoCUS):
|
|
|
4234
4230
|
)
|
|
4235
4231
|
print("\n\n==========")
|
|
4236
4232
|
J = Jmax # Number of steps for the loop on scales
|
|
4237
|
-
|
|
4233
|
+
|
|
4238
4234
|
L = self.NORIENT
|
|
4239
4235
|
norm_factor_S3 = 1.0
|
|
4240
4236
|
|
|
@@ -4803,6 +4799,12 @@ class funct(FOC.FoCUS):
|
|
|
4803
4799
|
if data2 is None:
|
|
4804
4800
|
if iso_ang:
|
|
4805
4801
|
if ref_sigma is not None:
|
|
4802
|
+
if return_table:
|
|
4803
|
+
return (S1_iso / ref_sigma["S1_sigma"]), \
|
|
4804
|
+
(S2_iso / ref_sigma["S2_sigma"]) , \
|
|
4805
|
+
(S3_iso / ref_sigma["S3_sigma"]) , \
|
|
4806
|
+
(S4_iso / ref_sigma["S4_sigma"])
|
|
4807
|
+
|
|
4806
4808
|
for_synthesis = self.backend.backend.cat(
|
|
4807
4809
|
(
|
|
4808
4810
|
mean_data / ref_sigma["std_data"],
|
|
@@ -4829,6 +4831,9 @@ class funct(FOC.FoCUS):
|
|
|
4829
4831
|
dim=-1,
|
|
4830
4832
|
)
|
|
4831
4833
|
else:
|
|
4834
|
+
if return_table:
|
|
4835
|
+
return S1_iso,S2_iso,S3_iso,S4_iso
|
|
4836
|
+
|
|
4832
4837
|
for_synthesis = self.backend.backend.cat(
|
|
4833
4838
|
(
|
|
4834
4839
|
mean_data / std_data,
|
|
@@ -4844,6 +4849,12 @@ class funct(FOC.FoCUS):
|
|
|
4844
4849
|
)
|
|
4845
4850
|
else:
|
|
4846
4851
|
if ref_sigma is not None:
|
|
4852
|
+
if return_table:
|
|
4853
|
+
return (S1 / ref_sigma["S1_sigma"]), \
|
|
4854
|
+
(S2 / ref_sigma["S2_sigma"]), \
|
|
4855
|
+
(S3 / ref_sigma["S3_sigma"]), \
|
|
4856
|
+
(S4 / ref_sigma["S4_sigma"])
|
|
4857
|
+
|
|
4847
4858
|
for_synthesis = self.backend.backend.cat(
|
|
4848
4859
|
(
|
|
4849
4860
|
mean_data / ref_sigma["std_data"],
|
|
@@ -4870,6 +4881,9 @@ class funct(FOC.FoCUS):
|
|
|
4870
4881
|
dim=-1,
|
|
4871
4882
|
)
|
|
4872
4883
|
else:
|
|
4884
|
+
if return_table:
|
|
4885
|
+
return S1,S2,S3,S4
|
|
4886
|
+
|
|
4873
4887
|
for_synthesis = self.backend.backend.cat(
|
|
4874
4888
|
(
|
|
4875
4889
|
mean_data / std_data,
|
|
@@ -4886,6 +4900,12 @@ class funct(FOC.FoCUS):
|
|
|
4886
4900
|
else:
|
|
4887
4901
|
if iso_ang:
|
|
4888
4902
|
if ref_sigma is not None:
|
|
4903
|
+
if return_table:
|
|
4904
|
+
return (S1_iso / ref_sigma["S1_sigma"]), \
|
|
4905
|
+
(S2_iso / ref_sigma["S2_sigma"]), \
|
|
4906
|
+
(S3_iso / ref_sigma["S3_sigma"]), \
|
|
4907
|
+
(S4_iso / ref_sigma["S4_sigma"])
|
|
4908
|
+
|
|
4889
4909
|
for_synthesis = self.backend.backend.cat(
|
|
4890
4910
|
(
|
|
4891
4911
|
mean_data / ref_sigma["std_data"],
|
|
@@ -4914,6 +4934,9 @@ class funct(FOC.FoCUS):
|
|
|
4914
4934
|
dim=-1,
|
|
4915
4935
|
)
|
|
4916
4936
|
else:
|
|
4937
|
+
if return_table:
|
|
4938
|
+
return S1_iso,S2_iso,S3_iso,S4_iso
|
|
4939
|
+
|
|
4917
4940
|
for_synthesis = self.backend.backend.cat(
|
|
4918
4941
|
(
|
|
4919
4942
|
mean_data / std_data,
|
|
@@ -4931,6 +4954,12 @@ class funct(FOC.FoCUS):
|
|
|
4931
4954
|
)
|
|
4932
4955
|
else:
|
|
4933
4956
|
if ref_sigma is not None:
|
|
4957
|
+
if return_table:
|
|
4958
|
+
return (S1 / ref_sigma["S1_sigma"]), \
|
|
4959
|
+
(S2 / ref_sigma["S2_sigma"]), \
|
|
4960
|
+
(S3 / ref_sigma["S3_sigma"]), \
|
|
4961
|
+
(S4 / ref_sigma["S4_sigma"])
|
|
4962
|
+
|
|
4934
4963
|
for_synthesis = self.backend.backend.cat(
|
|
4935
4964
|
(
|
|
4936
4965
|
mean_data / ref_sigma["std_data"],
|
|
@@ -4959,6 +4988,9 @@ class funct(FOC.FoCUS):
|
|
|
4959
4988
|
dim=-1,
|
|
4960
4989
|
)
|
|
4961
4990
|
else:
|
|
4991
|
+
if return_table:
|
|
4992
|
+
return S1,S2,S3,S4
|
|
4993
|
+
|
|
4962
4994
|
for_synthesis = self.backend.backend.cat(
|
|
4963
4995
|
(
|
|
4964
4996
|
mean_data / std_data,
|
|
@@ -5955,8 +5987,8 @@ class funct(FOC.FoCUS):
|
|
|
5955
5987
|
def from_gaussian(self, x):
|
|
5956
5988
|
|
|
5957
5989
|
x = self.backend.bk_clip_by_value(x,
|
|
5958
|
-
self.val_min+1E-
|
|
5959
|
-
self.val_max-1E-
|
|
5990
|
+
self.val_min+1E-7*(self.val_max-self.val_min),
|
|
5991
|
+
self.val_max-1E-7*(self.val_max-self.val_min))
|
|
5960
5992
|
return self.f_gaussian(self.backend.to_numpy(x))
|
|
5961
5993
|
|
|
5962
5994
|
def square(self, x):
|
|
@@ -6127,13 +6159,12 @@ class funct(FOC.FoCUS):
|
|
|
6127
6159
|
return result
|
|
6128
6160
|
else:
|
|
6129
6161
|
if sigma is None:
|
|
6130
|
-
tmp = x
|
|
6162
|
+
tmp = self.diff_data(x,y)
|
|
6131
6163
|
else:
|
|
6132
|
-
tmp = (x
|
|
6164
|
+
tmp = self.diff_data(x,y,sigma=sigma)
|
|
6165
|
+
|
|
6133
6166
|
# do abs in case of complex values
|
|
6134
|
-
return
|
|
6135
|
-
self.backend.bk_reduce_mean(self.backend.bk_square(tmp))
|
|
6136
|
-
)
|
|
6167
|
+
return tmp/x.shape[0]
|
|
6137
6168
|
|
|
6138
6169
|
def reduce_sum(self, x):
|
|
6139
6170
|
|
|
@@ -6295,7 +6326,7 @@ class funct(FOC.FoCUS):
|
|
|
6295
6326
|
Jmax=None,
|
|
6296
6327
|
edge=False,
|
|
6297
6328
|
to_gaussian=True,
|
|
6298
|
-
use_variance=
|
|
6329
|
+
use_variance=True,
|
|
6299
6330
|
synthesised_N=1,
|
|
6300
6331
|
input_image=None,
|
|
6301
6332
|
grd_mask=None,
|
|
@@ -6362,13 +6393,14 @@ class funct(FOC.FoCUS):
|
|
|
6362
6393
|
use_v = args[2]
|
|
6363
6394
|
ljmax = args[3]
|
|
6364
6395
|
|
|
6365
|
-
learn = scat_operator.
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
norm='self'
|
|
6396
|
+
learn = scat_operator.eval(
|
|
6397
|
+
u,
|
|
6398
|
+
Jmax=ljmax,
|
|
6399
|
+
norm='auto'
|
|
6370
6400
|
)
|
|
6371
|
-
|
|
6401
|
+
|
|
6402
|
+
if synthesised_N>1:
|
|
6403
|
+
learn = scat_operator.reduce_mean_batch(learn)
|
|
6372
6404
|
|
|
6373
6405
|
# compute scattering covariance of the current synthetised map called u
|
|
6374
6406
|
if use_v:
|
|
@@ -6574,6 +6606,8 @@ class funct(FOC.FoCUS):
|
|
|
6574
6606
|
)
|
|
6575
6607
|
sref = ref
|
|
6576
6608
|
else:
|
|
6609
|
+
self.clean_norm()
|
|
6610
|
+
|
|
6577
6611
|
ref = self.eval(
|
|
6578
6612
|
tmp[k],
|
|
6579
6613
|
image2=l_ref[k],
|
|
@@ -6590,7 +6624,7 @@ class funct(FOC.FoCUS):
|
|
|
6590
6624
|
mask=l_in_mask[k],
|
|
6591
6625
|
Jmax=l_jmax[k],
|
|
6592
6626
|
calc_var=True,
|
|
6593
|
-
norm='
|
|
6627
|
+
norm='auto'
|
|
6594
6628
|
)
|
|
6595
6629
|
else:
|
|
6596
6630
|
ref = self.eval(
|
|
@@ -6598,7 +6632,7 @@ class funct(FOC.FoCUS):
|
|
|
6598
6632
|
image2=l_ref[k],
|
|
6599
6633
|
mask=l_in_mask[k],
|
|
6600
6634
|
Jmax=l_jmax[k],
|
|
6601
|
-
norm='
|
|
6635
|
+
norm='auto'
|
|
6602
6636
|
)
|
|
6603
6637
|
sref = ref
|
|
6604
6638
|
|
|
@@ -6659,6 +6693,9 @@ class funct(FOC.FoCUS):
|
|
|
6659
6693
|
grd_mask=l_grd_mask[k],
|
|
6660
6694
|
)
|
|
6661
6695
|
|
|
6696
|
+
if not self.use_2D:
|
|
6697
|
+
self.clean_norm()
|
|
6698
|
+
|
|
6662
6699
|
t2 = time.time()
|
|
6663
6700
|
print("Total computation %.2fs" % (t2 - t1))
|
|
6664
6701
|
|
foscat/scat_cov_map2D.py
CHANGED
|
@@ -29,7 +29,7 @@ class funct(scat.funct):
|
|
|
29
29
|
image1, image2=image2, mask=mask, norm=norm, calc_var=calc_var, Jmax=Jmax
|
|
30
30
|
)
|
|
31
31
|
return scat_cov_map(
|
|
32
|
-
r.S2, r.S0, r.S3, r.S4, S1=r.S1, S3P=r.S3P, backend=r.backend
|
|
32
|
+
r.S2, r.S0, r.S3, r.S4, S1=r.S1, S3P=r.S3P, backend=r.backend,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
def scat_coeffs_apply(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: foscat
|
|
3
|
-
Version: 2025.
|
|
3
|
+
Version: 2025.8.4
|
|
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>
|
|
@@ -2,14 +2,16 @@ foscat/BkBase.py,sha256=2buIR9RK6g7HLoHJbzVCYhi1PkjDW6SXlu7IlF7SfA4,21611
|
|
|
2
2
|
foscat/BkNumpy.py,sha256=qvKxDoAPQD52Ui9qv_D_GZvWpXX2n9S9dOGlXz5uNdQ,10683
|
|
3
3
|
foscat/BkTensorflow.py,sha256=iIdLx6VTOfOEocfZBOGyizQn5geDLTfdWWAwDeQr9YA,20056
|
|
4
4
|
foscat/BkTorch.py,sha256=fWkNTrgK1MkpkS-bNVmC0ihJY_WlPs98ndperSh63i8,19593
|
|
5
|
-
foscat/CNN.py,sha256=
|
|
5
|
+
foscat/CNN.py,sha256=4vky7jqTshL1aYLWsc-hQwf7gDjTVjL7I6HZiAsa6x4,5158
|
|
6
6
|
foscat/CircSpline.py,sha256=CXi49FxF8ZoeZ17Ua8c1AZXe2B5ICEC9aCXb97atB3s,4028
|
|
7
|
-
foscat/FoCUS.py,sha256=
|
|
7
|
+
foscat/FoCUS.py,sha256=iXcj6qcYaiREEcozd4xHfr983CwWFxNxvGIqEJw-JMI,114717
|
|
8
8
|
foscat/GCNN.py,sha256=q7yWHCMJpP7-m3WvR3OQnp5taeYWaMxIY2hQ6SIb9gs,4487
|
|
9
|
-
foscat/
|
|
9
|
+
foscat/HOrientedConvol.py,sha256=S4Ru4holHT0ux6oMttHrKrXtxF4kGeVvoWE8AQs-RhI,21619
|
|
10
|
+
foscat/HealSpline.py,sha256=YRotJ1NQuXYFyFiM8fp6qkATIwRJ8lqIVo4vGXpHO-w,7472
|
|
10
11
|
foscat/Softmax.py,sha256=UDZGrTroYtmGEyokGUVpwNO_cgbICi9QVuRr8Yx52_k,2917
|
|
11
12
|
foscat/Spline1D.py,sha256=rKzzenduaZZ-yBDJd35it6Gyrj1spqb7hoIaUgISPzY,2983
|
|
12
|
-
foscat/Synthesis.py,sha256=
|
|
13
|
+
foscat/Synthesis.py,sha256=ClrUkSKm2426ZX56dHoepoSQ2rJvwTXQnPPtlC2cESY,14174
|
|
14
|
+
foscat/UNET.py,sha256=QIOv3ysz9lGKMFLmyfQarhzzh7gg833hk70Uo04u3-0,7027
|
|
13
15
|
foscat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
16
|
foscat/alm.py,sha256=XkK4rFVRoO-oJpr74iBffKt7hdS_iJkR016IlYm10gQ,33832
|
|
15
17
|
foscat/backend.py,sha256=l3aMwDyXP6jURMIvratFMGWCTcQpaR68KnUuuGDezqE,45418
|
|
@@ -20,13 +22,13 @@ foscat/loss_backend_torch.py,sha256=k3z18Dj3SaLKK6ZIKcm7GO4U_YKYVP6LtHG1aIbxkYk,
|
|
|
20
22
|
foscat/scat.py,sha256=qGYiBIysPt65MdmF07WWA4piVlTfA9-lFDTaicnqC2w,72822
|
|
21
23
|
foscat/scat1D.py,sha256=W5Uu6wdQ4ZsFKXpof0f1OBl-1wjJmW7ruvddRWxe7uM,53726
|
|
22
24
|
foscat/scat2D.py,sha256=boKj0ASqMMSy7uQLK6hPniG87m3hZGJBYBiq5v8F9IQ,532
|
|
23
|
-
foscat/scat_cov.py,sha256=
|
|
25
|
+
foscat/scat_cov.py,sha256=QKPIjb5Tq00onp5uPX7qR6k5CoqUc_A1rrT3pDlnXyM,271522
|
|
24
26
|
foscat/scat_cov1D.py,sha256=XOxsZZ5TYq8f34i2tUgIfzyaqaTDlICB3HzD2l_puro,531
|
|
25
27
|
foscat/scat_cov2D.py,sha256=pAm0fKw8wyXram0TFbtw8tGcc8QPKuPXpQk0kh10r4U,7078
|
|
26
28
|
foscat/scat_cov_map.py,sha256=9MzpwT2g9S3dmnjHEMK7PPLQ27oGQg2VFVsP_TDUU5E,2869
|
|
27
|
-
foscat/scat_cov_map2D.py,sha256=
|
|
28
|
-
foscat-2025.
|
|
29
|
-
foscat-2025.
|
|
30
|
-
foscat-2025.
|
|
31
|
-
foscat-2025.
|
|
32
|
-
foscat-2025.
|
|
29
|
+
foscat/scat_cov_map2D.py,sha256=zaIIYshXCqAeZ04I158GhD-Op4aoMlLnLEy7rxckVYY,2842
|
|
30
|
+
foscat-2025.8.4.dist-info/licenses/LICENSE,sha256=i0ukIr8ZUpkSY2sZaE9XZK-6vuSU5iG6IgX_3pjatP8,1505
|
|
31
|
+
foscat-2025.8.4.dist-info/METADATA,sha256=ur8T9ywlSsVA5J7Bb1WwkwizQhwwaT1ncuEr4ofLYUw,7215
|
|
32
|
+
foscat-2025.8.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
33
|
+
foscat-2025.8.4.dist-info/top_level.txt,sha256=AGySXBBAlJgb8Tj8af6m_F-aiNg2zNTcybCUPVOKjAg,7
|
|
34
|
+
foscat-2025.8.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|