[{ALLOW edit EISMainUsers}]
[{ALLOW view Anonymous}]
!!!Re-spiking AIA images

This page explains how to re-spike AIA images, and gives information about the AIA spikes files. AIA images are automatically de-spiked when converted from level-0 to level-1, ''however'' only the EUV wavelengths are de-spiked. The FUV wavelengths (1600, 1700) are not de-spiked.

Examples of solar features that can be affected by spike removal are flare kernels ([Young et al. 2013|http://adsabs.harvard.edu/abs/2013ApJ...766..127Y]) and jets ([Young & Muglach 2014|http://adsabs.harvard.edu/abs/2014SoPh..289.3313Y]), but essentially any small-scale, intense solar feature can be affected

!!The aia_respike routine

This is run as follows:

{{{
IDL> read_sdo, aia_file, index, data, /use_shared_lib
IDL> aia_respike, index, data, outindex, outdata
}}}

The routine automatically downloads the spikes file from the JSOC and puts it in your working directory (look for spikes.fits). All spikes in {{data}} are re-filled with their original values. __Make sure that you run aia_respike before you run aia_prep!__ (aia_prep will re-scale the images so the image is re-sampled and the spikes no longer correspond to their original positions.)

aia_respike also works on cutout data, but __the cutout file must be in standard level-1 format__. In particular, if you download the cutouts from the JSOC you should not use the register option, nor should you scale the images.  Also, you should run aia_respike before you run aia_prep.

!!The spikes files

Since aia_respike automatically downloads the spikes files, then generally you will not need to download them yourself. However, to get them from JSOC you have to use the RecordSet:

{{{
aia.lev1_euv_12s[2011.02.10_05:00/40m@1m][193]{spikes}
}}}

i.e., you append {spikes} to the query. There is no equivalent of cutouts for the spikes files - you have to download the whole file. For a single EUV wavelength, a complete day's worth of spikes files (7200 in all) will take up about 1 Gbyte of space.

The spikes file is read with read_sdo:

{{{
IDL> read_sdo, spike_file, index, data, /use_shared_lib
}}}

and you will see that {{data}} has a size (N,3) where N is the number of spikes. The first element gives the location of the spike as an integer. This can be converted to a 2D location using the SSW routine get_ij:

{{{
IDL> ij=get_ij(data[0,0],4096)
}}}

where 4096 is input because this is the size of full-disk AIA images.

The 2nd element of the array ({{{data[*,1]}}}) is the original value at the spike location, and the 3rd element ({{{data[*,2]}}}) is the value after the spike has been replaced.

!!Batch processing

If you want to re-spike a whole sequence of AIA images, then it's probably best to download the spikes files in advance, and then give the spikes data as an input to aia_respike (I've had problems whereby aia_respike fails to connect to JSOC to retrieve the spikes file and then it crashes). This can be done as follows:

{{{
IDL> read_sdo, aia_file, index, data, /use_shared_lib
IDL> read_sdo, spike_file, spk_index, spk_data, /use_shared_lib
IDL> aia_respike, index, data, outindex, outdata, ispikedd=spk_data
}}}

Of course make sure that your spikes file matches the data file to which it applies.