Note
Go to the end to download the full example code.
Full Walkthrough#
Here we see the functions needed to quickly extract properties from a magnetogram.
from sunpy.map import Map
from smart.calculate_properties import dB_dt, get_properties, smart_indentify_and_characterize
from smart.differential_rotation import diff_rotation
from smart.indexed_grown_mask import index_and_grow_mask
from smart.processing import smart_prep
hmi_map = Map(
"http://jsoc.stanford.edu/data/hmi/fits/2024/06/06/hmi.M_720s.20240606_230000_TAI.fits"
# "https://solmon.dias.ie/data/2024/06/06/HMI/fits/hmi.m_720s_nrt.20240606_230000_TAI.3.magnetogram.fits"
)
hmi_map_prev = Map(
"http://jsoc.stanford.edu/data/hmi/fits/2024/06/06/hmi.M_720s.20240606_000000_TAI.fits"
# "https://solmon.dias.ie/data/2024/06/06/HMI/fits/hmi.m_720s_nrt.20240606_000000_TAI.3.magnetogram.fits"
)
threshold_map, cos_correction = smart_prep(hmi_map)
threshold_map_prev, cos_correction_prev = smart_prep(hmi_map_prev)
rotated_map = diff_rotation(hmi_map, hmi_map_prev)
sorted_labels = index_and_grow_mask(hmi_map, rotated_map)
dBdt, dt = dB_dt(hmi_map, hmi_map_prev)
properties = get_properties(hmi_map, dBdt, dt, sorted_labels)
for i in range(len(properties)):
for prop, value in properties[i].items():
print(prop, ":", value)
print()
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
hmi.M_720s.20240606_230000_TAI.fits: 0%| | 0.00/1.00M [00:00<?, ?B/s]
hmi.M_720s.20240606_230000_TAI.fits: 0%| | 1.02k/1.00M [00:00<01:43, 9.72kB/s]
hmi.M_720s.20240606_230000_TAI.fits: 6%|▌ | 57.3k/1.00M [00:00<00:02, 322kB/s]
hmi.M_720s.20240606_230000_TAI.fits: 18%|█▊ | 181k/1.00M [00:00<00:01, 720kB/s]
hmi.M_720s.20240606_230000_TAI.fits: 46%|████▌ | 463k/1.00M [00:00<00:00, 1.51MB/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.71file/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.71file/s]
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
hmi.M_720s.20240606_000000_TAI.fits: 0%| | 0.00/1.00M [00:00<?, ?B/s]
hmi.M_720s.20240606_000000_TAI.fits: 0%| | 1.02k/1.00M [00:00<01:44, 9.62kB/s]
hmi.M_720s.20240606_000000_TAI.fits: 6%|▌ | 57.3k/1.00M [00:00<00:02, 320kB/s]
hmi.M_720s.20240606_000000_TAI.fits: 19%|█▉ | 193k/1.00M [00:00<00:01, 772kB/s]
hmi.M_720s.20240606_000000_TAI.fits: 48%|████▊ | 482k/1.00M [00:00<00:00, 1.56MB/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.71file/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.71file/s]
feature label : 1
flux emergence rate : 827.3424378920586 Wb / s
mean B : 0.3138936626971728 G
std B : 24.452945786497033 G
minimum B : -1068.5 G
maximum B : 1247.8000000000002 G
positive flux : 177288539080923.62 Wb
negative flux : -129515858814029.11 Wb
unsigned flux : 306804397894952.75 Wb
flux imbalance : 6.422172592806393
total area (millionths) : 9130.873555891341
feature label : 2
flux emergence rate : -304.62129596472585 Wb / s
mean B : -0.07426020437685889 G
std B : 14.54994365208442 G
minimum B : -551.9 G
maximum B : 1932.8000000000002 G
positive flux : 26759921477710.164 Wb
negative flux : -38061866759999.0 Wb
unsigned flux : 64821788237709.164 Wb
flux imbalance : -5.73545408499639
total area (millionths) : 2277.8357622914323
feature label : 3
flux emergence rate : -1293.9733357756866 Wb / s
mean B : -0.13868665301068178 G
std B : 8.564498212155844 G
minimum B : -964.4000000000001 G
maximum B : 825.9000000000001 G
positive flux : 14577470687179.123 Wb
negative flux : -35684724254132.34 Wb
unsigned flux : 50262194941311.46 Wb
flux imbalance : -2.381275933502072
total area (millionths) : 2259.0286077105293
feature label : 4
flux emergence rate : 84.01270514038454 Wb / s
mean B : 0.025186612505641772 G
std B : 19.939651013210433 G
minimum B : -1385.0 G
maximum B : 1562.8000000000002 G
positive flux : 54647681719126.57 Wb
negative flux : -50814434574571.56 Wb
unsigned flux : 105462116293698.12 Wb
flux imbalance : 27.512475015732637
total area (millionths) : 2128.1018776291826
feature label : 5
flux emergence rate : -102.26631425137631 Wb / s
mean B : -0.04553287273316437 G
std B : 11.116037438252599 G
minimum B : -1093.7 G
maximum B : 979.5 G
positive flux : 25584835325215.86 Wb
negative flux : -32514657839111.527 Wb
unsigned flux : 58099493164327.39 Wb
flux imbalance : -8.38397997175633
total area (millionths) : 2057.2133718541354
feature label : 6
flux emergence rate : -575.9158470730083 Wb / s
mean B : -0.01940480736960271 G
std B : 11.405571348136041 G
minimum B : -993.5 G
maximum B : 997.6 G
positive flux : 29840380776055.547 Wb
negative flux : -32793672824515.477 Wb
unsigned flux : 62634053600571.02 Wb
flux imbalance : -21.20821529764832
total area (millionths) : 1652.1361959674296
We can also use the smart_identify_and_characterize function to quickly and easily get these properties
smart_properties = smart_indentify_and_characterize(hmi_map, hmi_map_prev)
for i in range(len(smart_properties)):
for prop, value in smart_properties[i].items():
print(prop, ":", value)
print()
feature label : 1
flux emergence rate : 827.3424378920586 Wb / s
mean B : 0.3138936626971728 G
std B : 24.452945786497033 G
minimum B : -1068.5 G
maximum B : 1247.8000000000002 G
positive flux : 177288539080923.62 Wb
negative flux : -129515858814029.11 Wb
unsigned flux : 306804397894952.75 Wb
flux imbalance : 6.422172592806393
total area (millionths) : 9130.873555891341
feature label : 2
flux emergence rate : -304.62129596472585 Wb / s
mean B : -0.07426020437685889 G
std B : 14.54994365208442 G
minimum B : -551.9 G
maximum B : 1932.8000000000002 G
positive flux : 26759921477710.164 Wb
negative flux : -38061866759999.0 Wb
unsigned flux : 64821788237709.164 Wb
flux imbalance : -5.73545408499639
total area (millionths) : 2277.8357622914323
feature label : 3
flux emergence rate : -1293.9733357756866 Wb / s
mean B : -0.13868665301068178 G
std B : 8.564498212155844 G
minimum B : -964.4000000000001 G
maximum B : 825.9000000000001 G
positive flux : 14577470687179.123 Wb
negative flux : -35684724254132.34 Wb
unsigned flux : 50262194941311.46 Wb
flux imbalance : -2.381275933502072
total area (millionths) : 2259.0286077105293
feature label : 4
flux emergence rate : 84.01270514038454 Wb / s
mean B : 0.025186612505641772 G
std B : 19.939651013210433 G
minimum B : -1385.0 G
maximum B : 1562.8000000000002 G
positive flux : 54647681719126.57 Wb
negative flux : -50814434574571.56 Wb
unsigned flux : 105462116293698.12 Wb
flux imbalance : 27.512475015732637
total area (millionths) : 2128.1018776291826
feature label : 5
flux emergence rate : -102.26631425137631 Wb / s
mean B : -0.04553287273316437 G
std B : 11.116037438252599 G
minimum B : -1093.7 G
maximum B : 979.5 G
positive flux : 25584835325215.86 Wb
negative flux : -32514657839111.527 Wb
unsigned flux : 58099493164327.39 Wb
flux imbalance : -8.38397997175633
total area (millionths) : 2057.2133718541354
feature label : 6
flux emergence rate : -575.9158470730083 Wb / s
mean B : -0.01940480736960271 G
std B : 11.405571348136041 G
minimum B : -993.5 G
maximum B : 997.6 G
positive flux : 29840380776055.547 Wb
negative flux : -32793672824515.477 Wb
unsigned flux : 62634053600571.02 Wb
flux imbalance : -21.20821529764832
total area (millionths) : 1652.1361959674296
Total running time of the script: (0 minutes 19.148 seconds)