foscat 3.1.6__tar.gz → 3.2.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 (54) hide show
  1. foscat-3.2.0/LICENCE +13 -0
  2. foscat-3.2.0/PKG-INFO +174 -0
  3. foscat-3.2.0/README.md +143 -0
  4. foscat-3.2.0/pyproject.toml +90 -0
  5. foscat-3.2.0/setup.cfg +4 -0
  6. foscat-3.2.0/setup.py +25 -0
  7. foscat-3.2.0/src/foscat/CNN.py +151 -0
  8. {foscat-3.1.6 → foscat-3.2.0}/src/foscat/CircSpline.py +6 -3
  9. foscat-3.2.0/src/foscat/FoCUS.py +2706 -0
  10. foscat-3.2.0/src/foscat/GCNN.py +239 -0
  11. {foscat-3.1.6 → foscat-3.2.0}/src/foscat/Softmax.py +27 -22
  12. {foscat-3.1.6 → foscat-3.2.0}/src/foscat/Spline1D.py +8 -4
  13. foscat-3.2.0/src/foscat/Synthesis.py +441 -0
  14. foscat-3.2.0/src/foscat/backend.py +1005 -0
  15. foscat-3.2.0/src/foscat/backend_tens.py +62 -0
  16. foscat-3.2.0/src/foscat/loss_backend_tens.py +70 -0
  17. foscat-3.2.0/src/foscat/loss_backend_torch.py +59 -0
  18. foscat-3.2.0/src/foscat/scat.py +2021 -0
  19. foscat-3.2.0/src/foscat/scat1D.py +1537 -0
  20. foscat-3.2.0/src/foscat/scat2D.py +17 -0
  21. foscat-3.2.0/src/foscat/scat_cov.py +3732 -0
  22. foscat-3.2.0/src/foscat/scat_cov1D.py +18 -0
  23. foscat-3.2.0/src/foscat/scat_cov2D.py +18 -0
  24. foscat-3.2.0/src/foscat/scat_cov_map.py +93 -0
  25. foscat-3.2.0/src/foscat/scat_cov_map2D.py +94 -0
  26. foscat-3.2.0/src/foscat.egg-info/PKG-INFO +174 -0
  27. {foscat-3.1.6 → foscat-3.2.0}/src/foscat.egg-info/SOURCES.txt +2 -2
  28. foscat-3.1.6/PKG-INFO +0 -23
  29. foscat-3.1.6/README.md +0 -61
  30. foscat-3.1.6/setup.cfg +0 -8
  31. foscat-3.1.6/setup.py +0 -27
  32. foscat-3.1.6/src/foscat/CNN.py +0 -112
  33. foscat-3.1.6/src/foscat/FoCUS.py +0 -1990
  34. foscat-3.1.6/src/foscat/GCNN.py +0 -172
  35. foscat-3.1.6/src/foscat/GetGPUinfo.py +0 -36
  36. foscat-3.1.6/src/foscat/Synthesis.py +0 -386
  37. foscat-3.1.6/src/foscat/backend.py +0 -851
  38. foscat-3.1.6/src/foscat/backend_tens.py +0 -49
  39. foscat-3.1.6/src/foscat/loss_backend_tens.py +0 -60
  40. foscat-3.1.6/src/foscat/loss_backend_torch.py +0 -84
  41. foscat-3.1.6/src/foscat/scat.py +0 -1450
  42. foscat-3.1.6/src/foscat/scat1D.py +0 -1130
  43. foscat-3.1.6/src/foscat/scat2D.py +0 -15
  44. foscat-3.1.6/src/foscat/scat_cov.py +0 -2693
  45. foscat-3.1.6/src/foscat/scat_cov1D.py +0 -16
  46. foscat-3.1.6/src/foscat/scat_cov2D.py +0 -16
  47. foscat-3.1.6/src/foscat/scat_cov_map.py +0 -67
  48. foscat-3.1.6/src/foscat/scat_cov_map2D.py +0 -64
  49. foscat-3.1.6/src/foscat.egg-info/PKG-INFO +0 -23
  50. {foscat-3.1.6 → foscat-3.2.0}/src/foscat/__init__.py +0 -0
  51. {foscat-3.1.6 → foscat-3.2.0}/src/foscat/scat_cov1D.old.py +0 -0
  52. {foscat-3.1.6 → foscat-3.2.0}/src/foscat.egg-info/dependency_links.txt +0 -0
  53. {foscat-3.1.6 → foscat-3.2.0}/src/foscat.egg-info/requires.txt +0 -0
  54. {foscat-3.1.6 → foscat-3.2.0}/src/foscat.egg-info/top_level.txt +0 -0
foscat-3.2.0/LICENCE ADDED
@@ -0,0 +1,13 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, the Foscat developers All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+
9
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+
11
+ Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
foscat-3.2.0/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.1
2
+ Name: foscat
3
+ Version: 3.2.0
4
+ Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
5
+ Home-page: https://github.com/jmdelouis/FOSCAT
6
+ Author: Jean-Marc DELOUIS
7
+ Author-email: Jean-Marc DELOUIS <jean.marc.delouis@ifremer.fr>
8
+ Maintainer: Theo Foulquier
9
+ Maintainer-email: Theo Foulquier <theo.foulquier@ifremer.fr>
10
+ License: BSD-3-Clause
11
+ Project-URL: Repository, https://github.com/jmdelouis/FOSCAT.git
12
+ Project-URL: Issues, https://github.com/jmdelouis/FOSCAT/issues
13
+ Project-URL: Documentation, https://foscat-documentation.readthedocs.io/en/latest/index.html
14
+ Keywords: scattering transform,component separation,denoising
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENCE
25
+ Requires-Dist: imageio
26
+ Requires-Dist: imagecodecs
27
+ Requires-Dist: matplotlib
28
+ Requires-Dist: numpy
29
+ Requires-Dist: tensorflow
30
+ Requires-Dist: healpy
31
+
32
+ # foscat
33
+
34
+ [![Read the Docs](https://readthedocs.org/projects/foscat-documentation/badge/?version=latest)](https://foscat-documentation.readthedocs.io/en/latest)
35
+
36
+ A python package dedicated to image component separation based on scattering transform analysis designed for high performance computing.
37
+
38
+ ## the concept
39
+
40
+ The foscat genesis has been built to synthesise data (2D or Healpix) using Cross Scattering Transform. For a detailed method description please refer to https://arxiv.org/abs/2207.12527. This algorithm could be effectively usable for component separation (e.g. denoising).
41
+
42
+ A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO.
43
+
44
+ ## usage
45
+
46
+ # Short tutorial
47
+
48
+ https://github.com/IAOCEA/demo-foscat-pangeo-eosc/blob/main/Demo_Synthesis.ipynb
49
+
50
+ # FOSCAT_DEMO
51
+
52
+ The python scripts *demo.py* included in this package demonstrate how to use the foscat library to generate synthetic fields that have patterns with the same statistical properties as a specified image.
53
+
54
+ # Install foscat library
55
+
56
+ Before installing, make sure you have python installed in your enviroment.
57
+ The last version of the foscat library can be installed using PyPi:
58
+ ```
59
+ pip install foscat
60
+ ```
61
+ Load the FOSCAT_DEMO package from github.
62
+ ```
63
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
64
+ ```
65
+
66
+
67
+ ## Recommended installing procedures for mac users
68
+ It is recomended to use python=3.9*.
69
+ ```
70
+ micromamba create -n FOSCAT
71
+ micromamba install -n FOSCAT ‘python==3.9*’
72
+ micromamba activate FOSCAT
73
+ pip install foscat
74
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
75
+
76
+ ```
77
+
78
+ ## Recommended installing procedures HPC users
79
+ It is recomended to install tensorflow in advance. For [DATARMOR](https://pcdm.ifremer.fr/Equipement) for using GPU ;
80
+
81
+ ```
82
+ micromamba create -n FOSCAT
83
+ micromamba install -n FOSCAT ‘python==3.9*’
84
+ micromamba install -n FOSCAT ‘tensorflow==2.11.0’
85
+ micromamba activate FOSCAT
86
+ pip install foscat
87
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
88
+
89
+ ```
90
+
91
+ # Spherical data example
92
+
93
+ ## compute a synthetic image
94
+ ```
95
+ python demo.py -n=32 -k -c -s=100
96
+ ```
97
+ The *demo.py* script serves as a demonstration of the capabilities of the foscat library. It utilizes the Cross Wavelet Scattering Transform to generate a Healpix map that possesses the same characteristics as a specified input map.
98
+ - ```-n=32``` computes map with nside=32.
99
+ - ```-k``` uses 5x5 kernel.
100
+ - ```-c``` uses Scattering Covariance.
101
+ - ```-l``` uses LBFGS minimizer.
102
+ - ```-s=100``` computes 100 steps.
103
+ ```
104
+ python demo.py -n=8 [-c|--cov][-s|--steps=3000][-S=1234|--seed=1234][-k|--k5x5][-d|--data][-o|--out][-r|--orient] [-p|--path][-a|--adam]
105
+
106
+ ```
107
+ * The "-n" option specifies the nside of the input map. The maximum nside value is 256 with the default map.
108
+ * The "--cov" option (optional) uses scat_cov instead of scat.
109
+ * The "--steps" option (optional) specifies the number of iterations. If not specified, the default value is 1000.
110
+ * The "--seed" option (optional) specifies the seed of the random generator.
111
+ * The "--path" option (optional) allows you to define the path where the output files will be written. The default path is "data".
112
+ * The "--k5x5" option (optional) uses a 5x5 kernel instead of a 3x3.
113
+ * The "--data" option (optional) specifies the input data file to be used. If not specified, the default file "LSS_map_nside128.npy" will be used.
114
+ * The "--out" option (optional) specifies the output file name. If not specified, the output file will be saved in "demo".
115
+ * The "--orient" option (optional) specifies the number of orientations. If not specified, the default value is 4.
116
+ * The "--adam" option (optional) makes the synthesis using the ADAM optimizer instead of the L_BFGS.
117
+
118
+ ## plot the result
119
+
120
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo.py* script.
121
+
122
+ > python test2D.py
123
+
124
+ ```
125
+ python plotdemo.py -n=32 -c
126
+ ```
127
+
128
+ # 2D field demo
129
+
130
+ > python test2Dplot.py
131
+
132
+ # compute a synthetic turbulent field
133
+
134
+ The python scripts *demo2D.py* included in this package demonstrate how to use the foscat library to generate a 2D synthetic fields that have patterns with the same statistical properties as a specified 2D image. In this particular case, the input field is a sea surface temperature extracted from a north atlantic ocean simulation.
135
+
136
+ > python testHealpix.py
137
+
138
+ ```
139
+ python demo2d.py -n=32 -k -c
140
+ ```
141
+
142
+ > python testHplot.py
143
+
144
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo2D.py* script.
145
+ ```
146
+ python plotdemo2d.py -n=32 -c
147
+ ```
148
+ For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
149
+
150
+ > mpirun -np 3 testHealpix_mpi.py
151
+
152
+ ## Authors and acknowledgment
153
+
154
+ Authors: J.-M. Delouis, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
155
+
156
+ This work is part of the R & T Deepsee project supported by CNES. The authors acknowledge the heritage of the Planck-HFI consortium regarding data, software, knowledge. This work has been supported by the Programme National de Télédétection Spatiale (PNTS, http://programmes.insu.cnrs.fr/pnts/), grant n◦ PNTS-2020-08
157
+
158
+ ## License
159
+
160
+ BSD 3-Clause License
161
+
162
+ Copyright (c) 2022, the Foscat developers All rights reserved.
163
+
164
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
165
+
166
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
167
+
168
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
169
+
170
+ Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
171
+
172
+ ## Project status
173
+
174
+ It is a scientific driven development. We are open to any contributing development.
foscat-3.2.0/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # foscat
2
+
3
+ [![Read the Docs](https://readthedocs.org/projects/foscat-documentation/badge/?version=latest)](https://foscat-documentation.readthedocs.io/en/latest)
4
+
5
+ A python package dedicated to image component separation based on scattering transform analysis designed for high performance computing.
6
+
7
+ ## the concept
8
+
9
+ The foscat genesis has been built to synthesise data (2D or Healpix) using Cross Scattering Transform. For a detailed method description please refer to https://arxiv.org/abs/2207.12527. This algorithm could be effectively usable for component separation (e.g. denoising).
10
+
11
+ A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO.
12
+
13
+ ## usage
14
+
15
+ # Short tutorial
16
+
17
+ https://github.com/IAOCEA/demo-foscat-pangeo-eosc/blob/main/Demo_Synthesis.ipynb
18
+
19
+ # FOSCAT_DEMO
20
+
21
+ The python scripts *demo.py* included in this package demonstrate how to use the foscat library to generate synthetic fields that have patterns with the same statistical properties as a specified image.
22
+
23
+ # Install foscat library
24
+
25
+ Before installing, make sure you have python installed in your enviroment.
26
+ The last version of the foscat library can be installed using PyPi:
27
+ ```
28
+ pip install foscat
29
+ ```
30
+ Load the FOSCAT_DEMO package from github.
31
+ ```
32
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
33
+ ```
34
+
35
+
36
+ ## Recommended installing procedures for mac users
37
+ It is recomended to use python=3.9*.
38
+ ```
39
+ micromamba create -n FOSCAT
40
+ micromamba install -n FOSCAT ‘python==3.9*’
41
+ micromamba activate FOSCAT
42
+ pip install foscat
43
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
44
+
45
+ ```
46
+
47
+ ## Recommended installing procedures HPC users
48
+ It is recomended to install tensorflow in advance. For [DATARMOR](https://pcdm.ifremer.fr/Equipement) for using GPU ;
49
+
50
+ ```
51
+ micromamba create -n FOSCAT
52
+ micromamba install -n FOSCAT ‘python==3.9*’
53
+ micromamba install -n FOSCAT ‘tensorflow==2.11.0’
54
+ micromamba activate FOSCAT
55
+ pip install foscat
56
+ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
57
+
58
+ ```
59
+
60
+ # Spherical data example
61
+
62
+ ## compute a synthetic image
63
+ ```
64
+ python demo.py -n=32 -k -c -s=100
65
+ ```
66
+ The *demo.py* script serves as a demonstration of the capabilities of the foscat library. It utilizes the Cross Wavelet Scattering Transform to generate a Healpix map that possesses the same characteristics as a specified input map.
67
+ - ```-n=32``` computes map with nside=32.
68
+ - ```-k``` uses 5x5 kernel.
69
+ - ```-c``` uses Scattering Covariance.
70
+ - ```-l``` uses LBFGS minimizer.
71
+ - ```-s=100``` computes 100 steps.
72
+ ```
73
+ python demo.py -n=8 [-c|--cov][-s|--steps=3000][-S=1234|--seed=1234][-k|--k5x5][-d|--data][-o|--out][-r|--orient] [-p|--path][-a|--adam]
74
+
75
+ ```
76
+ * The "-n" option specifies the nside of the input map. The maximum nside value is 256 with the default map.
77
+ * The "--cov" option (optional) uses scat_cov instead of scat.
78
+ * The "--steps" option (optional) specifies the number of iterations. If not specified, the default value is 1000.
79
+ * The "--seed" option (optional) specifies the seed of the random generator.
80
+ * The "--path" option (optional) allows you to define the path where the output files will be written. The default path is "data".
81
+ * The "--k5x5" option (optional) uses a 5x5 kernel instead of a 3x3.
82
+ * The "--data" option (optional) specifies the input data file to be used. If not specified, the default file "LSS_map_nside128.npy" will be used.
83
+ * The "--out" option (optional) specifies the output file name. If not specified, the output file will be saved in "demo".
84
+ * The "--orient" option (optional) specifies the number of orientations. If not specified, the default value is 4.
85
+ * The "--adam" option (optional) makes the synthesis using the ADAM optimizer instead of the L_BFGS.
86
+
87
+ ## plot the result
88
+
89
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo.py* script.
90
+
91
+ > python test2D.py
92
+
93
+ ```
94
+ python plotdemo.py -n=32 -c
95
+ ```
96
+
97
+ # 2D field demo
98
+
99
+ > python test2Dplot.py
100
+
101
+ # compute a synthetic turbulent field
102
+
103
+ The python scripts *demo2D.py* included in this package demonstrate how to use the foscat library to generate a 2D synthetic fields that have patterns with the same statistical properties as a specified 2D image. In this particular case, the input field is a sea surface temperature extracted from a north atlantic ocean simulation.
104
+
105
+ > python testHealpix.py
106
+
107
+ ```
108
+ python demo2d.py -n=32 -k -c
109
+ ```
110
+
111
+ > python testHplot.py
112
+
113
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo2D.py* script.
114
+ ```
115
+ python plotdemo2d.py -n=32 -c
116
+ ```
117
+ For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
118
+
119
+ > mpirun -np 3 testHealpix_mpi.py
120
+
121
+ ## Authors and acknowledgment
122
+
123
+ Authors: J.-M. Delouis, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
124
+
125
+ This work is part of the R & T Deepsee project supported by CNES. The authors acknowledge the heritage of the Planck-HFI consortium regarding data, software, knowledge. This work has been supported by the Programme National de Télédétection Spatiale (PNTS, http://programmes.insu.cnrs.fr/pnts/), grant n◦ PNTS-2020-08
126
+
127
+ ## License
128
+
129
+ BSD 3-Clause License
130
+
131
+ Copyright (c) 2022, the Foscat developers All rights reserved.
132
+
133
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
134
+
135
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
136
+
137
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
138
+
139
+ Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
140
+
141
+ ## Project status
142
+
143
+ It is a scientific driven development. We are open to any contributing development.
@@ -0,0 +1,90 @@
1
+ [project]
2
+ name = "foscat"
3
+ version = "3.2.0"
4
+ description = "Generate synthetic Healpix or 2D data using Cross Scattering Transform"
5
+ readme = "README.md"
6
+ license = {text = "BSD-3-Clause"}
7
+ authors = [
8
+ {name = "Jean-Marc DELOUIS", email = "jean.marc.delouis@ifremer.fr"},
9
+ ]
10
+ maintainers = [
11
+ {name = "Theo Foulquier", email = "theo.foulquier@ifremer.fr"},
12
+ ]
13
+ dependencies = [
14
+ "imageio",
15
+ "imagecodecs",
16
+ "matplotlib",
17
+ "numpy",
18
+ "tensorflow",
19
+ "healpy",
20
+ ]
21
+ requires-python = ">= 3.9"
22
+ keywords = ["scattering transform", "component separation", "denoising"]
23
+ classifiers = [
24
+ "Intended Audience :: Science/Research",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ ]
32
+
33
+ [project.urls]
34
+ Repository = "https://github.com/jmdelouis/FOSCAT.git"
35
+ Issues = "https://github.com/jmdelouis/FOSCAT/issues"
36
+ Documentation = "https://foscat-documentation.readthedocs.io/en/latest/index.html"
37
+
38
+ [tool.setuptools]
39
+ package-dir = {"" = "src"}
40
+ packages = ["foscat"]
41
+
42
+ [build-system]
43
+ requires = ["setuptools"]
44
+ build-backend = "setuptools.build_meta"
45
+
46
+ [tool.ruff]
47
+ target-version = "py39"
48
+ builtins = ["ellipsis"]
49
+ exclude = [
50
+ ".git",
51
+ ".eggs",
52
+ "build",
53
+ "dist",
54
+ "__pycache__",
55
+ ]
56
+ line-length = 100
57
+
58
+ [tool.ruff.lint]
59
+ ignore = [
60
+ "E402", # E402: module level import not at top of file
61
+ "E501", # E501: line too long - let black worry about that
62
+ "E731", # E731: do not assign a lambda expression, use a def
63
+ # ignore for now, fix in a later PR
64
+ #"E741", # ambiguous variable name
65
+ "E722", # bare except
66
+ "UP031", # percent-based string interpolation
67
+ #"F401", # unused imports
68
+ #"F811", # redefinition of unused name
69
+ #"F821", # undefined name
70
+ #"F841", # unused local variable
71
+ ]
72
+ select = [
73
+ "F", # Pyflakes
74
+ "E", # Pycodestyle
75
+ "I", # isort
76
+ "UP", # Pyupgrade
77
+ "TID", # flake8-tidy-imports
78
+ "W",
79
+ ]
80
+ extend-safe-fixes = [
81
+ "TID252", # absolute imports
82
+ ]
83
+ fixable = ["I", "TID252"]
84
+
85
+ [tool.ruff.lint.isort]
86
+ known-first-party = ["foscat"]
87
+
88
+ [tool.ruff.lint.flake8-tidy-imports]
89
+ # Disallow all relative imports.
90
+ ban-relative-imports = "all"
foscat-3.2.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
foscat-3.2.0/setup.py ADDED
@@ -0,0 +1,25 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name="foscat",
5
+ version="3.2.0",
6
+ description="Generate synthetic Healpix or 2D data using Cross Scattering Transform",
7
+ 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 ",
8
+ license="License :: OSI Approved :: MIT License",
9
+ author="Jean-Marc DELOUIS",
10
+ author_email="jean.marc.delouis@ifremer.fr",
11
+ maintainer="Theo Foulquier",
12
+ maintainer_email="theo.foulquier@ifremer.fr",
13
+ packages=["foscat"],
14
+ package_dir={"": "src"},
15
+ url="https://github.com/jmdelouis/FOSCAT",
16
+ keywords=["Scattering transform", "Component separation", "denoising"],
17
+ install_requires=[
18
+ "imageio",
19
+ "imagecodecs",
20
+ "matplotlib",
21
+ "numpy",
22
+ "tensorflow",
23
+ "healpy",
24
+ ],
25
+ )
@@ -0,0 +1,151 @@
1
+ import pickle
2
+
3
+ import numpy as np
4
+
5
+ import foscat.scat_cov as sc
6
+
7
+
8
+ class CNN:
9
+
10
+ def __init__(
11
+ self,
12
+ scat_operator=None,
13
+ nparam=1,
14
+ nscale=1,
15
+ chanlist=[],
16
+ in_nside=1,
17
+ n_chan_in=1,
18
+ nbatch=1,
19
+ SEED=1234,
20
+ filename=None,
21
+ ):
22
+
23
+ if filename is not None:
24
+ outlist = pickle.load(open("%s.pkl" % (filename), "rb"))
25
+ self.scat_operator = sc.funct(KERNELSZ=outlist[3], all_type=outlist[7])
26
+ self.KERNELSZ = self.scat_operator.KERNELSZ
27
+ self.all_type = self.scat_operator.all_type
28
+ self.npar = outlist[2]
29
+ self.nscale = outlist[5]
30
+ self.chanlist = outlist[0]
31
+ self.in_nside = outlist[4]
32
+ self.nbatch = outlist[1]
33
+ self.n_chan_in = outlist[8]
34
+ self.x = self.scat_operator.backend.bk_cast(outlist[6])
35
+ self.out_nside = self.in_nside // (2**self.nscale)
36
+ else:
37
+ self.nscale = nscale
38
+ self.nbatch = nbatch
39
+ self.npar = nparam
40
+ self.n_chan_in = n_chan_in
41
+ self.scat_operator = scat_operator
42
+ if len(chanlist) != nscale + 1:
43
+ print(
44
+ "len of chanlist (here %d) should of nscale+1 (here %d)"
45
+ % (len(chanlist), nscale + 1)
46
+ )
47
+ return None
48
+
49
+ self.chanlist = chanlist
50
+ self.KERNELSZ = scat_operator.KERNELSZ
51
+ self.all_type = scat_operator.all_type
52
+ self.in_nside = in_nside
53
+ self.out_nside = self.in_nside // (2**self.nscale)
54
+
55
+ np.random.seed(SEED)
56
+ self.x = scat_operator.backend.bk_cast(
57
+ np.random.randn(self.get_number_of_weights())
58
+ / (self.KERNELSZ * self.KERNELSZ)
59
+ )
60
+
61
+ def save(self, filename):
62
+
63
+ outlist = [
64
+ self.chanlist,
65
+ self.nbatch,
66
+ self.npar,
67
+ self.KERNELSZ,
68
+ self.in_nside,
69
+ self.nscale,
70
+ self.get_weights().numpy(),
71
+ self.all_type,
72
+ self.n_chan_in,
73
+ ]
74
+
75
+ myout = open("%s.pkl" % (filename), "wb")
76
+ pickle.dump(outlist, myout)
77
+ myout.close()
78
+
79
+ def get_number_of_weights(self):
80
+ totnchan = 0
81
+ for i in range(self.nscale):
82
+ totnchan = totnchan + self.chanlist[i] * self.chanlist[i + 1]
83
+ return (
84
+ self.npar * 12 * self.out_nside**2 * self.chanlist[self.nscale]
85
+ + totnchan * self.KERNELSZ * self.KERNELSZ
86
+ + self.KERNELSZ * self.KERNELSZ * self.n_chan_in * self.chanlist[0]
87
+ )
88
+
89
+ def set_weights(self, x):
90
+ self.x = x
91
+
92
+ def get_weights(self):
93
+ return self.x
94
+
95
+ def eval(self, im, indices=None, weights=None):
96
+
97
+ x = self.x
98
+ ww = self.scat_operator.backend.bk_reshape(
99
+ x[0 : self.KERNELSZ * self.KERNELSZ * self.n_chan_in * self.chanlist[0]],
100
+ [self.KERNELSZ * self.KERNELSZ, self.n_chan_in, self.chanlist[0]],
101
+ )
102
+ nn = self.KERNELSZ * self.KERNELSZ * self.n_chan_in * self.chanlist[0]
103
+
104
+ im = self.scat_operator.healpix_layer(im, ww)
105
+ im = self.scat_operator.backend.bk_relu(im)
106
+
107
+ for k in range(self.nscale):
108
+ ww = self.scat_operator.backend.bk_reshape(
109
+ x[
110
+ nn : nn
111
+ + self.KERNELSZ
112
+ * self.KERNELSZ
113
+ * self.chanlist[k]
114
+ * self.chanlist[k + 1]
115
+ ],
116
+ [self.KERNELSZ * self.KERNELSZ, self.chanlist[k], self.chanlist[k + 1]],
117
+ )
118
+ nn = (
119
+ nn
120
+ + self.KERNELSZ
121
+ * self.KERNELSZ
122
+ * self.chanlist[k]
123
+ * self.chanlist[k + 1]
124
+ )
125
+ if indices is None:
126
+ im = self.scat_operator.healpix_layer(im, ww)
127
+ else:
128
+ im = self.scat_operator.healpix_layer(
129
+ im, ww, indices=indices[k], weights=weights[k]
130
+ )
131
+ im = self.scat_operator.backend.bk_relu(im)
132
+ im = self.scat_operator.ud_grade_2(im, axis=0)
133
+
134
+ ww = self.scat_operator.backend.bk_reshape(
135
+ x[
136
+ nn : nn
137
+ + self.npar * 12 * self.out_nside**2 * self.chanlist[self.nscale]
138
+ ],
139
+ [12 * self.out_nside**2 * self.chanlist[self.nscale], self.npar],
140
+ )
141
+
142
+ im = self.scat_operator.backend.bk_matmul(
143
+ self.scat_operator.backend.bk_reshape(
144
+ im, [1, 12 * self.out_nside**2 * self.chanlist[self.nscale]]
145
+ ),
146
+ ww,
147
+ )
148
+ im = self.scat_operator.backend.bk_reshape(im, [self.npar])
149
+ im = self.scat_operator.backend.bk_relu(im)
150
+
151
+ return im
@@ -1,6 +1,6 @@
1
-
2
1
  import math
3
2
 
3
+
4
4
  class CircSpline:
5
5
  def __init__(self, nodes, degree=3):
6
6
  """
@@ -14,7 +14,11 @@ class CircSpline:
14
14
  """
15
15
  Compute normalization factor for the ith element.
16
16
  """
17
- return pow(-1, i) * (self.degree + 1) / (math.factorial(self.degree + 1 - i) * math.factorial(i))
17
+ return (
18
+ pow(-1, i)
19
+ * (self.degree + 1)
20
+ / (math.factorial(self.degree + 1 - i) * math.factorial(i))
21
+ )
18
22
 
19
23
  def yplus(self, x):
20
24
  """
@@ -48,4 +52,3 @@ class CircSpline:
48
52
  tmp = 0.0
49
53
  y[self.nodes - 1 - i] += tmp
50
54
  return y
51
-