-
Notifications
You must be signed in to change notification settings - Fork 0
/
MovieFrame.py
166 lines (135 loc) · 4.47 KB
/
MovieFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"""
Generate two movie frames, using the same procedure as in MakeMovie
Intended for debugging
"""
import matplotlib.pyplot as plt
import numpy as np
from CIMP import Animate as an
from CIMP import Snapshot as snap
from sunpy.net import attrs as a
from astropy.io import fits
pcase = 2
# default directory for movies
outdir = '/home/mark.miesch/Products/image_processing/movies'
rmask = None
if pcase == 1:
title = "Model CME0 pos-30"
outfile = f"/CME0_pos30_p{pcase}.mp4"
instrument = 'ModelHAO0'
detector = 'original'
dir = '/home/mark.miesch/data/anny/CME0/pos-30/dcmer_030W_bang_0000_fits/tB'
bgfile = dir+'/frame_0000.fits'
background = 'ratio'
method = 'none'
colormap = 'soholasco2'
scale = (0.0,1.0)
elif pcase == 2:
title = "LASCO April 15, 2012"
outfile = f"/lasco_c3_2012_04_15_p{pcase}.mp4"
instrument = a.Instrument.lasco
detector = a.Detector.c3
dir = '/home/mark.miesch/data/lasco_monthly/c3/2012_04/15'
bgfile = '/home/mark.miesch/data/lasco_monthly/c3/2012_04/background.fts'
background = 'ratio'
method = 'none'
#colormap = 'soholasco2'
colormap = 'stereocor2'
scale = (0.0,1.0)
elif pcase == 3:
title = "LASCO Jan 17, 2014"
outfile = f"/lasco_c3_2014_01_17_p{pcase}.mp4"
instrument = a.Instrument.lasco
detector = a.Detector.c3
dir = '/home/mark.miesch/data/lasco_monthly/c3/2014_01/17'
bgfile = '/home/mark.miesch/data/lasco_monthly/c3/2014_01/background.fts'
background = 'ratio'
method = 'none'
colormap = 'soholasco2'
#colormap = 'stereocor2'
scale = (1.,1.1)
#scale = (0.,1.)
#file1 = '33385478.fts'
#file2 = '33385479.fts'
#file1 = '33385479.fts'
#file2 = '33385480.fts'
# frames 27-29
#file1 = '33385504.fts'
#file2 = '33385505.fts'
#file1 = '33385505.fts'
#file2 = '33385506.fts'
# frames 37-39
#file1 = '33385514.fts'
#file2 = '33385515.fts'
#file1 = '33385515.fts'
#file2 = '33385516.fts'
# frames 71-73
file1 = '33385564.fts'
file2 = '33385565.fts'
#file1 = '33385565.fts'
#file2 = '33385566.fts'
# subset of simulation data for testing & debugging
elif pcase == 4:
title = "Testing"
outfile = f"/testing.mp4"
instrument = 'ModelHAO0'
detector = 'original'
dir = '/home/mark.miesch/data/anny/testing'
bgfile = dir+'/frame_0000.fits'
background = 'ratio'
method = 'enhance mgn'
colormap = 'soholasco2'
cliprange = 'image'
scale = (0.0,0.1)
file1 = 'frame_0008.fits'
file2 = 'frame_0009.fits'
elif pcase == 7:
title = "LASCO April 15, 2012"
outfile = f"/lasco_c3_2012_04_15_p{pcase}_mgn.mp4"
instrument = a.Instrument.lasco
detector = a.Detector.c3
dir = '/home/mark.miesch/data/lasco_monthly/c3/2012_04/15'
bgfile = '/home/mark.miesch/data/lasco_monthly/c3/2012_04/background.fts'
background = 'ratio'
method = 'enhance_mgn'
colormap = 'soholasco2'
#colormap = 'stereocor2'
cliprange = (1.0,2.0)
scale = (0.0,1.0)
rmask = 1.05
file1 = '32296626.fts'
file2 = '32296627.fts'
outfile = outdir + '/' + outfile
m = an.movie(dir, bgfile = bgfile, outfile = outfile, \
instrument = instrument, detector = detector, \
cmap = colormap)
#-----------------------------------------------------------------
fpath = dir+'/'+file1
x1 = snap.snapshot(file = fpath, bgfile = bgfile, \
instrument = instrument, detector = detector)
x1.background_ratio(rescale = False)
#x1.enhance(detail='mgn')
#x1.mask_annulus(rmax=rmask)
map1 = x1.map()
fpath = dir+'/'+file2
x2 = snap.snapshot(file = fpath, bgfile = bgfile, \
instrument = instrument, detector = detector)
x2.background_ratio(rescale = False)
#x2.enhance(detail='mgn')
#x2.mask_annulus(rmax=rmask)
map2 = x2.map()
#-----------------------------------------------------------------
valid_pix = np.ma.masked_where(x1.data <= 0.0, x1.data)
threshold = 0.5 * np.nanmedian(valid_pix)
print(f"Threshold = {threshold}")
d = fits.ImageDataDiff(x1.data, x2.data, rtol = threshold)
mismatch = d.diff_ratio*100
print(f"pixel mismatch (percent): {mismatch}")
#-----------------------------------------------------------------
fig = plt.figure(figsize=[16,8])
ax = fig.add_subplot(1,2,1,projection=map1)
map1.plot(cmap = colormap, vmin = scale[0], vmax = scale[1], \
autoalign = True)
ax = fig.add_subplot(1,2,2,projection=map2)
map2.plot(cmap = colormap, vmin = scale[0], vmax = scale[1], \
autoalign = True)
plt.show()