=========================================================
; Version: 	sparse_em_v1.001_ys_v202106
; Author: 	Su et al. 2018, ApJL,  yang.su@pmo.ac.cn
;	Li et al. 2022, in prep. 
; Date : 	Dec. 31 2021

; version of get_em_from_aia.pro:   v202106 
 
	changed the code for the version v20190121V1.001_ys_v202106; 
	changed the tolc, bases_sigmas, and chianti94fix;
	added the missing factor 1.d26 (for the new version v1.001) for the input EM of AIA_SPARSE_EM_EM2IMAGE.

; version of aia_sparse_em_init.pro:   V1.001_ys_v202106
 
	based on the sparse code v1.001; 
	changed basis functions to Gaussian functions in linear T space, instead of Log(T) space;
	introduced a fixed factor of 0.33 to replace 'chianti94fix'. It applies a moderate correction to the AIA 94 response function that is between those in the two cases of 'chianti94fix = 0' and 'chianti94fix = 1'; 
	changed normalization factor;
	comments are added in 2021 Nov.

    Please cite both of the two papers when you use this code. 
    http://adsabs.harvard.edu/abs/2015ApJ...807..143C
    http://adsabs.harvard.edu/abs/2018ApJ...856L..17S 

=========================================================
; Author: Su et al. 2018, ApJL,  yang.su@pmo.ac.cn
; Date : Jan. 21 2019
; version of get_em_from_aia.pro:   v20190121
 
	Fixed a bug that caused the MC run to return zero uncertainties. Reported by: Wei Liu, Lei Lu 
	It does not affect the main result of the EM(T) maps.
	n_img should be the number of images times the number of pixels used to get the average intensities (of the pixels in map_in). Suggested by Wei Liu.   

; version of Example_em_20131113.pro:   v20190121
 
	n_img should be the number of images times the number of pixels used to get the average intensities (of the pixels in map_in). Suggested by Wei Liu. 
	changed the calculation of durs and data for the averaged images, especially for the cases of long/short exposure times.
	you may search for v20190121 for the changes. 
		
    Please cite both of the two papers when you use this code. 
    http://adsabs.harvard.edu/abs/2015ApJ...807..143C
    http://adsabs.harvard.edu/abs/2018ApJ...856L..17S 

=========================================================
; Author: Su et al. 2018, ApJL,  yang.su@pmo.ac.cn
; Date : May 30 2018
; version of aia_sparse_em_init.pro:   2018-05-29 V0.91_ys_v20180529
 
	Fixed one more bug （in the get_em_from_aia.pro, reported by Jianchao Xue）in the calulations of errors on the data generated in the MC loops: durs should be durs[ci]. 
	It will affect the uncertainties when n_mc is set, but will not affect the main results of the EM(T).
	
    Please cite both of the two papers when you use this code. 
    http://adsabs.harvard.edu/abs/2015ApJ...807..143C
    http://adsabs.harvard.edu/abs/2018ApJ...856L..17S 
 
=========================================================
; Author: Su et al. 2018, ApJL,  yang.su@pmo.ac.cn
; Date : May 29 2018
; version of aia_sparse_em_init.pro:   2018-05-29 V0.91_ys_v20180529

	(1) Fixed a few bugs. Many thanks to Shuhong Yang and Jianchao Xue for testing the beta version. 
	The results in the paper are not affected by these bugs. They were obtained from a different code, which is not for the purpose of general use.
	(2) Improvements have been made to get_em_from_aia.pro, aia_sparse_em_init.pro, and Example_em_20131113.pro. You may find the details in each one of them.
	(3) Reduced the number of messages on screen.
	
    Please cite both of the two papers when you use this code. 
    http://adsabs.harvard.edu/abs/2015ApJ...807..143C
    http://adsabs.harvard.edu/abs/2018ApJ...856L..17S 
 
	To get EM maps from AIA data, try to use or modify example_em_20131113.pro, and replace the fits with your files. It calls get_em_from_aia.pro.
	I suggest the users to use level 1 full-disk fits and process them to level 1.5.

=========================================================
; Author: Su et al. 2018, ApJL, submitted,  yang.su@pmo.ac.cn
; Date : Jan 23 2018
; version of aia_sparse_em_init.pro:   2018-01-23 V0.91_ys_v20180123

	This is a modified version of the original Sparse code. 
	If you can't get solution in large flares, try to rebin the maps by combining every 4 by 4 pixels, or try to introduce the 4th run with increased tolerance, or try to contact me.
	For details, see Su et al. 2018
	link to the paper will be added. 

	To get EM maps from AIA images, try example_em_20131113.pro,  and replace the fits with your files. It calls get_em_from_aia.pro

=========================================================
; Author: Mark Cheung, cheung@lmsal.com
; Date : Oct 20 2015

	Example script for running sparse dem code/
	See Cheung et al. (2015)
	http://adsabs.harvard.edu/abs/2015ApJ...807..143C for details about the method.

	Requirements
	------------
	1) Solarsoft installation
	2) The SSW_INSTR environment variable should include 'aia'
	3) Some sample AIA data files (*.genx) from http://www.lmsal.com/~cheung/AIA/tutorial_dem
	4) aia_sparse_em_init.pro and exercise1.pro from http://www.lmsal.com/~cheung/AIA/tutorial_dem/

	Steps
	-------
	1) IDL> .compile aia_sparse_em_init
	2) IDL> .r exercise1

	Additional steps (added 2016-01-07)
	----------------------------------
	Check DEM sensitivity to noise
	3) IDL> .r exercise2  ; after running exercise1
