Metadata-Version: 2.4
Name: ddon-efish
Version: 1.0.0
Summary: Lightweight local inference package for Decoder-DeepONet (DDON) EFISH electric-field reconstruction.
Project-URL: Homepage, https://github.com/ozzzzj/Decoder-DeepONet
Project-URL: Web App, https://ozzzzj.github.io/Decoder-DeepONet/
Project-URL: Paper, https://doi.org/10.1088/1361-6595/ae413f
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: numpy<3
Requires-Dist: onnxruntime>=1.17
Requires-Dist: scipy>=1.9

# Decoder-DeepONet (DDON)
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
polarized probe beam). <br>

To use the model and code, please cite: <br>

''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>

The related paper and analysis are available at the DOI 10.1088/1361-6595/ae413f. <br>

**Note** Scripts and model will be available soon...  <br>

## Environment recommended (model trained on):
- Python 3.10.15
- TensorFlow-gpu 2.10.1

## Main user file:
1. 'DeepONet_Resnet_Exp.py' % for script use
2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use

## Script files:
1. 'self_layers.py' %to import some self-defined layers
2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction

## Model file (DDON) and model description
- Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
  https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5

## Instructions to use the model for Efield prediction:
1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
   $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>
   or <br>
   $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
   
   **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>

2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
   $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>
   or <br>
   $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
   
   **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>
   **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>

3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
   $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$

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>
   $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
   **Note**: -0.068 is the max $u$ value from the training dataset. <br>

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.
   
   The MAT file structure is as follows:<br>
   
   <table>
  <tr>
    <td rowspan="3"><code>Profile_Px</code></td>
    <td>$P_x$</td>
    <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
  </tr>
  <tr>
    <td>$u$</td>
    <td>The phase mismatch value along $z$; dim: [109,1]</td>
  </tr>
  <tr>
    <td>$E_x$</td>
    <td>The electric field value along $z$; dim: [109,1]</td>
  </tr>
</table>## Choose how to use DDON

### 1. Online Web App — no installation

Run DDON directly in a web browser:

**[Launch the DDON E-field Reconstruction Web App](https://ozzzzj.github.io/Decoder-DeepONet/)**

The web app supports preprocessed CSV and MATLAB MAT inputs and performs inference locally in the browser using ONNX Runtime Web.

### 2. Local Packaged Inference — lightweight ONNX Runtime

For local prediction without installing TensorFlow, install this repository as a Python package:

```bash
pip install .
```

Python interface:

```python
from ddon import DDON

model = DDON()
E = model.predict(values, u=-0.35)
```

Command-line interface:

```bash
ddon predict Efish_vertical.mat -o prediction.csv
```

For MATLAB MAT input, `Profile_Px.Px` and `Profile_Px.u` are read automatically. CSV/TXT input can be used with `--u`:

```bash
ddon predict input.csv --u -0.35 -o prediction.mat
```

The ONNX model is downloaded automatically on first use and cached locally. This mode requires only NumPy, SciPy, and ONNX Runtime.

### 3. Full Python Research Code — To be released

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.


## Environment recommended (model trained on):
- Python 3.10.15
- TensorFlow-gpu 2.10.1

## Main user file:
1. 'DeepONet_Resnet_Exp.py' % for script use
2. 'DeepONet_Resnet_Exp.ipynb' % for jupyter editor use

## Script files:
1. 'self_layers.py' %to import some self-defined layers
2. 'PINN_Model_Predict.py' % run the model, output MATLAB .mat file, visualize the prediction
3. 'self_Predict_ModelResult.py' % child file of the 'PINN_Model_Predict.py', including necessary code for Efield prediction

## Model file (DDON) and model description
- Please download the DDON model via the release page for use (put it under the dir model log) or via: <br>
  https://github.com/ozzzzj/Decoder-DeepONet/releases/download/DDON/20260520_model_Batsize-512.h5

## Instructions to use the model for Efield prediction:
1. To use the model, please first interpolate the EFISH file to the following grid via MATLAB:
   $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>
   or <br>
   $z/z_R = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]$; <br>
   
   **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>

2. Then further normalize the $z/z_R$ by dividing $z_\mathrm{scale} = 50$, then the input grid should be:<br>
   $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>
   or <br>
   $z^\prime = z/z_R/50 = [-50:1:-2 \, -1:0.2:1 \, 2:1:50]/50$; <br>
   
   **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>
   **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>

3. Normalize the measured EFISH profile (along the laser propagation axis, $z$) by its maximum:
   $P_\mathrm{norm}(z) = P(z)/P_\mathrm{max}$

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>
   $u^\prime$ = $\Delta k \cdot z_\mathrm{R}$/-0.068. <br>
   **Note**: -0.068 is the max $u$ value from the training dataset. <br>

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.
   
   The MAT file structure is as follows:<br>
   
   <table>
  <tr>
    <td rowspan="3"><code>Profile_Px</code></td>
    <td>$P_x$</td>
    <td>$[z, P_x]$ (experimentally measured EFISH and normalized $z'$; dim: [109,2])</td>
  </tr>
  <tr>
    <td>$u$</td>
    <td>The phase mismatch value along $z$; dim: [109,1]</td>
  </tr>
  <tr>
    <td>$E_x$</td>
    <td>The electric field value along $z$; dim: [109,1]</td>
  </tr>
</table>
