foscat 3.0.13__tar.gz → 3.0.16__tar.gz
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-3.0.13 → foscat-3.0.16}/PKG-INFO +7 -1
- {foscat-3.0.13 → foscat-3.0.16}/setup.py +1 -1
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/FoCUS.py +59 -33
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/GCNN.py +9 -4
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/backend.py +16 -4
- foscat-3.0.16/src/foscat/backend_tens.py +49 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat_cov.py +16 -5
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat.egg-info/PKG-INFO +7 -1
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat.egg-info/SOURCES.txt +1 -0
- {foscat-3.0.13 → foscat-3.0.16}/README.md +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/setup.cfg +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/CircSpline.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/GetGPUinfo.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/Softmax.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/Spline1D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/Synthesis.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/__init__.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/loss_backend_tens.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/loss_backend_torch.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat1D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat2D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat_cov1D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat_cov2D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat_cov_map.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat/scat_cov_map2D.py +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat.egg-info/dependency_links.txt +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat.egg-info/requires.txt +0 -0
- {foscat-3.0.13 → foscat-3.0.16}/src/foscat.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: foscat
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.16
|
|
4
4
|
Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
|
|
5
5
|
Home-page: https://github.com/jmdelouis/FOSCAT
|
|
6
6
|
Author: Jean-Marc DELOUIS
|
|
@@ -9,6 +9,12 @@ Maintainer: Theo Foulquier
|
|
|
9
9
|
Maintainer-email: theo.foulquier@ifremer.fr
|
|
10
10
|
License: MIT
|
|
11
11
|
Keywords: Scattering transform,Component separation,denoising
|
|
12
|
+
Requires-Dist: imageio
|
|
13
|
+
Requires-Dist: imagecodecs
|
|
14
|
+
Requires-Dist: matplotlib
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Requires-Dist: tensorflow
|
|
17
|
+
Requires-Dist: healpy
|
|
12
18
|
|
|
13
19
|
Utilize the Cross Scattering Transform (described in https://arxiv.org/abs/2207.12527) to synthesize Healpix or 2D data that is suitable for component separation purposes, such as denoising.
|
|
14
20
|
A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO.
|
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name='foscat',
|
|
6
|
-
version='3.0.
|
|
6
|
+
version='3.0.16',
|
|
7
7
|
description='Generate synthetic Healpix or 2D data using Cross Scattering Transform' ,
|
|
8
8
|
long_description='Utilize the Cross Scattering Transform (described in https://arxiv.org/abs/2207.12527) to synthesize Healpix or 2D data that is suitable for component separation purposes, such as denoising. \n A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO. \n Complete doc can be found at https://foscat-documentation.readthedocs.io/en/latest/index.html. \n\n List of developers : J.-M. Delouis, T. Foulquier, L. Mousset, T. Odaka, F. Paul, E. Allys ' ,
|
|
9
9
|
license='MIT',
|
|
@@ -4,6 +4,7 @@ import os, sys
|
|
|
4
4
|
import foscat.backend as bk
|
|
5
5
|
from scipy.interpolate import griddata
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
TMPFILE_VERSION='V2_6'
|
|
8
9
|
|
|
9
10
|
class FoCUS:
|
|
@@ -27,9 +28,11 @@ class FoCUS:
|
|
|
27
28
|
JmaxDelta=0,
|
|
28
29
|
DODIV=False,
|
|
29
30
|
InitWave=None,
|
|
31
|
+
silent=False,
|
|
30
32
|
mpi_size=1,
|
|
31
33
|
mpi_rank=0):
|
|
32
34
|
|
|
35
|
+
self.__version__ = '3.0.16'
|
|
33
36
|
# P00 coeff for normalization for scat_cov
|
|
34
37
|
self.TMPFILE_VERSION=TMPFILE_VERSION
|
|
35
38
|
self.P1_dic = None
|
|
@@ -42,20 +45,25 @@ class FoCUS:
|
|
|
42
45
|
self.mpi_size=mpi_size
|
|
43
46
|
self.mpi_rank=mpi_rank
|
|
44
47
|
self.return_data=return_data
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
self.silent=silent
|
|
49
|
+
|
|
50
|
+
if not self.silent:
|
|
51
|
+
print('================================================')
|
|
52
|
+
print(' START FOSCAT CONFIGURATION')
|
|
53
|
+
print('================================================')
|
|
54
|
+
sys.stdout.flush()
|
|
50
55
|
|
|
51
56
|
self.TEMPLATE_PATH=TEMPLATE_PATH
|
|
52
57
|
if os.path.exists(self.TEMPLATE_PATH)==False:
|
|
53
|
-
|
|
58
|
+
if not self.silent:
|
|
59
|
+
print('The directory %s to store temporary information for FoCUS does not exist: Try to create it'%(self.TEMPLATE_PATH))
|
|
54
60
|
try:
|
|
55
61
|
os.system('mkdir -p %s'%(self.TEMPLATE_PATH))
|
|
56
|
-
|
|
62
|
+
if not self.silent:
|
|
63
|
+
print('The directory %s is created')
|
|
57
64
|
except:
|
|
58
|
-
|
|
65
|
+
if not self.silent:
|
|
66
|
+
print('Impossible to create the directory %s'%(self.TEMPLATE_PATH))
|
|
59
67
|
exit(0)
|
|
60
68
|
|
|
61
69
|
self.number_of_loss=0
|
|
@@ -65,13 +73,15 @@ class FoCUS:
|
|
|
65
73
|
self.padding=padding
|
|
66
74
|
|
|
67
75
|
if OSTEP!=0:
|
|
68
|
-
|
|
76
|
+
if not self.silent:
|
|
77
|
+
print('OPTION option is deprecated after version 2.0.6. Please use Jmax option')
|
|
69
78
|
JmaxDelta=OSTEP
|
|
70
79
|
else:
|
|
71
80
|
OSTEP=JmaxDelta
|
|
72
81
|
|
|
73
82
|
if JmaxDelta<-1:
|
|
74
|
-
|
|
83
|
+
if not self.silent:
|
|
84
|
+
print('Warning : Jmax can not be smaller than -1')
|
|
75
85
|
exit(0)
|
|
76
86
|
|
|
77
87
|
self.OSTEP=JmaxDelta
|
|
@@ -93,7 +103,8 @@ class FoCUS:
|
|
|
93
103
|
self.backend=bk.foscat_backend(BACKEND,
|
|
94
104
|
all_type=all_type,
|
|
95
105
|
mpi_rank=mpi_rank,
|
|
96
|
-
gpupos=gpupos
|
|
106
|
+
gpupos=gpupos,
|
|
107
|
+
silent=self.silent)
|
|
97
108
|
|
|
98
109
|
self.all_bk_type=self.backend.all_bk_type
|
|
99
110
|
self.all_cbk_type=self.backend.all_cbk_type
|
|
@@ -103,14 +114,15 @@ class FoCUS:
|
|
|
103
114
|
|
|
104
115
|
self.gpupos=(gpupos+mpi_rank)%self.backend.ngpu
|
|
105
116
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
if not self.silent:
|
|
118
|
+
print('============================================================')
|
|
119
|
+
print('== ==')
|
|
120
|
+
print('== ==')
|
|
121
|
+
print('== RUN ON GPU Rank %d : %s =='%(mpi_rank,self.gpulist[self.gpupos%self.ngpu]))
|
|
122
|
+
print('== ==')
|
|
123
|
+
print('== ==')
|
|
124
|
+
print('============================================================')
|
|
125
|
+
sys.stdout.flush()
|
|
114
126
|
|
|
115
127
|
l_NORIENT=NORIENT
|
|
116
128
|
if DODIV:
|
|
@@ -212,7 +224,8 @@ class FoCUS:
|
|
|
212
224
|
|
|
213
225
|
for i in range(1,6):
|
|
214
226
|
lout=(2**i)
|
|
215
|
-
|
|
227
|
+
if not self.silent:
|
|
228
|
+
print('Init Wave ',lout)
|
|
216
229
|
|
|
217
230
|
if self.InitWave is None:
|
|
218
231
|
wr,wi,ws,widx=self.init_index(lout)
|
|
@@ -322,7 +335,8 @@ class FoCUS:
|
|
|
322
335
|
indices=np.zeros([12*nside*nside,l_kernel,2],dtype='int')
|
|
323
336
|
for k in range(12*nside*nside):
|
|
324
337
|
if k%(nside*nside)==0:
|
|
325
|
-
|
|
338
|
+
if not self.silent:
|
|
339
|
+
print('Pre-compute nside=%6d %.2f%%'%(nside,100*k/(12*nside*nside)))
|
|
326
340
|
|
|
327
341
|
rot=[po[k]/np.pi*180.0,90+(-to[k])/np.pi*180.0]
|
|
328
342
|
r=hp.Rotator(rot=rot).get_inverse()
|
|
@@ -334,10 +348,12 @@ class FoCUS:
|
|
|
334
348
|
if transpose:
|
|
335
349
|
indices[:,:,1]=indices[:,:,1]//4
|
|
336
350
|
np.save('%s/FOSCAT_%s_W%d_%d_%d_CNN_Transpose.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,l_kernel,self.NORIENT,nside),indices)
|
|
337
|
-
|
|
351
|
+
if not self.silent:
|
|
352
|
+
print('Write %s/FOSCAT_%s_W%d_%d_%d_CNN_Transpose.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,l_kernel,self.NORIENT,nside))
|
|
338
353
|
else:
|
|
339
354
|
np.save('%s/FOSCAT_%s_W%d_%d_%d_CNNnpy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,l_kernel,self.NORIENT,nside),indices)
|
|
340
|
-
|
|
355
|
+
if not self.silent:
|
|
356
|
+
print('Write %s/FOSCAT_%s_W%d_%d_%d_CNN.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,l_kernel,self.NORIENT,nside))
|
|
341
357
|
|
|
342
358
|
|
|
343
359
|
if transpose:
|
|
@@ -355,7 +371,8 @@ class FoCUS:
|
|
|
355
371
|
l_kernel=self.KERNELSZ*self.KERNELSZ
|
|
356
372
|
|
|
357
373
|
if im.shape[1]!=ww.shape[1]:
|
|
358
|
-
|
|
374
|
+
if not self.silent:
|
|
375
|
+
print('Weights channels should be equal to the input image channels')
|
|
359
376
|
return -1
|
|
360
377
|
|
|
361
378
|
if self.ww_CNN_Transpose[nside] is None:
|
|
@@ -374,7 +391,8 @@ class FoCUS:
|
|
|
374
391
|
l_kernel=self.KERNELSZ*self.KERNELSZ
|
|
375
392
|
|
|
376
393
|
if im.shape[1]!=ww.shape[1]:
|
|
377
|
-
|
|
394
|
+
if not self.silent:
|
|
395
|
+
print('Weights channels should be equal to the input image channels')
|
|
378
396
|
return -1
|
|
379
397
|
|
|
380
398
|
if self.ww_CNN[nside] is None:
|
|
@@ -421,7 +439,8 @@ class FoCUS:
|
|
|
421
439
|
if self.use_2D:
|
|
422
440
|
ishape=list(im.shape)
|
|
423
441
|
if len(ishape)<axis+2:
|
|
424
|
-
|
|
442
|
+
if not self.silent:
|
|
443
|
+
print('Use of 2D scat with data that has less than 2D')
|
|
425
444
|
exit(0)
|
|
426
445
|
|
|
427
446
|
npix=im.shape[axis]
|
|
@@ -481,7 +500,8 @@ class FoCUS:
|
|
|
481
500
|
if self.use_2D:
|
|
482
501
|
ishape=list(im.shape)
|
|
483
502
|
if len(ishape)<axis+2:
|
|
484
|
-
|
|
503
|
+
if not self.silent:
|
|
504
|
+
print('Use of 2D scat with data that has less than 2D')
|
|
485
505
|
exit(0)
|
|
486
506
|
|
|
487
507
|
if nouty is None:
|
|
@@ -523,7 +543,8 @@ class FoCUS:
|
|
|
523
543
|
lout=int(np.sqrt(im.shape[axis]//12))
|
|
524
544
|
|
|
525
545
|
if self.pix_interp_val[lout][nout] is None:
|
|
526
|
-
|
|
546
|
+
if not self.silent:
|
|
547
|
+
print('compute lout nout',lout,nout)
|
|
527
548
|
th,ph=hp.pix2ang(nout,np.arange(12*nout**2,dtype='int'),nest=True)
|
|
528
549
|
p, w = hp.get_interp_weights(lout,th,ph,nest=True)
|
|
529
550
|
del th
|
|
@@ -880,7 +901,8 @@ class FoCUS:
|
|
|
880
901
|
|
|
881
902
|
for k in range(12*nside*nside):
|
|
882
903
|
if k%(nside*nside)==0:
|
|
883
|
-
|
|
904
|
+
if not self.silent:
|
|
905
|
+
print('Pre-compute nside=%6d %.2f%%'%(nside,100*k/(12*nside*nside)))
|
|
884
906
|
if nside>scale*2:
|
|
885
907
|
lidx=hp.get_all_neighbours(nside//scale,th[k//(scale*scale)],ph[k//(scale*scale)],nest=True)
|
|
886
908
|
lidx=np.concatenate([lidx,np.array([(k//(scale*scale))])],0)
|
|
@@ -932,7 +954,8 @@ class FoCUS:
|
|
|
932
954
|
wav=w.flatten()
|
|
933
955
|
wwav=wwav.flatten()
|
|
934
956
|
|
|
935
|
-
|
|
957
|
+
if not self.silent:
|
|
958
|
+
print('Write FOSCAT_%s_W%d_%d_%d_PIDX.npy'%(TMPFILE_VERSION,self.KERNELSZ**2,self.NORIENT,nside))
|
|
936
959
|
np.save('%s/FOSCAT_%s_W%d_%d_%d_PIDX.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,self.KERNELSZ**2,self.NORIENT,nside),indice)
|
|
937
960
|
np.save('%s/FOSCAT_%s_W%d_%d_%d_WAVE.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,self.KERNELSZ**2,self.NORIENT,nside),wav)
|
|
938
961
|
np.save('%s/FOSCAT_%s_W%d_%d_%d_PIDX2.npy'%(self.TEMPLATE_PATH,TMPFILE_VERSION,self.KERNELSZ**2,self.NORIENT,nside),indice2)
|
|
@@ -946,7 +969,8 @@ class FoCUS:
|
|
|
946
969
|
self.comp_idx_w25(nside)
|
|
947
970
|
else:
|
|
948
971
|
if self.rank==0:
|
|
949
|
-
|
|
972
|
+
if not self.silent:
|
|
973
|
+
print('Only 3x3 and 5x5 kernel have been developped for Healpix and you ask for %dx%d'%(KERNELSZ,KERNELSZ))
|
|
950
974
|
exit(0)
|
|
951
975
|
|
|
952
976
|
self.barrier()
|
|
@@ -1230,7 +1254,8 @@ class FoCUS:
|
|
|
1230
1254
|
|
|
1231
1255
|
ishape=list(in_image.shape)
|
|
1232
1256
|
if len(ishape)<axis+2:
|
|
1233
|
-
|
|
1257
|
+
if not self.silent:
|
|
1258
|
+
print('Use of 2D scat with data that has less than 2D')
|
|
1234
1259
|
exit(0)
|
|
1235
1260
|
|
|
1236
1261
|
npix=ishape[axis]
|
|
@@ -1354,7 +1379,8 @@ class FoCUS:
|
|
|
1354
1379
|
|
|
1355
1380
|
ishape=list(in_image.shape)
|
|
1356
1381
|
if len(ishape)<axis+2:
|
|
1357
|
-
|
|
1382
|
+
if not self.silent:
|
|
1383
|
+
print('Use of 2D scat with data that has less than 2D')
|
|
1358
1384
|
exit(0)
|
|
1359
1385
|
|
|
1360
1386
|
npix=ishape[axis]
|
|
@@ -11,6 +11,7 @@ class GCNN:
|
|
|
11
11
|
nscale=1,
|
|
12
12
|
chanlist=[],
|
|
13
13
|
in_nside=1,
|
|
14
|
+
n_chan_out=1,
|
|
14
15
|
nbatch=1,
|
|
15
16
|
SEED=1234,
|
|
16
17
|
filename=None):
|
|
@@ -27,12 +28,14 @@ class GCNN:
|
|
|
27
28
|
self.chanlist=outlist[0]
|
|
28
29
|
self.in_nside=outlist[4]
|
|
29
30
|
self.nbatch=outlist[1]
|
|
31
|
+
self.n_chan_out=outlist[8]
|
|
30
32
|
|
|
31
33
|
self.x=self.scat_operator.backend.bk_cast(outlist[6])
|
|
32
34
|
else:
|
|
33
35
|
self.nscale=nscale
|
|
34
36
|
self.nbatch=nbatch
|
|
35
37
|
self.npar=nparam
|
|
38
|
+
self.n_chan_out=n_chan_out
|
|
36
39
|
self.scat_operator=scat_operator
|
|
37
40
|
|
|
38
41
|
if len(chanlist)!=nscale+1:
|
|
@@ -56,7 +59,9 @@ class GCNN:
|
|
|
56
59
|
self.in_nside, \
|
|
57
60
|
self.nscale, \
|
|
58
61
|
self.get_weights().numpy(), \
|
|
59
|
-
self.all_type
|
|
62
|
+
self.all_type, \
|
|
63
|
+
self.n_chan_out]
|
|
64
|
+
|
|
60
65
|
myout=open("%s.pkl"%(filename),"wb")
|
|
61
66
|
pickle.dump(outlist,myout)
|
|
62
67
|
myout.close()
|
|
@@ -66,7 +71,7 @@ class GCNN:
|
|
|
66
71
|
for i in range(self.nscale):
|
|
67
72
|
totnchan=totnchan+self.chanlist[i]*self.chanlist[i+1]
|
|
68
73
|
return self.npar*12*self.in_nside**2*self.chanlist[0] \
|
|
69
|
-
+totnchan*self.KERNELSZ*self.KERNELSZ+self.chanlist[self.nscale]
|
|
74
|
+
+totnchan*self.KERNELSZ*self.KERNELSZ+self.chanlist[self.nscale]*self.n_chan_out
|
|
70
75
|
|
|
71
76
|
def set_weights(self,x):
|
|
72
77
|
self.x=x
|
|
@@ -93,8 +98,8 @@ class GCNN:
|
|
|
93
98
|
im=self.scat_operator.healpix_layer_transpose(im,ww)
|
|
94
99
|
im=self.scat_operator.backend.bk_relu(im)
|
|
95
100
|
|
|
96
|
-
ww=self.scat_operator.backend.bk_reshape(x[nn:],[self.chanlist[self.nscale],
|
|
101
|
+
ww=self.scat_operator.backend.bk_reshape(x[nn:],[self.chanlist[self.nscale],self.n_chan_out])
|
|
97
102
|
im=self.scat_operator.backend.bk_matmul(im,ww)
|
|
98
103
|
|
|
99
|
-
return
|
|
104
|
+
return im
|
|
100
105
|
|
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
|
3
3
|
|
|
4
4
|
class foscat_backend:
|
|
5
5
|
|
|
6
|
-
def __init__(self,name,mpi_rank=0,all_type='float64',gpupos=0):
|
|
6
|
+
def __init__(self,name,mpi_rank=0,all_type='float64',gpupos=0,silent=False):
|
|
7
7
|
|
|
8
8
|
self.TENSORFLOW=1
|
|
9
9
|
self.TORCH=2
|
|
@@ -71,7 +71,7 @@ class foscat_backend:
|
|
|
71
71
|
#===========================================================================
|
|
72
72
|
# INIT
|
|
73
73
|
if mpi_rank==0:
|
|
74
|
-
if self.BACKEND==self.TENSORFLOW:
|
|
74
|
+
if self.BACKEND==self.TENSORFLOW and silent==False:
|
|
75
75
|
print("Num GPUs Available: ", len(self.backend.config.experimental.list_physical_devices('GPU')))
|
|
76
76
|
sys.stdout.flush()
|
|
77
77
|
|
|
@@ -264,7 +264,14 @@ class foscat_backend:
|
|
|
264
264
|
if self.BACKEND==self.TORCH:
|
|
265
265
|
return x
|
|
266
266
|
if self.BACKEND==self.NUMPY:
|
|
267
|
-
|
|
267
|
+
res=np.zeros([x.shape[0],x.shape[1],x.shape[2],w.shape[3]],dtype=x.dtype)
|
|
268
|
+
for k in range(w.shape[2]):
|
|
269
|
+
for l in range(w.shape[3]):
|
|
270
|
+
for j in range(res.shape[0]):
|
|
271
|
+
tmp=self.scipy.signal.convolve2d(x[j,:,:,k],w[:,:,k,l], mode='same', boundary='fill', fillvalue=0.0)
|
|
272
|
+
res[j,:,:,l]+=tmp
|
|
273
|
+
del tmp
|
|
274
|
+
return res
|
|
268
275
|
|
|
269
276
|
def bk_threshold(self,x,threshold,greater=True):
|
|
270
277
|
|
|
@@ -297,9 +304,14 @@ class foscat_backend:
|
|
|
297
304
|
if self.BACKEND==self.TENSORFLOW:
|
|
298
305
|
return self.backend.nn.conv1d(x,w, stride=[1,1,1], padding='SAME')
|
|
299
306
|
if self.BACKEND==self.TORCH:
|
|
307
|
+
# Torch not yet done !!!
|
|
300
308
|
return self.backend.nn.conv1d(x,w, stride=1, padding='SAME')
|
|
301
309
|
if self.BACKEND==self.NUMPY:
|
|
302
|
-
|
|
310
|
+
res=np.zeros([x.shape[0],x.shape[1],w.shape[1]],dtype=x.dtype)
|
|
311
|
+
for k in range(w.shape[1]):
|
|
312
|
+
for l in range(w.shape[2]):
|
|
313
|
+
res[:,:,l]+=self.scipy.ndimage.convolve1d(x[:,:,k],w[:,k,l],axis=1,mode='constant',cval=0.0)
|
|
314
|
+
return res
|
|
303
315
|
|
|
304
316
|
def bk_flattenR(self,x):
|
|
305
317
|
if self.BACKEND==self.TENSORFLOW or self.BACKEND==self.TORCH:
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import tensorflow as tf
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
class foscat_backend_tens:
|
|
5
|
+
|
|
6
|
+
def __init__(self,backend):
|
|
7
|
+
|
|
8
|
+
self.bk=backend
|
|
9
|
+
# ---------------------------------------------−---------
|
|
10
|
+
|
|
11
|
+
@tf.function
|
|
12
|
+
def loss(self,x,batch,loss_function):
|
|
13
|
+
|
|
14
|
+
operation=loss_function.scat_operator
|
|
15
|
+
|
|
16
|
+
nx=1
|
|
17
|
+
if len(x.shape)>1:
|
|
18
|
+
nx=x.shape[0]
|
|
19
|
+
|
|
20
|
+
with tf.device(operation.gpulist[(operation.gpupos+self.curr_gpu)%operation.ngpu]):
|
|
21
|
+
print('%s Run [PROC=%04d] on GPU %s'%(loss_function.name,self.mpi_rank,
|
|
22
|
+
operation.gpulist[(operation.gpupos+self.curr_gpu)%operation.ngpu]))
|
|
23
|
+
sys.stdout.flush()
|
|
24
|
+
|
|
25
|
+
l_x=x
|
|
26
|
+
"""
|
|
27
|
+
if nx>1:
|
|
28
|
+
l_x={}
|
|
29
|
+
for i in range(nx):
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
if nx==1:
|
|
33
|
+
ndata=x.shape[0]
|
|
34
|
+
else:
|
|
35
|
+
ndata=x.shape[0]*x.shape[1]
|
|
36
|
+
|
|
37
|
+
if self.KEEP_TRACK is not None:
|
|
38
|
+
l,linfo=loss_function.eval(l_x,batch,return_all=True)
|
|
39
|
+
else:
|
|
40
|
+
l=loss_function.eval(l_x,batch)
|
|
41
|
+
|
|
42
|
+
g=tf.gradients(l,x)[0]
|
|
43
|
+
g=self.backend.check_dense(g,ndata)
|
|
44
|
+
self.curr_gpu=self.curr_gpu+1
|
|
45
|
+
|
|
46
|
+
if self.KEEP_TRACK is not None:
|
|
47
|
+
return l,g,linfo
|
|
48
|
+
else:
|
|
49
|
+
return l,g
|
|
@@ -1493,11 +1493,15 @@ class funct(FOC.FoCUS):
|
|
|
1493
1493
|
scat_cov(sS0, sP00, sC01, sC11, s1=sS1,c10=sC10,backend=self.backend)
|
|
1494
1494
|
|
|
1495
1495
|
# compute local direction to make the statistical analysis more efficient
|
|
1496
|
-
def stat_cfft(self,im,upscale=False,smooth_scale=0):
|
|
1496
|
+
def stat_cfft(self,im,image2=None,upscale=False,smooth_scale=0):
|
|
1497
1497
|
tmp=im
|
|
1498
|
+
if image2 is not None:
|
|
1499
|
+
tmpi2=image2
|
|
1498
1500
|
if upscale:
|
|
1499
1501
|
l_nside=int(np.sqrt(tmp.shape[1]//12))
|
|
1500
1502
|
tmp=self.up_grade(tmp,l_nside*2,axis=1)
|
|
1503
|
+
if image2 is not None:
|
|
1504
|
+
tmpi2=self.up_grade(tmpi2,l_nside*2,axis=1)
|
|
1501
1505
|
|
|
1502
1506
|
l_nside=int(np.sqrt(tmp.shape[1]//12))
|
|
1503
1507
|
nscale=int(np.log(l_nside)/np.log(2))
|
|
@@ -1505,6 +1509,11 @@ class funct(FOC.FoCUS):
|
|
|
1505
1509
|
cmat2={}
|
|
1506
1510
|
for k in range(nscale):
|
|
1507
1511
|
sim=self.backend.bk_abs(self.convol(tmp,axis=1))
|
|
1512
|
+
if image2 is not None:
|
|
1513
|
+
sim=self.backend.bk_real(self.backend.bk_L1(self.convol(tmp,axis=1)*self.backend.bk_conjugate(self.convol(tmpi2,axis=1))))
|
|
1514
|
+
else:
|
|
1515
|
+
sim=self.backend.bk_abs(self.convol(tmp,axis=1))
|
|
1516
|
+
|
|
1508
1517
|
cc=self.backend.bk_reduce_mean(sim[:,:,0]-sim[:,:,2],0)
|
|
1509
1518
|
ss=self.backend.bk_reduce_mean(sim[:,:,1]-sim[:,:,3],0)
|
|
1510
1519
|
for m in range(smooth_scale):
|
|
@@ -1582,6 +1591,8 @@ class funct(FOC.FoCUS):
|
|
|
1582
1591
|
|
|
1583
1592
|
if k<l_nside-1:
|
|
1584
1593
|
tmp=self.ud_grade_2(tmp,axis=1)
|
|
1594
|
+
if image2 is not None:
|
|
1595
|
+
tmpi2=self.ud_grade_2(tmpi2,axis=1)
|
|
1585
1596
|
return cmat,cmat2
|
|
1586
1597
|
|
|
1587
1598
|
def eval(self, image1, image2=None, mask=None, norm=None, Auto=True, calc_var=False,cmat=None,cmat2=None):
|
|
@@ -2410,13 +2421,13 @@ class funct(FOC.FoCUS):
|
|
|
2410
2421
|
"""
|
|
2411
2422
|
@tf.function
|
|
2412
2423
|
"""
|
|
2413
|
-
def eval_comp_fast(self, image1, image2=None,mask=None,norm=None, Auto=True):
|
|
2424
|
+
def eval_comp_fast(self, image1, image2=None,mask=None,norm=None, Auto=True,cmat=None,cmat2=None):
|
|
2414
2425
|
|
|
2415
|
-
res=self.eval(image1, image2=image2,mask=mask,Auto=Auto)
|
|
2426
|
+
res=self.eval(image1, image2=image2,mask=mask,Auto=Auto,cmat=cmat,cmat2=cmat2)
|
|
2416
2427
|
return res.S0,res.P00,res.S1,res.C01,res.C11,res.C10
|
|
2417
2428
|
|
|
2418
|
-
def eval_fast(self, image1, image2=None,mask=None,norm=None, Auto=True):
|
|
2419
|
-
s0,p0,s1,c01,c11,c10=self.eval_comp_fast(image1, image2=image2,mask=mask,Auto=Auto)
|
|
2429
|
+
def eval_fast(self, image1, image2=None,mask=None,norm=None, Auto=True,cmat=None,cmat2=None):
|
|
2430
|
+
s0,p0,s1,c01,c11,c10=self.eval_comp_fast(image1, image2=image2,mask=mask,Auto=Auto,cmat=cmat,cmat2=cmat2)
|
|
2420
2431
|
return scat_cov(s0, p0, c01, c11, s1=s1,c10=c10,backend=self.backend)
|
|
2421
2432
|
|
|
2422
2433
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: foscat
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.16
|
|
4
4
|
Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
|
|
5
5
|
Home-page: https://github.com/jmdelouis/FOSCAT
|
|
6
6
|
Author: Jean-Marc DELOUIS
|
|
@@ -9,6 +9,12 @@ Maintainer: Theo Foulquier
|
|
|
9
9
|
Maintainer-email: theo.foulquier@ifremer.fr
|
|
10
10
|
License: MIT
|
|
11
11
|
Keywords: Scattering transform,Component separation,denoising
|
|
12
|
+
Requires-Dist: imageio
|
|
13
|
+
Requires-Dist: imagecodecs
|
|
14
|
+
Requires-Dist: matplotlib
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Requires-Dist: tensorflow
|
|
17
|
+
Requires-Dist: healpy
|
|
12
18
|
|
|
13
19
|
Utilize the Cross Scattering Transform (described in https://arxiv.org/abs/2207.12527) to synthesize Healpix or 2D data that is suitable for component separation purposes, such as denoising.
|
|
14
20
|
A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|