foscat 3.0.14__tar.gz → 3.6.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.
- foscat-3.6.0/LICENCE +13 -0
- foscat-3.6.0/PKG-INFO +184 -0
- foscat-3.6.0/README.md +155 -0
- foscat-3.6.0/pyproject.toml +89 -0
- foscat-3.6.0/setup.cfg +4 -0
- foscat-3.6.0/src/foscat/CNN.py +151 -0
- foscat-3.6.0/src/foscat/CircSpline.py +119 -0
- foscat-3.6.0/src/foscat/FoCUS.py +2706 -0
- foscat-3.6.0/src/foscat/GCNN.py +239 -0
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat/Softmax.py +29 -20
- foscat-3.6.0/src/foscat/Spline1D.py +92 -0
- foscat-3.6.0/src/foscat/Synthesis.py +455 -0
- foscat-3.6.0/src/foscat/alm.py +690 -0
- foscat-3.6.0/src/foscat/alm_tools.py +11 -0
- foscat-3.6.0/src/foscat/backend.py +1061 -0
- foscat-3.6.0/src/foscat/backend_tens.py +63 -0
- foscat-3.6.0/src/foscat/loss_backend_tens.py +70 -0
- foscat-3.6.0/src/foscat/loss_backend_torch.py +58 -0
- foscat-3.6.0/src/foscat/scat.py +2030 -0
- foscat-3.6.0/src/foscat/scat1D.py +1546 -0
- foscat-3.6.0/src/foscat/scat2D.py +17 -0
- foscat-3.6.0/src/foscat/scat_cov.py +3844 -0
- foscat-3.6.0/src/foscat/scat_cov1D.py +18 -0
- foscat-3.6.0/src/foscat/scat_cov2D.py +18 -0
- foscat-3.6.0/src/foscat/scat_cov_map.py +93 -0
- foscat-3.6.0/src/foscat/scat_cov_map2D.py +94 -0
- foscat-3.6.0/src/foscat.egg-info/PKG-INFO +184 -0
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat.egg-info/SOURCES.txt +6 -3
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat.egg-info/requires.txt +1 -0
- foscat-3.0.14/PKG-INFO +0 -17
- foscat-3.0.14/README.md +0 -61
- foscat-3.0.14/setup.cfg +0 -8
- foscat-3.0.14/setup.py +0 -27
- foscat-3.0.14/src/foscat/CircSpline.py +0 -51
- foscat-3.0.14/src/foscat/FoCUS.py +0 -1508
- foscat-3.0.14/src/foscat/GCNN.py +0 -100
- foscat-3.0.14/src/foscat/GetGPUinfo.py +0 -36
- foscat-3.0.14/src/foscat/Spline1D.py +0 -42
- foscat-3.0.14/src/foscat/Synthesis.py +0 -387
- foscat-3.0.14/src/foscat/backend.py +0 -756
- foscat-3.0.14/src/foscat/loss_backend_tens.py +0 -60
- foscat-3.0.14/src/foscat/loss_backend_torch.py +0 -64
- foscat-3.0.14/src/foscat/scat.py +0 -1406
- foscat-3.0.14/src/foscat/scat1D.py +0 -1064
- foscat-3.0.14/src/foscat/scat2D.py +0 -15
- foscat-3.0.14/src/foscat/scat_cov.py +0 -2433
- foscat-3.0.14/src/foscat/scat_cov1D.py +0 -1474
- foscat-3.0.14/src/foscat/scat_cov2D.py +0 -16
- foscat-3.0.14/src/foscat/scat_cov_map.py +0 -67
- foscat-3.0.14/src/foscat/scat_cov_map2D.py +0 -64
- foscat-3.0.14/src/foscat.egg-info/PKG-INFO +0 -17
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat/__init__.py +0 -0
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat.egg-info/dependency_links.txt +0 -0
- {foscat-3.0.14 → foscat-3.6.0}/src/foscat.egg-info/top_level.txt +0 -0
foscat-3.6.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.6.0/PKG-INFO
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: foscat
|
|
3
|
+
Version: 3.6.0
|
|
4
|
+
Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
|
|
5
|
+
Author-email: Jean-Marc DELOUIS <jean.marc.delouis@ifremer.fr>
|
|
6
|
+
Maintainer-email: Theo Foulquier <theo.foulquier@ifremer.fr>
|
|
7
|
+
License: BSD-3-Clause
|
|
8
|
+
Project-URL: Repository, https://github.com/jmdelouis/FOSCAT.git
|
|
9
|
+
Project-URL: Issues, https://github.com/jmdelouis/FOSCAT/issues
|
|
10
|
+
Project-URL: Documentation, https://foscat-documentation.readthedocs.io/en/latest/index.html
|
|
11
|
+
Keywords: scattering transform,component separation,denoising
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENCE
|
|
22
|
+
Requires-Dist: imageio
|
|
23
|
+
Requires-Dist: imagecodecs
|
|
24
|
+
Requires-Dist: matplotlib
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: tensorflow
|
|
27
|
+
Requires-Dist: healpy
|
|
28
|
+
Requires-Dist: spherical
|
|
29
|
+
|
|
30
|
+
# foscat
|
|
31
|
+
|
|
32
|
+
[](https://foscat-documentation.readthedocs.io/en/latest)
|
|
33
|
+
|
|
34
|
+
A python package dedicated to image component separation based on scattering transform analysis designed for high performance computing.
|
|
35
|
+
|
|
36
|
+
## the concept
|
|
37
|
+
|
|
38
|
+
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).
|
|
39
|
+
|
|
40
|
+
A demo package for this process can be found at https://github.com/jmdelouis/FOSCAT_DEMO.
|
|
41
|
+
|
|
42
|
+
## usage
|
|
43
|
+
|
|
44
|
+
# Short tutorial
|
|
45
|
+
|
|
46
|
+
https://github.com/IAOCEA/demo-foscat-pangeo-eosc/blob/main/Demo_Synthesis.ipynb
|
|
47
|
+
|
|
48
|
+
# FOSCAT_DEMO
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
# Install foscat library
|
|
53
|
+
|
|
54
|
+
Before installing, make sure you have python installed in your enviroment.
|
|
55
|
+
The last version of the foscat library can be installed using PyPi:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pip install foscat
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Load the FOSCAT_DEMO package from github.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Recommended installing procedures for mac users
|
|
68
|
+
|
|
69
|
+
It is recomended to use python=3.9\*.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
micromamba create -n FOSCAT
|
|
73
|
+
micromamba install -n FOSCAT ‘python==3.9*’
|
|
74
|
+
micromamba activate FOSCAT
|
|
75
|
+
pip install foscat
|
|
76
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Recommended installing procedures HPC users
|
|
81
|
+
|
|
82
|
+
It is recomended to install tensorflow in advance. For [DATARMOR](https://pcdm.ifremer.fr/Equipement) for using GPU ;
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
micromamba create -n FOSCAT
|
|
86
|
+
micromamba install -n FOSCAT ‘python==3.9*’
|
|
87
|
+
micromamba install -n FOSCAT ‘tensorflow==2.11.0’
|
|
88
|
+
micromamba activate FOSCAT
|
|
89
|
+
pip install foscat
|
|
90
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
# Spherical data example
|
|
95
|
+
|
|
96
|
+
## compute a synthetic image
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
python demo.py -n=32 -k -c -s=100
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
- `-n=32` computes map with nside=32.
|
|
105
|
+
- `-k` uses 5x5 kernel.
|
|
106
|
+
- `-c` uses Scattering Covariance.
|
|
107
|
+
- `-l` uses LBFGS minimizer.
|
|
108
|
+
- `-s=100` computes 100 steps.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
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]
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- The "-n" option specifies the nside of the input map. The maximum nside value is 256 with the default map.
|
|
116
|
+
- The "--cov" option (optional) uses scat_cov instead of scat.
|
|
117
|
+
- The "--steps" option (optional) specifies the number of iterations. If not specified, the default value is 1000.
|
|
118
|
+
- The "--seed" option (optional) specifies the seed of the random generator.
|
|
119
|
+
- The "--path" option (optional) allows you to define the path where the output files will be written. The default path is "data".
|
|
120
|
+
- The "--k5x5" option (optional) uses a 5x5 kernel instead of a 3x3.
|
|
121
|
+
- 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.
|
|
122
|
+
- The "--out" option (optional) specifies the output file name. If not specified, the output file will be saved in "demo".
|
|
123
|
+
- The "--orient" option (optional) specifies the number of orientations. If not specified, the default value is 4.
|
|
124
|
+
- The "--adam" option (optional) makes the synthesis using the ADAM optimizer instead of the L_BFGS.
|
|
125
|
+
|
|
126
|
+
## plot the result
|
|
127
|
+
|
|
128
|
+
The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo.py_ script.
|
|
129
|
+
|
|
130
|
+
> python test2D.py
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
python plotdemo.py -n=32 -c
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
# 2D field demo
|
|
137
|
+
|
|
138
|
+
> python test2Dplot.py
|
|
139
|
+
|
|
140
|
+
# compute a synthetic turbulent field
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
> python testHealpix.py
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
python demo2d.py -n=32 -k -c
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
> python testHplot.py
|
|
151
|
+
|
|
152
|
+
The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo2D.py_ script.
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
python plotdemo2d.py -n=32 -c
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
|
|
159
|
+
|
|
160
|
+
> mpirun -np 3 testHealpix_mpi.py
|
|
161
|
+
|
|
162
|
+
## Authors and acknowledgment
|
|
163
|
+
|
|
164
|
+
Authors: J.-M. Delouis, P. Campeti, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
|
|
165
|
+
|
|
166
|
+
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
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
BSD 3-Clause License
|
|
171
|
+
|
|
172
|
+
Copyright (c) 2022, the Foscat developers All rights reserved.
|
|
173
|
+
|
|
174
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
175
|
+
|
|
176
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
182
|
+
## Project status
|
|
183
|
+
|
|
184
|
+
It is a scientific driven development. We are open to any contributing development.
|
foscat-3.6.0/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# foscat
|
|
2
|
+
|
|
3
|
+
[](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
|
+
```
|
|
29
|
+
pip install foscat
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Load the FOSCAT_DEMO package from github.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Recommended installing procedures for mac users
|
|
39
|
+
|
|
40
|
+
It is recomended to use python=3.9\*.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
micromamba create -n FOSCAT
|
|
44
|
+
micromamba install -n FOSCAT ‘python==3.9*’
|
|
45
|
+
micromamba activate FOSCAT
|
|
46
|
+
pip install foscat
|
|
47
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Recommended installing procedures HPC users
|
|
52
|
+
|
|
53
|
+
It is recomended to install tensorflow in advance. For [DATARMOR](https://pcdm.ifremer.fr/Equipement) for using GPU ;
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
micromamba create -n FOSCAT
|
|
57
|
+
micromamba install -n FOSCAT ‘python==3.9*’
|
|
58
|
+
micromamba install -n FOSCAT ‘tensorflow==2.11.0’
|
|
59
|
+
micromamba activate FOSCAT
|
|
60
|
+
pip install foscat
|
|
61
|
+
git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
# Spherical data example
|
|
66
|
+
|
|
67
|
+
## compute a synthetic image
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
python demo.py -n=32 -k -c -s=100
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
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.
|
|
74
|
+
|
|
75
|
+
- `-n=32` computes map with nside=32.
|
|
76
|
+
- `-k` uses 5x5 kernel.
|
|
77
|
+
- `-c` uses Scattering Covariance.
|
|
78
|
+
- `-l` uses LBFGS minimizer.
|
|
79
|
+
- `-s=100` computes 100 steps.
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
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]
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- The "-n" option specifies the nside of the input map. The maximum nside value is 256 with the default map.
|
|
87
|
+
- The "--cov" option (optional) uses scat_cov instead of scat.
|
|
88
|
+
- The "--steps" option (optional) specifies the number of iterations. If not specified, the default value is 1000.
|
|
89
|
+
- The "--seed" option (optional) specifies the seed of the random generator.
|
|
90
|
+
- The "--path" option (optional) allows you to define the path where the output files will be written. The default path is "data".
|
|
91
|
+
- The "--k5x5" option (optional) uses a 5x5 kernel instead of a 3x3.
|
|
92
|
+
- 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.
|
|
93
|
+
- The "--out" option (optional) specifies the output file name. If not specified, the output file will be saved in "demo".
|
|
94
|
+
- The "--orient" option (optional) specifies the number of orientations. If not specified, the default value is 4.
|
|
95
|
+
- The "--adam" option (optional) makes the synthesis using the ADAM optimizer instead of the L_BFGS.
|
|
96
|
+
|
|
97
|
+
## plot the result
|
|
98
|
+
|
|
99
|
+
The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo.py_ script.
|
|
100
|
+
|
|
101
|
+
> python test2D.py
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
python plotdemo.py -n=32 -c
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
# 2D field demo
|
|
108
|
+
|
|
109
|
+
> python test2Dplot.py
|
|
110
|
+
|
|
111
|
+
# compute a synthetic turbulent field
|
|
112
|
+
|
|
113
|
+
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.
|
|
114
|
+
|
|
115
|
+
> python testHealpix.py
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
python demo2d.py -n=32 -k -c
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
> python testHplot.py
|
|
122
|
+
|
|
123
|
+
The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo2D.py_ script.
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
python plotdemo2d.py -n=32 -c
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
|
|
130
|
+
|
|
131
|
+
> mpirun -np 3 testHealpix_mpi.py
|
|
132
|
+
|
|
133
|
+
## Authors and acknowledgment
|
|
134
|
+
|
|
135
|
+
Authors: J.-M. Delouis, P. Campeti, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
|
|
136
|
+
|
|
137
|
+
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
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
BSD 3-Clause License
|
|
142
|
+
|
|
143
|
+
Copyright (c) 2022, the Foscat developers All rights reserved.
|
|
144
|
+
|
|
145
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
146
|
+
|
|
147
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
## Project status
|
|
154
|
+
|
|
155
|
+
It is a scientific driven development. We are open to any contributing development.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "foscat"
|
|
3
|
+
version = "3.6.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
|
+
|
|
11
|
+
maintainers = [
|
|
12
|
+
{ name = "Theo Foulquier", email = "theo.foulquier@ifremer.fr" },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
"imageio",
|
|
17
|
+
"imagecodecs",
|
|
18
|
+
"matplotlib",
|
|
19
|
+
"numpy",
|
|
20
|
+
"tensorflow",
|
|
21
|
+
"healpy",
|
|
22
|
+
"spherical",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
requires-python = ">= 3.9"
|
|
26
|
+
keywords = ["scattering transform", "component separation", "denoising"]
|
|
27
|
+
classifiers = [
|
|
28
|
+
"Intended Audience :: Science/Research",
|
|
29
|
+
"License :: OSI Approved :: MIT License",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.9",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Repository = "https://github.com/jmdelouis/FOSCAT.git"
|
|
39
|
+
Issues = "https://github.com/jmdelouis/FOSCAT/issues"
|
|
40
|
+
Documentation = "https://foscat-documentation.readthedocs.io/en/latest/index.html"
|
|
41
|
+
|
|
42
|
+
[tool.setuptools]
|
|
43
|
+
package-dir = { "" = "src" }
|
|
44
|
+
packages = ["foscat"]
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["setuptools"]
|
|
48
|
+
build-backend = "setuptools.build_meta"
|
|
49
|
+
|
|
50
|
+
[tool.ruff]
|
|
51
|
+
target-version = "py39"
|
|
52
|
+
builtins = ["ellipsis"]
|
|
53
|
+
exclude = [
|
|
54
|
+
".git",
|
|
55
|
+
".eggs",
|
|
56
|
+
"build",
|
|
57
|
+
"dist",
|
|
58
|
+
"__pycache__",
|
|
59
|
+
]
|
|
60
|
+
line-length = 100
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
ignore = [
|
|
64
|
+
"E402", # E402: module level import not at top of file
|
|
65
|
+
"E501", # E501: line too long - let black worry about that
|
|
66
|
+
"E731", # E731: do not assign a lambda expression, use a def
|
|
67
|
+
# ignore for now, fix in a later PR
|
|
68
|
+
"E722", # bare except
|
|
69
|
+
"UP031", # percent-based string interpolation
|
|
70
|
+
]
|
|
71
|
+
select = [
|
|
72
|
+
"F", # Pyflakes
|
|
73
|
+
"E", # Pycodestyle
|
|
74
|
+
"I", # isort
|
|
75
|
+
"UP", # Pyupgrade
|
|
76
|
+
"TID", # flake8-tidy-imports
|
|
77
|
+
"W",
|
|
78
|
+
]
|
|
79
|
+
extend-safe-fixes = [
|
|
80
|
+
"TID252", # absolute imports
|
|
81
|
+
]
|
|
82
|
+
fixable = ["I", "TID252"]
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint.isort]
|
|
85
|
+
known-first-party = ["foscat"]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint.flake8-tidy-imports]
|
|
88
|
+
# Disallow all relative imports.
|
|
89
|
+
ban-relative-imports = "all"
|
foscat-3.6.0/setup.cfg
ADDED
|
@@ -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
|