forked from Cadair/sunspot_experiments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_stara.py
47 lines (33 loc) · 1.34 KB
/
run_stara.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
from functools import partial
import astropy.units as u
import matplotlib.pyplot as plt
from astropy.time import Time
from astropy.table import QTable, vstack
from skimage.measure import regionprops, label, regionprops_table
from skimage.color import label2rgb
import sunpy.map
from stara import stara
maps = sunpy.map.Map("./data/*720*")
maps = [m.resample((1024, 1024) * u.pix) for m in maps]
segs = list(map(partial(stara, limb_filter=10 * u.percent), maps))
def get_regions(segmentation, smap):
labelled = label(segmentation)
if labelled.max() == 0:
return QTable()
regions = regionprops_table(labelled, smap.data,
properties=["label",
"centroid",
"area",
"min_intensity"])
regions['obstime'] = Time([smap.date] * regions['label'].size)
regions['center_coord'] = smap.pixel_to_world(regions['centroid-0'] * u.pix,
regions['centroid-1'] * u.pix).heliographic_stonyhurst
return QTable(regions)
print(list(map(get_regions, segs, maps)))
# for smap, seg in zip(maps, segs):
# plt.figure()
# ax = plt.subplot(projection=smap)
# smap.plot()
# ax.contour(seg, levels=0)
# plt.colorbar()
plt.show()