Difference between revisions of "Tutorial:How to contribute to the flare wiki pages"

From stix
Jump to: navigation, search
(Undo revision 11178 by Hualin (talk))
(Tag: Undo)
Line 3: Line 3:
 
More  modules can be integrated into the pipeline.
 
More  modules can be integrated into the pipeline.
 
If you wish to contribute code to the pipeline, please prepare plugins similar to the template below and send them to [mailto:hualin.xiao@fhnw.ch Hualin Xiao]
 
If you wish to contribute code to the pipeline, please prepare plugins similar to the template below and send them to [mailto:hualin.xiao@fhnw.ch Hualin Xiao]
Please refer to [https://pub023.cs.technik.fhnw.ch/wiki/index.php?title=Tutorial:Flare_Processing_Plugins_for_WIKI |Flare data processing plugins] on how to prepare plugins.
+
<syntaxhighlight lang="python">
 +
#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
 +
</syntaxhighlight>
 +
 
 +
Below is a plugin example.
 +
<syntaxhighlight lang="python">
 +
 
 +
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
 +
    if sdo_res:
 +
        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
 +
    return None
 +
 
 +
if __name__=='__main__':
 +
    #for test only
 +
    plot('.',0,'2021-04-01T00:00:00', '2021-04-01T00:10:00', '2021-04-01T00:05:00' )
 +
 
 +
</syntaxhighlight>
 +
It is also possible to integrate IDL code, which is compatible with GDL, into the pipeline.

Revision as of 11:43, 14 May 2021

Flare wiki pages are created by the flare data processing pipeline. At present, it only processes data from a few instruments. More modules can be integrated into the pipeline. If you wish to contribute code to the pipeline, please prepare plugins 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 a plugin example.

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
    if sdo_res:
        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
    return None

if __name__=='__main__':
    #for test only
    plot('.',0,'2021-04-01T00:00:00', '2021-04-01T00:10:00', '2021-04-01T00:05:00' )

It is also possible to integrate IDL code, which is compatible with GDL, into the pipeline.