foscat 3.2.0__tar.gz → 3.3.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 (35) hide show
  1. {foscat-3.2.0/src/foscat.egg-info → foscat-3.3.0}/PKG-INFO +39 -36
  2. {foscat-3.2.0 → foscat-3.3.0}/README.md +38 -26
  3. {foscat-3.2.0 → foscat-3.3.0}/pyproject.toml +23 -28
  4. foscat-3.3.0/src/foscat/CircSpline.py +75 -0
  5. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/FoCUS.py +3 -3
  6. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/Softmax.py +1 -1
  7. foscat-3.3.0/src/foscat/Spline1D.py +92 -0
  8. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/Synthesis.py +23 -9
  9. foscat-3.3.0/src/foscat/alm.py +134 -0
  10. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/backend.py +44 -25
  11. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/backend_tens.py +2 -1
  12. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/loss_backend_torch.py +0 -1
  13. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat.py +15 -6
  14. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat1D.py +15 -6
  15. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat_cov.py +993 -931
  16. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat_cov1D.py +2 -2
  17. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat_cov2D.py +2 -2
  18. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat_cov_map.py +16 -16
  19. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat_cov_map2D.py +16 -16
  20. {foscat-3.2.0 → foscat-3.3.0/src/foscat.egg-info}/PKG-INFO +39 -36
  21. {foscat-3.2.0 → foscat-3.3.0}/src/foscat.egg-info/SOURCES.txt +1 -2
  22. foscat-3.2.0/setup.py +0 -25
  23. foscat-3.2.0/src/foscat/CircSpline.py +0 -54
  24. foscat-3.2.0/src/foscat/Spline1D.py +0 -46
  25. foscat-3.2.0/src/foscat/scat_cov1D.old.py +0 -1547
  26. {foscat-3.2.0 → foscat-3.3.0}/LICENCE +0 -0
  27. {foscat-3.2.0 → foscat-3.3.0}/setup.cfg +0 -0
  28. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/CNN.py +0 -0
  29. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/GCNN.py +0 -0
  30. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/__init__.py +0 -0
  31. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/loss_backend_tens.py +0 -0
  32. {foscat-3.2.0 → foscat-3.3.0}/src/foscat/scat2D.py +0 -0
  33. {foscat-3.2.0 → foscat-3.3.0}/src/foscat.egg-info/dependency_links.txt +0 -0
  34. {foscat-3.2.0 → foscat-3.3.0}/src/foscat.egg-info/requires.txt +0 -0
  35. {foscat-3.2.0 → foscat-3.3.0}/src/foscat.egg-info/top_level.txt +0 -0
@@ -1,11 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foscat
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
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
5
  Author-email: Jean-Marc DELOUIS <jean.marc.delouis@ifremer.fr>
8
- Maintainer: Theo Foulquier
9
6
  Maintainer-email: Theo Foulquier <theo.foulquier@ifremer.fr>
10
7
  License: BSD-3-Clause
11
8
  Project-URL: Repository, https://github.com/jmdelouis/FOSCAT.git
@@ -22,12 +19,6 @@ Classifier: Programming Language :: Python :: 3.12
22
19
  Requires-Python: >=3.9
23
20
  Description-Content-Type: text/markdown
24
21
  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
22
 
32
23
  # foscat
33
24
 
@@ -49,23 +40,27 @@ https://github.com/IAOCEA/demo-foscat-pangeo-eosc/blob/main/Demo_Synthesis.ipynb
49
40
 
50
41
  # FOSCAT_DEMO
51
42
 
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.
43
+ 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
44
 
54
45
  # Install foscat library
55
46
 
56
- Before installing, make sure you have python installed in your enviroment.
47
+ Before installing, make sure you have python installed in your enviroment.
57
48
  The last version of the foscat library can be installed using PyPi:
49
+
58
50
  ```
59
51
  pip install foscat
60
52
  ```
53
+
61
54
  Load the FOSCAT_DEMO package from github.
55
+
62
56
  ```
63
57
  git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
64
58
  ```
65
59
 
60
+ ## Recommended installing procedures for mac users
61
+
62
+ It is recomended to use python=3.9\*.
66
63
 
67
- ## Recommended installing procedures for mac users
68
- It is recomended to use python=3.9*.
69
64
  ```
70
65
  micromamba create -n FOSCAT
71
66
  micromamba install -n FOSCAT ‘python==3.9*’
@@ -75,8 +70,9 @@ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
75
70
 
76
71
  ```
77
72
 
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 ;
73
+ ## Recommended installing procedures HPC users
74
+
75
+ It is recomended to install tensorflow in advance. For [DATARMOR](https://pcdm.ifremer.fr/Equipement) for using GPU ;
80
76
 
81
77
  ```
82
78
  micromamba create -n FOSCAT
@@ -91,33 +87,38 @@ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
91
87
  # Spherical data example
92
88
 
93
89
  ## compute a synthetic image
90
+
94
91
  ```
95
92
  python demo.py -n=32 -k -c -s=100
96
93
  ```
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.
94
+
95
+ 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.
96
+
97
+ - `-n=32` computes map with nside=32.
98
+ - `-k` uses 5x5 kernel.
99
+ - `-c` uses Scattering Covariance.
100
+ - `-l` uses LBFGS minimizer.
101
+ - `-s=100` computes 100 steps.
102
+
103
103
  ```
104
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
105
 
106
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.
107
+
108
+ - The "-n" option specifies the nside of the input map. The maximum nside value is 256 with the default map.
109
+ - The "--cov" option (optional) uses scat_cov instead of scat.
110
+ - The "--steps" option (optional) specifies the number of iterations. If not specified, the default value is 1000.
111
+ - The "--seed" option (optional) specifies the seed of the random generator.
112
+ - The "--path" option (optional) allows you to define the path where the output files will be written. The default path is "data".
113
+ - The "--k5x5" option (optional) uses a 5x5 kernel instead of a 3x3.
114
+ - 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.
115
+ - The "--out" option (optional) specifies the output file name. If not specified, the output file will be saved in "demo".
116
+ - The "--orient" option (optional) specifies the number of orientations. If not specified, the default value is 4.
117
+ - The "--adam" option (optional) makes the synthesis using the ADAM optimizer instead of the L_BFGS.
117
118
 
118
119
  ## plot the result
119
120
 
120
- The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo.py* script.
121
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo.py_ script.
121
122
 
122
123
  > python test2D.py
123
124
 
@@ -131,7 +132,7 @@ python plotdemo.py -n=32 -c
131
132
 
132
133
  # compute a synthetic turbulent field
133
134
 
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
+ 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
 
136
137
  > python testHealpix.py
137
138
 
@@ -141,17 +142,19 @@ python demo2d.py -n=32 -k -c
141
142
 
142
143
  > python testHplot.py
143
144
 
144
- The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo2D.py* script.
145
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo2D.py_ script.
146
+
145
147
  ```
146
148
  python plotdemo2d.py -n=32 -c
147
149
  ```
150
+
148
151
  For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
149
152
 
150
153
  > mpirun -np 3 testHealpix_mpi.py
151
154
 
152
155
  ## Authors and acknowledgment
153
156
 
154
- Authors: J.-M. Delouis, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
157
+ Authors: J.-M. Delouis, P. Campeti, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
155
158
 
156
159
  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
160
 
@@ -18,23 +18,27 @@ https://github.com/IAOCEA/demo-foscat-pangeo-eosc/blob/main/Demo_Synthesis.ipynb
18
18
 
19
19
  # FOSCAT_DEMO
20
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.
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
22
 
23
23
  # Install foscat library
24
24
 
25
- Before installing, make sure you have python installed in your enviroment.
25
+ Before installing, make sure you have python installed in your enviroment.
26
26
  The last version of the foscat library can be installed using PyPi:
27
+
27
28
  ```
28
29
  pip install foscat
29
30
  ```
31
+
30
32
  Load the FOSCAT_DEMO package from github.
33
+
31
34
  ```
32
35
  git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
33
36
  ```
34
37
 
38
+ ## Recommended installing procedures for mac users
39
+
40
+ It is recomended to use python=3.9\*.
35
41
 
36
- ## Recommended installing procedures for mac users
37
- It is recomended to use python=3.9*.
38
42
  ```
39
43
  micromamba create -n FOSCAT
40
44
  micromamba install -n FOSCAT ‘python==3.9*’
@@ -44,8 +48,9 @@ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
44
48
 
45
49
  ```
46
50
 
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 ;
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 ;
49
54
 
50
55
  ```
51
56
  micromamba create -n FOSCAT
@@ -60,33 +65,38 @@ git clone https://github.com/jmdelouis/FOSCAT_DEMO.git
60
65
  # Spherical data example
61
66
 
62
67
  ## compute a synthetic image
68
+
63
69
  ```
64
70
  python demo.py -n=32 -k -c -s=100
65
71
  ```
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
+ 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
+
72
81
  ```
73
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]
74
83
 
75
84
  ```
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.
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.
86
96
 
87
97
  ## plot the result
88
98
 
89
- The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo.py* script.
99
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo.py_ script.
90
100
 
91
101
  > python test2D.py
92
102
 
@@ -100,7 +110,7 @@ python plotdemo.py -n=32 -c
100
110
 
101
111
  # compute a synthetic turbulent field
102
112
 
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.
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.
104
114
 
105
115
  > python testHealpix.py
106
116
 
@@ -110,17 +120,19 @@ python demo2d.py -n=32 -k -c
110
120
 
111
121
  > python testHplot.py
112
122
 
113
- The following script generates a series of plots that showcase different aspects of the synthesis process using the *demo2D.py* script.
123
+ The following script generates a series of plots that showcase different aspects of the synthesis process using the _demo2D.py_ script.
124
+
114
125
  ```
115
126
  python plotdemo2d.py -n=32 -c
116
127
  ```
128
+
117
129
  For more information, see the [documentation](https://foscat-documentation.readthedocs.io/en/latest/index.html).
118
130
 
119
131
  > mpirun -np 3 testHealpix_mpi.py
120
132
 
121
133
  ## Authors and acknowledgment
122
134
 
123
- Authors: J.-M. Delouis, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
135
+ Authors: J.-M. Delouis, P. Campeti, T. Foulquier, J. Mangin, L. Mousset, T. Odaka, F. Paul, E. Allys
124
136
 
125
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
126
138
 
@@ -1,14 +1,14 @@
1
1
  [project]
2
2
  name = "foscat"
3
- version = "3.2.0"
3
+ version = "3.3.0"
4
4
  description = "Generate synthetic Healpix or 2D data using Cross Scattering Transform"
5
5
  readme = "README.md"
6
- license = {text = "BSD-3-Clause"}
6
+ license = { text = "BSD-3-Clause" }
7
7
  authors = [
8
- {name = "Jean-Marc DELOUIS", email = "jean.marc.delouis@ifremer.fr"},
8
+ { name = "Jean-Marc DELOUIS", email = "jean.marc.delouis@ifremer.fr" },
9
9
  ]
10
10
  maintainers = [
11
- {name = "Theo Foulquier", email = "theo.foulquier@ifremer.fr"},
11
+ { name = "Theo Foulquier", email = "theo.foulquier@ifremer.fr" },
12
12
  ]
13
13
  dependencies = [
14
14
  "imageio",
@@ -36,7 +36,7 @@ Issues = "https://github.com/jmdelouis/FOSCAT/issues"
36
36
  Documentation = "https://foscat-documentation.readthedocs.io/en/latest/index.html"
37
37
 
38
38
  [tool.setuptools]
39
- package-dir = {"" = "src"}
39
+ package-dir = { "" = "src" }
40
40
  packages = ["foscat"]
41
41
 
42
42
  [build-system]
@@ -47,38 +47,33 @@ build-backend = "setuptools.build_meta"
47
47
  target-version = "py39"
48
48
  builtins = ["ellipsis"]
49
49
  exclude = [
50
- ".git",
51
- ".eggs",
52
- "build",
53
- "dist",
54
- "__pycache__",
50
+ ".git",
51
+ ".eggs",
52
+ "build",
53
+ "dist",
54
+ "__pycache__",
55
55
  ]
56
56
  line-length = 100
57
57
 
58
58
  [tool.ruff.lint]
59
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
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
+ "E722", # bare except
65
+ "UP031", # percent-based string interpolation
71
66
  ]
72
67
  select = [
73
- "F", # Pyflakes
74
- "E", # Pycodestyle
75
- "I", # isort
76
- "UP", # Pyupgrade
77
- "TID", # flake8-tidy-imports
78
- "W",
68
+ "F", # Pyflakes
69
+ "E", # Pycodestyle
70
+ "I", # isort
71
+ "UP", # Pyupgrade
72
+ "TID", # flake8-tidy-imports
73
+ "W",
79
74
  ]
80
75
  extend-safe-fixes = [
81
- "TID252", # absolute imports
76
+ "TID252", # absolute imports
82
77
  ]
83
78
  fixable = ["I", "TID252"]
84
79
 
@@ -0,0 +1,75 @@
1
+ import numpy as np
2
+
3
+
4
+ class CircSpline:
5
+ def __init__(self, nodes, degree=3):
6
+ """
7
+ Initializes the Spline1D instance.
8
+
9
+ Parameters:
10
+ - nodes (int): The number of nodes in the spline.
11
+ - degree (int): The degree of the spline. Default is 3.
12
+ """
13
+ self.degree = degree
14
+ self.nodes = nodes
15
+
16
+
17
+ def cubic_spline_function(self,x):
18
+ """
19
+ Evaluate the cubic spline basis function.
20
+
21
+ Args:
22
+ x (float or array): Input value(s) to evaluate the spline basis function.
23
+
24
+ Returns:
25
+ float or array: Result of the cubic spline basis function.
26
+ """
27
+ return -2 * x**3 + 3 * x**2
28
+
29
+
30
+ def eval(self,x):
31
+ """
32
+ Compute a 3rd-degree cubic spline with 4-point support.
33
+
34
+ Args:
35
+ x (float or array): Input value(s) to compute the spline.
36
+
37
+ Returns:
38
+ indices (array): Indices of the spline support points.
39
+ coefficients (array): Normalized spline coefficients.
40
+ """
41
+ N=self.nodes
42
+
43
+ if isinstance(x, float):
44
+ # Single scalar input
45
+ base_idx = int(x * (N))
46
+ indices = np.zeros([4], dtype="int")
47
+ coefficients = np.zeros([4])
48
+ else:
49
+ # Array input
50
+ base_idx = (x * (N)).astype("int")
51
+ indices = np.zeros([4, x.shape[0]], dtype="int")
52
+ coefficients = np.zeros([4, x.shape[0]])
53
+
54
+ # Compute the fractional part of the input
55
+ fractional_part = x * (N) - base_idx
56
+
57
+ # Compute spline coefficients for 4 support points
58
+ coefficients[3] = self.cubic_spline_function(fractional_part / 2) / 2
59
+ coefficients[2] = self.cubic_spline_function(0.5 + fractional_part / 2) / 2
60
+ coefficients[1] = self.cubic_spline_function(1 - fractional_part / 2) / 2
61
+ coefficients[0] = self.cubic_spline_function(0.5 - fractional_part / 2) / 2
62
+
63
+ # Assign indices for the support points
64
+ indices[3] = (base_idx + 3)%N
65
+ indices[2] = (base_idx + 2)%N
66
+ indices[1] = (base_idx + 1)%N
67
+ indices[0] = base_idx
68
+
69
+ # Adjust indices to start from 0
70
+ indices = indices - 1
71
+ # Square coefficients and normalize
72
+ coefficients = coefficients * coefficients
73
+ coefficients /= np.sum(coefficients, axis=0)
74
+
75
+ return indices, coefficients
@@ -38,7 +38,7 @@ class FoCUS:
38
38
  mpi_rank=0,
39
39
  ):
40
40
 
41
- self.__version__ = "3.2.0"
41
+ self.__version__ = "3.3.0"
42
42
  # P00 coeff for normalization for scat_cov
43
43
  self.TMPFILE_VERSION = TMPFILE_VERSION
44
44
  self.P1_dic = None
@@ -2193,7 +2193,7 @@ class FoCUS:
2193
2193
  + ishape[axis + 2 :],
2194
2194
  )
2195
2195
 
2196
- return self.backend.bk_reshape(res, in_image.shape+[self.NORIENT])
2196
+ return self.backend.bk_reshape(res, in_image.shape + [self.NORIENT])
2197
2197
  elif self.use_1D:
2198
2198
  ishape = list(in_image.shape)
2199
2199
  if len(ishape) < axis + 1:
@@ -2265,7 +2265,7 @@ class FoCUS:
2265
2265
  res, ishape[0:axis] + [res.shape[1]] + ishape[axis + 1 :]
2266
2266
  )
2267
2267
 
2268
- return self.backend.bk_reshape(res, in_image.shape+[self.NORIENT])
2268
+ return self.backend.bk_reshape(res, in_image.shape + [self.NORIENT])
2269
2269
 
2270
2270
  else:
2271
2271
  nside = int(np.sqrt(image.shape[axis] // 12))
@@ -1,4 +1,4 @@
1
- #import tensorflow as tf
1
+ # import tensorflow as tf
2
2
  from tensorflow.keras.layers import Dense, Softmax
3
3
  from tensorflow.keras.models import Sequential
4
4
 
@@ -0,0 +1,92 @@
1
+ import numpy as np
2
+
3
+ class Spline1D:
4
+ def __init__(self, nodes, degree=3):
5
+ """
6
+ Initializes the Spline1D instance.
7
+
8
+ Parameters:
9
+ - nodes (int): The number of nodes in the spline.
10
+ - degree (int): The degree of the spline. Default is 3.
11
+ """
12
+ self.degree = degree
13
+ self.nodes = nodes
14
+
15
+
16
+ def cubic_spline_function(self,x):
17
+ """
18
+ Evaluate the cubic spline basis function.
19
+
20
+ Args:
21
+ x (float or array): Input value(s) to evaluate the spline basis function.
22
+
23
+ Returns:
24
+ float or array: Result of the cubic spline basis function.
25
+ """
26
+ return -2 * x**3 + 3 * x**2
27
+
28
+
29
+ def eval(self,x):
30
+ """
31
+ Compute a 3rd-degree cubic spline with 4-point support.
32
+
33
+ Args:
34
+ x (float or array): Input value(s) to compute the spline.
35
+
36
+ Returns:
37
+ indices (array): Indices of the spline support points.
38
+ coefficients (array): Normalized spline coefficients.
39
+ """
40
+ N=self.nodes
41
+
42
+ if isinstance(x, float):
43
+ # Single scalar input
44
+ base_idx = int(x * (N-1))
45
+ indices = np.zeros([4], dtype="int")
46
+ coefficients = np.zeros([4])
47
+ else:
48
+ # Array input
49
+ base_idx = (x * (N-1)).astype("int")
50
+ indices = np.zeros([4, x.shape[0]], dtype="int")
51
+ coefficients = np.zeros([4, x.shape[0]])
52
+
53
+ # Compute the fractional part of the input
54
+ fractional_part = x * (N-1) - base_idx
55
+
56
+ # Compute spline coefficients for 4 support points
57
+ coefficients[3] = self.cubic_spline_function(fractional_part / 2) / 2
58
+ coefficients[2] = self.cubic_spline_function(0.5 + fractional_part / 2) / 2
59
+ coefficients[1] = self.cubic_spline_function(1 - fractional_part / 2) / 2
60
+ coefficients[0] = self.cubic_spline_function(0.5 - fractional_part / 2) / 2
61
+
62
+ # Assign indices for the support points
63
+ indices[3] = base_idx + 3
64
+ indices[2] = base_idx + 2
65
+ indices[1] = base_idx + 1
66
+ indices[0] = base_idx
67
+
68
+ # Handle boundary conditions
69
+ if isinstance(x, float):
70
+ if indices[0] == 0:
71
+ indices[0] = 1
72
+ if indices[1] == 0:
73
+ indices[1] = 1
74
+ if indices[2] == N + 1:
75
+ indices[2] = N
76
+ if indices[3] == N + 1:
77
+ indices[3] = N
78
+ if indices[3] == N + 2:
79
+ indices[3] = N
80
+ else:
81
+ indices[0, indices[0] == 0] = 1
82
+ indices[1, indices[1] == 0] = 1
83
+ indices[2, indices[2] >= N + 1] = N
84
+ indices[3, indices[3] >= N + 1] = N
85
+
86
+ # Adjust indices to start from 0
87
+ indices = indices - 1
88
+ # Square coefficients and normalize
89
+ coefficients = coefficients * coefficients
90
+ coefficients /= np.sum(coefficients, axis=0)
91
+
92
+ return indices, coefficients