Note
Click here to download the full example code
Simple Radynversion Example
The following illustrates configuring and using Radynversion with some small SST/CRISP images. To load this data we use the crispy package.
from crispy import CRISPSequence
from crispy.utils import CRISP_sequence_constructor
from matplotlib import pyplot as plt
from smug.radynversion_adapter import RadynversionAdapter
from smug.radynversion_model import model_params, pretrained_radynversion
Plot the Halpha intensity map (see crispy’s documentation for how this is used.).
files = [
"../tests/mini_crisp_l2_20140906_152724_6563_r00459.fits",
"../tests/mini_crisp_l2_20140906_152724_8542_r00459.fits",
]
ims = CRISPSequence(CRISP_sequence_constructor(files))
ims.list[0][7].intensity_map()
plt.show()
/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/astropy/wcs/wcs.py:725: FITSFixedWarning: 'datfix' made the change 'Set MJD-AVG to 56906.705521 from DATE-AVG'.
warnings.warn(
/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/astropy/wcs/wcs.py:725: FITSFixedWarning: 'datfix' made the change 'Set MJD-AVG to 56906.705580 from DATE-AVG'.
warnings.warn(
/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/astropy/wcs/wcsapi/fitswcs.py:493: AstropyUserWarning: target cannot be converted to ICRS, so will not be set on SpectralCoord
warnings.warn('target cannot be converted to ICRS, so will '
Configure model, and Adapter class containing utilities to run the model and correctly transform the parameters.
radynversion_version = "1.1.1"
ad = RadynversionAdapter(
model=pretrained_radynversion(version=radynversion_version),
**model_params[radynversion_version]
)
Downloading: "https://www.astro.gla.ac.uk/users/USER-MANAGED/solar_model_weights/Radynversion_1.1.1.pth.tar" to /home/runner/.cache/torch/hub/checkpoints/Radynversion_1.1.1.pth.tar
0%| | 0.00/45.2M [00:00<?, ?B/s]
0%| | 32.0k/45.2M [00:00<02:48, 280kB/s]
0%| | 64.0k/45.2M [00:00<02:49, 279kB/s]
0%| | 96.0k/45.2M [00:00<02:49, 279kB/s]
0%| | 144k/45.2M [00:00<02:22, 333kB/s]
0%| | 208k/45.2M [00:00<01:54, 413kB/s]
1%| | 288k/45.2M [00:00<01:32, 508kB/s]
1%| | 368k/45.2M [00:00<01:22, 569kB/s]
1%|1 | 464k/45.2M [00:00<01:11, 652kB/s]
1%|1 | 576k/45.2M [00:01<01:02, 752kB/s]
1%|1 | 688k/45.2M [00:01<00:57, 819kB/s]
2%|1 | 848k/45.2M [00:01<00:46, 993kB/s]
2%|2 | 0.98M/45.2M [00:01<00:41, 1.11MB/s]
3%|2 | 1.19M/45.2M [00:01<00:35, 1.32MB/s]
3%|3 | 1.39M/45.2M [00:01<00:31, 1.46MB/s]
4%|3 | 1.59M/45.2M [00:01<00:29, 1.57MB/s]
4%|4 | 1.86M/45.2M [00:01<00:25, 1.80MB/s]
5%|4 | 2.17M/45.2M [00:02<00:21, 2.10MB/s]
6%|5 | 2.61M/45.2M [00:02<00:16, 2.63MB/s]
7%|6 | 3.08M/45.2M [00:02<00:14, 3.09MB/s]
8%|8 | 3.72M/45.2M [00:02<00:11, 3.87MB/s]
10%|9 | 4.50M/45.2M [00:02<00:08, 4.79MB/s]
12%|#2 | 5.56M/45.2M [00:02<00:06, 6.18MB/s]
15%|#5 | 6.91M/45.2M [00:02<00:05, 7.91MB/s]
19%|#9 | 8.64M/45.2M [00:02<00:03, 10.2MB/s]
23%|##2 | 10.4M/45.2M [00:02<00:03, 11.7MB/s]
27%|##6 | 12.1M/45.2M [00:03<00:02, 12.9MB/s]
31%|### | 13.9M/45.2M [00:03<00:02, 13.7MB/s]
35%|###4 | 15.6M/45.2M [00:03<00:02, 14.2MB/s]
38%|###8 | 17.4M/45.2M [00:03<00:01, 14.6MB/s]
42%|####2 | 19.1M/45.2M [00:03<00:01, 15.0MB/s]
46%|####6 | 20.9M/45.2M [00:03<00:01, 15.2MB/s]
50%|##### | 22.7M/45.2M [00:03<00:01, 15.3MB/s]
54%|#####3 | 24.4M/45.2M [00:03<00:01, 15.4MB/s]
58%|#####7 | 26.2M/45.2M [00:04<00:01, 15.4MB/s]
62%|######1 | 27.9M/45.2M [00:04<00:01, 15.4MB/s]
66%|######5 | 29.7M/45.2M [00:04<00:01, 15.5MB/s]
70%|######9 | 31.5M/45.2M [00:04<00:00, 15.5MB/s]
73%|#######3 | 33.2M/45.2M [00:04<00:00, 15.6MB/s]
77%|#######7 | 35.0M/45.2M [00:04<00:00, 15.5MB/s]
81%|########1 | 36.7M/45.2M [00:04<00:00, 15.5MB/s]
85%|########5 | 38.5M/45.2M [00:04<00:00, 15.6MB/s]
89%|########8 | 40.2M/45.2M [00:04<00:00, 15.6MB/s]
93%|#########2| 42.0M/45.2M [00:05<00:00, 15.6MB/s]
97%|#########6| 43.8M/45.2M [00:05<00:00, 15.6MB/s]
100%|##########| 45.2M/45.2M [00:05<00:00, 9.03MB/s]
Run the inversion for a small slice of the data.
inv = ad.invert_dual_cubes(ims[:, :1, :3])
0%| | 0/2 [00:00<?, ?it/s]
50%|##### | 1/2 [00:04<00:04, 4.78s/it]
100%|##########| 2/2 [00:07<00:00, 3.37s/it]
100%|##########| 2/2 [00:07<00:00, 3.59s/it]
Display the inversion results for a pixel
inv[:, 0, 1].plot_params(eb=True)
plt.show()
Total running time of the script: ( 0 minutes 17.167 seconds)