ddon-efish 1.0.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.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddon-efish
3
+ Version: 1.0.0
4
+ Summary: Lightweight local inference package for Decoder-DeepONet (DDON) EFISH electric-field reconstruction.
5
+ Project-URL: Homepage, https://github.com/ozzzzj/Decoder-DeepONet
6
+ Project-URL: Web App, https://ozzzzj.github.io/Decoder-DeepONet/
7
+ Project-URL: Paper, https://doi.org/10.1088/1361-6595/ae413f
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: numpy<3
11
+ Requires-Dist: onnxruntime>=1.17
12
+ Requires-Dist: scipy>=1.9
13
+
14
+ # Decoder-DeepONet (DDON)
15
+ Model and code of Decoder DeepONet (DDON) for Electric field reconstruction from EFISH measurements. This model is specifically designed for vertically polarized EFISH signals (for a vertically
16
+ polarized probe beam). <br>
17
+
18
+ To use the model and code, please cite: <br>
19
+
20
+ ''Yang, Z., Sugeng, E.S., Alicherif, M. and Chng, T.L., 2026. An interpretable operator-learning model for electric field profile reconstruction in discharges based on the EFISH method. Plasma Sources Science and Technology, 35(2), p.025035.'' <br>
21
+
22
+ The related paper and analysis are available at the DOI 10.1088/1361-6595/ae413f. <br>
23
+
24
+ **Note** Scripts and model will be available soon... <br>
25
+
26
+ ## Environment recommended (model trained on):
27
+ - Python 3.10.15
28
+ - TensorFlow-gpu 2.10.1
29
+
30
+ ## Main user file:
31
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
32
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
33
+
34
+ ## Script files:
35
+ 1. 'self_layers.py' %to import some self-defined layers
36
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
37
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
38
+
39
+ ## Model file (DDON) and model description
40
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
41
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
42
+
43
+ ## Instructions to use the model for Efield prediction:
44
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
45
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
46
+ or <br>
47
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
48
+
49
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
50
+
51
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
52
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
53
+ or <br>
54
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
55
+
56
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
57
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
58
+
59
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
60
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
61
+
62
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
63
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
64
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
65
+
66
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
67
+
68
+ The MAT file structure is as follows:<br>
69
+
70
+ <table>
71
+ <tr>
72
+ <td rowspan="3"><code>Profile_Px</code></td>
73
+ <td>$P_x$</td>
74
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
75
+ </tr>
76
+ <tr>
77
+ <td>$u$</td>
78
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
79
+ </tr>
80
+ <tr>
81
+ <td>$E_x$</td>
82
+ <td>The electric field value along $z$; dim: [109,1]</td>
83
+ </tr>
84
+ </table>## Choose how to use DDON
85
+
86
+ ### 1. Online Web App — no installation
87
+
88
+ Run DDON directly in a web browser:
89
+
90
+ **[Launch the DDON E-field Reconstruction Web App](https://ozzzzj.github.io/Decoder-DeepONet/)**
91
+
92
+ The web app supports preprocessed CSV and MATLAB MAT inputs and performs inference locally in the browser using ONNX Runtime Web.
93
+
94
+ ### 2. Local Packaged Inference — lightweight ONNX Runtime
95
+
96
+ For local prediction without installing TensorFlow, install this repository as a Python package:
97
+
98
+ ```bash
99
+ pip install .
100
+ ```
101
+
102
+ Python interface:
103
+
104
+ ```python
105
+ from ddon import DDON
106
+
107
+ model = DDON()
108
+ E = model.predict(values, u=-0.35)
109
+ ```
110
+
111
+ Command-line interface:
112
+
113
+ ```bash
114
+ ddon predict Efish_vertical.mat -o prediction.csv
115
+ ```
116
+
117
+ For MATLAB MAT input, `Profile_Px.Px` and `Profile_Px.u` are read automatically. CSV/TXT input can be used with `--u`:
118
+
119
+ ```bash
120
+ ddon predict input.csv --u -0.35 -o prediction.mat
121
+ ```
122
+
123
+ The ONNX model is downloaded automatically on first use and cached locally. This mode requires only NumPy, SciPy, and ONNX Runtime.
124
+
125
+ ### 3. Full Python Research Code — To be released
126
+
127
+ The full TensorFlow research implementation, including the original prediction, evaluation, and analysis workflow, is not included in the current public release and will be released separately in the future.
128
+
129
+
130
+ ## Environment recommended (model trained on):
131
+ - Python 3.10.15
132
+ - TensorFlow-gpu 2.10.1
133
+
134
+ ## Main user file:
135
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
136
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
137
+
138
+ ## Script files:
139
+ 1. 'self_layers.py' %to import some self-defined layers
140
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
141
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
142
+
143
+ ## Model file (DDON) and model description
144
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
145
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
146
+
147
+ ## Instructions to use the model for Efield prediction:
148
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
149
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
150
+ or <br>
151
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
152
+
153
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
154
+
155
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
156
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
157
+ or <br>
158
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
159
+
160
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
161
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
162
+
163
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
164
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
165
+
166
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
167
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
168
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
169
+
170
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
171
+
172
+ The MAT file structure is as follows:<br>
173
+
174
+ <table>
175
+ <tr>
176
+ <td rowspan="3"><code>Profile_Px</code></td>
177
+ <td>$P_x$</td>
178
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
179
+ </tr>
180
+ <tr>
181
+ <td>$u$</td>
182
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
183
+ </tr>
184
+ <tr>
185
+ <td>$E_x$</td>
186
+ <td>The electric field value along $z$; dim: [109,1]</td>
187
+ </tr>
188
+ </table>
@@ -0,0 +1,175 @@
1
+ # Decoder-DeepONet (DDON)
2
+ Model and code of Decoder DeepONet (DDON) for Electric field reconstruction from EFISH measurements. This model is specifically designed for vertically polarized EFISH signals (for a vertically
3
+ polarized probe beam). <br>
4
+
5
+ To use the model and code, please cite: <br>
6
+
7
+ ''Yang, Z., Sugeng, E.S., Alicherif, M. and Chng, T.L., 2026. An interpretable operator-learning model for electric field profile reconstruction in discharges based on the EFISH method. Plasma Sources Science and Technology, 35(2), p.025035.'' <br>
8
+
9
+ The related paper and analysis are available at the DOI 10.1088/1361-6595/ae413f. <br>
10
+
11
+ **Note** Scripts and model will be available soon... <br>
12
+
13
+ ## Environment recommended (model trained on):
14
+ - Python 3.10.15
15
+ - TensorFlow-gpu 2.10.1
16
+
17
+ ## Main user file:
18
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
19
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
20
+
21
+ ## Script files:
22
+ 1. 'self_layers.py' %to import some self-defined layers
23
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
24
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
25
+
26
+ ## Model file (DDON) and model description
27
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
28
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
29
+
30
+ ## Instructions to use the model for Efield prediction:
31
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
32
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
33
+ or <br>
34
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
35
+
36
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
37
+
38
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
39
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
40
+ or <br>
41
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
42
+
43
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
44
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
45
+
46
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
47
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
48
+
49
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
50
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
51
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
52
+
53
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
54
+
55
+ The MAT file structure is as follows:<br>
56
+
57
+ <table>
58
+ <tr>
59
+ <td rowspan="3"><code>Profile_Px</code></td>
60
+ <td>$P_x$</td>
61
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
62
+ </tr>
63
+ <tr>
64
+ <td>$u$</td>
65
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
66
+ </tr>
67
+ <tr>
68
+ <td>$E_x$</td>
69
+ <td>The electric field value along $z$; dim: [109,1]</td>
70
+ </tr>
71
+ </table>## Choose how to use DDON
72
+
73
+ ### 1. Online Web App — no installation
74
+
75
+ Run DDON directly in a web browser:
76
+
77
+ **[Launch the DDON E-field Reconstruction Web App](https://ozzzzj.github.io/Decoder-DeepONet/)**
78
+
79
+ The web app supports preprocessed CSV and MATLAB MAT inputs and performs inference locally in the browser using ONNX Runtime Web.
80
+
81
+ ### 2. Local Packaged Inference — lightweight ONNX Runtime
82
+
83
+ For local prediction without installing TensorFlow, install this repository as a Python package:
84
+
85
+ ```bash
86
+ pip install .
87
+ ```
88
+
89
+ Python interface:
90
+
91
+ ```python
92
+ from ddon import DDON
93
+
94
+ model = DDON()
95
+ E = model.predict(values, u=-0.35)
96
+ ```
97
+
98
+ Command-line interface:
99
+
100
+ ```bash
101
+ ddon predict Efish_vertical.mat -o prediction.csv
102
+ ```
103
+
104
+ For MATLAB MAT input, `Profile_Px.Px` and `Profile_Px.u` are read automatically. CSV/TXT input can be used with `--u`:
105
+
106
+ ```bash
107
+ ddon predict input.csv --u -0.35 -o prediction.mat
108
+ ```
109
+
110
+ The ONNX model is downloaded automatically on first use and cached locally. This mode requires only NumPy, SciPy, and ONNX Runtime.
111
+
112
+ ### 3. Full Python Research Code — To be released
113
+
114
+ The full TensorFlow research implementation, including the original prediction, evaluation, and analysis workflow, is not included in the current public release and will be released separately in the future.
115
+
116
+
117
+ ## Environment recommended (model trained on):
118
+ - Python 3.10.15
119
+ - TensorFlow-gpu 2.10.1
120
+
121
+ ## Main user file:
122
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
123
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
124
+
125
+ ## Script files:
126
+ 1. 'self_layers.py' %to import some self-defined layers
127
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
128
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
129
+
130
+ ## Model file (DDON) and model description
131
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
132
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
133
+
134
+ ## Instructions to use the model for Efield prediction:
135
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
136
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
137
+ or <br>
138
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
139
+
140
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
141
+
142
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
143
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
144
+ or <br>
145
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
146
+
147
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
148
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
149
+
150
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
151
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
152
+
153
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
154
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
155
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
156
+
157
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
158
+
159
+ The MAT file structure is as follows:<br>
160
+
161
+ <table>
162
+ <tr>
163
+ <td rowspan="3"><code>Profile_Px</code></td>
164
+ <td>$P_x$</td>
165
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
166
+ </tr>
167
+ <tr>
168
+ <td>$u$</td>
169
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
170
+ </tr>
171
+ <tr>
172
+ <td>$E_x$</td>
173
+ <td>The electric field value along $z$; dim: [109,1]</td>
174
+ </tr>
175
+ </table>
@@ -0,0 +1,3 @@
1
+ from .predictor import DDON
2
+
3
+ __all__ = ["DDON"]
@@ -0,0 +1,42 @@
1
+ import argparse
2
+
3
+ from .io import load_input, save_output
4
+ from .predictor import DDON
5
+
6
+
7
+ def main():
8
+ parser = argparse.ArgumentParser(
9
+ prog="ddon",
10
+ description="Local DDON electric-field reconstruction.",
11
+ )
12
+ sub = parser.add_subparsers(dest="command", required=True)
13
+
14
+ predict = sub.add_parser("predict", help="Run DDON inference.")
15
+ predict.add_argument("input", help="Input .mat, .csv, or .txt file.")
16
+ predict.add_argument(
17
+ "--u",
18
+ type=float,
19
+ default=None,
20
+ help="Raw u value. Required for CSV/TXT; MAT reads Profile_Px.u automatically.",
21
+ )
22
+ predict.add_argument(
23
+ "-o", "--output", default="ddon_prediction.csv",
24
+ help="Output .csv or .mat file.",
25
+ )
26
+ predict.add_argument("--model", default=None, help="Optional local DDON.onnx path.")
27
+
28
+ args = parser.parse_args()
29
+
30
+ values, file_u, y_true = load_input(args.input)
31
+ u = args.u if args.u is not None else file_u
32
+ if u is None:
33
+ parser.error("--u is required when input does not contain Profile_Px.u")
34
+
35
+ model = DDON(model_path=args.model)
36
+ efield = model.predict(values, u)
37
+ save_output(args.output, values[:, 0], efield, y_true)
38
+ print(f"Saved prediction to {args.output}")
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()
@@ -0,0 +1,54 @@
1
+ from pathlib import Path
2
+
3
+ import numpy as np
4
+ from scipy.io import loadmat, savemat
5
+
6
+
7
+ def load_input(path):
8
+ path = Path(path)
9
+ suffix = path.suffix.lower()
10
+
11
+ if suffix == ".mat":
12
+ mat = loadmat(path, squeeze_me=True, struct_as_record=False)
13
+ if "Profile_Px" not in mat:
14
+ raise ValueError("MAT file must contain Profile_Px.")
15
+ profile = mat["Profile_Px"]
16
+ values = np.asarray(profile.Px, dtype=np.float32)
17
+ u = float(np.asarray(profile.u).reshape(-1)[0])
18
+ y_true = None
19
+ if hasattr(profile, "Ex"):
20
+ ex = np.asarray(profile.Ex).squeeze()
21
+ if ex.size == 109:
22
+ y_true = ex.reshape(109)
23
+ return values, u, y_true
24
+
25
+ if suffix in {".csv", ".txt"}:
26
+ values = np.loadtxt(path, delimiter="," if suffix == ".csv" else None)
27
+ return np.asarray(values, dtype=np.float32), None, None
28
+
29
+ raise ValueError("Supported input formats are .mat, .csv, and .txt.")
30
+
31
+
32
+ def save_output(path, z, efield, y_true=None):
33
+ path = Path(path)
34
+ suffix = path.suffix.lower()
35
+ z = np.asarray(z).reshape(-1)
36
+ efield = np.asarray(efield).reshape(-1)
37
+
38
+ if suffix == ".mat":
39
+ data = {"z": z, "efield": efield}
40
+ if y_true is not None:
41
+ data["Ex"] = np.asarray(y_true).reshape(-1)
42
+ savemat(path, data)
43
+ return
44
+
45
+ if suffix == ".csv":
46
+ cols = [z, efield]
47
+ header = "z,efield"
48
+ if y_true is not None:
49
+ cols.append(np.asarray(y_true).reshape(-1))
50
+ header += ",Ex"
51
+ np.savetxt(path, np.column_stack(cols), delimiter=",", header=header, comments="")
52
+ return
53
+
54
+ raise ValueError("Output file must end in .csv or .mat.")
@@ -0,0 +1,54 @@
1
+ from pathlib import Path
2
+ from urllib.request import urlretrieve
3
+
4
+ import numpy as np
5
+ import onnxruntime as ort
6
+
7
+
8
+ MODEL_URL = "https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON-WEB/DDON.onnx"
9
+ U_SCALE = -1.0
10
+ EXPECTED_POINTS = 109
11
+
12
+
13
+ class DDON:
14
+ """Lightweight local DDON inference using ONNX Runtime."""
15
+
16
+ def __init__(self, model_path=None):
17
+ if model_path is None:
18
+ model_path = Path.home() / ".ddon" / "DDON.onnx"
19
+ self.model_path = Path(model_path)
20
+ if not self.model_path.exists():
21
+ self.model_path.parent.mkdir(parents=True, exist_ok=True)
22
+ print(f"Downloading DDON model to {self.model_path}")
23
+ urlretrieve(MODEL_URL, self.model_path)
24
+
25
+ self.session = ort.InferenceSession(
26
+ str(self.model_path),
27
+ providers=["CPUExecutionProvider"],
28
+ )
29
+
30
+ def predict(self, values, u):
31
+ values = np.asarray(values, dtype=np.float32)
32
+ if values.shape != (EXPECTED_POINTS, 2):
33
+ raise ValueError(
34
+ f"values must have shape ({EXPECTED_POINTS}, 2); got {values.shape}"
35
+ )
36
+ if not np.all(np.isfinite(values)):
37
+ raise ValueError("values contains NaN or infinite values")
38
+
39
+ raw_u = float(np.asarray(u).reshape(-1)[0])
40
+ if not np.isfinite(raw_u):
41
+ raise ValueError("u must be finite")
42
+
43
+ values_input = values.reshape(1, EXPECTED_POINTS, 2)
44
+ u_input = np.asarray([[raw_u / U_SCALE]], dtype=np.float32)
45
+
46
+ inputs = self.session.get_inputs()
47
+ outputs = self.session.run(
48
+ None,
49
+ {
50
+ inputs[0].name: values_input,
51
+ inputs[1].name: u_input,
52
+ },
53
+ )
54
+ return np.asarray(outputs[0]).squeeze().reshape(EXPECTED_POINTS)
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddon-efish
3
+ Version: 1.0.0
4
+ Summary: Lightweight local inference package for Decoder-DeepONet (DDON) EFISH electric-field reconstruction.
5
+ Project-URL: Homepage, https://github.com/ozzzzj/Decoder-DeepONet
6
+ Project-URL: Web App, https://ozzzzj.github.io/Decoder-DeepONet/
7
+ Project-URL: Paper, https://doi.org/10.1088/1361-6595/ae413f
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: numpy<3
11
+ Requires-Dist: onnxruntime>=1.17
12
+ Requires-Dist: scipy>=1.9
13
+
14
+ # Decoder-DeepONet (DDON)
15
+ Model and code of Decoder DeepONet (DDON) for Electric field reconstruction from EFISH measurements. This model is specifically designed for vertically polarized EFISH signals (for a vertically
16
+ polarized probe beam). <br>
17
+
18
+ To use the model and code, please cite: <br>
19
+
20
+ ''Yang, Z., Sugeng, E.S., Alicherif, M. and Chng, T.L., 2026. An interpretable operator-learning model for electric field profile reconstruction in discharges based on the EFISH method. Plasma Sources Science and Technology, 35(2), p.025035.'' <br>
21
+
22
+ The related paper and analysis are available at the DOI 10.1088/1361-6595/ae413f. <br>
23
+
24
+ **Note** Scripts and model will be available soon... <br>
25
+
26
+ ## Environment recommended (model trained on):
27
+ - Python 3.10.15
28
+ - TensorFlow-gpu 2.10.1
29
+
30
+ ## Main user file:
31
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
32
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
33
+
34
+ ## Script files:
35
+ 1. 'self_layers.py' %to import some self-defined layers
36
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
37
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
38
+
39
+ ## Model file (DDON) and model description
40
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
41
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
42
+
43
+ ## Instructions to use the model for Efield prediction:
44
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
45
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
46
+ or <br>
47
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
48
+
49
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
50
+
51
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
52
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
53
+ or <br>
54
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
55
+
56
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
57
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
58
+
59
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
60
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
61
+
62
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
63
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
64
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
65
+
66
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
67
+
68
+ The MAT file structure is as follows:<br>
69
+
70
+ <table>
71
+ <tr>
72
+ <td rowspan="3"><code>Profile_Px</code></td>
73
+ <td>$P_x$</td>
74
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
75
+ </tr>
76
+ <tr>
77
+ <td>$u$</td>
78
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
79
+ </tr>
80
+ <tr>
81
+ <td>$E_x$</td>
82
+ <td>The electric field value along $z$; dim: [109,1]</td>
83
+ </tr>
84
+ </table>## Choose how to use DDON
85
+
86
+ ### 1. Online Web App — no installation
87
+
88
+ Run DDON directly in a web browser:
89
+
90
+ **[Launch the DDON E-field Reconstruction Web App](https://ozzzzj.github.io/Decoder-DeepONet/)**
91
+
92
+ The web app supports preprocessed CSV and MATLAB MAT inputs and performs inference locally in the browser using ONNX Runtime Web.
93
+
94
+ ### 2. Local Packaged Inference — lightweight ONNX Runtime
95
+
96
+ For local prediction without installing TensorFlow, install this repository as a Python package:
97
+
98
+ ```bash
99
+ pip install .
100
+ ```
101
+
102
+ Python interface:
103
+
104
+ ```python
105
+ from ddon import DDON
106
+
107
+ model = DDON()
108
+ E = model.predict(values, u=-0.35)
109
+ ```
110
+
111
+ Command-line interface:
112
+
113
+ ```bash
114
+ ddon predict Efish_vertical.mat -o prediction.csv
115
+ ```
116
+
117
+ For MATLAB MAT input, `Profile_Px.Px` and `Profile_Px.u` are read automatically. CSV/TXT input can be used with `--u`:
118
+
119
+ ```bash
120
+ ddon predict input.csv --u -0.35 -o prediction.mat
121
+ ```
122
+
123
+ The ONNX model is downloaded automatically on first use and cached locally. This mode requires only NumPy, SciPy, and ONNX Runtime.
124
+
125
+ ### 3. Full Python Research Code — To be released
126
+
127
+ The full TensorFlow research implementation, including the original prediction, evaluation, and analysis workflow, is not included in the current public release and will be released separately in the future.
128
+
129
+
130
+ ## Environment recommended (model trained on):
131
+ - Python 3.10.15
132
+ - TensorFlow-gpu 2.10.1
133
+
134
+ ## Main user file:
135
+ 1. 'DeepONet_Resnet_Exp.py' % for script use
136
+ 2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use
137
+
138
+ ## Script files:
139
+ 1. 'self_layers.py' %to import some self-defined layers
140
+ 2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
141
+ 3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction
142
+
143
+ ## Model file (DDON) and model description
144
+ - Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
145
+ https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5
146
+
147
+ ## Instructions to use the model for Efield prediction:
148
+ 1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
149
+ $z/z_R = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 \, 24:2:50]$; <br>
150
+ or <br>
151
+ $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
152
+
153
+ **Note**: The first grid point is recommended and should be tried first, as it may always show good predictions; otherwise, try the second to see if better results can be gotten. <br>
154
+
155
+ 2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
156
+ $z^\prime = z/z_R/50 = [-50:2:-24 \, -22:1:-16 \, -15:0.5:-1.5 \, -1:0.2:1 \, 1.5:0.5:15 \, 16:1:22 24:2:50]/50$; <br>
157
+ or <br>
158
+ $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
159
+
160
+ **Note 1**: $z^\prime \in [-1,1]$; crop the input EFISH profile if the normalized and scaled range (z/z_R/50) goes beyond this range. <br>
161
+ **Note 2**: The sampling grid outside your experiment range could be set to zero, as the DDON accepts zero input outside the key feature range. For how to quantify the key range, please refer to our paper. Please ensure the input range is at least 4.2*FWHM of your input EFISH profile (normalized), although sometimes a smaller sampling range than this criterion also works. <br>
162
+
163
+ 3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
164
+ $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$
165
+
166
+ 4. Estimate the phase mismatch value $u$ through the wave-factor mismatch $\Delta k$ and Rayleigh range $z_\mathrm{R}$, and normalize it as input: <br>
167
+ $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
168
+ **Note**: -0.068 is the max $u$ value from the training dataset. <br>
169
+
170
+ 5. Import the MAT file as structure files and obtain the prediction. Or you can modify the code to fit your data structure as well.
171
+
172
+ The MAT file structure is as follows:<br>
173
+
174
+ <table>
175
+ <tr>
176
+ <td rowspan="3"><code>Profile_Px</code></td>
177
+ <td>$P_x$</td>
178
+ <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
179
+ </tr>
180
+ <tr>
181
+ <td>$u$</td>
182
+ <td>The phase mismatch value along $z$; dim: [109,1]</td>
183
+ </tr>
184
+ <tr>
185
+ <td>$E_x$</td>
186
+ <td>The electric field value along $z$; dim: [109,1]</td>
187
+ </tr>
188
+ </table>
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ ddon/__init__.py
4
+ ddon/cli.py
5
+ ddon/io.py
6
+ ddon/predictor.py
7
+ ddon_efish.egg-info/PKG-INFO
8
+ ddon_efish.egg-info/SOURCES.txt
9
+ ddon_efish.egg-info/dependency_links.txt
10
+ ddon_efish.egg-info/entry_points.txt
11
+ ddon_efish.egg-info/requires.txt
12
+ ddon_efish.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ddon = ddon.cli:main
@@ -0,0 +1,3 @@
1
+ numpy<3
2
+ onnxruntime>=1.17
3
+ scipy>=1.9
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ddon-efish"
7
+ version = "1.0.0"
8
+ description = "Lightweight local inference package for Decoder-DeepONet (DDON) EFISH electric-field reconstruction."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ dependencies = [
12
+ "numpy<3",
13
+ "onnxruntime>=1.17",
14
+ "scipy>=1.9"
15
+ ]
16
+
17
+ [project.scripts]
18
+ ddon = "ddon.cli:main"
19
+
20
+ [tool.setuptools.packages.find]
21
+ include = ["ddon*"]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/ozzzzj/Decoder-DeepONet"
25
+ "Web App" = "https://ozzzzj.github.io/Decoder-DeepONet/"
26
+ Paper = "https://doi.org/10.1088/1361-6595/ae413f"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+