foscat 3.8.2__tar.gz → 3.9.0__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.
Files changed (36) hide show
  1. {foscat-3.8.2/src/foscat.egg-info → foscat-3.9.0}/PKG-INFO +1 -1
  2. {foscat-3.8.2 → foscat-3.9.0}/pyproject.toml +1 -1
  3. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/BkBase.py +36 -35
  4. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/BkNumpy.py +53 -62
  5. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/BkTensorflow.py +87 -88
  6. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/BkTorch.py +91 -72
  7. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/FoCUS.py +72 -56
  8. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/Synthesis.py +3 -3
  9. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/alm.py +188 -170
  10. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/backend.py +84 -70
  11. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat_cov.py +1849 -2086
  12. foscat-3.9.0/src/foscat/scat_cov2D.py +211 -0
  13. {foscat-3.8.2 → foscat-3.9.0/src/foscat.egg-info}/PKG-INFO +1 -1
  14. foscat-3.8.2/src/foscat/scat_cov2D.py +0 -118
  15. {foscat-3.8.2 → foscat-3.9.0}/LICENSE +0 -0
  16. {foscat-3.8.2 → foscat-3.9.0}/README.md +0 -0
  17. {foscat-3.8.2 → foscat-3.9.0}/setup.cfg +0 -0
  18. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/CNN.py +0 -0
  19. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/CircSpline.py +0 -0
  20. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/GCNN.py +0 -0
  21. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/Softmax.py +0 -0
  22. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/Spline1D.py +0 -0
  23. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/__init__.py +0 -0
  24. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/backend_tens.py +0 -0
  25. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/loss_backend_tens.py +0 -0
  26. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/loss_backend_torch.py +0 -0
  27. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat.py +0 -0
  28. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat1D.py +0 -0
  29. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat2D.py +0 -0
  30. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat_cov1D.py +0 -0
  31. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat_cov_map.py +0 -0
  32. {foscat-3.8.2 → foscat-3.9.0}/src/foscat/scat_cov_map2D.py +0 -0
  33. {foscat-3.8.2 → foscat-3.9.0}/src/foscat.egg-info/SOURCES.txt +0 -0
  34. {foscat-3.8.2 → foscat-3.9.0}/src/foscat.egg-info/dependency_links.txt +0 -0
  35. {foscat-3.8.2 → foscat-3.9.0}/src/foscat.egg-info/requires.txt +0 -0
  36. {foscat-3.8.2 → foscat-3.9.0}/src/foscat.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: foscat
3
- Version: 3.8.2
3
+ Version: 3.9.0
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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "foscat"
3
- version = "3.8.2"
3
+ version = "3.9.0"
4
4
  description = "Generate synthetic Healpix or 2D data using Cross Scattering Transform"
5
5
  readme = "README.md"
6
6
  license = { text = "BSD-3-Clause" }
@@ -1,14 +1,15 @@
1
1
  import numpy as np
2
2
 
3
+
3
4
  class BackendBase:
4
-
5
+
5
6
  def __init__(self, name, mpi_rank=0, all_type="float64", gpupos=0, silent=False):
6
-
7
- self.BACKEND=name
8
- self.mpi_rank=mpi_rank
9
- self.all_type=all_type
10
- self.gpupos=gpupos
11
- self.silent=silent
7
+
8
+ self.BACKEND = name
9
+ self.mpi_rank = mpi_rank
10
+ self.all_type = all_type
11
+ self.gpupos = gpupos
12
+ self.silent = silent
12
13
  # ---------------------------------------------−---------
13
14
  # table use to compute the iso orientation rotation
14
15
  self._iso_orient = {}
@@ -101,6 +102,7 @@ class BackendBase:
101
102
  return self.bk_reshape(
102
103
  self.backend.matmul(self.bk_reshape(x, oshape), lmat), oshape2
103
104
  )
105
+
104
106
  def calc_iso_orient(self, norient):
105
107
  tmp = np.zeros([norient * norient, norient])
106
108
  for i in range(norient):
@@ -188,7 +190,9 @@ class BackendBase:
188
190
  tmp[:, :, k, l_orient] = np.cos(x * k) * np.cos((x.T) * l_orient)
189
191
 
190
192
  self._fft_2_orient[(norient, nharm, imaginary)] = self.bk_cast(
191
- self.bk_constant(tmp.reshape(norient * norient, (1 + nharm) * (1 + nharm)))
193
+ self.bk_constant(
194
+ tmp.reshape(norient * norient, (1 + nharm) * (1 + nharm))
195
+ )
192
196
  )
193
197
  self._fft_2_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
194
198
  self._fft_2_orient[(norient, nharm, imaginary)],
@@ -343,7 +347,7 @@ class BackendBase:
343
347
  self._fft_3_orient[(norient, nharm, imaginary)],
344
348
  0 * self._fft_3_orient[(norient, nharm, imaginary)],
345
349
  )
346
-
350
+
347
351
  # ---------------------------------------------−---------
348
352
  # -- BACKEND DEFINITION --
349
353
  # ---------------------------------------------−---------
@@ -355,7 +359,7 @@ class BackendBase:
355
359
 
356
360
  def bk_sparse_dense_matmul(self, smat, mat):
357
361
  raise NotImplementedError("This is an abstract class.")
358
-
362
+
359
363
  def conv2d(self, x, w, strides=[1, 1, 1, 1], padding="SAME"):
360
364
  raise NotImplementedError("This is an abstract class.")
361
365
 
@@ -379,9 +383,6 @@ class BackendBase:
379
383
 
380
384
  def bk_flattenR(self, x):
381
385
  raise NotImplementedError("This is an abstract class.")
382
-
383
- def bk_flatten(self, x):
384
- raise NotImplementedError("This is an abstract class.")
385
386
 
386
387
  def bk_flatten(self, x):
387
388
  raise NotImplementedError("This is an abstract class.")
@@ -442,7 +443,7 @@ class BackendBase:
442
443
 
443
444
  def bk_tensor(self, data):
444
445
  raise NotImplementedError("This is an abstract class.")
445
-
446
+
446
447
  def bk_shape_tensor(self, shape):
447
448
  raise NotImplementedError("This is an abstract class.")
448
449
 
@@ -460,7 +461,7 @@ class BackendBase:
460
461
 
461
462
  def bk_tanh(self, data):
462
463
  raise NotImplementedError("This is an abstract class.")
463
-
464
+
464
465
  def bk_max(self, data):
465
466
  raise NotImplementedError("This is an abstract class.")
466
467
 
@@ -499,11 +500,11 @@ class BackendBase:
499
500
 
500
501
  def bk_fft(self, data):
501
502
  raise NotImplementedError("This is an abstract class.")
502
-
503
- def bk_fftn(self, data,dim=None):
503
+
504
+ def bk_fftn(self, data, dim=None):
504
505
  raise NotImplementedError("This is an abstract class.")
505
506
 
506
- def bk_ifftn(self, data,dim=None,norm=None):
507
+ def bk_ifftn(self, data, dim=None, norm=None):
507
508
  raise NotImplementedError("This is an abstract class.")
508
509
 
509
510
  def bk_rfft(self, data):
@@ -524,32 +525,32 @@ class BackendBase:
524
525
  def bk_relu(self, x):
525
526
  raise NotImplementedError("This is an abstract class.")
526
527
 
527
- def bk_clip_by_value(self, x,xmin,xmax):
528
+ def bk_clip_by_value(self, x, xmin, xmax):
528
529
  raise NotImplementedError("This is an abstract class.")
529
530
 
530
531
  def bk_cast(self, x):
531
532
  raise NotImplementedError("This is an abstract class.")
532
-
533
- def bk_variable(self,x):
533
+
534
+ def bk_variable(self, x):
534
535
  raise NotImplementedError("This is an abstract class.")
535
-
536
- def bk_assign(self,x,y):
536
+
537
+ def bk_assign(self, x, y):
537
538
  raise NotImplementedError("This is an abstract class.")
538
-
539
- def bk_constant(self,x):
539
+
540
+ def bk_constant(self, x):
540
541
  raise NotImplementedError("This is an abstract class.")
541
-
542
- def bk_cos(self,x):
542
+
543
+ def bk_cos(self, x):
543
544
  raise NotImplementedError("This is an abstract class.")
544
-
545
- def bk_sin(self,x):
545
+
546
+ def bk_sin(self, x):
546
547
  raise NotImplementedError("This is an abstract class.")
547
-
548
- def bk_arctan2(self,c,s):
548
+
549
+ def bk_arctan2(self, c, s):
549
550
  raise NotImplementedError("This is an abstract class.")
550
-
551
- def bk_empty(self,list):
551
+
552
+ def bk_empty(self, list):
552
553
  raise NotImplementedError("This is an abstract class.")
553
-
554
- def to_numpy(self,x):
554
+
555
+ def to_numpy(self, x):
555
556
  raise NotImplementedError("This is an abstract class.")
@@ -1,11 +1,13 @@
1
- import foscat.BkBase as BackendBase
2
1
  import numpy as np
3
2
 
3
+ import foscat.BkBase as BackendBase
4
+
5
+
4
6
  class BkNumpy(BackendBase.BackendBase):
5
-
7
+
6
8
  def __init__(self, *args, **kwargs):
7
9
  # Impose que use_2D=True pour la classe scat
8
- super().__init__(name='tensorflow', *args, **kwargs)
10
+ super().__init__(name="tensorflow", *args, **kwargs)
9
11
 
10
12
  # ===========================================================================
11
13
  # INIT
@@ -31,13 +33,14 @@ class BkNumpy(BackendBase.BackendBase):
31
33
  self.all_bk_type = self.backend.float64
32
34
  self.all_cbk_type = self.backend.complex128
33
35
  else:
34
- print("ERROR INIT FOCUS ", all_type, " should be float32 or float64")
36
+ print(
37
+ "ERROR INIT FOCUS ", self.all_type, " should be float32 or float64"
38
+ )
35
39
  return None
36
-
40
+
37
41
  # ===========================================================================
38
42
  # INIT
39
43
 
40
- gpus = []
41
44
  gpuname = "CPU:0"
42
45
  self.gpulist = {}
43
46
  self.gpulist[0] = gpuname
@@ -49,27 +52,25 @@ class BkNumpy(BackendBase.BackendBase):
49
52
  def bk_SparseTensor(self, indice, w, dense_shape=[]):
50
53
  return self.scipy.sparse.coo_matrix(
51
54
  (w, (indice[:, 0], indice[:, 1])), shape=dense_shape
52
- )
55
+ )
53
56
 
54
57
  def bk_stack(self, list, axis=0):
55
58
  return self.backend.stack(list, axis=axis)
56
59
 
57
60
  def bk_sparse_dense_matmul(self, smat, mat):
58
61
  return smat.dot(mat)
59
-
62
+
60
63
  def conv2d(self, x, w, strides=[1, 1, 1, 1], padding="SAME"):
61
- res = np.zeros(
62
- [x.shape[0], x.shape[1], x.shape[2], w.shape[3]], dtype=x.dtype
63
- )
64
+ res = np.zeros([x.shape[0], x.shape[1], x.shape[2], w.shape[3]], dtype=x.dtype)
64
65
  for k in range(w.shape[2]):
65
66
  for l_orient in range(w.shape[3]):
66
67
  for j in range(res.shape[0]):
67
68
  tmp = self.scipy.signal.convolve2d(
68
- x[j, :, :, k],
69
- w[:, :, k, l_orient],
70
- mode="same",
71
- boundary="symm",
72
- )
69
+ x[j, :, :, k],
70
+ w[:, :, k, l_orient],
71
+ mode="same",
72
+ boundary="symm",
73
+ )
73
74
  res[j, :, :, l_orient] += tmp
74
75
  del tmp
75
76
  return res
@@ -79,8 +80,8 @@ class BkNumpy(BackendBase.BackendBase):
79
80
  for k in range(w.shape[2]):
80
81
  for j in range(res.shape[0]):
81
82
  tmp = self.scipy.signal.convolve1d(
82
- x[j, :, k], w[:, k], mode="same", boundary="symm"
83
- )
83
+ x[j, :, k], w[:, k], mode="same", boundary="symm"
84
+ )
84
85
  res[j, :, :] += tmp
85
86
  del tmp
86
87
  return res
@@ -114,10 +115,6 @@ class BkNumpy(BackendBase.BackendBase):
114
115
  return np.concatenate([x.real.flatten(), x.imag.flatten()], 0)
115
116
  else:
116
117
  return x.flatten()
117
-
118
-
119
- def bk_flatten(self, x):
120
- return x.flatten()
121
118
 
122
119
  def bk_flatten(self, x):
123
120
  return x.flatten()
@@ -144,10 +141,6 @@ class BkNumpy(BackendBase.BackendBase):
144
141
  # ---------------------------------------------−---------
145
142
  # return a tensor size
146
143
 
147
- def bk_size(self, data):
148
- return data.size
149
-
150
-
151
144
  def bk_reduce_mean(self, data, axis=None):
152
145
 
153
146
  if axis is None:
@@ -223,7 +216,7 @@ class BkNumpy(BackendBase.BackendBase):
223
216
 
224
217
  def bk_tensor(self, data):
225
218
  return data
226
-
219
+
227
220
  def bk_shape_tensor(self, shape):
228
221
  return np.zeros(shape)
229
222
 
@@ -284,28 +277,27 @@ class BkNumpy(BackendBase.BackendBase):
284
277
  def bk_zeros(self, shape, dtype=None):
285
278
  return np.zeros(shape, dtype=dtype)
286
279
 
287
- def bk_gather(self, data, idx,axis=0):
288
- if axis==0:
280
+ def bk_gather(self, data, idx, axis=0):
281
+ if axis == 0:
289
282
  return data[idx]
290
- elif axis==1:
291
- return data[:,idx]
292
- elif axis==2:
293
- return data[:,:,idx]
294
- elif axis==3:
295
- return data[:,:,:,idx]
296
- return data[:,:,:,:,idx]
297
-
283
+ elif axis == 1:
284
+ return data[:, idx]
285
+ elif axis == 2:
286
+ return data[:, :, idx]
287
+ elif axis == 3:
288
+ return data[:, :, :, idx]
289
+ return data[:, :, :, :, idx]
298
290
 
299
291
  def bk_reverse(self, data, axis=0):
300
292
  return np.reverse(data, axis=axis)
301
293
 
302
294
  def bk_fft(self, data):
303
295
  return self.backend.fft.fft(data)
304
-
305
- def bk_fftn(self, data,dim=None):
296
+
297
+ def bk_fftn(self, data, dim=None):
306
298
  return self.backend.fft.fftn(data)
307
299
 
308
- def bk_ifftn(self, data,dim=None,norm=None):
300
+ def bk_ifftn(self, data, dim=None, norm=None):
309
301
  return self.backend.fft.ifftn(data)
310
302
 
311
303
  def bk_rfft(self, data):
@@ -327,8 +319,8 @@ class BkNumpy(BackendBase.BackendBase):
327
319
  def bk_relu(self, x):
328
320
  return (x > 0) * x
329
321
 
330
- def bk_clip_by_value(self, x,xmin,xmax):
331
- return self.backend.clip(x,xmin,xmax)
322
+ def bk_clip_by_value(self, x, xmin, xmax):
323
+ return self.backend.clip(x, xmin, xmax)
332
324
 
333
325
  def bk_cast(self, x):
334
326
  if isinstance(x, np.float64):
@@ -364,29 +356,28 @@ class BkNumpy(BackendBase.BackendBase):
364
356
  out_type = self.all_bk_type
365
357
 
366
358
  return x.astype(out_type)
367
-
368
- def bk_variable(self,x):
369
-
359
+
360
+ def bk_variable(self, x):
361
+
370
362
  return self.bk_cast(x)
371
-
372
- def bk_assign(self,x,y):
373
- x=y
374
-
375
- def bk_constant(self,x):
376
-
363
+
364
+ def bk_assign(self, x, y):
365
+ return y
366
+
367
+ def bk_constant(self, x):
377
368
  return self.bk_cast(x)
378
-
379
- def bk_cos(self,x):
369
+
370
+ def bk_cos(self, x):
380
371
  return self.backend.cos(x)
381
-
382
- def bk_sin(self,x):
372
+
373
+ def bk_sin(self, x):
383
374
  return self.backend.sin(x)
384
-
385
- def bk_arctan2(self,c,s):
386
- return self.backend.arctan2(c,s)
387
-
388
- def bk_empty(self,list):
375
+
376
+ def bk_arctan2(self, c, s):
377
+ return self.backend.arctan2(c, s)
378
+
379
+ def bk_empty(self, list):
389
380
  return self.backend.empty(list)
390
-
391
- def to_numpy(self,x):
381
+
382
+ def to_numpy(self, x):
392
383
  return x