# Examples

This folder contains runnable IDL and Python example scripts.

The Python examples are intentionally the convenience layer. When key science inputs are omitted, they fill the repository's demonstration defaults and emit warnings describing the assumptions they made.

## Repository Fixture Dataset

The repository-owned example fixtures are distributed separately from `gximagecomputing` in:

- `https://github.com/suncast-org/pyGXrender-test-data`

Recommended local layout:

```text
@SUNCAST-ORG/
  gximagecomputing/
  pyGXrender-test-data/
```

Install the default fixture set with:

```bash
cd ../pyGXrender-test-data
scripts/install_dataset.sh
```

The shell-based render example wrappers under `tests/` will auto-detect fixtures from:

```text
../pyGXrender-test-data/raw
```

or from `GXRENDER_TEST_DATA_ROOT` if you set it explicitly.

## Python CLI Example (`python/cli/RenderExampleMW.py`)

`python/cli/RenderExampleMW.py` is designed to work with CHR models generated by both `pyampp.py` and `gx_ampp.pro`.
When a `gx_ampp` `.sav` model is used as input, the Python renderer is expected to produce maps similar (within numerical precision) to those produced by the IDL `RenderExampleMW.pro` routine from the same model.

To run these examples, first generate a CHR model with one of these tools:
- `pyampp.py`: available from GitHub ([suncast-org/pyAMPP](https://github.com/suncast-org/pyAMPP)) or via PyPI (`pip install pyampp`).
- `gx_ampp.pro`: part of SolarSoft `GX_Simulator` ([Gelu-Nita/GX_SIMULATOR](https://github.com/Gelu-Nita/GX_SIMULATOR)).

Both renderers accept both model container formats in this workflow:
- Python `python/cli/RenderExampleMW.py`: `.h5` and `.sav`
- IDL `RenderExampleMW.pro`: `.sav` directly, and `.h5` through `LoadGXmodel -> ConvertToGX`

Before running, you can configure the EBTEL table path once in your shell:

```bash
export GXIMAGECOMPUTING_EBTEL_PATH="$SSW/packages/gx_simulator/euv/ebtel/ebtel_ss.sav"
```

If `$SSW` is not defined in your environment, use an absolute path:

```bash
export GXIMAGECOMPUTING_EBTEL_PATH="/full/path/to/ssw/packages/gx_simulator/euv/ebtel/ebtel_ss.sav"
```

Then run from the repository root:

```bash
python examples/python/cli/RenderExampleMW.py --model-path /path/to/your.chr.sav --model-format auto
```

Or with installed CLI entry point:

```bash
gxrender-mw --model-path /path/to/your.chr.h5 --model-format auto
```

## Python SDK Examples (MW/EUV, In-Memory Friendly)

For application integration without CLI/`argparse` overhead, use the SDK examples.

MW SDK example:

```bash
python examples/python/sdk/sdk_render_mw.py --model-path /path/to/your.chr.sav
```

This example uses typed SDK options/result objects and supports `--no-save-outputs`
for fully in-memory rendering. When MW science inputs are omitted, it applies the same example defaults as the CLI wrapper and warns.

EUV SDK example:

```bash
python examples/python/sdk/sdk_render_euv.py --model-path /path/to/your.chr.sav --response-sav /path/to/resp_aia_20251126T153431.sav
```

This example uses typed SDK options/result objects and supports `--no-save-outputs`
for fully in-memory rendering. When EUV science inputs are omitted, it applies the example defaults and warns.

## Local IDL Compile (MW/EUV)

When testing local IDL changes in this repository (instead of SSW-installed routines), compile the local helper routines first so they take precedence.

From the IDL prompt:

```idl
@/Users/gelu/Library/CloudStorage/Dropbox/@Projects/@SUNCAST-ORG/gximagecomputing/examples/idl/compile_local_idl
```

For the EUV example, also compile the EUV example routine explicitly:

```idl
.compile '/Users/gelu/Library/CloudStorage/Dropbox/@Projects/@SUNCAST-ORG/gximagecomputing/examples/idl/RenderExampleEUV.pro'
```

Then run:

```idl
RenderExampleEUV, MODelfile='/path/to/your.chr.sav', EBTELfile='', /NO_PLOT
```

## Viewing Rendered Maps (MW and EUV)

After rendering, use the interactive viewer CLI for both MW and EUV outputs:

```bash
gxrender-map-view /path/to/rendered_maps.h5
```

It supports Python HDF5 outputs and IDL SAV/XDR map containers for both MW and EUV.
See the main repository `README.md` section `Render Map Viewer GUI (gxrender-map-view)`
for full usage, examples, and GUI controls.
