Difference between revisions of "Tutorial:How to contribute to the flare wiki pages"
(14 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Flare wiki pages are created by the flare data processing pipeline, by using [https://www.mediawiki.org/wiki/API:Edit |WIKI APIs]. | Flare wiki pages are created by the flare data processing pipeline, by using [https://www.mediawiki.org/wiki/API:Edit |WIKI APIs]. | ||
− | |||
− | If you | + | The created pages can be edited manually or by using scripts. |
+ | |||
+ | == Integrate your code to STIX flare processing pipeline == | ||
+ | If you have python code to be integrated into the pipeline, please prepare them similar to the template below and send them to [mailto:hualin.xiao@fhnw.ch Hualin Xiao] | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
#import module_name | #import module_name | ||
Line 15: | Line 17: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Below is | + | Below is an example of plugins. |
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
Line 30: | Line 32: | ||
print('AIA data not available') | print('AIA data not available') | ||
return None | return None | ||
− | + | ||
− | + | sdo = Map(sdo_res[0]) | |
− | + | fig = plt.figure(figsize=(6, 6), dpi=100) | |
− | + | ax = fig.add_subplot(projection=sdo) | |
− | + | sdo.plot(clip_interval=[1, 100] * u.percent, axes=ax) | |
− | + | fname=os.path.join(folder, f'AIA_{wavelen}_{flare_id}.png') | |
− | + | plt.savefig(fname, dpi=100) | |
− | + | return fname | |
− | + | ||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | == Attach data to Wiki using APIs == | |
− | + | If it is impossible to integrate your code into the pipeline, or you only want to push your results to wiki pages, | |
+ | you can use [https://www.mediawiki.org/wiki/API:Edit wiki http APIs] or [https://www.mediawiki.org/wiki/Manual:Pywikibot Pywikibot]. |
Latest revision as of 15:39, 20 May 2021
Flare wiki pages are created by the flare data processing pipeline, by using |WIKI APIs.
The created pages can be edited manually or by using scripts.
1 Integrate your code to STIX flare processing pipeline
If you have python code to be integrated into the pipeline, please prepare them similar to the template below and send them to Hualin Xiao
#import module_name
def plugin_name(flare_id, start_utc, end_utc, flare_peak_utc):
#Flare ID, start UTC, end UTC and peak UTC values will be provided by the pipeline
# A plugin usually consist of blocks as below:
# - data retrieving, for example using sunpy Fido
# - data processing
# - plotting
# - save plot to file
return plot_filename
Below is an example of plugins.
import astropy.units as u
from matplotlib import pyplot as plt
from sunpy.net import Fido, attrs as a
from sunpy.map import Map
def plot(folder,flare_id , start_utc, end_utc, peak_utc, wavelen=131, overwrite=False):
sdo_query = Fido.search(a.Time(utc_start, utc_end), a.Instrument('AIA'),
a.Wavelength(wavelen* u.angstrom))
sdo_res = Fido.fetch(sdo_query[0], progress=False, path=folder)
if not sdo_res:
print('AIA data not available')
return None
sdo = Map(sdo_res[0])
fig = plt.figure(figsize=(6, 6), dpi=100)
ax = fig.add_subplot(projection=sdo)
sdo.plot(clip_interval=[1, 100] * u.percent, axes=ax)
fname=os.path.join(folder, f'AIA_{wavelen}_{flare_id}.png')
plt.savefig(fname, dpi=100)
return fname
2 Attach data to Wiki using APIs
If it is impossible to integrate your code into the pipeline, or you only want to push your results to wiki pages, you can use wiki http APIs or Pywikibot.