# Prerequisites
To access and work with SDO data within IDL, you need Solar Soft to be installed.
The following instruments must be installed and set in you SSW_INSTR variable : *vso, aia, hmi and ontology*.
See the [Solar Soft documentation](http://www.lmsal.com/solarsoft/) if you don't know how.
# How To
Downloading SDO data with IDL and the VSO is a 2 steps process:
1. Search data with the procedure [**vso_search**](http://hesperia.gsfc.nasa.gov/ssw/gen/idl/clients/vso/vso_search.pro)
1. Download the data on your hard drive with the procedure [**vso_get**](http://hesperia.gsfc.nasa.gov/ssw/gen/idl/clients/vso/vso_get.pro)
Because the SDO data is compressed, to read it you need to use the procedure [**read_sdo**](http://hesperia.gsfc.nasa.gov/ssw/vobs/ontology/idl/jsoc/read_sdo.pro)
There is several IDL procedures to process and visualise AIA data:
* [**aia_prep**](http://hesperia.gsfc.nasa.gov/ssw/sdo/aia/idl/calibration/aia_prep.pro) See below for documentation and examples.
* [**aia_intscale**](http://hesperia.gsfc.nasa.gov/ssw/sdo/aia/idl/pubrel/aia_intscale.pro) To improve the contrast for visualization.
* [**aia_respike**](http://hesperia.gsfc.nasa.gov/ssw/sdo/aia/idl/calibration/aia_respike.pro) To inverse the despiking of AIA data.
# Available SDO data through VSO
See [JSOC](http://jsoc.stanford.edu/JsocSeries_DataProducts_map.html) for information about SDO data series
The most common ones are
| Instrument | Series | VSO_SEARCH parameters |
| --- | --- | --- |
| AIA | aia.lev1 | inst='aia' |
| HMI | hmi.Ic_45s | inst='hmi', physobs='intensity' |
| HMI | hmi.M_45s | inst='hmi', physobs='los_magnetic_field' |
| HMI | hmi.V_45s | inst='hmi', physobs='los_velocity' |
# Examples
## Search & download AIA data
```idl
; Search AIA 171 Angstrom data for the 6th december 2010 with a cadence of 3600 seconds (1 hour)
results = VSO_SEARCH('6-dec-2010', '7-dec-2010', inst='aia', wave='171', sample=3600)
; Sort the results by date and print the date
results = results(SORT(cat.time.start))
print, results.time.start
; Download the first two
status = VSO_GET(results[0:2], pixels=4096, filenames=files, /rice, /use_network)
; The local filenames will be in the files variable
print, files
```
## Read AIA image & plot it
```idl
; Read the image and header of the AIA fits file located at files[0] (see above)
; Because SDO files are rice compressed you need to use the specialised read_sdo procedure for this
READ_SDO, files[0], header, image
; Improve the contrast with aia_intscale and plot the resulting image
image = AIA_INTSCALE(image, exptime=header.EXPTIME, wavelnth=header.WAVELNTH, bytescale=1)
plot_image, image
; Load AIA standard colour table and plot the image using it
AIA_LCT, rr, gg, bb, wavelnth=header.WAVELNTH, /load
plot_image, image
; Save the image to PNG
png_file = header.T_OBS + ".png"
WRITE_PNG, png_file, image
```
## Run AIA prep
```idl
; Prep the AIA fits file located at files[0] (see above) and save it to directory outdir
AIA_PREP, files[0], [0], /do_write_fits, outdir='.', /verbose
; Prep the AIA fits file located at files[0] (see above) and save the resulting image to prepped_image
AIA_PREP, files[0], [0], prepped_header, prepped_image
```
## Search & download HMI data
```idl
; Search HMI magnetogram data for the 6th december 2010 with a cadence of 3600 seconds (1 hour)
results = VSO_SEARCH('6-dec-2010', '7-dec-2010', inst='hmi', physobs='los_magnetic_field', sample=3600)
; Download the first two
status = VSO_GET(results[0:2], pixels=4096, filenames=files, /rice, /use_network)
; Search HMI continuum data for the 6th december 2010 with a cadence of 3600 seconds (1 hour)
results = VSO_SEARCH('6-dec-2010', '7-dec-2010', inst='hmi', physobs='intensity', sample=3600)
```