foscat 3.0.30__tar.gz → 3.0.31__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.30 → foscat-3.0.31}/PKG-INFO +1 -1
- {foscat-3.0.30 → foscat-3.0.31}/setup.py +1 -1
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/FoCUS.py +58 -14
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat.egg-info/PKG-INFO +1 -1
- {foscat-3.0.30 → foscat-3.0.31}/README.md +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/setup.cfg +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/CNN.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/CircSpline.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/GCNN.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/GetGPUinfo.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/Softmax.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/Spline1D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/Synthesis.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/__init__.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/backend.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/backend_tens.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/loss_backend_tens.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/loss_backend_torch.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat1D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat2D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat_cov.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat_cov1D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat_cov2D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat_cov_map.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat/scat_cov_map2D.py +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat.egg-info/SOURCES.txt +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat.egg-info/dependency_links.txt +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat.egg-info/requires.txt +0 -0
- {foscat-3.0.30 → foscat-3.0.31}/src/foscat.egg-info/top_level.txt +0 -0
|
@@ -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.31',
|
|
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',
|
|
@@ -32,7 +32,7 @@ class FoCUS:
|
|
|
32
32
|
mpi_size=1,
|
|
33
33
|
mpi_rank=0):
|
|
34
34
|
|
|
35
|
-
self.__version__ = '3.0.
|
|
35
|
+
self.__version__ = '3.0.31'
|
|
36
36
|
# P00 coeff for normalization for scat_cov
|
|
37
37
|
self.TMPFILE_VERSION=TMPFILE_VERSION
|
|
38
38
|
self.P1_dic = None
|
|
@@ -323,7 +323,7 @@ class FoCUS:
|
|
|
323
323
|
# ---------------------------------------------−---------
|
|
324
324
|
# make the CNN working : index reporjection of the kernel on healpix
|
|
325
325
|
|
|
326
|
-
def calc_indices_convol(self,nside,kernel):
|
|
326
|
+
def calc_indices_convol(self,nside,kernel,rotation=None):
|
|
327
327
|
to,po=hp.pix2ang(nside,np.arange(12*nside*nside),nest=True)
|
|
328
328
|
x,y,z=hp.pix2vec(nside,np.arange(12*nside*nside),nest=True)
|
|
329
329
|
|
|
@@ -346,7 +346,10 @@ class FoCUS:
|
|
|
346
346
|
print('Nside=%d KenelSZ=%d %.2f%%'%(nside,kernel,k/(12*nside**2)*100))
|
|
347
347
|
idx2=hp.query_disc(nside, vec[k], np.pi/nside, inclusive=True,nest=True)
|
|
348
348
|
t2,p2=hp.pix2ang(nside,idx2,nest=True)
|
|
349
|
-
|
|
349
|
+
if rotation is None:
|
|
350
|
+
rot=[po[k]/np.pi*180.0,90+(-to[k])/np.pi*180.0]
|
|
351
|
+
else:
|
|
352
|
+
rot=[po[k]/np.pi*180.0,90+(-to[k])/np.pi*180.0,rotation[k]]
|
|
350
353
|
r=hp.Rotator(rot=rot)
|
|
351
354
|
t2,p2=r(t2,p2)
|
|
352
355
|
idx3=hp.ang2pix(nside,t2,p2,nest=True)
|
|
@@ -364,12 +367,46 @@ class FoCUS:
|
|
|
364
367
|
|
|
365
368
|
indices=indices[0:nn]
|
|
366
369
|
weights=weights[0:nn]
|
|
367
|
-
|
|
370
|
+
if k%(nside*nside)==nside*nside-1:
|
|
371
|
+
print('Nside=%d KenelSZ=%d Total Number of value=%d Ratio of the matrix %.2g%%'%(nside,
|
|
368
372
|
kernel,
|
|
369
373
|
nn,
|
|
370
374
|
100*nn/(kernel*12*nside**2*12*nside**2)))
|
|
371
375
|
return indices,weights,xc,yc,zc
|
|
372
376
|
|
|
377
|
+
# ---------------------------------------------−---------
|
|
378
|
+
def calc_orientation(self,im): # im is [Ndata,12*Nside**2]
|
|
379
|
+
nside=int(np.sqrt(im.shape[1]//12))
|
|
380
|
+
l_kernel=self.KERNELSZ*self.KERNELSZ
|
|
381
|
+
norient=32
|
|
382
|
+
w=np.zeros([l_kernel,1,2*norient])
|
|
383
|
+
ca=np.cos(np.arange(norient)/norient*np.pi)
|
|
384
|
+
sa=np.sin(np.arange(norient)/norient*np.pi)
|
|
385
|
+
stat=np.zeros([12*nside**2,norient])
|
|
386
|
+
|
|
387
|
+
if self.ww_CNN[nside] is None:
|
|
388
|
+
self.init_CNN_index(nside,transpose=False)
|
|
389
|
+
|
|
390
|
+
y=self.Y_CNN[nside]
|
|
391
|
+
z=self.Z_CNN[nside]
|
|
392
|
+
|
|
393
|
+
for k in range(norient):
|
|
394
|
+
w[:,0,k]=(np.exp(-0.5*nside**2*((y)**2+(z)**2))*np.cos(nside*(y*ca[k]+z*sa[k])*np.pi/2))
|
|
395
|
+
w[:,0,k+norient]=(np.exp(-0.5*nside**2*((y)**2+(z)**2))*np.sin(nside*(y*ca[k]+z*sa[k])*np.pi/2))
|
|
396
|
+
w[:,0,k]=w[:,0,k]-np.mean(w[:,0,k])
|
|
397
|
+
w[:,0,k+norient]=w[:,0,k]-np.mean(w[:,0,k+norient])
|
|
398
|
+
|
|
399
|
+
for k in range(im.shape[0]):
|
|
400
|
+
tmp=im[k].reshape(12*nside**2,1)
|
|
401
|
+
im2=self.healpix_layer(tmp,w)
|
|
402
|
+
stat=stat+im2[:,0:norient]**2+im2[:,norient:]**2
|
|
403
|
+
|
|
404
|
+
rotation=(np.argmax(stat,1)).astype('float')/32.*180.0
|
|
405
|
+
|
|
406
|
+
indices,weights,x,y,z=self.calc_indices_convol(nside,9,rotation=rotation)
|
|
407
|
+
|
|
408
|
+
return indices,weights
|
|
409
|
+
|
|
373
410
|
def init_CNN_index(self,nside,transpose=False):
|
|
374
411
|
l_kernel=int(self.KERNELSZ*self.KERNELSZ)
|
|
375
412
|
try:
|
|
@@ -391,7 +428,6 @@ class FoCUS:
|
|
|
391
428
|
self.X_CNN[nside]=xc
|
|
392
429
|
self.Y_CNN[nside]=yc
|
|
393
430
|
self.Z_CNN[nside]=zc
|
|
394
|
-
print(weights.min(),weights.max())
|
|
395
431
|
self.ww_CNN[nside]=self.backend.bk_SparseTensor(indices,
|
|
396
432
|
weights,[12*nside*nside*l_kernel,
|
|
397
433
|
12*nside*nside])
|
|
@@ -403,9 +439,9 @@ class FoCUS:
|
|
|
403
439
|
if self.ww_CNN[nside] is None:
|
|
404
440
|
self.init_CNN_index(nside)
|
|
405
441
|
return self.X_CNN[nside],self.Y_CNN[nside],self.Z_CNN[nside]
|
|
406
|
-
|
|
442
|
+
|
|
407
443
|
# ---------------------------------------------−---------
|
|
408
|
-
def healpix_layer_transpose(self,im,ww):
|
|
444
|
+
def healpix_layer_transpose(self,im,ww,indices=None,weights=None):
|
|
409
445
|
nside=int(np.sqrt(im.shape[0]//12))
|
|
410
446
|
l_kernel=self.KERNELSZ*self.KERNELSZ
|
|
411
447
|
|
|
@@ -413,13 +449,13 @@ class FoCUS:
|
|
|
413
449
|
if not self.silent:
|
|
414
450
|
print('Weights channels should be equal to the input image channels')
|
|
415
451
|
return -1
|
|
416
|
-
tmp=self.healpix_layer(im,ww)
|
|
452
|
+
tmp=self.healpix_layer(im,ww,indices=indices,weights=weights)
|
|
417
453
|
|
|
418
454
|
return self.up_grade(tmp,2*nside)
|
|
419
455
|
|
|
420
456
|
# ---------------------------------------------−---------
|
|
421
457
|
# ---------------------------------------------−---------
|
|
422
|
-
def healpix_layer(self,im,ww):
|
|
458
|
+
def healpix_layer(self,im,ww,indices=None,weights=None):
|
|
423
459
|
nside=int(np.sqrt(im.shape[0]//12))
|
|
424
460
|
l_kernel=self.KERNELSZ*self.KERNELSZ
|
|
425
461
|
|
|
@@ -427,12 +463,20 @@ class FoCUS:
|
|
|
427
463
|
if not self.silent:
|
|
428
464
|
print('Weights channels should be equal to the input image channels')
|
|
429
465
|
return -1
|
|
430
|
-
|
|
431
|
-
if
|
|
432
|
-
self.
|
|
466
|
+
|
|
467
|
+
if indices is None:
|
|
468
|
+
if self.ww_CNN[nside] is None:
|
|
469
|
+
self.init_CNN_index(nside,transpose=False)
|
|
470
|
+
mat=self.ww_CNN[nside]
|
|
471
|
+
else:
|
|
472
|
+
if weights is None:
|
|
473
|
+
print('healpix_layer : If indices is not none weights should be specify')
|
|
474
|
+
return 0
|
|
433
475
|
|
|
434
|
-
|
|
435
|
-
|
|
476
|
+
mat=self.backend.bk_SparseTensor(indices,weights,[12*nside*nside*l_kernel,12*nside*nside])
|
|
477
|
+
|
|
478
|
+
tmp=self.backend.bk_sparse_dense_matmul(mat,im)
|
|
479
|
+
|
|
436
480
|
density=self.backend.bk_reshape(tmp,[12*nside*nside,l_kernel*im.shape[1]])
|
|
437
481
|
|
|
438
482
|
return self.backend.bk_matmul(density,self.backend.bk_reshape(ww,[l_kernel*im.shape[1],ww.shape[2]]))
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|