From fdc7ba4e67f8db335c4b45753ebf97964736488d Mon Sep 17 00:00:00 2001 From: aringlis Date: Tue, 4 Dec 2012 12:23:30 -0500 Subject: [PATCH 01/44] added utility get_combined_chisq.pro. Takes reduced chi-squared values (from AIA and RHESSI) as input, and outputs the combined reduced chi-squared. --- get_combined_chisq.pro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 get_combined_chisq.pro diff --git a/get_combined_chisq.pro b/get_combined_chisq.pro new file mode 100644 index 0000000..0353cec --- /dev/null +++ b/get_combined_chisq.pro @@ -0,0 +1,17 @@ +FUNCTION get_combined_chisq,chi_red_aia,chi_red_hsi + +n_aia=6 +n_hsi=21 +nfree=3 + +chi_full_aia=chi_red_aia*(n_aia-nfree) +chi_full_hsi=chi_red_hsi*(n_hsi-nfree) + +chi_full_combo=chi_full_aia+chi_full_hsi + +chi_red_combo=chi_full_combo/(n_aia + n_hsi - nfree) + +return, chi_red_combo + + +END From 3638e6cb84a8f021562f343797a650af675b2873 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 4 Dec 2012 15:08:07 -0500 Subject: [PATCH 02/44] bug fix. Fileset is case sensitive. Now allow both upper and lower case. --- aiafile_to_time.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiafile_to_time.pro b/aiafile_to_time.pro index a9ecefb..8334df8 100644 --- a/aiafile_to_time.pro +++ b/aiafile_to_time.pro @@ -6,13 +6,13 @@ FUNCTION aiafile_to_time, f, fileset = fileset dim = n_elements(f) result = strarr(dim) -default, fileset, 'aia' +default, fileset, 'AIA' FOR i = 0, dim-1 DO BEGIN filename = file_basename(f[i]) - IF fileset EQ 'aia' THEN BEGIN + IF (fileset EQ 'AIA') OR (fileset EQ 'aia') THEN BEGIN year = strmid(filename,3,4) month = strmid(filename,7,2) day = strmid(filename,9,2) From d4d4f448be716c385bc2e61c1be17fab56159a23 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 4 Dec 2012 15:57:21 -0500 Subject: [PATCH 03/44] added extra plotting commands to do_dem_analysis.pro. Additional small tweak for aiafile_to_time.pro. --- aiafile_to_time.pro | 2 +- do_dem_analysis.pro | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/aiafile_to_time.pro b/aiafile_to_time.pro index 8334df8..a3d5c28 100644 --- a/aiafile_to_time.pro +++ b/aiafile_to_time.pro @@ -17,7 +17,7 @@ FOR i = 0, dim-1 DO BEGIN month = strmid(filename,7,2) day = strmid(filename,9,2) time = strmid(filename,12,2) + ':' + strmid(filename,14,2) + ':' + strmid(filename,16,2) - ENDIF ELSE IF fileset EQ 'ssw_cutout' THEN BEGIN + ENDIF ELSE IF (fileset EQ 'ssw_cutout') OR (fileset EQ 'SSW_CUTOUT') THEN BEGIN year = strmid(filename,11,4) month = strmid(filename,15,2) day = strmid(filename,17,2) diff --git a/do_dem_analysis.pro b/do_dem_analysis.pro index ace1ad6..067c5d5 100644 --- a/do_dem_analysis.pro +++ b/do_dem_analysis.pro @@ -1,10 +1,10 @@ PRO do_dem_analysis,image_file=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time -default,image_file,'hsi_image_20110716_170350.fits' -default,spec_file, 'hsi_spectrum_20110716_161036_d1.fits' -default,drm_file, 'hsi_srm_20110716_161036_d1.fits' -default,fit_time,['16-Jul-2011 17:02:00.000', '16-Jul-2011 17:03:00.000'] -default,bkg_time,['16-Jul-2011 17:36:00.000', '16-Jul-2011 17:39:00.000'] +default,image_file,'hsi_image_20120910_072102.fits' +default,spec_file, 'hsi_spectrum_20120910_063840_d1.fits' +default,drm_file, 'hsi_srm_20120910_063840_d1.fits' +default,fit_time,['10-Sep-2012 07:22:00.000', '10-Sep-2012 07:23:00.000'] +default,bkg_time,['10-Sep-2012 07:08:00.000', '10-Sep-2012 07:12:00.000'] aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/aia_only @@ -20,7 +20,18 @@ aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec plot_aia_flux_ratios plot_aia_flux_ratios,/epstein +plot_combo_dem +plot_combo_dem,n=10,/epstein +plot_hsi_count_spectrum_from_dem,/ps,type='aia' +plot_hsi_count_spectrum_from_dem,/ps,type='hsi' +plot_hsi_count_spectrum_from_dem,/ps,type='combo' +plot_hsi_count_spectrum_from_dem,/ps,type='aia',/epstein +plot_hsi_count_spectrum_from_dem,/ps,type='hsi',/epstein +plot_hsi_count_spectrum_from_dem,/ps,type='combo',/epstein + +plot_aia_flux_ratios,/outps +plot_aia_flux_ratios,/epstein,/outps END From 0c49aba61c553af81de125ea9b8fb93f652b6fd4 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 13 Dec 2012 17:51:59 -0500 Subject: [PATCH 04/44] made n_aia,n_hsi and nfree keywords with default settings. --- get_combined_chisq.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/get_combined_chisq.pro b/get_combined_chisq.pro index 0353cec..56b0473 100644 --- a/get_combined_chisq.pro +++ b/get_combined_chisq.pro @@ -1,8 +1,8 @@ -FUNCTION get_combined_chisq,chi_red_aia,chi_red_hsi +FUNCTION get_combined_chisq,chi_red_aia,chi_red_hsi,n_aia=n_aia,n_hsi=n_hsi,nfree=nfree -n_aia=6 -n_hsi=21 -nfree=3 +default,n_aia,6 +default,n_hsi,21 +default,nfree,3 chi_full_aia=chi_red_aia*(n_aia-nfree) chi_full_hsi=chi_red_hsi*(n_hsi-nfree) From bceaca0734b0c09aac9ff5377a57bc3758ab9b67 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 13 Dec 2012 17:53:36 -0500 Subject: [PATCH 05/44] added get_rhessi_chisq.pro. Recalculates RHESSI chi-squared values for a given energy range and systematic uncertainty, provided that the original aia_hsi_fit_results.sav file exists. --- get_rhessi_chisq.pro | 150 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 get_rhessi_chisq.pro diff --git a/get_rhessi_chisq.pro b/get_rhessi_chisq.pro new file mode 100644 index 0000000..a2687c0 --- /dev/null +++ b/get_rhessi_chisq.pro @@ -0,0 +1,150 @@ +;NAME: +; GET_RHESSI_CHISQ +;PURPOSE: +; Re-calculate the reduced chi-squared map for RHESSI, fitted over a given energy range. The real and model fluxes +; come from a previously saved aia_hsi_fit_results.sav file. The uncertainties for RHESSI are calculated from the square root of +; the model counts, added in quadrature with the square root of the background counts and the systematic uncertainty (2% by default). +;CATEGORY: +; SPECTRA, XRAYS, STATISTICS +;CALLING SEQUENCE: +; get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n +; +;PREREQUISITES: +; An IDL save file called aia_hsi_fit_results_epstein.sav needs to exist in the local directory. +; The SPEX branch of SSW must be installed. +; +;INPUTS: +; ERANGE - a two-element vector specifying the energy range, in keV, over which to find chi-squared. e.g. [5,12] or [4,8]. +;KEYWORD INPUTS: +; EPSTEIN - if set, restores the aia_hsi_fit_results_epstein.sav file. +; N - the steepness index of the Epstein profile. Default is 10. +; SPEC_FILE - the RHESSI spectral file to use. Only needed to initialise OSPEX and get some extra information that is not stored in +; the aia_hsi_fit_results_epstein.sav file. +; DRM_FILE - the RHESSI SRM file corresponding to the given spectral file. +; FIT_TIME - the time over which the RHESSI fit was performed. +; BKG_TIME - the time denoting the chosen RHESSI background interval. +; UNCERT - the level of systematic uncertainty. Default is 0.02 (2%). +;OUTPUTS: +; CHISQ_RESULTS - a 2D array containing the RHESSI reduced chi-squared for each iteration of the fit parameters. +;WRITTEN: +; Andrew Inglis - 2012/12/13 +; +; + + + + + +PRO get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert + +default,epstein,1 +default,n,10 +default,uncert,0.02 + +default,erange,[5,12] + +spec_file='hsi_spectrum_20110826_200140_d1.fits' +drm_file='hsi_srm_20110826_200140_d1.fits' +fit_time=['26-Aug-2011 20:53:00.000', '26-Aug-2011 20:54:00.000'] +bkg_time=['26-Aug-2011 20:34:00.000', '26-Aug-2011 20:38:00.000'] + + +;want to input the model flux from aia_hsi_fit_results.sav +;model_count_rate = obj -> calc_func_components(this_interval=0, /use_fitted, photons=0, spex_units='rate') +;model_crate=model_count_rate.yvals + +;restore the file where the fit results were saved. The model array is included here for every parameter iteration +;the real flux data is also included. +IF keyword_set(epstein) THEN BEGIN + restore,'aia_hsi_fit_results_epstein.sav',/verbose + ah=aia_hsi_fit_results +ENDIF ELSE BEGIN + restore,'aia_hsi_fit_results.sav',/verbose + ah=aia_hsi_fit_results +ENDELSE + +model_flux_array=ah.model_count_flux_hsi + + +;now need to get the object associated with the real data. Just do this once by calling get_hsi_table_entry (param values don't matter) and retrieving the info. + +IF keyword_set(epstein) THEN BEGIN + get_hsi_table_entry,[0.01,0.09,8.0,0.6,0.27,n,1],model_count_flux,real_count_flux,axis,summary, obj=obj, $ + spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,epstein=epstein +ENDIF ELSE BEGIN + get_hsi_table_entry,[0.01,0.09,8.0,0.6,0.27,1],model_count_flux,real_count_flux,axis,summary, obj=obj, $ + spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time +ENDELSE + +;results=spex_read_fit_results('ospex_results_12_dec_2012.fits') + + +;now retrieve summary information from OSPEX object +results=summary + +;define a mask so that only the chosen energy range is fitted +mask=where((results.spex_summ_energy[1,*] gt erange[0]) AND (results.spex_summ_energy[1,*] lt erange[1])) +q=mask + +;get the background error +bke=results.spex_summ_bk_error + +;q=where(results.spex_summ_emask[0:50]) +;q=mask + +;get the count rates of the actual observations +real_crate=results.spex_summ_ct_rate + + +;need the livetime during the fit interval, rather than the full duration +ltime=obj->getdata(class='spex_fitint') +ltime=ltime.ltime[0] + + +sz=size(model_flux_array) +chisq_results=fltarr(sz[1],sz[2]) + + +for i=0,sz[1] -1 do begin + for j=0,sz[2]-1 do begin + + ;convert the flux array to count rates by multiplying by the area and the bin width. + model_crate=reform(model_flux_array[i,j,*])* summary.spex_summ_area * 0.353605 + + + + ;calculate sigma + sigma_cts=sqrt((model_crate*ltime) + (results.spex_summ_bk_rate * ltime)) + sigma_bk=sqrt(results.spex_summ_bk_rate * ltime) + sigma_sys=uncert * (real_crate*ltime) + + sigma_cts_rate = sigma_cts/ltime + sigma_bk = results.spex_summ_bk_error + sigma_sys_rate = sigma_sys/ltime + + ;sigma_tot=sqrt(sigma_cts^2 + sigma_bk^2 + sigma_sys^2) + ;work out the total sigma by adding the error contributions in quadrature + sigma_tot_rate = sqrt(sigma_cts_rate^2 + sigma_bk^2 + sigma_sys_rate^2) + +;sigma_tot_rate=sigma_tot/ltime + + + ;work out (O-E)^2/sigma^2 for each element + values=(real_crate[q] - model_crate[q])^2 / sigma_tot_rate[q]^2 + ;find the number of data points + npoints = n_elements(q) + ;find the reduced X^2 + chisq_red = total(values)/(npoints-1) + + chisq_results[i,j]=chisq_red + + endfor +endfor + + +print,'Best reduced chi-squared is: ', min(chisq_results,loc) + +print,'Found at location: ',array_indices(chisq_results,loc) + + +END \ No newline at end of file From 1a1ad2584f07e5802ca498cc1fbe8ba84788708c Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 13 Dec 2012 18:00:26 -0500 Subject: [PATCH 06/44] added combo_chi.pro utility function to calculate the combined minimum in chi-squared space of a pair of chi-squared maps. --- combo_chi.pro | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 combo_chi.pro diff --git a/combo_chi.pro b/combo_chi.pro new file mode 100644 index 0000000..1a2be3d --- /dev/null +++ b/combo_chi.pro @@ -0,0 +1,35 @@ +;NAME: +; COMBO_CHI +;PURPOSE: +; Utility function to combine AIA and RHESSI chi^2 maps. given a pair of 2D chi^2 maps, the minimum in the +; combined map will be found, and the reduced chi^2 of this minimum recalculated. +; +;INPUTS: +; chi1 - the AIA chi^2 map +; chi2 - the RHESSI chi^2 map. +;KEYWORDS: +; n_aia - number of AIA data points. Default is 6 +; n_hsi - number of RHESSI data points. Default is 21 +; nfree - number of free parameters. Default is 3 +;OUTPUT: +; returns the reduced chi^2 value of the combined map, and prints its array location. +;WRITTEN: +; Andrew Inglis, 2012/12/13 +; + +FUNCTION combo_chi,chi1,chi2,n_aia=n_aia,n_hsi=n_hsi,nfree=nfree + +chi_combo=chi1 + chi2 + +m=min(chi_combo,loc) +p=array_indices(chi_combo,loc) +print,'mininum in joint chi-squared located at: ',p + +print,'individual reduced chi-squared values are :',chi1[p[0],p[1]],chi2[p[0],p[1]] + +c=get_combined_chisq(chi1[p[0],p[1]],chi2[p[0],p[1]],n_aia=n_aia,n_hsi=n_hsi,nfree=nfree) +print,'combined reduced chi-squared value is :',c + +return,c;[chi1[p[0],p[1]],chi2[p[0],p[1]]] + +END From 504f9b73888345227d595e7d6e8b117100b56b4e Mon Sep 17 00:00:00 2001 From: aringlis Date: Fri, 14 Dec 2012 11:34:18 -0500 Subject: [PATCH 07/44] deleted old,unnecessary or legacy files from repository. --- aia_hsi_dem_analysis_manual.pro | 300 ---------------------- aia_hsi_dem_analysis_manual_test.pro | 325 ------------------------ aia_teem_map.old2.pro | 362 --------------------------- aia_teem_map.old3.pro | 301 ---------------------- aia_teem_map.old4.pro | 342 ------------------------- aia_teem_movie.old1.pro | 272 -------------------- aia_teem_total.old1.pro | 151 ----------- aia_teem_total.old2.pro | 163 ------------ aia_teem_total.old3.pro | 190 -------------- hannnah_aia.pro | 87 ------- ospex_script_27_apr_2012.pro | 45 ---- 11 files changed, 2538 deletions(-) delete mode 100755 aia_hsi_dem_analysis_manual.pro delete mode 100644 aia_hsi_dem_analysis_manual_test.pro delete mode 100644 aia_teem_map.old2.pro delete mode 100644 aia_teem_map.old3.pro delete mode 100644 aia_teem_map.old4.pro delete mode 100644 aia_teem_movie.old1.pro delete mode 100644 aia_teem_total.old1.pro delete mode 100644 aia_teem_total.old2.pro delete mode 100644 aia_teem_total.old3.pro delete mode 100644 hannnah_aia.pro delete mode 100644 ospex_script_27_apr_2012.pro diff --git a/aia_hsi_dem_analysis_manual.pro b/aia_hsi_dem_analysis_manual.pro deleted file mode 100755 index 2253e7d..0000000 --- a/aia_hsi_dem_analysis_manual.pro +++ /dev/null @@ -1,300 +0,0 @@ -PRO aia_hsi_dem_analysis_manual, DIR = dir, HSI_IMAGE = hsi_image, FILESET = fileset, FORCE_TABLE = force_table, aia_only=aia_only - -;first section should be to get the AIA fluxes based on the RHESSI image. Have some code that already does this. - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -teem_table='teem_table.sav' - - -file_list = get_aia_file_list(dir, fileset = fileset) -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;hardcoded this for 21 June 2011 flare -marker=120;120 - -;area of 1 AIA pixel in cm^2 -aia_pixel_area = 1.85589e+15 - - -t_min = 5.5 -t_max = 8.0 - -t_min = 6.0 -t_max = 7.5 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -tsig_min = 0.01 -tsig_max = 0.40 -tsig_d = 0.005 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -f = file_search(teem_table) - -area = aia_teem_pixel_area(file_list[0,0]) - -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area - - -; if a hsi_image was given then create a mask out of it -IF hsi_image[0] NE '' THEN BEGIN - fits2map, file_list[marker,0], aiamap - fits2map, hsi_image, hsimap - ; interpolate the rhessi map to the aia map - - mask_map = inter_map(hsimap,aiamap) - mask_map = drot_map(mask_map, time = aiamap.time) - m = max(mask_map.data) - ; set the mask at everything above 50% contour - index = where(mask_map.data LE m*0.5, complement = complement) - mask_map.data[index] = 0 - mask_map.data[complement] = 1 - - ; now define the inverse mask - invmask_map = mask_map - invmask_map.data[index] = 1 - invmask_map.data[complement] = 0 -ENDIF - -num_aia_pixels=total(mask_map.data) -print,num_aia_pixels - -flare_area=aia_pixel_area*num_aia_pixels -;stop - -;;;;;; - - - -default, save_dir, '' - -nwave = n_elements(wave_) -flux_ = fltarr(nwave) -texp_ = fltarr(nwave) - -file_iw = reform(file_list[marker,*]) - -;file_bk_iw = reform(file_list(marker-100,*)) - -FOR iw = 0, nwave-1 DO BEGIN - - read_sdo,file_iw[iw],index,data -; read_sdo,file_bk_iw[iw],index_bk,data_bk - - index2map,index,float(data),map -; index2map,index_bk,float(data_bk),map_bk - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange -; sub_map, map_bk,smap_bk,xrange=xrange,yrange=yrange - map = smap -; map_bk = smap_bk - data = smap.data - ; data_bk = smap_bk.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - image = data - texp = map.dur - texp_[iw]=texp - dateobs = map.time - - IF keyword_set(mask_map) then begin - mask = mask_map.data - ; zero out everything that is not in the mask - FOR k = 0, i2 DO BEGIN - FOR l = 0, j2 DO BEGIN - data[k,l] = data[k,l]*mask[k,l] -; data_bk[k,l] = data_bk[k,l] * mask[k,l] - ENDFOR - ENDFOR - ENDIF - - flux_[iw] = total(data[i1:i2,j1:j2])/texp; - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) - print,'Total flux in ', wave_(iw),flux_(iw) -ENDFOR - -;stop - -;then do the mapping using the AIA fluxes. Since RHESSI is basically 1 pixel for spectrum we only need one summed AIA pixel too. - - - - -restore, save_dir + teem_table, /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig - -nfree=3 - - -;flux_obs = reform(images[i,j,*]) - flux_obs = flux_ / num_aia_pixels - counts = flux_obs*texp_ - ;stop - ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. - noise = 0.2*flux_obs;sqrt(counts)/texp_ - - chimin = 9999. - chi6min = 9999. - chimin_hsi=9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - chi2d_hsi = fltarr(nte,nsig) - em_2d = fltarr(nte,nsig) - em_2d_hsi = fltarr(nte,nsig) - flux_dem_3d = fltarr(nte,nsig,6) - model_count_flux_hsi = fltarr(nte,nsig,301) - real_count_flux_hsi = fltarr(nte,nsig,301) - - telog_err = [0,0] - sig_err = [0,0] - sig_errsymmetric = 0. - telog_errsymmetric = 0. - - FOR k=15, 15 DO BEGIN - FOR l = 18, 18 DO BEGIN - flux_dem1 = reform(flux[k,l,*]) - em1 = 1.106e22 ;total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - flux_dem_3d[k,l,*]=flux_dem - chi = sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - em_2d[k,l] = em1 - ;add in RHESSI - em_hsi=em1 /1e25 - em_hsi=em_hsi/1e24 ; - em_hsi=em_hsi*flare_area;39.*2e15 - em_hsi=em_hsi*11.6e6 ; convert to cm^-3 kev^-1 - ;IF (k eq 0) THEN BEGIN - ;em_hsi=em_hsi * (10^telog(1) - 10^telog(0)) - ;ENDIF ELSE BEGIN - ;em_hsi=em_hsi * (10^telog(k) - 10^telog(k-1)) - ;ENDELSE - tinkev=(10^telog(k)) / 11.6e6 - em_2d_hsi[k,l]=em_hsi - IF NOT keyword_set(aia_only) THEN BEGIN - get_hsi_table_entry,[em_hsi,0.09,6.0,tsig(l),tinkev,1],model_count_flux,real_count_flux,axis,summary, obj=obj - - ;if the model function is all zeros then deal with this - typ=datatype(model_count_flux) - ;find the data type of model_count_flux. If there is no model flux at all then an integer of -1 will be - ;returned in place of the usual structure. - IF (typ eq 'INT') then begin - model_count_flux_hsi[k,l,*] = 0. - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = 9999. - ENDIF ELSE BEGIN - model_count_flux_hsi[k,l,*] = model_count_flux.yvals - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = summary.spex_summ_chisq - ENDELSE - ENDIF - ;stop - IF (chi le chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[k] - sig_best = tsig[l] - flux_dem_best = flux_dem - - ENDIF - IF NOT keyword_set(aia_only) THEN BEGIN - IF (chi2d_hsi[k,l] le chimin_hsi) THEN BEGIN - chimin_hsi=chi2d_hsi[k,l] - em_best_hsi=em_2d_hsi[k,l] - telog_best_hsi = telog[k] - sig_best_hsi = tsig[l] - model_count_flux_hsi_best=model_count_flux_hsi[k,l,*] - ENDIF - ENDIF - ENDFOR - ENDFOR - -; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin LT 9999.) THEN BEGIN - - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF - ENDIF - - - - ;window, 0 - ;loadct, 0 - ;hsi_linecolors - ;nlevels = 20 - ;levels = chimin * (findgen(nlevels)*0.1 + 1.0) - ;anot = strarr(20) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - ;oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - ;leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - ;legend, leg, psym = 4 - ;contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - ;window, 1 - ;emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - ;plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ;ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - - ; plot the RHESSI chi^2 map - ;hsi_levels = chimin_hsi * (findgen(nlevels)*0.1 + 1.0) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;window,5 - ;contour,chi_hsi,telog,tsig, levels = hsi_levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig',title='RHESSI X^2 map' - ;oplot, [telog_best_hsi], [sig_best_hsi], psym = symcat(16), color = 6 - ;leg = num2str(chimin_hsi) + '[' + num2str(telog_best_hsi) + ',' + num2str(sig_best_hsi) + ']' - ;legend, leg, psym = 4 - ;contour,chi_hsi,telog, tsig, levels=[chimin_hsi + 2.3],/over,thick=2, color = 6 - ;ENDIF - -;SAVE,chi2d,chi_hsi,axis,em_2d,em_2d_hsi,real_count_flux_hsi,model_count_flux_hsi,flux_dem_best,flux_dem,em_best,em_best_hsi,telog_best,$ -;telog_best_hsi,sig_best,sig_best_hsi,chimin,chimin_hsi,flare_area,filename='aia_hsi_fit_results_bk.sav',/verbose -; ;stop - -IF keyword_set(aia_only) THEN BEGIN - aia_fit_results=create_struct('flux_obs',flux_obs,'flux_dem_3d',flux_dem_3d,'chi_2d',chi2d,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ - 'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'telog_best',telog_best,$ - 'sig_best',sig_best,'chimin',chimin,'flare_area',flare_area,'telog',telog,'tsig',tsig) - - SAVE,aia_fit_results,filename='aia_fit_results_manual.sav',/verbose -ENDIF ELSE BEGIN - aia_hsi_fit_results=create_struct('flux_obs',flux_obs,'flux_dem_3d',flux_dem_3d,'chi_2d',chi2d,'chi2d_hsi',chi2d_hsi,'axis',axis,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ - 'real_count_flux_hsi',real_count_flux_hsi,'model_count_flux_hsi',model_count_flux_hsi,'model_count_flux_hsi_best',model_count_flux_hsi_best,$ - 'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'em_best_hsi',em_best_hsi,'telog_best',telog_best,'telog_best_hsi',telog_best_hsi,$ - 'sig_best',sig_best,'sig_best_hsi',sig_best_hsi,'chimin',chimin,'chimin_hsi',chimin_hsi,'flare_area',flare_area,'telog',telog,'tsig',tsig) - - SAVE,aia_hsi_fit_results,filename='aia_hsi_fit_results_manual.sav',/verbose -ENDELSE - - - - - - - -END \ No newline at end of file diff --git a/aia_hsi_dem_analysis_manual_test.pro b/aia_hsi_dem_analysis_manual_test.pro deleted file mode 100644 index 5ddc431..0000000 --- a/aia_hsi_dem_analysis_manual_test.pro +++ /dev/null @@ -1,325 +0,0 @@ -PRO aia_hsi_dem_analysis_manual_test, DIR = dir, FILESET = fileset, FORCE_TABLE = force_table, aia_only=aia_only,epstein=epstein,flux_=flux_,pixels=pixels,n=n - -;first section should be to get the AIA fluxes based on the RHESSI image. Have some code that already does this. - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -IF keyword_set(epstein) THEN BEGIN -teem_table='teem_table_epstein.sav' -ENDIF ELSE BEGIN -teem_table='teem_table.sav' -ENDELSE - - -file_list = get_aia_file_list(dir, fileset = fileset) -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;hardcoded this for 21 June 2011 flare -marker=120;120 - -;area of 1 AIA pixel in cm^2 -aia_pixel_area = 1.85589e+15 - - -t_min = 5.5 -t_max = 8.0 - -t_min = 6.0 -t_max = 7.5 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -tsig_min = 0.01 -tsig_max = 0.40 -tsig_d = 0.005 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -f = file_search(teem_table) - -area = aia_teem_pixel_area(file_list[0,0]) * (4^2) - -IF keyword_set(epstein) THEN BEGIN -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table_epstein, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area, n=n -ENDIF ELSE BEGIN -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area -ENDELSE - - - -; if a hsi_image was given then create a mask out of it -;IF hsi_image[0] NE '' THEN BEGIN; -; fits2map, file_list[marker,0], aiamap -; fits2map, hsi_image, hsimap - ; interpolate the rhessi map to the aia map - -; mask_map = inter_map(hsimap,aiamap) -; mask_map = drot_map(mask_map, time = aiamap.time) -; m = max(mask_map.data) - ; set the mask at everything above 50% contour -; index = where(mask_map.data LE m*0.5, complement = complement) -; mask_map.data[index] = 0 -; mask_map.data[complement] = 1 - - ; now define the inverse mask -; invmask_map = mask_map -; invmask_map.data[index] = 1 -; invmask_map.data[complement] = 0 -;ENDIF - -;num_aia_pixels=total(mask_map.data) -;print,num_aia_pixels - -flare_area=0;aia_pixel_area*num_aia_pixels -;stop - -;;;;;; - - - -default, save_dir, '' - -nwave = n_elements(wave_) - -;IF NOT keyword_set(flux_) THEN BEGIN -;flux_ = fltarr(nwave) -;ENDIF - -;texp_ = fltarr(nwave) - -;file_iw = reform(file_list[marker,*]) - -;file_bk_iw = reform(file_list(marker-100,*)) - -;IF NOT keyword_set(flux_) THEN BEGIN - -;FOR iw = 0, nwave-1 DO BEGIN - -; read_sdo,file_iw[iw],index,data -; read_sdo,file_bk_iw[iw],index_bk,data_bk - - ; index2map,index,float(data),map -; index2map,index_bk,float(data_bk),map_bk - -; IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN -; sub_map, map, smap, xrange = xrange, yrange = yrange -; sub_map, map_bk,smap_bk,xrange=xrange,yrange=yrange -; map = smap -; map_bk = smap_bk -; data = smap.data - ; data_bk = smap_bk.data - ; ENDIF - -; s = size(data) -; i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - -; image = data -; texp = map.dur -; texp_[iw]=texp -; dateobs = map.time - -; IF keyword_set(mask_map) then begin -; mask = mask_map.data - ; zero out everything that is not in the mask -; FOR k = 0, i2 DO BEGIN -; FOR l = 0, j2 DO BEGIN -; data[k,l] = data[k,l]*mask[k,l] -; data_bk[k,l] = data_bk[k,l] * mask[k,l] -; ENDFOR -; ENDFOR -; ENDIF - -; flux_[iw] = total(data[i1:i2,j1:j2])/texp; - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) -; print,'Total flux in ', wave_(iw),flux_(iw) -;ENDFOR - -;ENDIF -;stop - -;then do the mapping using the AIA fluxes. Since RHESSI is basically 1 pixel for spectrum we only need one summed AIA pixel too. - - - -restore, save_dir + teem_table, /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig - -nfree=3 - -IF keyword_set(pixels) THEN BEGIN -num_aia_pixels=pixels -ENDIF ELSE BEGIN -num_aia_pixels=1 -ENDELSE - - -;flux_obs = reform(images[i,j,*]) - flux_obs = flux_ ;/ num_aia_pixels - ; counts = flux_obs*texp_ - ;stop - ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. - noise = 0.2*flux_obs;sqrt(counts)/texp_ - - chimin = 9999. - chi6min = 9999. - chimin_hsi=9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - chi2d_hsi = fltarr(nte,nsig) - em_2d = fltarr(nte,nsig) - em_2d_hsi = fltarr(nte,nsig) - flux_dem_3d = fltarr(nte,nsig,6) - model_count_flux_hsi = fltarr(nte,nsig,301) - real_count_flux_hsi = fltarr(nte,nsig,301) - - telog_err = [0,0] - sig_err = [0,0] - sig_errsymmetric = 0. - telog_errsymmetric = 0. - - FOR k=0, nte-1 DO BEGIN - FOR l = 0, nsig-1 DO BEGIN - flux_dem1 = reform(flux[k,l,*]) - em1 = total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - flux_dem_3d[k,l,*]=flux_dem - chi = sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - em_2d[k,l] = em1 - ;add in RHESSI - em_hsi=em1 /1e25 - em_hsi=em_hsi/1e24 ; - em_hsi=em_hsi*flare_area;39.*2e15 - em_hsi=em_hsi*11.6e6 ; convert to cm^-3 kev^-1 - ;IF (k eq 0) THEN BEGIN - ;em_hsi=em_hsi * (10^telog(1) - 10^telog(0)) - ;ENDIF ELSE BEGIN - ;em_hsi=em_hsi * (10^telog(k) - 10^telog(k-1)) - ;ENDELSE - tinkev=(10^telog(k)) / 11.6e6 - em_2d_hsi[k,l]=em_hsi - IF NOT keyword_set(aia_only) THEN BEGIN - get_hsi_table_entry,[em_hsi,0.09,6.0,tsig(l),tinkev,1],model_count_flux,real_count_flux,axis,summary, obj=obj - - ;if the model function is all zeros then deal with this - typ=datatype(model_count_flux) - ;find the data type of model_count_flux. If there is no model flux at all then an integer of -1 will be - ;returned in place of the usual structure. - IF (typ eq 'INT') then begin - model_count_flux_hsi[k,l,*] = 0. - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = 9999. - ENDIF ELSE BEGIN - model_count_flux_hsi[k,l,*] = model_count_flux.yvals - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = summary.spex_summ_chisq - ENDELSE - ENDIF - ;stop - IF (chi le chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[k] - sig_best = tsig[l] - flux_dem_best = flux_dem - - ENDIF - IF NOT keyword_set(aia_only) THEN BEGIN - IF (chi2d_hsi[k,l] le chimin_hsi) THEN BEGIN - chimin_hsi=chi2d_hsi[k,l] - em_best_hsi=em_2d_hsi[k,l] - telog_best_hsi = telog[k] - sig_best_hsi = tsig[l] - model_count_flux_hsi_best=model_count_flux_hsi[k,l,*] - ENDIF - ENDIF - ENDFOR - ENDFOR - -; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin LT 9999.) THEN BEGIN - - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF - ENDIF - - - - ;window, 0 - ;loadct, 0 - ;hsi_linecolors - ;nlevels = 20 - ;levels = chimin * (findgen(nlevels)*0.1 + 1.0) - ;anot = strarr(20) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - ;oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - ;leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - ;legend, leg, psym = 4 - ;contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - ;window, 1 - ;emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - ;plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ;ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - - ; plot the RHESSI chi^2 map - ;hsi_levels = chimin_hsi * (findgen(nlevels)*0.1 + 1.0) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;window,5 - ;contour,chi_hsi,telog,tsig, levels = hsi_levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig',title='RHESSI X^2 map' - ;oplot, [telog_best_hsi], [sig_best_hsi], psym = symcat(16), color = 6 - ; - ;legend, leg, psym = 4 - ;contour,chi_hsi,telog, tsig, levels=[chimin_hsi + 2.3],/over,thick=2, color = 6 - ;ENDIF - -;SAVE,chi2d,chi_hsi,axis,em_2d,em_2d_hsi,real_count_flux_hsi,model_count_flux_hsi,flux_dem_best,flux_dem,em_best,em_best_hsi,telog_best,$ -;telog_best_hsi,sig_best,sig_best_hsi,chimin,chimin_hsi,flare_area,filename='aia_hsi_fit_results_bk.sav',/verbose -; ;stop - -IF keyword_set(aia_only) THEN BEGIN - aia_fit_results=create_struct('flux_obs',flux_obs,'flux_dem_3d',flux_dem_3d,'chi_2d',chi2d,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ - 'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'telog_best',telog_best,$ - 'sig_best',sig_best,'chimin',chimin,'flare_area',flare_area,'telog',telog,'tsig',tsig) - - IF keyword_set(epstein) THEN BEGIN - SAVE,aia_fit_results,filename='aia_fit_results_epstein_manual.sav',/verbose - ENDIF ELSE BEGIN - SAVE,aia_fit_results,filename='aia_fit_results_manual.sav',/verbose - ENDELSE -ENDIF ELSE BEGIN - aia_hsi_fit_results=create_struct('flux_obs',flux_obs,'flux_dem_3d',flux_dem_3d,'chi_2d',chi2d,'chi2d_hsi',chi2d_hsi,'axis',axis,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ - 'real_count_flux_hsi',real_count_flux_hsi,'model_count_flux_hsi',model_count_flux_hsi,'model_count_flux_hsi_best',model_count_flux_hsi_best,$ - 'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'em_best_hsi',em_best_hsi,'telog_best',telog_best,'telog_best_hsi',telog_best_hsi,$ - 'sig_best',sig_best,'sig_best_hsi',sig_best_hsi,'chimin',chimin,'chimin_hsi',chimin_hsi,'flare_area',flare_area,'telog',telog,'tsig',tsig) - - SAVE,aia_hsi_fit_results,filename='aia_hsi_fit_results_manual.sav',/verbose -ENDELSE - - - - - - - -END \ No newline at end of file diff --git a/aia_teem_map.old2.pro b/aia_teem_map.old2.pro deleted file mode 100644 index f9a316c..0000000 --- a/aia_teem_map.old2.pro +++ /dev/null @@ -1,362 +0,0 @@ -pro aia_teem_map,fileset = fileset,FOV = fov,wave_,npix,teem_table,teem_map, FILElist = filelist, VERBOSE = verbose, filename_extra = FILENAME_extra, SAVE_DIR = save_dir, DEBUG = debug - -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates EM and Te temperature maps -; based on single-Gaussian fits in each macropixel -; -; Syntax : IDL>aia_teem_map,fileset,fov,wave_,npix,teem_table,teem_map -; -; Inputs : fileset = common filename part of 6 wavelength FITS images -; wave_ = strarr(6) with wavelengths in Angstroem -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = size of macropixel (spatial resolution) -; teem_table = filename of DEM lookup table -; (calculated previously with AIA_TEEM_TABLE.PRO) -; teem_map = savefile containing EM and Te maps -; -; Outputs : postscript file _col.ps (if io=2) -; -; History : 3-Mar-2011, Version 1 written by Markus J. Aschwanden -; 16-May-2011, made fov optional. If not given, uses the -; whole images. -; made fileset optional. Added filelist keyword to just give a list of files. -; : 5-Oct-2011 - Added search for 1 sigma contour in chi^2 space to calculate errors in telog and tsig - A. Inglis -; -; Contact : aschwanden@lmsal.com -;- - -default, save_dir, '' - -;_________________________________________________________________________ -t1 = systime(0,/seconds) -nwave = n_elements(wave_) -default, filename_extra, '' - -IF keyword_set(fileset) THEN BEGIN - files = strarr(6) - FOR iw = 0, nwave-1 DO BEGIN - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - searchstring=fileset+'*'+wave_[iw]+'_.fts' - file_iw = file_search(searchstring, count=nfiles) - files[iw]=file_iw[u] - ENDFOR -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - files = filelist - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(files,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - ;files = files[s] -ENDELSE -;_____________________REBINNING IMAGES___________________________________ - -texp_ =fltarr(nwave) -for iw=0,nwave-1 do begin - ;read_sdo,files(iw),index,data - fits2map, files[iw], map - - IF keyword_set(FOV) THEN BEGIN - sub_map, map, smap, xrange = fov[0:1], yrange = fov[2:3] - map = smap - ENDIF - - dim = size(map.data) - - ; schriste (16-may-2011) - ; If Keyword FOV not given then determine the FOV - ; of the whole image automatically - ;IF keyword_set(fov) THEN BEGIN - ; i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ;ENDIF ELSE BEGIN - ;s = size(data) - s = size(map.data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ;ENDELSE - - ;dim =size(data) - nx0 =dim[1] - ny0 =dim[2] - - ;IF (i1 ge nx0) or (i2 ge nx0) or (j1 ge ny0) or (j2 ge ny0) then begin - ; print,'FOV=',i1,i2,j1,j2 - ; print,'image size=',nx0,ny0 - ; stop,'ERROR in subimage range i1,i2,j1,j2 for image with size nx0,ny0 - ;ENDIF - - ;image = data[i1:i2,j1:j2] - image = map.data - ;texp = index.exptime - texp = map.dur - ;dateobs = index.date_obs - dateobs = anytim(map.time, /CCSDS) - IF (iw eq 0) THEN BEGIN - dim =size(image) - nx =dim[1] - ny =dim[2] - nxx =(nx/npix) - nyy =(ny/npix) - i3 =nxx*npix-1 - j3 =nyy*npix-1 - x =i1+(npix*findgen(nxx)+0.5) - y =j1+(npix*findgen(nyy)+0.5) - images=fltarr(nxx,nyy,nwave) - ENDIF - if (npix eq 1) then images[*,*,iw]=float(image)/texp - if (npix gt 1) then images[*,*,iw]=rebin(float(image[0:i3,0:j3]),nxx,nyy)/texp - texp_(iw)=texp - - ;PLOT the image as a MAP - id = map.id - ;id = strmid(index.TELESCOP,0,3) + '/' + strmid(index.instrume,0,3) - - xy_cen = get_map_center(map) - xcen = xy_cen[0] - ycen = xy_cen[1] - - aia_lct, rr, gg, bb, wavelnth=wave_[iw], /load - ;a = index.CROTA2 - ;xcen = index.CRVAL1 + index.CDELT1*cos(a)*(0.5*(index.NAXIS1+1)- index.CRPIX1)-index.CDELT2*sin(a)*((index.NAXIS2+1)/2-index.CRPIX2) - ;ycen = index.CRVAL2 + index.CDELT1*sin(a)*((index.NAXIS1+1)*0.5-index.CRPIX1) + index.CDELT2*cos(a)*((index.NAXIS2+1)*0.5-index.CRPIX2) - - dx = map.dx*npix - dy = map.dy*npix - - map = make_map(images[*,*,iw], time = dateobs, id = id, dur = texp, xc = xcen, yc = ycen, dx = dx, dy = dy) - - aia_lct, rr, gg, bb, wavelnth=wave_[iw], /load - plot_map, map, /limb, /log - tvscl, images[*,*,iw] -endfor - -;________________________TEMPERATURE MAP_________________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -dim =size(flux) -nte =dim[1] -nsig =dim[2] -nwave =dim[3] -ntot =nte*nsig -te_map =fltarr(nxx,nyy) -em_map =fltarr(nxx,nyy) -sig_map =fltarr(nxx,nyy) -flux_dem_map = fltarr(nxx, nyy, nwave) -chi_map = fltarr(nxx,nyy) -em_errmap = fltarr(nxx,nyy) -telog_errmap=fltarr(nxx,nyy,2) -tsig_errmap=fltarr(nxx,nyy,2) -telog_errmap_symmetric=fltarr(nxx,nyy) -tsig_errmap_symmetric=fltarr(nxx,nyy) -chi_map6=fltarr(nxx,nyy,6) -te_best =0. -em_best =0. -sig_best=0. -r0 =0.95*(4096/2) -x0 =4096/2 -y0 =4096/2 -nfree =3 - -FOR j = 0, nyy-1 DO BEGIN - if (nx eq 4096) then ind=where(sqrt((x-x0)^2+(y(j)-y0)^2) le r0,nind) - if (nx lt 4096) then ind=findgen(nxx) - i1 = min(ind) > 0 - i2 = max(ind) < (nxx-1) - FOR i = i1, i2 DO BEGIN - flux_obs=reform(images[i,j,*]) - counts=flux_obs*texp_ - noise=sqrt(counts)/texp_ - chimin=9999. - chi6min=9999. - chi2d = fltarr(nte,nsig) - FOR k=0,nte-1 DO BEGIN - FOR l=0,nsig-1 DO BEGIN - flux_dem1=reform(flux(k,l,*)) - em1 =total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2))/total(flux_dem1) - flux_dem=flux_dem1*em1 - chi =sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6=abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - IF (chi le chimin) THEN BEGIN - chimin =chi - chi6min =chi6 - em_best =alog10(em1) - em_best_err = em1_err/em_best - te_best =telog(k) - sig_best =tsig(l) - flux_dem_best = flux_dem - ENDIF - ENDFOR - ENDFOR - - ; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin ne 9999.) THEN BEGIN - ;chimin defaults to 9999. if bad pixel (i.e. no data), so skip those - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3],path_xy=path_xy,path_info=path_info,/path_data_coords,closed=0 - IF exist(path_xy) THEN BEGIN - testxmax=MAX(path_xy(0,*)) - testxmin=MIN(path_xy(0,*)) - testymax=MAX(path_xy(1,*)) - testymin=MIN(path_xy(1,*)) - - telog_err=[testxmin,testxmax] - te_best - ;error bars are asymmetric - symmetrise! - telog_errsymmetric=sqrt(telog_err(0)^2 + telog_err(1)^2) - - tsig_err=[sig_best - testymin,testymax - sig_best] - ;error bars are asymmetric - symmetrise! - ;tsig_errsymmetric=sqrt(tsig_err(0)^2 + tsig_err(1)^2) - tsig_errsymmetric = max(tsig_err) - ;print,telog_errsymmetric - ;print,tsig_errsymmetric - ;print,telog_err - ;print,tsig_err - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - - IF keyword_set(VERBOSE) THEN BEGIN - print, i, j - print, 'Using wavelengths:', wave_ - print, 'Obs flux:', flux_obs - print, 'Fit flux:', flux_dem_best - print, 'Fit/Obs', flux_dem_best/flux_obs - print, 'min Chisq = ', chimin - print, 'log(T) = ', te_best - print, 'telog err = ', telog_err + te_best - print, 'T sigma = ', sig_best - print, 'T sig err = ', tsig_err + sig_best - print, 'log(EM) = ', em_best - - print, '' - loadct, 0 - hsi_linecolors - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR y = 0, nlevels-1 DO anot[y] = num2str(levels[y]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 't_sig' - oplot, [te_best], [sig_best], psym = symcat(16), color = 6 - leg = num2str(chimin) + '[log(T) = ' + num2str(te_best) + ', T_sig = ' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog,tsig,levels=[chimin + 2.3],/over,thick=2, color = 6 - IF keyword_set(DEBUG) THEN stop - ENDIF - - flux_dem_map[i,j,*] = flux_dem_best - em_map[i,j]=em_best - te_map[i,j]=te_best - sig_map[i,j]=sig_best - chi_map[i,j]=chimin - chi_map6[i,j,*]=chi6min - telog_errmap[i,j,0:1]=telog_err[0:1] - tsig_errmap[i,j,0:1]=tsig_err[0:1] - telog_errmap_symmetric[i,j]=telog_errsymmetric - tsig_errmap_symmetric[i,j]=tsig_errsymmetric - ;telog_errmap(i,j,*)=telog_err - ;tsig_errmap(i,j,*)=tsig_err - - ENDFOR - IF (j mod 10) eq 0 THEN print,j,nyy -ENDFOR - -help,telog_errmap_symmetric -help,tsig_errmap_symmetric - -;print,telog_errmap_symmetric(50:70,50:70) -;print,tsig_errmap_symmetric(50:70,50:70) - -aia_map = make_map(images[*,*,0], time = dateobs, id = id, dur = texp, xc = xcen, yc = ycen, dx = dx, dy = dy) - -aia_map_cube = replicate(aia_map, 6) -aia_simul_map_cube = aia_map_cube - -FOR i = 0, n_elements(wave_)-1 DO BEGIN - aia_map_cube[i].data = images[*,*,i] - aia_map_cube[i].id = 'SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -FOR i = 0, n_elements(wave_)-1 DO BEGIN - aia_simul_map_cube[i].data = flux_dem_map[*,*,i] - aia_simul_map_cube[i].id = 'Simulated SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -temperature_map = aia_map -temperature_map.data = te_map -temperature_map.id = 'log(Temperature [MK])' -emission_map = aia_map -emission_map.data = em_map -emission_map.id = 'log(Emission Measure [cm!U-3!N]' -sigma_map = aia_map -sigma_map.data = sig_map -sigma_map.id = 'Sigma' -chisq_map = aia_map -chisq_map.data = chi_map -chisq_map.id = textoidl('\chi^2') -tsig_error_map_minus = aia_map -tsig_error_map_minus.data = tsig_errmap[*,*,0] -tsig_error_map_minus.id = 'Tsig error minus' -telog_error_map_minus = aia_map -telog_error_map_minus.data = tsig_errmap[*,*,1] -telog_error_map_minus.id = 'Telog error minus' - -tsig_error_map_plus = aia_map -tsig_error_map_plus.data = tsig_errmap[*,*,0] -tsig_error_map_plus.id = 'Tsig error plus' -telog_error_map_plus = aia_map -telog_error_map_plus.data = tsig_errmap[*,*,1] -telog_error_map_plus.id = 'Telog error plus' - -;temperature_map = make_map( te_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Temperature [MK])', time = dateobs) - -;emission_map = make_map( em_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Emission Measure [cm!U-3!N]', time = dateobs) - -;sigma_map = make_map( sig_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'Sigma', time = dateobs) - -;chisq_map = make_map( chi_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;tsig_error_map_minus = make_map( tsig_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;telog_error_map_minus = make_map( telog_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;tsig_error_map_plus = make_map( tsig_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;telog_error_map_plus = make_map( telog_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;________________________STATISTICS OF CHI-2 FITS_________________ -print,'Statistics of chi2=' -statistic,chi_map -print,'Statistics of chi2 (94 A)' -statistic,chi_map6(*,*,5) -print,'log(EM)-range = ',minmax(em_map) - -;________________________SAVE MAPS________________________________ -;save,filename=teem_map,te_map,em_map,sig_map,chi_map,dateobs - -;save,filename=save_dir + teem_map,te_map,em_map,sig_map,chi_map,tsig_errmap_symmetric,telog_errmap_symmetric,temperature_map,emission_map,sigma_map,chisq_map,aia_map_cube, dateobs , aia_simul_map_cube - -save,temperature_map,emission_map,sigma_map,chisq_map,tsig_error_map_minus,tsig_error_map_plus,telog_error_map_minus,telog_error_map_plus,aia_simul_map_cube, aia_map_cube, filename=save_dir + 'tempmap' + filename_extra + '.sav' - -print,'TE+EM maps saved in file : ',teem_map -t2 =systime(0,/seconds) - -print,'Computation time = ',(t2-t1)/60.0,' min' - -IF keyword_set(DEBUG) THEN stop - -END diff --git a/aia_teem_map.old3.pro b/aia_teem_map.old3.pro deleted file mode 100644 index 981b6e9..0000000 --- a/aia_teem_map.old3.pro +++ /dev/null @@ -1,301 +0,0 @@ -pro aia_teem_map,fileset = fileset,FOV = fov,wave_,npix,teem_table,teem_map, FILElist = filelist, VERBOSE = verbose, filename_extra = FILENAME_extra, SAVE_DIR = save_dir, DEBUG = debug - -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates EM and Te temperature maps -; based on single-Gaussian fits in each macropixel -; -; Syntax : IDL>aia_teem_map,fileset,fov,wave_,npix,teem_table,teem_map -; -; Inputs : fileset = common filename part of 6 wavelength FITS images -; wave_ = strarr(6) with wavelengths in Angstroem -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = size of macropixel (spatial resolution) -; teem_table = filename of DEM lookup table -; (calculated previously with AIA_TEEM_TABLE.PRO) -; teem_map = savefile containing EM and Te maps -; -; Outputs : postscript file _col.ps (if io=2) -; -; History : 3-Mar-2011, Version 1 written by Markus J. Aschwanden -; 16-May-2011, made fov optional. If not given, uses the -; whole images. -; made fileset optional. Added filelist keyword to just give a list of files. -; : 5-Oct-2011 - Added search for 1 sigma contour in chi^2 space to calculate errors in telog and tsig - A. Inglis -; : 1-Feb-2011 - Changed definition of files (see lines 51-55) so that files = filelist directly. Solves issues with AIA2011xxx file formats. -; -; Contact : aschwanden@lmsal.com -;- - -default, save_dir, '' - -;_________________________________________________________________________ -t1 = systime(0,/seconds) -nwave = n_elements(wave_) -default, filename_extra, '' - -IF keyword_set(fileset) THEN BEGIN - files = strarr(6) - FOR iw = 0, nwave-1 DO BEGIN - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - searchstring=fileset+'*'+wave_[iw]+'_.fts' - file_iw = file_search(searchstring, count=nfiles) - files[iw]=file_iw[u] - ENDFOR -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - files = filelist - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(files,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - ;files = files[s] -ENDELSE -;_____________________REBINNING IMAGES___________________________________ - -texp_ =fltarr(nwave) -for iw=0,nwave-1 do begin - read_sdo,files(iw),index,data - - ; schriste (16-may-2011) - ; If Keyword FOV not given then determine the FOV - ; of the whole image automatically - IF keyword_set(fov) THEN BEGIN - i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ENDIF ELSE BEGIN - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ENDELSE - - dim =size(data) - nx0 =dim[1] - ny0 =dim[2] - if (i1 ge nx0) or (i2 ge nx0) or (j1 ge ny0) or (j2 ge ny0) then begin - print,'FOV=',i1,i2,j1,j2 - print,'image size=',nx0,ny0 - stop,'ERROR in subimage range i1,i2,j1,j2 for image with size nx0,ny0 - endif - image =data[i1:i2,j1:j2] - texp =index.exptime - dateobs=index.date_obs - if (iw eq 0) then begin - dim =size(image) - nx =dim[1] - ny =dim[2] - nxx =(nx/npix) - nyy =(ny/npix) - i3 =nxx*npix-1 - j3 =nyy*npix-1 - x =i1+(npix*findgen(nxx)+0.5) - y =j1+(npix*findgen(nyy)+0.5) - images=fltarr(nxx,nyy,nwave) - endif - if (npix eq 1) then images(*,*,iw)=float(image)/texp - if (npix gt 1) then images(*,*,iw)=rebin(float(image[0:i3,0:j3]),nxx,nyy)/texp - texp_(iw)=texp - - ;PLOT the image as a MAP - id = strmid(index.TELESCOP,0,3) + '/' + strmid(index.instrume,0,3) - aia_lct, rr, gg, bb, wavelnth=index.WAVELNTH, /load - a = index.CROTA2 - xcen = index.CRVAL1 + index.CDELT1*cos(a)*(0.5*(index.NAXIS1+1)- index.CRPIX1)-index.CDELT2*sin(a)*((index.NAXIS2+1)/2-index.CRPIX2) - ycen = index.CRVAL2 + index.CDELT1*sin(a)*((index.NAXIS1+1)*0.5-index.CRPIX1) + index.CDELT2*cos(a)*((index.NAXIS2+1)*0.5-index.CRPIX2) - map = make_map(data, time = index.t_obs, id = id, dur = index.exptime, xc = xcen, yc = ycen, dx = index.cdelt1, dy = index.cdelt2) - ;plot_map, map, /limb - -endfor - -;________________________TEMPERATURE MAP_________________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -dim =size(flux) -nte =dim[1] -nsig =dim[2] -nwave =dim[3] -ntot =nte*nsig -te_map =fltarr(nxx,nyy) -em_map =fltarr(nxx,nyy) -sig_map =fltarr(nxx,nyy) -flux_dem_map = fltarr(nxx, nyy, nwave) -chi_map = fltarr(nxx,nyy) -em_errmap = fltarr(nxx,nyy) -telog_errmap=fltarr(nxx,nyy,2) -tsig_errmap=fltarr(nxx,nyy,2) -telog_errmap_symmetric=fltarr(nxx,nyy) -tsig_errmap_symmetric=fltarr(nxx,nyy) -chi_map6=fltarr(nxx,nyy,6) -te_best =0. -em_best =0. -sig_best=0. -r0 =0.95*(4096/2) -x0 =4096/2 -y0 =4096/2 -nfree =3 -;stop -FOR j = 0, nyy-1 DO BEGIN - if (nx eq 4096) then ind=where(sqrt((x-x0)^2+(y(j)-y0)^2) le r0,nind) - if (nx lt 4096) then ind=findgen(nxx) - i1 = min(ind) > 0 - i2 = max(ind) < (nxx-1) - FOR i = i1, i2 DO BEGIN - flux_obs=reform(images[i,j,*]) - counts=flux_obs*texp_ - noise=sqrt(counts)/texp_ - chimin=9999. - chi6min=9999. - chi2d = fltarr(nte,nsig) - FOR k=0,nte-1 DO BEGIN - FOR l=0,nsig-1 DO BEGIN - flux_dem1=reform(flux(k,l,*)) - em1 =total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2))/total(flux_dem1) - flux_dem=flux_dem1*em1 - chi =sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6=abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - IF (chi le chimin) THEN BEGIN - chimin =chi - chi6min =chi6 - em_best =alog10(em1) - em_best_err = em1_err/em_best - te_best =telog(k) - sig_best =tsig(l) - flux_dem_best = flux_dem - ENDIF - ENDFOR - ENDFOR - - ; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin ne 9999.) THEN BEGIN - ;chimin defaults to 9999. if bad pixel (i.e. no data), so skip those - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3],path_xy=path_xy,path_info=path_info,/path_data_coords,closed=0 - IF exist(path_xy) THEN BEGIN - testxmax=MAX(path_xy(0,*)) - testxmin=MIN(path_xy(0,*)) - testymax=MAX(path_xy(1,*)) - testymin=MIN(path_xy(1,*)) - - telog_err=[testxmin,testxmax] - te_best - ;error bars are asymmetric - symmetrise! - telog_errsymmetric=sqrt(telog_err(0)^2 + telog_err(1)^2) - - tsig_err=[sig_best - testymin,testymax - sig_best] - ;error bars are asymmetric - symmetrise! - ;tsig_errsymmetric=sqrt(tsig_err(0)^2 + tsig_err(1)^2) - tsig_errsymmetric = max(tsig_err) - ;print,telog_errsymmetric - ;print,tsig_errsymmetric - ;print,telog_err - ;print,tsig_err - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - - IF keyword_set(VERBOSE) THEN BEGIN - print, wave_ - print, flux_obs - print, flux_dem_best - print, flux_dem_best/flux_obs - - loadct, 0 - hsi_linecolors - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR y = 0, nlevels-1 DO anot[y] = num2str(levels[y]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 't_sig' - oplot, [te_best], [sig_best], psym = symcat(16), color = 6 - leg = num2str(chimin) + '[' + num2str(te_best) + ',' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog,tsig,levels=[chimin + 2.3],/over,thick=2, color = 6 - stop - ENDIF - ;stop - flux_dem_map[i,j,*] = flux_dem_best - em_map[i,j]=em_best - te_map[i,j]=te_best - sig_map[i,j]=sig_best - chi_map[i,j]=chimin - chi_map6[i,j,*]=chi6min - telog_errmap[i,j,0:1]=telog_err[0:1] - tsig_errmap[i,j,0:1]=tsig_err[0:1] - telog_errmap_symmetric[i,j]=telog_errsymmetric - tsig_errmap_symmetric[i,j]=tsig_errsymmetric - ;telog_errmap(i,j,*)=telog_err - ;tsig_errmap(i,j,*)=tsig_err - - ENDFOR - IF (j mod 10) eq 0 THEN print,j,nyy -ENDFOR - -help,telog_errmap_symmetric -help,tsig_errmap_symmetric - -;print,telog_errmap_symmetric(50:70,50:70) -;print,tsig_errmap_symmetric(50:70,50:70) - -aia_map_cube = make_map( images[*,*,0], xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = '', time = dateobs) -aia_map_cube = replicate(aia_map_cube, 6) -aia_simul_map_cube = aia_map_cube - -FOR i = 0, n_elements(wave_)-1 DO BEGIN - aia_map_cube[i].data = images[*,*,i] - aia_map_cube[i].id = 'SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -FOR i = 0, n_elements(wave_)-1 DO BEGIN - aia_simul_map_cube[i].data = flux_dem_map[*,*,i] - aia_simul_map_cube[i].id = 'Simulated SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - - -temperature_map = make_map( te_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Temperature [MK])', time = dateobs) - -emission_map = make_map( em_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Emission Measure [cm!U-3!N]', time = dateobs) - -sigma_map = make_map( sig_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'Sigma', time = dateobs) - -chisq_map = make_map( chi_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -tsig_error_map_minus = make_map( tsig_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -telog_error_map_minus = make_map( telog_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -tsig_error_map_plus = make_map( tsig_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -telog_error_map_plus = make_map( telog_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;________________________STATISTICS OF CHI-2 FITS_________________ -print,'Statistics of chi2=' -statistic,chi_map -print,'Statistics of chi2 (94 A)' -statistic,chi_map6(*,*,5) -print,'log(EM)-range = ',minmax(em_map) - -;________________________SAVE MAPS________________________________ -;save,filename=teem_map,te_map,em_map,sig_map,chi_map,dateobs -save,filename=save_dir + teem_map,te_map,em_map,sig_map,chi_map,tsig_errmap_symmetric,telog_errmap_symmetric,temperature_map,emission_map,sigma_map,chisq_map,aia_map_cube, dateobs , aia_simul_map_cube -save,temperature_map,emission_map,sigma_map,chisq_map,tsig_error_map_minus,tsig_error_map_plus,telog_error_map_minus,telog_error_map_plus,aia_simul_map_cube, filename=save_dir + 'tempmap' + filename_extra + '.sav' - -print,'TE+EM maps saved in file : ',teem_map -t2 =systime(0,/seconds) - -print,'Computation time = ',(t2-t1)/60.0,' min' - -IF keyword_set(DEBUG) THEN stop - -END diff --git a/aia_teem_map.old4.pro b/aia_teem_map.old4.pro deleted file mode 100644 index 5fb5d4f..0000000 --- a/aia_teem_map.old4.pro +++ /dev/null @@ -1,342 +0,0 @@ -pro aia_teem_map,fileset = fileset,wave_,npix,teem_table,teem_map, FILElist = filelist, VERBOSE = verbose, filename_extra = FILENAME_extra, SAVE_DIR = save_dir, DEBUG = debug, XRANGE = xrange, YRANGE = yrange - -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates EM and Te temperature maps -; based on single-Gaussian fits in each macropixel -; -; Syntax : IDL> aia_teem_map,fileset,fov,wave_,npix,teem_table,teem_map -; -; Inputs : fileset = common filename part of 6 wavelength FITS images -; wave_ = strarr(6) with wavelengths in Angstroem -; /// fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view - deprecated -; xrange = fltarr(2) the xrange in arcsec for the subimage -; yrange = fltarr(2) the yrange in arcsec for the subimage -; npix = size of macropixel (spatial resolution) -; teem_table = filename of DEM lookup table -; (calculated previously with AIA_TEEM_TABLE.PRO) -; teem_map = savefile containing EM and Te maps -; -; Outputs : postscript file _col.ps (if io=2) -; -; History : 3-Mar-2011, Version 1 written by Markus J. Aschwanden -; 16-May-2011, made fov optional. If not given, uses the -; whole images. -; made fileset optional. Added filelist keyword to just give a list of files. -; : 5-Oct-2011 - Added search for 1 sigma contour in chi^2 space to calculate errors in telog and tsig - A. Inglis -; : 1-Feb-2011 - Changed definition of files (see lines 51-55) so that files = filelist directly. Solves issues with AIA2011xxx file formats. -; -; Contact : aschwanden@lmsal.com -;- - -default, save_dir, '' - -;_________________________________________________________________________ -t1 = systime(0,/seconds) -nwave = n_elements(wave_) -default, filename_extra, '' - -IF keyword_set(fileset) THEN BEGIN - files = strarr(6) - FOR iw = 0, nwave-1 DO BEGIN - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - searchstring=fileset+'*'+wave_[iw]+'_.fts' - file_iw = file_search(searchstring, count=nfiles) - files[iw]=file_iw[u] - ENDFOR -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - files = filelist - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(files,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - ;files = files[s] -ENDELSE -;_____________________REBINNING IMAGES___________________________________ - -texp_ = fltarr(nwave) - -FOR iw = 0, nwave-1 DO BEGIN - read_sdo,files[iw],index,data - index2map,index,data,map - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - map = smap - data = smap.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - dim =size(data) - nx0 =dim[1] - ny0 =dim[2] - - image = map.data - texp = map.dur - dateobs = map.time - - IF (iw EQ 0) then begin - dim = size(image) - nx = dim[1] - ny = dim[2] - nxx = (nx/npix) - nyy = (ny/npix) - i3 = nxx*npix-1 - j3 = nyy*npix-1 - ;x = i1+(npix*findgen(nxx)+0.5) - ;y = j1+(npix*findgen(nyy)+0.5) - images = fltarr(nxx,nyy,nwave) - x = get_map_xp(map, /oned) - y = get_map_yp(map, /oned) - ENDIF - - IF (npix EQ 1) THEN images[*,*,iw] = float(image)/texp - IF (npix GT 1) THEN BEGIN - images[*,*,iw] = rebin(float(image[0:i3,0:j3]),nxx,nyy)/texp - sub_map, map, smap, xrange = [0,i3], yrange = [0,j3], /pixel - rmap = rebin_map(smap, nxx, nyy) - x = get_map_xp(rmap, /oned) - y = get_map_yp(rmap, /oned) - map = rmap - ENDIF - - texp_[iw]=texp - - IF iw EQ 0 THEN aia_map_cube = replicate(map, nwave) ELSE aia_map_cube[iw] = map - - IF keyword_set(DEBUG) THEN BEGIN - aia_lct, rr, gg, bb, wavelnth=wave_[iw], /load - plot_map, map, /limb, /log - ENDIF -ENDFOR - -;________________________TEMPERATURE MAP_________________________________ -restore, save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig -te_map = fltarr(nxx,nyy) -em_map = fltarr(nxx,nyy) -sig_map = fltarr(nxx,nyy) -flux_dem_map = fltarr(nxx, nyy, nwave) -chi_map = fltarr(nxx,nyy) -em_errmap = fltarr(nxx,nyy) -telog_errmap = fltarr(nxx,nyy,2) -tsig_errmap = fltarr(nxx,nyy,2) -telog_errmap_symmetric = fltarr(nxx,nyy) -tsig_errmap_symmetric = fltarr(nxx,nyy) -chi_map6 = fltarr(nxx,nyy,6) -te_best = 0. -em_best = 0. -sig_best = 0. -;r0 = 0.95*(4096/2) -;x0 = 4096/2 -;y0 = 4096/2 -nfree = 3 -;stop -temp = get_sun(dateobs) -solar_radius = temp[1] - -FOR j = 0, nyy-1 DO BEGIN - ; the following code makes sure that regions with radial distance beyond r0 - ; are not considered. - ry = sqrt(x^2 + y[j]^2) - ind = where(ry LE solar_radius, count) - ;if (nx eq 4096) then ind=where(sqrt((x-x0)^2+(y(j)-y0)^2) le r0,nind) - ;if (nx lt 4096) then ind=findgen(nxx) - ;i1 = min(ind) > 0 - ;i2 = max(ind) < (nxx-1) - if count NE 0 THEN BEGIN - i1 = min(ind) - i2 = max(ind) - ENDIF ELSE continue - - FOR i = i1, i2-1 DO BEGIN - flux_obs=reform(images[i,j,*]) - counts=flux_obs*texp_ - noise=sqrt(counts)/texp_ - chimin = 9999. - chi6min = 9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - FOR k=0, nte-1 DO BEGIN - FOR l = 0, nsig-1 DO BEGIN - flux_dem1=reform(flux(k,l,*)) - em1 =total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2))/total(flux_dem1) - flux_dem=flux_dem1*em1 - chi =sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6=abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - IF (chi le chimin) THEN BEGIN - chimin =chi - chi6min =chi6 - em_best =alog10(em1) - em_best_err = em1_err/em_best - te_best =telog(k) - sig_best =tsig(l) - flux_dem_best = flux_dem - ENDIF - ENDFOR - ENDFOR - - ; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin NE 9999.) THEN BEGIN - ;chimin defaults to 9999. if bad pixel (i.e. no data), so skip those - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3],path_xy=path_xy,path_info=path_info,/path_data_coords,closed=0 - IF exist(path_xy) THEN BEGIN - testxmax=MAX(path_xy(0,*)) - testxmin=MIN(path_xy(0,*)) - testymax=MAX(path_xy(1,*)) - testymin=MIN(path_xy(1,*)) - - telog_err=[testxmin,testxmax] - te_best - ;error bars are asymmetric - symmetrise! - telog_errsymmetric=sqrt(telog_err(0)^2 + telog_err(1)^2) - - tsig_err=[sig_best - testymin,testymax - sig_best] - ;error bars are asymmetric - symmetrise! - ;tsig_errsymmetric=sqrt(tsig_err(0)^2 + tsig_err(1)^2) - tsig_errsymmetric = max(tsig_err) - ;print,telog_errsymmetric - ;print,tsig_errsymmetric - ;print,telog_err - ;print,tsig_err - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. - ENDELSE - - IF keyword_set(VERBOSE) THEN BEGIN - print, 'j = ', j - print, 'chimin = ', chimin - print, 'Wavelength:', wave_ - print, 'Observed flux:', flux_obs - print, 'Fitted flux:', flux_dem_best - print, 'Fitted/Obs flux:', flux_dem_best/flux_obs - - IF chimin LT 9999. THEN BEGIN - loadct, 0 - hsi_linecolors - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 't_sig' - oplot, [te_best], [sig_best], psym = symcat(16), color = 6 - leg = num2str(chimin) + '[' + num2str(te_best) + ',' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog,tsig,levels=[chimin + 2.3],/over,thick=2, color = 6 - ENDIF - stop - ENDIF - ;stop - flux_dem_map[i,j,*] = flux_dem_best - em_map[i,j]=em_best - te_map[i,j]=te_best - sig_map[i,j]=sig_best - chi_map[i,j]=chimin - chi_map6[i,j,*]=chi6min - telog_errmap[i,j,0:1]=telog_err[0:1] - tsig_errmap[i,j,0:1]=tsig_err[0:1] - telog_errmap_symmetric[i,j]=telog_errsymmetric - tsig_errmap_symmetric[i,j]=tsig_errsymmetric - ;telog_errmap(i,j,*)=telog_err - ;tsig_errmap(i,j,*)=tsig_err - - ENDFOR - IF (j mod 10) eq 0 THEN print,j,nyy -ENDFOR - -help,telog_errmap_symmetric -help,tsig_errmap_symmetric - -;print,telog_errmap_symmetric(50:70,50:70) -;print,tsig_errmap_symmetric(50:70,50:70) - -aia_simul_map_cube = aia_map_cube - -FOR i = 0, nwave-1 DO BEGIN - aia_simul_map_cube[i].data = flux_dem_map[*,*,i] - aia_simul_map_cube[i].id = 'Simulated SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -temperature_map = map -temperature_map.data = te_map -temperature_map.id = 'log(Temperature [MK])' -temperature_map.time = dateobs - -emission_map = map -emission_map.data = em_map -emission_map.id = 'log(Emission Measure [cm!U-3!N]' -emission_map.time = dateobs - -sigma_map = map -sigma_map.data = sig_map -sigma_map.id = 'Sigma' -sigma_map.time = dateobs - -chisq_map = map -chisq_map.data = chi_map -chisq_map.id = textoidl('\chi^2') -chisq_map.time = dateobs - -tsig_error_map_minus = map -tsig_error_map_minus.data = tsig_errmap[*,*,0] -tsig_error_map_minus.id = 'Temp sigma err -' -tsig_error_map_minus.time = dateobs - -telog_error_map_minus = map -telog_error_map_minus.data = telog_errmap[*,*,0] -telog_error_map_minus.id = 'log(Temp) err -' -telog_error_map_minus.time = dateobs - -tsig_error_map_plus = map -tsig_error_map_plus.data = tsig_errmap[*,*,1] -tsig_error_map_plus.id = 'Temp sigma err +' -tsig_error_map_plus.time = dateobs - -tsig_error_map_plus = map -tsig_error_map_plus.data = telog_errmap[*,*,1] -tsig_error_map_plus.id = 'log(Temp) err +' -tsig_error_map_plus.time = dateobs - -;________________________STATISTICS OF CHI-2 FITS_________________ -print,'Statistics of chi2=' -statistic,chi_map -print,'Statistics of chi2 (94 A)' -statistic,chi_map6(*,*,5) -print,'log(EM)-range = ',minmax(em_map) - -;________________________SAVE MAPS________________________________ -;save,filename=teem_map,te_map,em_map,sig_map,chi_map,dateobs -save,filename=save_dir + teem_map,te_map,em_map,sig_map,chi_map,tsig_errmap_symmetric,telog_errmap_symmetric,temperature_map,emission_map,sigma_map,chisq_map,aia_map_cube, dateobs , aia_simul_map_cube -save,temperature_map,emission_map,sigma_map,chisq_map,tsig_error_map_minus,tsig_error_map_plus,telog_error_map_minus,telog_error_map_plus,aia_simul_map_cube, filename=save_dir + 'tempmap' + filename_extra + '.sav' - -print,'TE+EM maps saved in file : ',teem_map -t2 =systime(0,/seconds) - -print,'Computation time = ',(t2-t1)/60.0,' min' - -IF keyword_set(DEBUG) THEN stop - -END diff --git a/aia_teem_movie.old1.pro b/aia_teem_movie.old1.pro deleted file mode 100644 index 0f4d704..0000000 --- a/aia_teem_movie.old1.pro +++ /dev/null @@ -1,272 +0,0 @@ -PRO aia_teem_movie, DIR = dir, istart = istart, HSI_FITS = hsi_fits, DEBUG = debug, OUTPLOT = outplot, XRAYSPEC = xrayspec, SAVE_DIR = save_dir, flare_num = FLARE_NUM, VERBOSE = verbose, ISTOP = istop, fileset = fileset, fov = fov, npix = npix, FORCE_TABLE = force_table, q94 = q94 - -; -; -;KEYWORDS: -; SAVE_DIR - -; FOV - must be given in arcsec [xmin,xmax,ymin,ymax] -; -;WRITTEN: Steven Christe (11-Oct-2011) -;REVISION: Steven Christe (6-Jan-2011) - -default, istart, 0 -default, dir, '~/Desktop/hsi_flare_20110716_170350/' -default, hsi_fits, '~/Dropbox/idl/aia_deem/hsi_image_20110716_170350.fits' -default, save_fit, '' -default, hsi_image, '' -default, fileset, 'ssw_cutout' -default, npix, 6 ;(macropixel size=4x4 pixels, yields 512x512 map) -default, q94, 6.7 ;(correction factor for low-temperature 94 A response) - -IF keyword_set(flare_num) THEN BEGIN - ;dir = '~/Desktop/' + ['hsi_flare_20110716_170350/', $ - ;'hsi_flare_20110826_205258/', $ - ;'hsi_flare_20110603_071626/', $ - ;'hsi_flare_20110621_182202/'] - - dir = '~/Desktop/' + [ $ - 'hsi_flare_20110603_071626/', $ - 'hsi_flare_20110621_182202/', $ - 'hsi_flare_20110716_170350/', $ - 'hsi_flare_20110826_205258/', $ - 'hsi_flare_20101016/'] - - ;key 0->2 1->3, 2->0, 3->1 - - save_dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/', $ - 'flare4_deem/'] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'ospex_*.fits') - hsi_fits = f[0] - - f = file_search(hsi_fits_dir + 'hsi_image*.fits') - hsi_image = f[0] - - dir = dir[flare_num-1] - save_dir = save_dir[flare_num-1] -ENDIF - -;note: flare happens at i = 120 -loadct,0 -hsi_linecolors - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -file_list = get_aia_file_list(dir, fileset = fileset) - -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;t_min = 5.0 -;t_max = 6.5 -;t_d = 0.1 -;telog1 = t_d * findgen((t_max - t_min)/t_d) + t_min - -t_min = 5.5 -t_max = 8.0 - -t_min = 5.5 -t_max = 7.0 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -;telog = [telog1,telog2] - -;te_range=[0.1,100]*1.e6 ; ([K], valid temperature range for DEM solutions) - -;tsig=0.1*(1+1*findgen(10)) ; (values of Gaussian logarithmic temperature widths) -tsig_min = 0.01 -tsig_max = 1.0 -tsig_d = 0.01 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -;not sure what the following does -vers='a' ; (version number of label in filenames used for full images) - -; Savefile that contains DEM loopup table -teem_table='teem_table.sav' -; Savefile that contains EM and Te maps -teem_map =fileset+vers+'_teem_map.sav' -; jpg-file that shows EM and Te maps -teem_jpeg=fileset+vers+'_teem_map.jpg' -; only need to do this once - -f = file_search(teem_table) -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table,wave_,tsig,telog=telog,q94,filelist=file_list[0,*], teem_table, save_dir = save_dir - -;aia_teem_table,wave_,tsig,te_range=te_range,q94,filelist=file_list[0,*], teem_table, save_dir = save_dir - -IF NOT keyword_set(istop) THEN istop = nfiles[0] - -IF hsi_image[0] NE '' THEN BEGIN - fits2map, file_list[0,0], aiamap - fits2map, hsi_image, map - ; interpolate the rhessi map to the aia map - imap = inter_map(map,aiamap) - m = max(imap.data) - ; set the mask at everything above 50% contour - index = where(imap.data LE m*0.5, complement = complement) - imap.data[index] = 0 - imap.data[complement] = 1 - mask = imap.data - invmask = NOT mask -ENDIF - - -FOR i = istart, nfiles[0]-1 DO BEGIN - ;window,0 - IF fileset EQ 'ssw_cutout' THEN cur_time = anytim(aiacutout_to_time(file_list[i,0]),/yoh) - IF fileset EQ 'AIA' THEN cur_time = anytim(aiaprep_to_time(file_list[i,0]), /yoh) - print, cur_time - ; Savefile that contains EM and Te maps - teem_map ='teem_data_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) + '.sav' - - teem_tot ='teem_tot_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) + '_q94_' + num2str(10*q94, length = 2) + '.sav' - - aia_teem_map,wave_,npix,teem_table,teem_map,filelist = file_list[i,*], filename_extra = '_' + num2str(i, padchar = '0', length = 3), save_dir = save_dir, debug = debug, verbose = verbose, fov = fov - - IF hsi_image[0] NE '' THEN BEGIN - tx ='teem_tot_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) - teem_tot = [tx + '_mask_.sav',tx + '_invmask_.sav'] - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot[0],filelist = file_list[i,*], mask = mask, /plot, save_dir = save_dir, fov = fov - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot[1],filelist = file_list[i,*], mask = invmask, save_dir = save_dir, fov = fov - ENDIF ELSE BEGIN - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot,filelist = file_list[i,*], fov = fov - ENDELSE - - stop - - IF keyword_set(OUTPLOT) THEN BEGIN - set_plot, 'z' - loadct,0 - hsi_linecolors - device, set_resolution = [800, 600] - ENDIF - - IF keyword_set(HSI_FITS) THEN BEGIN - - restore, save_dir + teem_tot[0] - telog_mask = telog - emlog_mask = emlog - emlog_err_mask = emlog_err - restore, save_dir + teem_tot[1] - - hsi_linecolors - yrange = [min([emlog_mask, emlog]), max([emlog_mask, emlog])] - plot, telog, emlog, xtitle = 'log(Temperature [MK])', ytitle = 'log(Emmission Measure [cm!U-5!N])', /nodata, yrange = yrange, /ystyle,title = cur_time, charsize = 2.0 - - oplot, telog, emlog, thick = 2.0, linestyle = 1, psym = symcat(16), color = 6 - oploterr, telog, emlog, emlog_err, /nohat, color = 6, errcolor = 6 - - oplot, telog_mask, emlog_mask, thick = 2.0, psym = symcat(16), color = 7 - oploterr, telog_mask, emlog_mask, emlog_err_mask, /nohat, color = 7, errcolor = 7 - - ;get the maxima - m = max(emlog, mindex) - max_t = telog[mindex] - - m = max(emlog_mask, mindex) - max_t_mask = telog_mask[mindex] - - ;text = ['Flare T!Lmax!N = ' + mynum2str(10^max_t_mask),'Background T!Lmax!N = ' + mynum2str(10^max_t)] - - ; now fit a line/power-law to the data above 5 MK - index = where(telog GE alog10(5e6)) - x = telog_mask[index] - y = emlog_mask[index] - eq_mask = linfit(x,y) - - oplot, [alog10(5e6), alog10(1e8)], eq_mask[1]*[alog10(5e6), alog10(1e8)] + eq_mask[0], color = 5 - - x = telog[index] - y = emlog[index] - eq_bkg = linfit(x,y) - - oplot, [alog10(5e6), alog10(1e8)], eq_bkg[1]*[alog10(5e6), alog10(1e8)] + eq_bkg[0], color = 6 - - IF keyword_set(HSI_FITS) THEN BEGIN - print, hsi_image - print, hsi_fits - fits2map, hsi_image, map - c = 0.5 - frac = n_elements(where(map.data/max(map.data) GE c))/float(n_elements(map.data)) - area = n_elements(map.data)*frac*map.dx*map.dy * 712e5^2.0 - - result = spex_read_fit_results(hsi_fits) - p = result.spex_summ_params - - ;now find the fit that is closest in time to time t - hsi_time = result.spex_summ_time_interval - ;con1 = anytim(t) LE anytim(hsi_time[1,*]) - ;con2 = anytim(t) GE anytim(hsi_time[0,*]) - - params = p[*,0] - - ;multi_therm_pow - ;DEM(T) = a[0] * (2/T)^a[3] - ;a[0] diff emission measure at T = 2 keV, 10^49 cm^(-3) keV^-1 - ;a[1] min plasma temperature (keV) - ;a[2] max plasma temperature (keV) - ;a[3] power law index - ;a[4] relative abundance - - hsi_telog = alog10([params[1], params[2]]*11.6d6) - hsi_emlog = alog10(1/11.6d6*1d49*params[0]*([2.0/params[1], 2.0/params[2]])^(params[3])) - - hsi_emlog = hsi_emlog - alog10(area) - oplot, hsi_telog, hsi_emlog, thick = 2.0, color = 4 - - ;legend, ['rhessi (' + textoidl('\alpha = ') + num2str(-params[3], length = 4) + ')', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ;legend, ['rhessi (' + textoidl('\alpha = ') + num2str(-params[3], length = 4) + ')', color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - - hsi_time_str = anytim(hsi_time, /yoh) - t = strmid(hsi_time_str[0], 0,10) + strmid(hsi_time_str[0], 10,8) + ' to ' + strmid(hsi_time_str[1], 10,8) - text = ['aia', 'aia (bkg)', 'rhessi (' + t + ')'] - - legend, text, linestyle = [0,1, 0], /left, box = 1, /bottom, charsize = 1.5, pspacing = 1, color = [7,6,4], textcolor = [7,6,4] - - text = textoidl('\alpha_{fit} = ') + [num2str(eq_bkg[1], length = 4), num2str(eq_mask[1], length = 4)] - text = [text, textoidl('\alpha_{hsi} = ') + num2str(-params[3], length = 4)] - legend, text, linestyle = [0,0,0], color = [5,6,4], charsize = 1.5, /top, /right, pspacing = 1, thick = [1,1,2] - - ENDIF ELSE BEGIN - text = ['aia', 'aia (bkg)'] - - legend, text, linestyle = [0,1], /left, box = 1, /bottom, charsize = 1.5, pspacing = 1, color = [7,6], textcolor = [7,6] - - text = textoidl('\alpha_{fit} = ') + [num2str(eq_bkg[1], length = 4), num2str(eq_mask[1], length = 4)] - legend, text, linestyle = [0,0], color = [5,6], charsize = 1.5, /top, /right, pspacing = 1 - - ;legend, ['rhessi', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ENDELSE - - IF keyword_set(OUTPLOT) THEN BEGIN - tvlct, r, g, b, /get - outfile = save_dir + 'dem_' + num2str(i, length = 3, padchar = '0') + '_' + break_time(cur_time) + '_' + num2str(i, padchar = '0', length = 3) + '.png' - write_png, outfile, tvrd(), r,g,b - set_plot, 'x' - ENDIF - -ENDIF - - IF keyword_set(XRAYSPEC) THEN BEGIN - ; now simulate the x-ray spectrum for this area - dem = [transpose(telog), transpose(emlog)] - result = chianti_spec_from_dem(dem, /plot) - IF keyword_set(hsi_fits) THEN BEGIN - dem_mask = [transpose(telog_mask), transpose(emlog_mask)] - result_mask = chianti_spec_from_dem(dem_mask) - oplot, result_mask[0,*], result_mask[1,*] - ENDIF - ENDIF - - IF keyword_set(debug) THEN stop - -ENDFOR - -END \ No newline at end of file diff --git a/aia_teem_total.old1.pro b/aia_teem_total.old1.pro deleted file mode 100644 index 6d552ff..0000000 --- a/aia_teem_total.old1.pro +++ /dev/null @@ -1,151 +0,0 @@ -pro aia_teem_total,fileset = fileset,fov = fov,npix,wave_,q94,teem_table,teem_map,teem_tot, mask = mask, filelist = filelist, PLOT = plot, SAVE_DIR = save_dir -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates temperature map -; based on single-Gaussian fit -; -; Syntax : IDL>aia_teem_total,fileset,fov,wave_,teem_map -; -; Inputs : fileset = strarr(6) with filenames of 6 wavelength FITS images -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = macropixel size -; wave_ = strarr(6) with wavelengths in Angstroem -; q94 = empirical correction factor of 94 A response -; teem_table = savefile containing DEM lookup table -; teem_map = savefile containing EM and Te maps -; mask = given a mask, return the dem only from within it. -; -; Outputs : teem_tot = savefile containing total DEM and fluxes -; -; History : 9-Mar-2011, Version 1 written by Markus J. Aschwanden -; : 10-May-2011, Version 2 added mask keyword by S. Christe -; -; Contact : aschwanden@lmsal.com -;- - -default, save_dir, '' -;_____________________TOTAL FLUX_________________________________________ -nwave = n_elements(wave_) -flux_ = fltarr(nwave) - -IF keyword_set(fileset) THEN BEGIN - searchstring=fileset+'*'+wave_(0)+'*' - file_iw=file_search(searchstring,count=nfiles) -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(filelist,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - file_iw = filelist -ENDELSE - -FOR iw = 0, nwave-1 DO BEGIN - - fits2map, file_iw[iw], map - - IF keyword_set(FOV) THEN BEGIN - sub_map, map, smap, xrange = fov[0:1], yrange = fov[2:3] - map = smap - ENDIF - - dim = size(map.data) - - IF keyword_set(mask) THEN BEGIN - print,total(map.data) - FOR k=0, dim[0] do begin - FOR l=0, dim[1] do begin - data[k,l]=data[k,l]*mask[k,l] - ENDFOR - ENDFOR - mask_frac=total(mask)/(dim[0]*dim[1]) - ENDIF ELSE mask_frac = 1 - - texp = map.dur - flux_[iw] = total(map.data)/texp - ;flux_(iw)=total(data)/texp - print, wave_[iw], flux_[iw] -ENDFOR - -;_____________________AIA RESPONSE FUNCTION________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -nte =n_elements(telog) - -;_____________________READ DEM PER PIXEL__________________________ -restore,save_dir + teem_map ;-->te_map,em_map,sig_map,chi_map,dateobs -dim =size(em_map) -nx =dim(1) -ny =dim(2) -IF NOT keyword_set(mask) THEN tempmask = replicate(1,nx,ny) ELSE tempmask = congrid(mask,nx,ny) -em_tot =fltarr(nte) -em =fltarr(nte) -te =fltarr(nte) -sig =fltarr(nte) -em_errtot=fltarr(nte) -error_array=fltarr(nx,ny,nte) -nmacro = float(nx)*float(ny) -FOR j=0,ny-1 do begin - FOR i=0,nx-1 do begin - em[*] = tempmask[i,j]*10.^em_map[i,j] ;log(EM)-->EM - te[*] =te_map[i,j]*tempmask[i,j] ;log(te) - sig[*] =sig_map[i,j]*tempmask[i,j] - em_tot =em_tot+em*exp(-(telog-te)^2/(2.*sig^2))/(nmacro * mask_frac) - IF (sig[0] gt 0.) THEN begin - error1=double(tsig_errmap_symmetric[i,j]) - error2=double(telog_errmap_symmetric[i,j]) - error3=(2.*(error2/telog-te)*(-(telog-te)^2.)) ; error in -(telog-te)^2 - careful with minus sign. - error4=2.*(error1/sig)*(sig^2.) ; error in sig^2 - error5=2.*error4 ; error in 2sig^2 - error6=sqrt( (error3/(telog-te)^2.) + (error5/(2.*sig^2.)) ) * ((telog-te)^2. / (2.*sig^2.)) ;error in exponent: {(telog-te)^2/(2*sig^2)} - error7=error6 * exp(-(telog-te)^2./(2.*sig^2.)) ;error once the exp is done. - error8=error7*(em/nmacro) ; final error in em at i,j - ;check FOR -NaN values - p=finite(error8) - index = WHERE (p gt 0,count,complement=index_c) - comp_count = n_elements(p) - count - ;replace NaN values with 0. - IF comp_count NE 0 THEN BEGIN - error8[index_c] = 0. - ;store the error FOR this i,j in an array. - error_array[i,j,*]=error8 - ENDIF - ENDIF ELSE begin - error_array[i,j,*]=0. - ;em_errtot = em_errtot + 0. - ENDELSE - - ENDFOR -ENDFOR -emlog = alog10(em_tot) - - -;get sum of the squares FOR each element of em_errtot = fltarr(nte). This gives the final error in em_tot summed over all the pixels. -FOR j = 0,nte-1 DO em_errtot[j] = reform(sqrt(total(error_array[*,*,j]^2.))) - -;get error in em_log rather than em_tot -emlog_err = (em_errtot/em_tot) - -clearplot -IF keyword_set(PLOT) THEN BEGIN - plot,telog,emlog,yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - oploterr, telog, emlog, emlog_err -ENDIF - -;______________________TOTAL FLUX FROM DEM________________________ -flux_dem=fltarr(nwave) -qflux =fltarr(nwave) -FOR iw=0,nwave-1 do begin - flux_dem[iw]=total(resp_corr[*,iw] * em_tot*dte) * nmacro*npix^2 * mask_frac - qflux[iw] = flux_dem[iw]/flux_[iw] - print,flux_(iw),flux_dem(iw),qflux(iw) -ENDFOR - -;______________________SAVE RESULTS_______________________________ -save,filename=save_dir + teem_tot,telog,emlog,flux_,flux_dem,qflux, emlog_err -;save,filename='teem_tot_test'+strtrim(string(u),2)+'.sav',telog,emlog,emlog_err,flux_,flux_dem,qflux - -END diff --git a/aia_teem_total.old2.pro b/aia_teem_total.old2.pro deleted file mode 100644 index fec7ff2..0000000 --- a/aia_teem_total.old2.pro +++ /dev/null @@ -1,163 +0,0 @@ -pro aia_teem_total,fileset = fileset,fov = fov,npix,wave_,q94,teem_table,teem_map,teem_tot, mask = mask, filelist = filelist, PLOT = plot, SAVE_DIR = save_dir -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates temperature map -; based on single-Gaussian fit -; -; Syntax : IDL>aia_teem_total,fileset,fov,wave_,teem_map -; -; Inputs : fileset = strarr(6) with filenames of 6 wavelength FITS images -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = macropixel size -; wave_ = strarr(6) with wavelengths in Angstroem -; q94 = empirical correction factor of 94 A response -; teem_table = savefile containing DEM lookup table -; teem_map = savefile containing EM and Te maps -; mask = given a mask, return the dem only from within it. -; -; Outputs : teem_tot = savefile containing total DEM and fluxes -; -; History : 9-Mar-2011, Version 1 written by Markus J. Aschwanden -; : 10-May-2011, Version 2 added mask keyword by S. Christe -; :1-Feb-2012 Version 2 - fixed outstanding bugs in code - A. Inglis -; a) Lines 44-50 did not handle the AIA2011xxxx file format and have been replaced by setting -; file_iw=filelist directly (filelist is now in correct handling order already). -; b)Error calculation was missing mask_frac on the denominator when error 8 is calculated (line 113) -; c)mask_frac is now calculated correctly! See line 79. -; -; Contact : aschwanden@lmsal.com -;- -; -default, save_dir, '' -;_____________________TOTAL FLUX_________________________________________ -nwave =n_elements(wave_) -flux_ =fltarr(nwave) - -IF keyword_set(fileset) THEN BEGIN - searchstring=fileset+'*'+wave_(0)+'*' - file_iw=file_search(searchstring,count=nfiles) -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(filelist,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - ;file_iw = filelist[s] - file_iw=filelist -ENDELSE - -FOR iw=0,nwave-1 do begin - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - ;file_iw=findfile(searchstring,count=nfiles) - - read_sdo,file_iw[iw],index,data - IF keyword_set(fov) THEN BEGIN - i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ENDIF ELSE BEGIN - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ENDELSE - IF keyword_set(mask) then begin - ;tempmask=congrid(mask,i2+1,j2+1) - - print,total(data) - FOR k=0,i2 do begin - FOR l=0,j2 do begin - data[k,l]=data[k,l]*mask[k,l] - ENDFOR - ENDFOR - ENDIF - - texp =index.exptime - flux_(iw)=total(data(i1:i2,j1:j2))/texp - ;flux_(iw)=total(data)/texp - print,wave_(iw),flux_(iw) -ENDFOR -IF keyword_set(mask) THEN mask_frac=total(mask)/((i2-i1)*(j2-j1)) ELSE mask_frac = 1.; (i2-i1)*(j2-j1) - - -;_____________________AIA RESPONSE FUNCTION________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -nte =n_elements(telog) - -;_____________________READ DEM PER PIXEL__________________________ -restore,save_dir + teem_map ;-->te_map,em_map,sig_map,chi_map,dateobs -dim =size(em_map) -nx =dim(1) -ny =dim(2) -IF NOT keyword_set(mask) THEN tempmask = replicate(1,nx,ny) ELSE tempmask = congrid(mask,nx,ny) -em_tot =dblarr(nte) -em =dblarr(nte) -te =dblarr(nte) -sig =dblarr(nte) -em_errtot=dblarr(nte) -error_array=dblarr(nx,ny,nte) -nmacro = float(nx)*float(ny) -FOR j=0,ny-1 do begin - FOR i=0,nx-1 do begin - em[*] = tempmask[i,j]*10.^em_map[i,j] ;log(EM)-->EM - te[*] =te_map[i,j]*tempmask[i,j] ;log(te) - sig[*] =sig_map[i,j]*tempmask[i,j] - em_tot =em_tot+em*exp(-(telog-te)^2/(2.*sig^2))/(nmacro * mask_frac) - IF (sig[0] gt 0.) THEN begin - error1=double(tsig_errmap_symmetric[i,j]) - error2=double(telog_errmap_symmetric[i,j]) - error3=(2.*(error2/telog-te)*(-(telog-te)^2.)) ; error in -(telog-te)^2 - careful with minus sign. - error4=2.*(error1/sig)*(sig^2.) ; error in sig^2 - error5=2.*error4 ; error in 2sig^2 - error6=sqrt( (error3/(telog-te)^2.) + (error5/(2.*sig^2.)) ) * ((telog-te)^2. / (2.*sig^2.)) ;error in exponent: {(telog-te)^2/(2*sig^2)} - error7=error6 * exp(-(telog-te)^2./(2.*sig^2.)) ;error once the exp is done. - error8=error7*(em/(nmacro*mask_frac)) ; final error in em at i,j 01/27/12 - added mask_frac - ARI - ;check FOR -NaN values - p=finite(error8) - index = WHERE (p gt 0,count,complement=index_c) - ;replace NaN values with 0. - error8(index_c)=0. - ;store the error FOR this i,j in an array. - error_array[i,j,*]=error8 - ENDIF ELSE begin - error_array[i,j,*]=0. - ;em_errtot = em_errtot + 0. - ENDELSE - ;print,em,error1,error2,error3,error4,error5,error6,error7,error8 - ;stop - ENDFOR -ENDFOR -emlog = alog10(em_tot) - - -;get sum of the squares FOR each element of em_errtot = fltarr(nte). This gives the final error in em_tot summed over all the pixels. -FOR j = 0,nte-1 DO em_errtot[j] = reform(sqrt(total(error_array[*,*,j]^2.))) - -;get error in em_log rather than em_tot -emlog_err = (em_errtot/em_tot) - -print,em_tot -print,emlog -print,em_errtot -print,emlog_err -stop -clearplot -IF keyword_set(PLOT) THEN BEGIN - plot,telog,emlog,yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - oploterr, telog, emlog, emlog_err -ENDIF - -;______________________TOTAL FLUX FROM DEM________________________ -flux_dem=fltarr(nwave) -qflux =fltarr(nwave) -FOR iw=0,nwave-1 do begin - flux_dem[iw]=total(resp_corr[*,iw] * em_tot*dte) * nmacro*npix^2 * mask_frac - qflux[iw] = flux_dem[iw]/flux_[iw] - print,flux_(iw),flux_dem(iw),qflux(iw) -ENDFOR - -;______________________SAVE RESULTS_______________________________ -save,filename=save_dir + teem_tot,telog,emlog,flux_,flux_dem,qflux, emlog_err, error_array -;save,filename='teem_tot_test'+strtrim(string(u),2)+'.sav',telog,emlog,emlog_err,flux_,flux_dem,qflux - -END diff --git a/aia_teem_total.old3.pro b/aia_teem_total.old3.pro deleted file mode 100644 index d697b37..0000000 --- a/aia_teem_total.old3.pro +++ /dev/null @@ -1,190 +0,0 @@ -pro aia_teem_total,fileset = fileset,fov = fov,npix,wave_,q94,teem_table,teem_map,teem_tot, mask_map = mask_map, filelist = filelist, PLOT = plot, SAVE_DIR = save_dir -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates temperature map -; based on single-Gaussian fit -; -; Syntax : IDL>aia_teem_total,fileset,fov,wave_,teem_map -; -; Inputs : fileset = strarr(6) with filenames of 6 wavelength FITS images -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = macropixel size -; wave_ = strarr(6) with wavelengths in Angstroem -; q94 = empirical correction factor of 94 A response -; teem_table = savefile containing DEM lookup table -; teem_map = savefile containing EM and Te maps -; mask_map = given a mask as a map, return the dem only where it equals 1. -; -; Outputs : teem_tot = savefile containing total DEM and fluxes -; -; History : 9-Mar-2011, Version 1 written by Markus J. Aschwanden -; : 10-May-2011, Version 2 added mask keyword by S. Christe -; :1-Feb-2012 Version 2 - fixed outstanding bugs in code - A. Inglis -; a) Lines 44-50 did not handle the AIA2011xxxx file format and have been replaced by setting -; file_iw=filelist directly (filelist is now in correct handling order already). -; b)Error calculation was missing mask_frac on the denominator when error 8 is calculated (line 113) -; c)mask_frac is now calculated correctly! See line 79. -; -; Contact : aschwanden@lmsal.com -;- -; -default, save_dir, '' -;_____________________TOTAL FLUX_________________________________________ -nwave =n_elements(wave_) -flux_ =fltarr(nwave) - -IF keyword_set(fileset) THEN BEGIN - searchstring=fileset+'*'+wave_(0)+'*' - file_iw=file_search(searchstring,count=nfiles) -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - ;s = fltarr(nwave) - ;FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(filelist,'*' + num2str(wave_[i]) + '_.fts') EQ 1) - ;file_iw = filelist[s] - file_iw=filelist -ENDELSE - -FOR iw=0,nwave-1 do begin - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - ;file_iw=findfile(searchstring,count=nfiles) - - read_sdo,files[iw],index,data - index2map,index,data,map - - IF keyword_set(fov) THEN BEGIN - i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ENDIF ELSE BEGIN - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ENDELSE - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - map = smap - data = smap.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - image = data - texp = map.dur - dateobs = map.time - mask = mask_map.data - - IF keyword_set(mask_map) then begin - print,total(data) - FOR k=0, i2 DO BEGIN - FOR l=0, j2 DO BEGIN - data[k,l]=data[k,l]*mask[k,l] - ENDFOR - ENDFOR - ENDIF - - flux_[iw]=total(data[i1:i2,j1:j2])/texp - print,wave_(iw),flux_(iw) -ENDFOR -IF keyword_set(mask) THEN mask_frac=total(mask)/((i2-i1)*(j2-j1)) ELSE mask_frac = 1.; (i2-i1)*(j2-j1) - - -;_____________________AIA RESPONSE FUNCTION________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -nte =n_elements(telog) - -;_____________________READ DEM PER PIXEL__________________________ -restore,save_dir + teem_map ;-->te_map,em_map,sig_map,chi_map,dateobs -dim =size(em_map) -nx =dim(1) -ny =dim(2) -IF NOT keyword_set(mask) THEN tempmask = replicate(1,nx,ny) ELSE tempmask = congrid(mask,nx,ny) -em_tot =dblarr(nte) -em =dblarr(nte) -te =dblarr(nte) -sig =dblarr(nte) -em_errtot=dblarr(nte) -error_array=dblarr(nx,ny,nte) -energy=fltarr(nx,ny) -kb=1.3806503e-16 -nmacro = float(nx)*float(ny) -FOR j=0,ny-1 do begin - FOR i=0,nx-1 do begin - em[*] = tempmask[i,j]*10.^em_map[i,j] ;log(EM)-->EM - te[*] =te_map[i,j]*tempmask[i,j] ;log(te) - sig[*] =sig_map[i,j]*tempmask[i,j] - em_tot =em_tot+em*exp(-(telog-te)^2/(2.*sig^2))/(nmacro * mask_frac) - IF (sig[0] gt 0.) THEN begin - error1=double(tsig_errmap_symmetric[i,j]) - error2=double(telog_errmap_symmetric[i,j]) - error3=(2.*(error2/telog-te)*(-(telog-te)^2.)) ; error in -(telog-te)^2 - careful with minus sign. - error4=2.*(error1/sig)*(sig^2.) ; error in sig^2 - error5=2.*error4 ; error in 2sig^2 - error6=sqrt( (error3/(telog-te)^2.) + (error5/(2.*sig^2.)) ) * ((telog-te)^2. / (2.*sig^2.)) ;error in exponent: {(telog-te)^2/(2*sig^2)} - error7=error6 * exp(-(telog-te)^2./(2.*sig^2.)) ;error once the exp is done. - error8=error7*(em/(nmacro*mask_frac)) ; final error in em at i,j 01/27/12 - added mask_frac - ARI - ;check FOR -NaN values - p=finite(error8) - index = WHERE (p gt 0,count,complement=index_c) - ;replace NaN values with 0. - error8(index_c)=0. - ;store the error FOR this i,j in an array. - error_array[i,j,*]=error8 - - ;calculate the energy in each pixel by integrating the emission measure. ARI 2011/11/18 - ;1.8805014e11 converts from pixels to cm^2 - ;Assume V=A^1.5 - - ;Energy = 1.5k * V^1/2 * Integral(EM ^ 1/2 dT) - - ;integrate the square root of emission measure. Need to convert to cm^-5 hence the /1.8805013e15 - em_integral=int_tabulated((10^telog),sqrt(em*1.8805013e15),/double) - energy(i,j)=1.5 * em_integral * sqrt((nmacro*npix^2*mask_frac*1.8805014e15)^1.5) * kb - print,'test numbers: ',total(sqrt(em)),em_integral, sqrt((nmacro*npix^2*mask_frac*1.8805014e15)^1.5), kb, energy(i,j) - - ENDIF ELSE begin - error_array[i,j,*]=0. - ;em_errtot = em_errtot + 0. - ENDELSE - ;print,em,error1,error2,error3,error4,error5,error6,error7,error8 - ;stop - ENDFOR -ENDFOR -emlog = alog10(em_tot) - - -;get sum of the squares FOR each element of em_errtot = fltarr(nte). This gives the final error in em_tot summed over all the pixels. -FOR j = 0,nte-1 DO em_errtot[j] = reform(sqrt(total(error_array[*,*,j]^2.))) - -;get error in em_log rather than em_tot -emlog_err = (em_errtot/em_tot) - -print,em_tot -print,emlog -print,em_errtot -print,emlog_err -stop -clearplot -IF keyword_set(PLOT) THEN BEGIN - plot,telog,emlog,yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - oploterr, telog, emlog, emlog_err -ENDIF - -;______________________TOTAL FLUX FROM DEM________________________ -flux_dem=fltarr(nwave) -qflux =fltarr(nwave) -FOR iw=0,nwave-1 do begin - flux_dem[iw]=total(resp_corr[*,iw] * em_tot*dte) * nmacro*npix^2 * mask_frac - qflux[iw] = flux_dem[iw]/flux_[iw] - print,flux_(iw),flux_dem(iw),qflux(iw) -ENDFOR - -;______________________SAVE RESULTS_______________________________ -save,filename=save_dir + teem_tot,telog,emlog,flux_,flux_dem,qflux, emlog_err, error_array, energy -;save,filename='teem_tot_test'+strtrim(string(u),2)+'.sav',telog,emlog,emlog_err,flux_,flux_dem,qflux - -END diff --git a/hannnah_aia.pro b/hannnah_aia.pro deleted file mode 100644 index f38ab42..0000000 --- a/hannnah_aia.pro +++ /dev/null @@ -1,87 +0,0 @@ -;; example of how to use the regularized inversion to get DEMs -;; i.e. how to use data2dem_reg.pro -;; -;; MODIFICATION HISTORY: -;; 18-11-2011 Created IGH - -; ; Get the sdo/aia temperature responses -; tresp=aia_get_response(/temperature,/dn) -; save, tresp,filename='aia_resp.dat' -restore,file='aia_resp.dat' - - -; ; order of filters to use -;; don't want 304 -;; order is A94 A131 A171 A193 A211 A304 A335 -filt=[0,1,2,3,4,6] -; print,tresp.channels[filt] - -restore, '~/Downloads/for_jim.sav', /verbose - -; ; data in dn/s/px -; ; the order should be the same as filt above -; ; these values are for a Guassian model DEM -;dn_in=[274.2, 166.9, 2842.9, 8496.3, 6941.9, 876.1] -dn_in=[tot94, tot131, tot171, tot193, tot211, tot335] - -; ; error in dn/s/px -; ; taken as the read + photon noise -;edn_in=[14.9, 10.9, 41.1, 65.3, 47.1, 14.1] -edn_in=[totnoise94, totnoise131, totnoise171, totnoise193, totnoise211, totnoise335] - -; ; Just the temperature response ordered by filters as dn -; ; default units of DN cm^5/ s/px -TRmatrix=tresp.all[*,filt] -; ; what is the logT binning of the temperature responses -logt=tresp.logte - -; ;order of regularization, default is 0th -order=0 -; ;control the regularization parameter/chisq of result in DEM space: reg_tweak=1 -reg_tweak=1 -; ;Use guess solution in final regularization? default is no, guess=0. -guess=0. - -; run the regularization -reg=data2dem_reg(logT, TRmatrix, dn_in, edn_in,$ - mint=5.7, maxt=7.3, nt=33, $ - order=order,reg_tweak=reg_tweak, guess=guess, $ - channels=tresp.channels[filt]) - -; now to plot the results.... -linecolors -!p.charsize=1.5 -; plot the regularized DEM and both vertical and horizontal errors -window,1,xsize=650,ysize=500,title='Regularized DEM' -!p.multi=0 -ploterr,reg.logt,reg.dem,reg.elogt,reg.edem,$ - /nohat,errcolor=9,yrange=max(reg.dem)*[1e-3,1.2],$ - xrange=minmax(reg.logt),xstyle=17,/ylog,$ - xtitle='log!D10!N T',ytitle='DEM(T) [cm!U-5!N K!U-1!N]' - -window,2,xsize=500,ysize=500,title='DN-space and Residuals' -!p.multi=[0,1,2] -nf=n_elements(reg.channels) -plot,indgen(nf),reg.data,/ylog,psym=6,$ - xrange=[-1,nf],xtickf='(a1)',xticks=nf+1,ystyle=16,thick=3,$ - ytit='DN s!U-1!N',xtit=' ',/nodata,$ - yrange=[0.9*min(reg.data),1.1*max(reg.data)] -oplot,indgen(nf),reg.data_reg,psym=6,color=5,thick=1 -oplot,indgen(nf),reg.data,psym=7,color=2,thick=2 -for i=0, nf-1 do oplot, [i,i],reg.data[i]+[-reg.edata[i],reg.edata[i]],thick=5,color=2 - -maxr=1.1*max(abs(reg.residuals)) -plot,indgen(nf),reg.residuals,xrange=[-1,nf],xtickn=[' ',reg.channels,' '],$ - xticks=nf+1,ystyle=17,thick=1,yrange=maxr*[-1,1],psym=6,$ - ytit='Residuals',xtit='Filter' -oplot,[-2,nf],[0,0],lines=1 -xyouts,-0.5,.75*maxr,'chisq='+string(reg.chisq,format='(f4.1)'),/data - -window,3,xsize=500,ysize=500,title='RK Matrix' -!p.multi=0 -loadct,8,/silent -gamma_ct,2. -rn=reg.rk -for i=0,n_elements(reg.logt)-1 do rn[i,*]=rn[i,*]/max(rn[i,*]) -image_tv,transpose(rn),reg.logt,reg.logt,ytitle='Temperature Bin' -oplot,[0,20],[0,20] diff --git a/ospex_script_27_apr_2012.pro b/ospex_script_27_apr_2012.pro deleted file mode 100644 index fcd86b4..0000000 --- a/ospex_script_27_apr_2012.pro +++ /dev/null @@ -1,45 +0,0 @@ -; OSPEX script created Fri Apr 27 16:42:22 2012 by OSPEX writescript method. -; -; Call this script with the keyword argument, obj=obj to return the -; OSPEX object reference for use at the command line as well as in the GUI. -; For example: -; ospex_script_27_apr_2012, obj=obj -; -; Note that this script simply sets parameters in the OSPEX object as they -; were when you wrote the script, and optionally restores fit results. -; To make OSPEX do anything in this script, you need to add some action commands. -; For instance, the command -; obj -> dofit, /all -; would tell OSPEX to do fits in all your fit time intervals. -; See the OSPEX methods section in the OSPEX documentation at -; http://hesperia.gsfc.nasa.gov/ssw/packages/spex/doc/ospex_explanation.htm -; for a complete list of methods and their arguments. -; -pro ospex_script_27_apr_2012, obj=obj -if not is_class(obj,'SPEX',/quiet) then obj = ospex() -obj-> set, $ - spex_specfile= '/Users/schriste/Desktop/flare_0_rhessi/hsi_spectrum_20110603_064600.fits' -obj-> set, $ - spex_drmfile= '/Users/schriste/Desktop/flare_0_rhessi/hsi_srm_20110603_064600.fits' -obj-> set, spex_source_angle= 22.2012 -obj-> set, spex_source_xy= [19.0353, -362.247] -obj-> set, spex_fit_time_interval= [' 3-Jun-2011 07:15:48.000', $ - ' 3-Jun-2011 07:16:56.000'] -obj-> set, spex_bk_time_interval=[' 3-Jun-2011 07:10:24.000', ' 3-Jun-2011 07:13:32.000'] -obj-> set, fit_function= 'vth+thick2' -obj-> set, fit_comp_params= [0.00100097, 0.965864, 1.00000, 0.488585, 6.03198, 100000., $ - 11.1289, 8.74125, 32000.0] -obj-> set, fit_comp_minima= [1.00000e-20, 0.500000, 0.0100000, 1.00000e-10, 1.10000, $ - 1.00000, 1.10000, 1.00000, 100.000] -obj-> set, fit_comp_maxima= [1.00000e+20, 8.00000, 10.0000, 1.00000e+10, 20.0000, 100000., $ - 20.0000, 1000.00, 1.00000e+07] -obj-> set, fit_comp_free_mask= [1B, 1B, 0B, 1B, 1B, 0B, 1B, 1B, 0B] -obj-> set, fit_comp_spectrum= ['full', ''] -obj-> set, fit_comp_model= ['chianti', ''] -obj-> set, spex_autoplot_units= 'Flux' -obj-> set, spex_eband= [[3.00000, 6.00000], [6.00000, 12.0000], [12.0000, 25.0000], $ - [25.0000, 50.0000], [50.0000, 100.000], [100.000, 300.000]] -obj-> set, spex_tband= [[' 3-Jun-2011 06:46:00.000', ' 3-Jun-2011 07:00:47.000'], $ - [' 3-Jun-2011 07:00:47.000', ' 3-Jun-2011 07:15:34.000'], [' 3-Jun-2011 07:15:34.000', $ - ' 3-Jun-2011 07:30:21.000'], [' 3-Jun-2011 07:30:21.000', ' 3-Jun-2011 07:45:08.000']] -end From fd11e49786f34c640107c8c917e283eb450e5d64 Mon Sep 17 00:00:00 2001 From: aringlis Date: Fri, 14 Dec 2012 11:36:45 -0500 Subject: [PATCH 08/44] deleted legacy file get_mask_script.pro. --- get_mask_script.pro | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 get_mask_script.pro diff --git a/get_mask_script.pro b/get_mask_script.pro deleted file mode 100755 index e168c86..0000000 --- a/get_mask_script.pro +++ /dev/null @@ -1,20 +0,0 @@ -PRO get_mask_script,mask_map,invmask_map - - fits2map, 'AIA20110621_182200_0171.fits', aiamap - fits2map, 'hsi_image_20110621_182202.fits', hsimap - ; interpolate the rhessi map to the aia map - - mask_map = inter_map(hsimap,aiamap) - mask_map = drot_map(mask_map, time = aiamap.time) - m = max(mask_map.data) - ; set the mask at everything above 50% contour - index = where(mask_map.data LE m*0.5, complement = complement) - mask_map.data[index] = 0 - mask_map.data[complement] = 1 - - ; now define the inverse mask - invmask_map = mask_map - invmask_map.data[index] = 1 - invmask_map.data[complement] = 0 - -END \ No newline at end of file From ae638f98e19ac9f64ee672d52c03a1ee40345761 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Fri, 14 Dec 2012 14:25:28 -0500 Subject: [PATCH 09/44] reworked get_combined_chisq.pro function. Now accepts either two chi-squared maps as the input or two scalar chi-squared values. Removed chi_combo.pro as functionality now incorporated into get_combined_chisq function. --- combo_chi.pro | 35 --------------------- get_combined_chisq.pro | 70 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 36 deletions(-) delete mode 100644 combo_chi.pro diff --git a/combo_chi.pro b/combo_chi.pro deleted file mode 100644 index 1a2be3d..0000000 --- a/combo_chi.pro +++ /dev/null @@ -1,35 +0,0 @@ -;NAME: -; COMBO_CHI -;PURPOSE: -; Utility function to combine AIA and RHESSI chi^2 maps. given a pair of 2D chi^2 maps, the minimum in the -; combined map will be found, and the reduced chi^2 of this minimum recalculated. -; -;INPUTS: -; chi1 - the AIA chi^2 map -; chi2 - the RHESSI chi^2 map. -;KEYWORDS: -; n_aia - number of AIA data points. Default is 6 -; n_hsi - number of RHESSI data points. Default is 21 -; nfree - number of free parameters. Default is 3 -;OUTPUT: -; returns the reduced chi^2 value of the combined map, and prints its array location. -;WRITTEN: -; Andrew Inglis, 2012/12/13 -; - -FUNCTION combo_chi,chi1,chi2,n_aia=n_aia,n_hsi=n_hsi,nfree=nfree - -chi_combo=chi1 + chi2 - -m=min(chi_combo,loc) -p=array_indices(chi_combo,loc) -print,'mininum in joint chi-squared located at: ',p - -print,'individual reduced chi-squared values are :',chi1[p[0],p[1]],chi2[p[0],p[1]] - -c=get_combined_chisq(chi1[p[0],p[1]],chi2[p[0],p[1]],n_aia=n_aia,n_hsi=n_hsi,nfree=nfree) -print,'combined reduced chi-squared value is :',c - -return,c;[chi1[p[0],p[1]],chi2[p[0],p[1]]] - -END diff --git a/get_combined_chisq.pro b/get_combined_chisq.pro index 56b0473..6d72535 100644 --- a/get_combined_chisq.pro +++ b/get_combined_chisq.pro @@ -1,16 +1,84 @@ -FUNCTION get_combined_chisq,chi_red_aia,chi_red_hsi,n_aia=n_aia,n_hsi=n_hsi,nfree=nfree +;NAME: +; GET_COMBINED_CHISQ +;PURPOSE: +; Utility function to combine reduced AIA and RHESSI chi^2 maps. given a pair of 2D chi^2 maps, the +; combined reduced chi-squared map will be found. The mimimum of the combined map is printed out. +; +;INPUTS: +; chi_red_aia - the AIA reduced chi^2 map (or a single AIA chi-squared value if /SINGLE is set) +; chi_red_hsi - the RHESSI reduced chi^2 map (or a single RHESSI chi-squared value if /SINGLE is set) +;KEYWORDS: +; n_aia - number of AIA data points. Default is 6 +; n_hsi - number of RHESSI data points. Default is 21 +; nfree - number of free parameters + 1. Default is 3 +; single - if set, the inputs chi_red_aia and chi_red_hsi are assumed to be single scalar values. +;OUTPUT: +; returns the combined reduced chi^2 map, and prints out its minimum and location. +;WRITTEN: +; Andrew Inglis, 2012/12/04 +; Andrew Inglis, 2012/12/14 - reworked function. Now accepts either two chi-squared maps as the input, or +; two chi-squared scalar values. The number of AIA and RHESSI points are now keywords +; as is the number of degrees of freedom. +; Added /SINGLE keyword to allow input of two scalar values. +; + + + +FUNCTION get_combined_chisq,chi_red_aia,chi_red_hsi,n_aia=n_aia,n_hsi=n_hsi,nfree=nfree,single=single default,n_aia,6 default,n_hsi,21 default,nfree,3 +IF (n_elements(chi_red_aia) eq 1) OR (n_elements(chi_red_hsi) eq 1) THEN BEGIN + print,' ' + print,'---------------------------------------------' + print,'Scalar inputs detected. Using /SINGLE keyword' + single=1 +ENDIF + +IF (n_elements(chi_red_aia) ne n_elements(chi_red_hsi)) THEN BEGIN + print,' ' + print,'---------------------------------------------' + print,'Mismatched input dimensions. Aborting.' + return,-1 +ENDIF + +print,'------------------------------------------' +print,'the following parameters were used:' +print,'N_AIA = ',n_aia +print,'N_HSI = ',n_hsi +print,'NFREE = ',nfree +print,'------------------------------------------' + + + +;First, reverse engineer the full chi-squared values by multiplying by (N - nfree) chi_full_aia=chi_red_aia*(n_aia-nfree) chi_full_hsi=chi_red_hsi*(n_hsi-nfree) +;combine the two full chi-squared maps chi_full_combo=chi_full_aia+chi_full_hsi +;find the reduced chi-squared for this new combined map. Divide by the TOTAL number of data points - nfree chi_red_combo=chi_full_combo/(n_aia + n_hsi - nfree) +;if just a single value then need to avoid an error. Otherwise, find the minimum value in the new chi-squared map. +IF keyword_set(single) THEN BEGIN + chi_red_best = chi_red_combo + p2=0 +ENDIF ELSE BEGIN + m2=min(chi_red_combo,loc2) + p2=array_indices(chi_red_combo,loc2) + chi_red_best = chi_red_combo[p2[0],p2[1]] +ENDELSE + + +print,'combined reduced chi-squared minimum value is :',chi_red_best +print,'located at: ',p2 +print,'Returning combined reduced chi-squared map.' + +;return the combined reduced chi-squared map or value. return, chi_red_combo From f7f78f994da8d1e93828853d136d8ef74957d94a Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 18 Dec 2012 14:12:29 -0500 Subject: [PATCH 10/44] modifications to get_combined_chisq.pro --- get_combined_chisq.pro | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/get_combined_chisq.pro b/get_combined_chisq.pro index 6d72535..6790005 100644 --- a/get_combined_chisq.pro +++ b/get_combined_chisq.pro @@ -73,9 +73,17 @@ ENDIF ELSE BEGIN chi_red_best = chi_red_combo[p2[0],p2[1]] ENDELSE +c_index=where(chi_red_combo lt 3.0) +print,'Combined chi-squared values < 3: ', chi_red_combo[c_index] +print,'Associated AIA chi-squareds: ', chi_red_aia[c_index] +print,'Associated HSI chi-squareds: ', chi_red_hsi[c_index] + print,'combined reduced chi-squared minimum value is :',chi_red_best print,'located at: ',p2 + +;IF (chi_red_aia[p2[0],p2[1]] lt 3.0) THEN print,'AIA criterion FULFILLED (X^2 < 3.0)' ELSE print,'AIA criterion FAILED (X^2 > 3.0)' + print,'Returning combined reduced chi-squared map.' ;return the combined reduced chi-squared map or value. From ca12849501094fc71d77c748690d89b21f55b848 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 18 Dec 2012 15:12:17 -0500 Subject: [PATCH 11/44] added all_events,pro, which holds important parameters for all events. --- all_events.pro | 66 ++++++++++++++++++++++++++++++++++++++++++ get_combined_chisq.pro | 5 +++- get_rhessi_chisq.pro | 8 ++--- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 all_events.pro diff --git a/all_events.pro b/all_events.pro new file mode 100644 index 0000000..1b16726 --- /dev/null +++ b/all_events.pro @@ -0,0 +1,66 @@ +PRO all_events,event,spec_file,drm_file,fit_time,bkg_time + +CASE event of +1: BEGIN + spec_file='hsi_spectrum_20110605_010128_d1.fits' + drm_file='hsi_srm_20110605_010128_d1.fits' + fit_time=['05-Jun-2011 02:13:30.000', '05-Jun-2011 02:14:30.000'] + bkg_time=['05-Jun-2011 02:02:00.000', '05-Jun-2011 02:06:00.000'] + END +2: BEGIN + spec_file = 'hsi_spectrum_20110606_120744_d1.fits' + drm_file = 'hsi_srm_20110606_120744_d1.fits' + fit_time = ['06-Jun-2011 13:19:00.000', '06-Jun-2011 13:20:00.000'] + bkg_time = ['06-Jun-2011 13:05:00.000', '06-Jun-2011 13:09:00.000'] + END +3: BEGIN + spec_file = 'hsi_spectrum_20110621_175120_d1.fits' + drm_file = 'hsi_srm_20110621_175120_d1.fits' + fit_time = ['21-Jun-2011 18:22:00.000', '21-Jun-2011 18:23:00.000'] + bkg_time = ['21-Jun-2011 18:36:00.000', '21-Jun-2011 18:39:00.000'] + END +4: BEGIN + spec_file = 'hsi_spectrum_20110716_161036_d1.fits' + drm_file = 'hsi_srm_20110716_161036_d1.fits' + fit_time = ['16-Jul-2011 17:02:00.000', '16-Jul-2011 17:03:00.000'] + bkg_time = ['16-Jul-2011 17:36:00.000', '16-Jul-2011 17:39:00.000'] + END +5: BEGIN + spec_file = 'hsi_spectrum_20110826_200140_d1.fits' + drm_file = 'hsi_srm_20110826_200140_d1.fits' + fit_time = ['26-Aug-2011 20:53:00.000', '26-Aug-2011 20:54:00.000'] + bkg_time = ['26-Aug-2011 20:34:00.000', '26-Aug-2011 20:38:00.000'] + END +6: BEGIN + spec_file = 'hsi_spectrum_20111010_232840_d1.fits' + drm_file = 'hsi_srm_20111010_232840_d1.fits' + fit_time = ['11-Oct-2011 00:35:00.000', '11-Oct-2011 00:36:00.000'] + bkg_time = ['11-Oct-2011 00:44:00.000', '11-Oct-2011 00:48:00.000'] + END +7: BEGIN + spec_file = 'hsi_spectrum_20120620_151020_d1.fits' + drm_file = 'hsi_srm_20120620_151020_d1.fits' + fit_time = ['20-Jun-2012 15:48:00.000', '20-Jun-2012 15:49:00.000'] + bkg_time = ['20-Jun-2012 15:33:00.000', '20-Jun-2012 15:37:00.000'] + END +8: BEGIN + spec_file = 'hsi_spectrum_20120910_063840_d1.fits' + drm_file = 'hsi_srm_20120910_063840_d1.fits' + fit_time = ['10-Sep-2012 07:22:00.000', '10-Sep-2012 07:23:00.000'] + bkg_time = ['10-Sep-2012 07:08:00.000', '10-Sep-2012 07:12:00.000'] + END +9: BEGIN + spec_file = 'hsi_spectrum_20110716_161036_d1.fits' + drm_file = 'hsi_srm_20110716_161036_d1.fits' + fit_time = ['16-Jul-2011 17:02:00.000', '16-Jul-2011 17:03:00.000'] + bkg_time = ['16-Jul-2011 17:36:00.000', '16-Jul-2011 17:39:00.000'] + END +10:BEGIN + spec_file = 'hsi_spectrum_20120927_053956_d1.fits' + drm_file = 'hsi_srm_20120927_053956_d1.fits' + fit_time = ['27-Sep-2012 06:56:00.000', '27-Sep-2012 06:57:00.000'] + bkg_time = ['27-Sep-2012 06:40:00.000', '27-Sep-2012 06:42:00.000'] + END +ENDCASE + +END diff --git a/get_combined_chisq.pro b/get_combined_chisq.pro index 6790005..8b4744b 100644 --- a/get_combined_chisq.pro +++ b/get_combined_chisq.pro @@ -74,10 +74,13 @@ ENDIF ELSE BEGIN ENDELSE c_index=where(chi_red_combo lt 3.0) +IF c_index ne -1 THEN BEGIN print,'Combined chi-squared values < 3: ', chi_red_combo[c_index] print,'Associated AIA chi-squareds: ', chi_red_aia[c_index] print,'Associated HSI chi-squareds: ', chi_red_hsi[c_index] - +ENDIF ELSE BEGIN +print,'No combined chi-squared values found < 3.0' +ENDELSE print,'combined reduced chi-squared minimum value is :',chi_red_best print,'located at: ',p2 diff --git a/get_rhessi_chisq.pro b/get_rhessi_chisq.pro index a2687c0..acd8a93 100644 --- a/get_rhessi_chisq.pro +++ b/get_rhessi_chisq.pro @@ -43,10 +43,10 @@ default,uncert,0.02 default,erange,[5,12] -spec_file='hsi_spectrum_20110826_200140_d1.fits' -drm_file='hsi_srm_20110826_200140_d1.fits' -fit_time=['26-Aug-2011 20:53:00.000', '26-Aug-2011 20:54:00.000'] -bkg_time=['26-Aug-2011 20:34:00.000', '26-Aug-2011 20:38:00.000'] +default,spec_file,'hsi_spectrum_20110826_200140_d1.fits' +default,drm_file,'hsi_srm_20110826_200140_d1.fits' +default,fit_time,['26-Aug-2011 20:53:00.000', '26-Aug-2011 20:54:00.000'] +default,bkg_time,['26-Aug-2011 20:34:00.000', '26-Aug-2011 20:38:00.000'] ;want to input the model flux from aia_hsi_fit_results.sav From 7d5020765cf7c71e2aa08126d46751300f619af6 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 8 Jan 2013 15:58:19 -0500 Subject: [PATCH 12/44] added averaging of AIA image sets within RHESSI fit time. Now use averaged flux to calculate AIA X^2 table. --- aia_hsi_dem_analysis.pro | 147 +++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 61 deletions(-) diff --git a/aia_hsi_dem_analysis.pro b/aia_hsi_dem_analysis.pro index ae64bad..943b45a 100644 --- a/aia_hsi_dem_analysis.pro +++ b/aia_hsi_dem_analysis.pro @@ -158,14 +158,20 @@ f = file_search(teem_table) file_list = get_aia_file_list(dir, fileset = fileset) FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) -;this is the time where we want to extract a set of 6 AIA images -aia_time=anytim(fit_time[0],/utime) +;this is the start time where we want to begin extracting sets of 6 AIA images +aia_start_time=anytim(fit_time[0],/utime) +;this is the end time where we want to stop extracting sets of 6 AIA images +aia_end_time=anytim(fit_time[1],/utime) -;find the closest time to AIA_TIME available from the AIA data files. MARKER stores the array index of this +;find the closest start time to AIA_TIME available from the AIA data files. MARKER stores the array index of this filetimes=anytim(aiafile_to_time(file_list[*,0], fileset=fileset),/utime) -marker=value_locate(filetimes,aia_time) +startmarker=value_locate(filetimes,aia_start_time) +endmarker=value_locate(filetimes,aia_end_time) -print,'AIA selected time is: ',anytim(filetimes(marker),/vms) +; + +print,'AIA selected start time is: ',anytim(filetimes(startmarker),/vms) +print,'AIA selected end time is: ',anytim(filetimes(endmarker),/vms) ;find the area of 1 AIA pixel in cm^2 aia_pixel_area = aia_teem_pixel_area(file_list[0,0]) @@ -190,7 +196,7 @@ IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telo ; if a hsi_image was given then create a mask out of it ;IF hsi_image[0] NE '' THEN BEGIN IF keyword_set(hsi_image) THEN BEGIN - fits2map, file_list[marker,0], aiamap + fits2map, file_list[startmarker,0], aiamap fits2map, hsi_image, hsimap ; interpolate the rhessi map to the aia map @@ -210,7 +216,7 @@ IF keyword_set(hsi_image) THEN BEGIN invmask_map.data[complement] = 0 ENDIF ELSE BEGIN ;if no RHESSI image, then by default entire AIA map is used - fits2map,file_list[marker,0], mask_map + fits2map,file_list[startmarker,0], mask_map mask_map.data[*] = 1 ENDELSE @@ -218,76 +224,94 @@ nwave = n_elements(wave_) flux_ = fltarr(nwave) texp_ = fltarr(nwave) -file_iw = reform(file_list[marker,*]) + ;file_bk_iw = reform(file_list(marker-100,*)) -;now we are ready to read the 6 AIA data files at the time of interest +;now we are ready to read the AIA data files at the time of interest ;--------------------------------------------------------------------- -FOR iw = 0, nwave-1 DO BEGIN + +;need to loop over the RHESSI fit interval and average the AIA image sets within that interval +flux_all=fltarr(nwave) +flux_all[*]=0. +FOR pp = startmarker,endmarker DO BEGIN + + file_iw = reform(file_list[pp,*]) + + FOR iw = 0, nwave-1 DO BEGIN - read_sdo,file_iw[iw],index,data -; read_sdo,file_bk_iw[iw],index_bk,data_bk + read_sdo,file_iw[iw],index,data +; read_sdo,file_bk_iw[iw],index_bk,data_bk - index2map,index,float(data),map -; index2map,index_bk,float(data_bk),map_bk + index2map,index,float(data),map +; index2map,index_bk,float(data_bk),map_bk - ;------------------------------------------------------------------------------------------ - ;sometimes image dimensions can vary slightly between EUV wavelengths. Perform a check here - mask_dim=size(mask_map.data) - image_dim=size(map.data) - - ;if mask dimensions don't match with the latest image then congrid the mask to compensate - IF (mask_dim[1] ne image_dim[1]) OR (mask_dim[2] ne image_dim[2]) THEN BEGIN - mask_map=rebin_map(mask_map,image_dim[1],image_dim[2]) - ;only want binary values in mask - for a=0,image_dim[1]-1 do begin - for b=0,image_dim[2]-1 do begin - IF (mask_map.data[a,b] gt 0.5) THEN mask_map.data[a,b] = 1.0 ELSE mask_map.data[a,b]=0.0 + ;------------------------------------------------------------------------------------------ + ;sometimes image dimensions can vary slightly between EUV wavelengths. Perform a check here + mask_dim=size(mask_map.data) + image_dim=size(map.data) + + ;if mask dimensions don't match with the latest image then congrid the mask to compensate + IF (mask_dim[1] ne image_dim[1]) OR (mask_dim[2] ne image_dim[2]) THEN BEGIN + mask_map=rebin_map(mask_map,image_dim[1],image_dim[2]) + ;only want binary values in mask + for a=0,image_dim[1]-1 do begin + for b=0,image_dim[2]-1 do begin + IF (mask_map.data[a,b] gt 0.5) THEN mask_map.data[a,b] = 1.0 ELSE mask_map.data[a,b]=0.0 + endfor endfor - endfor - ;print a warning message that a congrid was performed - print,' ' - print,'------------------------------------------------------------------------------------' - print,'Warning: image dimensions changed between wavelengths. Mask map had to be rebinned.' - print,'------------------------------------------------------------------------------------' - ENDIF + ;print a warning message that a congrid was performed + print,' ' + print,'------------------------------------------------------------------------------------' + print,'Warning: image dimensions changed between wavelengths. Mask map had to be rebinned.' + print,'------------------------------------------------------------------------------------' + ENDIF - ;------------------------------------------------------------------------------------------ + ;------------------------------------------------------------------------------------------ - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - map = smap - data = smap.data - ;also need to create a sub map for the mask - sub_map, mask_map, smask_map, xrange = xrange, yrange = yrange - mask_map = smask_map - ENDIF + IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN + sub_map, map, smap, xrange = xrange, yrange = yrange + map = smap + data = smap.data + ;also need to create a sub map for the mask + sub_map, mask_map, smask_map, xrange = xrange, yrange = yrange + mask_map = smask_map + ENDIF - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 + s = size(data) + i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - image = data - texp = map.dur - texp_[iw]=texp - dateobs = map.time + image = data + texp = map.dur + texp_[iw]=texp + dateobs = map.time - IF keyword_set(mask_map) then begin - mask = mask_map.data - ; zero out everything that is not in the mask - FOR k = 0, i2 DO BEGIN - FOR l = 0, j2 DO BEGIN - data[k,l] = data[k,l]*mask[k,l] -; data_bk[k,l] = data_bk[k,l] * mask[k,l] - ENDFOR - ENDFOR - ENDIF + IF keyword_set(mask_map) then begin + mask = mask_map.data + ; zero out everything that is not in the mask + FOR k = 0, i2 DO BEGIN + FOR l = 0, j2 DO BEGIN + data[k,l] = data[k,l]*mask[k,l] +; data_bk[k,l] = data_bk[k,l] * mask[k,l] + ENDFOR + ENDFOR + ENDIF - flux_[iw] = total(data[i1:i2,j1:j2])/texp; - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) - print,'Total flux in ', wave_(iw),flux_(iw) + flux_[iw] = total(data[i1:i2,j1:j2])/texp; - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) + print,'Total flux in ', wave_(iw),flux_(iw) + ENDFOR + +;add up all the fluxes in the RHESSI fit interval +flux_all=flux_all + flux_ + ENDFOR +;find the average AIA flux in each channel during the RHESSI fit interval +flux_ave=flux_all / ((endmarker - startmarker) + 1) + + + ;now work out the area of the region of interest by finding out how many '1' pixels are under the mask ;----------------------------------------------------------------------------------------------------- num_aia_pixels=total(mask_map.data) @@ -311,7 +335,8 @@ nfree=3 ;flux_obs = reform(images[i,j,*]) - flux_obs = flux_ / num_aia_pixels + ;flux_obs = flux_ / num_aia_pixels + flux_obs = flux_ave / num_aia_pixels counts = flux_obs*texp_ ;stop ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. From 25e38ce7086a05a0772c740c5a6e764d2fbfe76c Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 8 Jan 2013 16:00:19 -0500 Subject: [PATCH 13/44] corrected information for event #9 --- all_events.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/all_events.pro b/all_events.pro index 1b16726..4667870 100644 --- a/all_events.pro +++ b/all_events.pro @@ -50,10 +50,10 @@ CASE event of bkg_time = ['10-Sep-2012 07:08:00.000', '10-Sep-2012 07:12:00.000'] END 9: BEGIN - spec_file = 'hsi_spectrum_20110716_161036_d1.fits' - drm_file = 'hsi_srm_20110716_161036_d1.fits' - fit_time = ['16-Jul-2011 17:02:00.000', '16-Jul-2011 17:03:00.000'] - bkg_time = ['16-Jul-2011 17:36:00.000', '16-Jul-2011 17:39:00.000'] + spec_file = 'hsi_spectrum_20120915_212508_d1.fits' + drm_file = 'hsi_srm_20120915_212508_d1.fits' + fit_time = ['15-Sep-2012 22:44:00.000', '15-Sep-2012 22:45:00.000'] + bkg_time = ['15-Sep-2012 22:30:00.000', '15-Sep-2012 22:34:00.000'] END 10:BEGIN spec_file = 'hsi_spectrum_20120927_053956_d1.fits' From d1912eb573549f8b5f303c60e2dca30438ece651 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Wed, 9 Jan 2013 11:43:18 -0500 Subject: [PATCH 14/44] added RHESSI image files to list of event information for each microflare. --- all_events.pro | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/all_events.pro b/all_events.pro index 4667870..8814e56 100644 --- a/all_events.pro +++ b/all_events.pro @@ -1,61 +1,71 @@ -PRO all_events,event,spec_file,drm_file,fit_time,bkg_time +PRO all_events,event,image_file,spec_file,drm_file,fit_time,bkg_time CASE event of -1: BEGIN +1: BEGIN + image_file='hsi_image_20110605_021354.fits' spec_file='hsi_spectrum_20110605_010128_d1.fits' drm_file='hsi_srm_20110605_010128_d1.fits' fit_time=['05-Jun-2011 02:13:30.000', '05-Jun-2011 02:14:30.000'] bkg_time=['05-Jun-2011 02:02:00.000', '05-Jun-2011 02:06:00.000'] END 2: BEGIN + image_file='hsi_image_20110606_131900.fits' spec_file = 'hsi_spectrum_20110606_120744_d1.fits' drm_file = 'hsi_srm_20110606_120744_d1.fits' fit_time = ['06-Jun-2011 13:19:00.000', '06-Jun-2011 13:20:00.000'] bkg_time = ['06-Jun-2011 13:05:00.000', '06-Jun-2011 13:09:00.000'] END 3: BEGIN + image_file='hsi_image_20110621_182202.fits' spec_file = 'hsi_spectrum_20110621_175120_d1.fits' drm_file = 'hsi_srm_20110621_175120_d1.fits' fit_time = ['21-Jun-2011 18:22:00.000', '21-Jun-2011 18:23:00.000'] bkg_time = ['21-Jun-2011 18:36:00.000', '21-Jun-2011 18:39:00.000'] END 4: BEGIN + image_file='hsi_image_20110716_170350.fits' spec_file = 'hsi_spectrum_20110716_161036_d1.fits' drm_file = 'hsi_srm_20110716_161036_d1.fits' fit_time = ['16-Jul-2011 17:02:00.000', '16-Jul-2011 17:03:00.000'] bkg_time = ['16-Jul-2011 17:36:00.000', '16-Jul-2011 17:39:00.000'] END 5: BEGIN + image_file='hsi_image_20110826_205258.fits' spec_file = 'hsi_spectrum_20110826_200140_d1.fits' drm_file = 'hsi_srm_20110826_200140_d1.fits' fit_time = ['26-Aug-2011 20:53:00.000', '26-Aug-2011 20:54:00.000'] bkg_time = ['26-Aug-2011 20:34:00.000', '26-Aug-2011 20:38:00.000'] END 6: BEGIN + image_file='hsi_image_20111011_003506.fits' spec_file = 'hsi_spectrum_20111010_232840_d1.fits' drm_file = 'hsi_srm_20111010_232840_d1.fits' fit_time = ['11-Oct-2011 00:35:00.000', '11-Oct-2011 00:36:00.000'] bkg_time = ['11-Oct-2011 00:44:00.000', '11-Oct-2011 00:48:00.000'] END 7: BEGIN + image_file='hsi_image_20120620_154846.fits' spec_file = 'hsi_spectrum_20120620_151020_d1.fits' drm_file = 'hsi_srm_20120620_151020_d1.fits' fit_time = ['20-Jun-2012 15:48:00.000', '20-Jun-2012 15:49:00.000'] bkg_time = ['20-Jun-2012 15:33:00.000', '20-Jun-2012 15:37:00.000'] END 8: BEGIN + image_file = 'hsi_image_20120910_072102.fits' spec_file = 'hsi_spectrum_20120910_063840_d1.fits' drm_file = 'hsi_srm_20120910_063840_d1.fits' fit_time = ['10-Sep-2012 07:22:00.000', '10-Sep-2012 07:23:00.000'] bkg_time = ['10-Sep-2012 07:08:00.000', '10-Sep-2012 07:12:00.000'] END 9: BEGIN + image_file='hsi_image_20120915_224402.fits' spec_file = 'hsi_spectrum_20120915_212508_d1.fits' drm_file = 'hsi_srm_20120915_212508_d1.fits' fit_time = ['15-Sep-2012 22:44:00.000', '15-Sep-2012 22:45:00.000'] bkg_time = ['15-Sep-2012 22:30:00.000', '15-Sep-2012 22:34:00.000'] END 10:BEGIN + image_file='hsi_image_20120927_065710.fits' spec_file = 'hsi_spectrum_20120927_053956_d1.fits' drm_file = 'hsi_srm_20120927_053956_d1.fits' fit_time = ['27-Sep-2012 06:56:00.000', '27-Sep-2012 06:57:00.000'] From e9240990380c900d82f637591ee8bc3d6feef8c2 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Wed, 9 Jan 2013 13:43:11 -0500 Subject: [PATCH 15/44] added a new script to redo the AIA analysis with averaged flux data and RHESSI data in the 4-8 keV range only. --- redo_analysis.pro | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 redo_analysis.pro diff --git a/redo_analysis.pro b/redo_analysis.pro new file mode 100644 index 0000000..6c1aafd --- /dev/null +++ b/redo_analysis.pro @@ -0,0 +1,38 @@ +PRO redo_analysis,event + +;load the important information for the event in question +all_events,event,image_file,spec_file,drm_file,fit_time,bkg_time + + +;now redo the AIA analysis using averaged AIA data, for both the Gaussian and Epstein DEM functions +aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/aia_only + +aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/epstein,/aia_only,n=10 + +;set some parameters +erange=[4,8] +uncert=0.04 +epstein=0 +;analyse the Gaussian profile +restore,'aia_fit_results.sav',/verbose +a=aia_fit_results + +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert + +r=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) + + + + +;analyse the Epstein profile +epstein=1 +restore,'aia_fit_results_epstein.sav',/verbose +ae=aia_fit_results + +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert + +re=get_combined_chisq(ae.chi_2d,chisq_results,n_aia=6,n_hsi=12) + + + +END \ No newline at end of file From ce1ec04474edb71c079ec4a50cbd5329c4fd1291 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Wed, 9 Jan 2013 14:17:33 -0500 Subject: [PATCH 16/44] added EMFACTOR keyword to allow recalculation of chi-squared values using a different EM_0 value. --- get_rhessi_chisq.pro | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/get_rhessi_chisq.pro b/get_rhessi_chisq.pro index acd8a93..a784773 100644 --- a/get_rhessi_chisq.pro +++ b/get_rhessi_chisq.pro @@ -7,7 +7,7 @@ ;CATEGORY: ; SPECTRA, XRAYS, STATISTICS ;CALLING SEQUENCE: -; get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n +; get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor ; ;PREREQUISITES: ; An IDL save file called aia_hsi_fit_results_epstein.sav needs to exist in the local directory. @@ -24,10 +24,13 @@ ; FIT_TIME - the time over which the RHESSI fit was performed. ; BKG_TIME - the time denoting the chosen RHESSI background interval. ; UNCERT - the level of systematic uncertainty. Default is 0.02 (2%). +; EMFACTOR - if the value of EM_0 has changed, use this to modify the RHESSI model flux. The model flux will be multiplied by the value of EMFACTOR. +; Hence if the new value of EM_0 is half the original, EMFACTOR = 0.5 ;OUTPUTS: ; CHISQ_RESULTS - a 2D array containing the RHESSI reduced chi-squared for each iteration of the fit parameters. ;WRITTEN: ; Andrew Inglis - 2012/12/13 +; Andrew Inglis - 2013/01/09 - added EMFACTOR to allow recalculation of chi-squared with a different value of EM_0. ; ; @@ -35,7 +38,7 @@ -PRO get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert +PRO get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor default,epstein,1 default,n,10 @@ -63,8 +66,11 @@ ENDIF ELSE BEGIN ah=aia_hsi_fit_results ENDELSE -model_flux_array=ah.model_count_flux_hsi - +IF keyword_set(emfactor) THEN BEGIN + model_flux_array=ah.model_count_flux_hsi * emfactor +ENDIF ELSE BEGIN + model_flux_array=ah.model_count_flux_hsi +ENDELSE ;now need to get the object associated with the real data. Just do this once by calling get_hsi_table_entry (param values don't matter) and retrieving the info. From 259089e7d0afff4f16a184a01f9e36337a694469 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Wed, 9 Jan 2013 14:36:05 -0500 Subject: [PATCH 17/44] added use of EMFACTOR keyword when calling get_rhessi_chisq.pro. --- redo_analysis.pro | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/redo_analysis.pro b/redo_analysis.pro index 6c1aafd..193c6d1 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -9,6 +9,14 @@ aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/epstein,/aia_only,n=10 +;DO GAUSSIAN RECALCULATIONS +;-------------------------------------------------------------------------------------- + +;for reference +restore,'aia_hsi_fit_results.sav' +ah=aia_hsi_fit_results + + ;set some parameters erange=[4,8] uncert=0.04 @@ -17,21 +25,31 @@ epstein=0 restore,'aia_fit_results.sav',/verbose a=aia_fit_results -get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert +;find the ratio of EM_0 (new) / EM_0 (old) - use this to modify RHESSI model fluxes. +emfactor=a.em_2d[0,0]/ah.em_2d[0,0] -r=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor +r=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +;DO EPSTEIN RECALCULATIONS +;-------------------------------------------------------------------------------------- +;for reference +restore,'aia_hsi_fit_results_epstein.sav' +ah=aia_hsi_fit_results ;analyse the Epstein profile epstein=1 restore,'aia_fit_results_epstein.sav',/verbose -ae=aia_fit_results +a=aia_fit_results + +;find the ratio of EM_0 (new) / EM_0 (old) - use this to modify RHESSI model fluxes. +emfactor=a.em_2d[0,0]/ah.em_2d[0,0] -get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor -re=get_combined_chisq(ae.chi_2d,chisq_results,n_aia=6,n_hsi=12) +re=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) From f4e9ee5199f50282a5da95a60627cfcdc80c462a Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 10 Jan 2013 10:43:20 -0500 Subject: [PATCH 18/44] added routine to replot combined DEM figure. --- replot_combo_dem.pro | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 replot_combo_dem.pro diff --git a/replot_combo_dem.pro b/replot_combo_dem.pro new file mode 100644 index 0000000..fb1f55b --- /dev/null +++ b/replot_combo_dem.pro @@ -0,0 +1,98 @@ +PRO replot_combo_dem,n=n,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results + +IF keyword_set(epstein) THEN BEGIN + restore,'aia_hsi_fit_results_epstein.sav',/verbose + ah=aia_hsi_fit_results +ENDIF ELSE BEGIN + restore,'aia_hsi_fit_results.sav',/verbose + ah=aia_hsi_fit_results +ENDELSE + +IF keyword_set(epstein) THEN BEGIN + restore,'aia_fit_results_epstein.sav',/verbose + a=aia_fit_results +ENDIF ELSE BEGIN + restore,'aia_fit_results.sav',/verbose + a=aia_fit_results +ENDELSE + +telog=ah.telog +tsig=ah.tsig + +m=min(chisq_results,loc) +loc=array_indices(chisq_results,loc) +hsi_telog=telog[loc[0]] +hsi_tsig=tsig[loc[1]] + +hsi_emconvert=a.em_2d[loc[0],loc[1]] +;hsi_emconvert=hsi_emconvert*1d24 +;hsi_emconvert=hsi_emconvert*1d25 +;hsi_emconvert=hsi_emconvert/(ah.flare_area * 11.6e6) +;hsi_emconvert=hsi_emconvert*emfactor +;chi_combo=a.chi_2d+a.chi2d_hsi + + +;combo_min=MIN(chi_combo,pos) +;pos=array_indices(chi_combo,pos) +pos=combobest + +telog_best_combo=telog(pos[0]) +tsig_best_combo=tsig(pos[1]) +em_best_combo=a.em_2d[pos[0],pos[1]] + + +;plot the dems +aia_dem=get_dem_from_params(telog,[(10^(a.em_best)),a.telog_best,a.sig_best],n=n,epstein=epstein) + +hsi_dem=get_dem_from_params(telog,[hsi_emconvert,hsi_telog,hsi_tsig],n=n,epstein=epstein) + +combo_dem=get_dem_from_params(telog,[(em_best_combo),telog_best_combo,tsig_best_combo],n=n,epstein=epstein) + +;window,1,xsize=756 +set_plot,'ps' +device,encaps=1,color=1 +IF keyword_set(epstein) THEN BEGIN + device,filename='replot_combo_dem_epstein.ps' +ENDIF ELSE BEGIN + device,filename='replot_combo_dem.ps' +ENDELSE + +loadct,39 +plot,telog,alog10(aia_dem),thick=3,xthick=3,ythick=3,charthick=3,charsize=1.5,linestyle=0,yrange=[18,23],ytitle='log EM (cm!U-5!N K!U-1!N)',xtitle = 'log T (K)',/nodata +oplot,telog,alog10(aia_dem),thick=3,color=240 +oplot,telog,alog10(hsi_dem),thick=3,linestyle=2 + +oplot,telog,alog10(combo_dem),thick=3,linestyle=0,color=50 + +ssw_legend,['AIA','HSI','AIA and HSI'],linestyle=[0,2,0],thick=[3,3,3],color=[240,0,50],/right,charsize=1.2,charthick=3 +device,/close +;set_plot,'x' + +;device,color=1,bits_per_pixel=16 +;IF keyword_set(epstein) THEN BEGIN +; device,filename='replot_combo_chi_surface_epstein.ps' +;ENDIF ELSE BEGIN +; device,filename='replot_combo_chi_surface.ps' +;ENDELSE + +;loadct,3 +;shade_surf,chi_combo,telog,tsig,charsize=2,/zlog,ax=40,az=70,yrange=[0,0.5],xtitle='log T (K)',ytitle='sigma',ztitle='chi_combo' + +;device,/close +;set_plot,'x' +;device,color=1,bits_per_pixel=16 +;IF keyword_set(epstein) THEN BEGIN +; device,filename='replot_combo_chi_contour_epstein.ps' +;ENDIF ELSE BEGIN +; device,filename='replot_combo_chi_contour.ps' +;ENDELSE +;window,1 +;loadct,0 + +;nlevels = 200 +;levels = a.chimin_hsi * (findgen(nlevels) + 1.0) +;contour,chi_combo,telog,tsig,charsize=2,levels=levels,thick=2,yrange=[0,0.5],xthick=3,ythick=3,charthick=3 + +;device,/close +;set_plot,'x' +END From a7668d769bb730a413f2670b4b4b5f5c1e24c1e2 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 10 Jan 2013 10:45:17 -0500 Subject: [PATCH 19/44] added routines to replot the AIA flux ratio figure and the RHESSI count spectrum figure. --- replot_aia_flux_ratios.pro | 128 +++++++++++++++++++++++++ replot_hsi_count_spectrum_from_dem.pro | 90 +++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 replot_aia_flux_ratios.pro create mode 100644 replot_hsi_count_spectrum_from_dem.pro diff --git a/replot_aia_flux_ratios.pro b/replot_aia_flux_ratios.pro new file mode 100644 index 0000000..87a3055 --- /dev/null +++ b/replot_aia_flux_ratios.pro @@ -0,0 +1,128 @@ +PRO replot_aia_flux_ratios, epstein=epstein, OUTPS = outps, combobest=combobest + +;plots modelled vs observed AIA flux for a given model DEM. + + +;restore,'aia_fit_results_manual.sav',/verbose +;a_man=aia_fit_results + +;set_plot,'ps' +;device,encaps=1,filename='aia_flux_ratios_for_hsi_best.ps' + +;plot,findgen(6)+1,a_man.flux_dem_3d[15,18,*]/a_man.flux_obs,psym=4,symsize=2,charsize=1.2,xrange=[0,7],xticks=7, $ +;xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle='flux_model/flux_obs',yran=[-0.2,2.5] + +;oploterr,findgen(6)+1,a_man.flux_dem_3d[15,18,*]/a_man.flux_obs,findgen(6)*0 + 0.2,psym=4,symsize=2 + +;oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=2 +;leg = num2str(a_man.chimin) + '[' + num2str(22.04) +',' + num2str(6.75) + ',' + num2str(0.1) + ']' + +;leg = num2str(a_man.chimin) + '[' + num2str(6.75) + ',' + num2str(0.1) + ']' +;legend, leg, psym = 4,charsize=1.2 + +;device,/close +;set_plot,'x' + + + +IF keyword_set(epstein) THEN BEGIN +restore,'aia_fit_results_epstein.sav' +a=aia_fit_results +fname='replot_aia_flux_ratios_for_aia_best_epstein.ps' +ENDIF ELSE BEGIN +restore,'aia_fit_results.sav' +a=aia_fit_results +fname='replot_aia_flux_ratios_for_aia_best.ps' +ENDELSE + +tt=value_locate(a.telog,a.telog_best) +ss=value_locate(a.tsig,a.sig_best) + +IF keyword_set(OUTPS) THEN BEGIN + set_plot,'ps' + device,encaps=1,filename=fname +ENDIF + +!P.MULTI = [0,1,2] +!y.margin=[2,1] +hsi_linecolors +plot,findgen(6)+1,a.flux_dem_best,charsize=1.2,xrange = [0,7],xticks=7, $ +xtickname=[' ','131A','171A','193A','211A','335A','94A',' '], ytitle='AIA DN Numbers', /nodata,xthick=3,ythick=3,thick=3,charthick=3 + +oploterr,findgen(6)+1,a.flux_obs,a.flux_obs*0.2, psym = symcat(14),symsize=2, /nohat,thick=3 +oplot, findgen(6)+1, a.flux_dem_best, psym = 7, symsize = 1,thick=3 + +ssw_legend, ['AIA observed', 'FIT'], psym = [symcat(14), 7], charsize = 1.0,charthick=3,thick=3 + +plot,findgen(6)+1,a.flux_dem_best/a.flux_obs,psym=4,symsize=2,charsize=1.2,xrange=[0,7],xticks=7, $ +xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle='flux_model/flux_obs',yran=[0.0,2.5],thick=3,xthick=3,ythick=3,charthick=3 + +oploterr,findgen(6)+1,a.flux_dem_3d[tt,ss,*]/a.flux_obs,findgen(6)*0 + 0.2,psym=symcat(14),symsize=2,thick=3 +oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3 + +leg = textoidl('\chi^2 = ') + num2str(a.chimin, length = 5) + ' [log(EM) = ' + num2str(a.em_best, length = 5) + ' cm!U-5!N, log(Tmax) = ' + num2str(a.telog_best, length = 5) + ' (' + num2str(10d^a.telog_best/1d6, length=5) + ' MK), sigma = ' + num2str(a.sig_best) + ']' +ssw_legend, leg, psym = symcat(14),charsize=0.75,charthick=3 +!P.MULTI = 0 +!y.margin=[4,2] +IF keyword_set(OUTPS) THEN BEGIN + device,/close + set_plot,'x' +;ENDIF + +print,' ' +print,'------------------------------' +print,'Wrote file: ',fname +print,'------------------------------' +print,' ' + +ENDIF +;f = file_search('aia_hsi_fit_results*') + +;IF f[0] NE '' THEN BEGIN + IF keyword_set(epstein) THEN BEGIN +; restore,'aia_hsi_fit_results_epstein.sav' +; ah=aia_hsi_fit_results + fname='replot_aia_flux_ratios_for_best_combo_epstein.ps' + ENDIF ELSE BEGIN +; restore,'aia_hsi_fit_results.sav' +; ah=aia_hsi_fit_results + fname='replot_aia_flux_ratios_for_best_combo.ps' + ENDELSE + + ;chi_combo=ah.chi_2d+ah.chi2d_hsi + ;m= min(chi_combo,pos) + ;pos=array_indices(chi_combo,pos) + pos=combobest + chi_label=a.chi_2d[pos[0],pos[1]] + IF keyword_set(OUTPS) THEN BEGIN + set_plot,'ps' + device,encaps=1,color=1,filename=fname + ENDIF + loadct,39 + plot,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,psym=4,symsize=2,charsize=1.5,xrange=[0,7],xticks=7, $ + xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle=textoidl('flux_{model}/flux_{obs}'),yran=[0.0,2.5], charthick=2,thick=2,xthick=2,ythick=2 + + oploterr,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,findgen(6)*0 + 0.2,psym=4,symsize=2,thick=2 + oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3,color=240 + + leg = [(textoidl('\chi^2_{aia} = ' + num2str(chi_label,length=4))), ('EM = '+ num2str(alog10(a.em_2d[pos[0],pos[1]]),length=4) $ + +', log T = '+num2str(a.telog[pos[0]],length=4) + ', ' + textoidl('\sigma') + ' = ' + num2str(a.tsig[pos[1]],length=4))]; + '[' + num2str(alog10(ah.em_2d[pos[0],pos[1]])) +',' + num2str(ah.telog[pos[0]]) + ',' + num2str(ah.tsig[pos[1]]) + ']' + legend, leg,charsize=1.2,/top,/left,thick=2,charthick=2 + + IF keyword_set(OUTPS) THEN BEGIN + device,/close + set_plot,'x' + ;ENDIF + + print,' ' + print,'------------------------------' + print,'Wrote file: ',fname + print,'------------------------------' + print,' ' + + ENDIF + +;ENDIF + + +END diff --git a/replot_hsi_count_spectrum_from_dem.pro b/replot_hsi_count_spectrum_from_dem.pro new file mode 100644 index 0000000..3bdadca --- /dev/null +++ b/replot_hsi_count_spectrum_from_dem.pro @@ -0,0 +1,90 @@ +PRO replot_hsi_count_spectrum_from_dem,epstein=epstein,ps=ps,type=type,chisq_results=chisq_results,combobest=combobest,emfactor=emfactor + +default,type,'combo' + + +IF keyword_set(epstein) THEN BEGIN + restore,'aia_hsi_fit_results_epstein.sav',/verbose +ENDIF ELSE BEGIN + restore,'aia_hsi_fit_results.sav',/verbose +ENDELSE + +a=aia_hsi_fit_results + + +IF keyword_set(epstein) THEN BEGIN + restore,'aia_fit_results_epstein.sav',/verbose +ENDIF ELSE BEGIN + restore,'aia_fit_results.sav',/verbose +ENDELSE + +;find the best-fit AIA parameters and assign the model spectrum +f=aia_fit_results +tloc=value_locate(f.telog,f.telog_best) +sigloc=value_locate(f.tsig,f.sig_best) + +aia_spec=a.model_count_flux_hsi[tloc,sigloc,*]*emfactor + +;find the best-fit combo parameters and assign the model spectrum +pos=[combobest[0],combobest[1]] +;chi_combo=a.chi_2d + a.chi2d_hsi +;m=min(chi_combo,pos) +;pos=array_indices(chi_combo,pos) +combo_spec=a.model_count_flux_hsi[pos[0],pos[1],*]*emfactor + +;find the best-fit RHESSI parameters and assign the model spectrum +m=min(chisq_results,hsipos) +hsipos=array_indices(chisq_results,hsipos) +hsi_spec=a.model_count_flux_hsi[hsipos[0],hsipos[1],*] * emfactor + +;xticks=[' ',' ','5',' ',' ',' ',' ','10'] + +IF (type eq 'hsi') THEN BEGIN + model=hsi_spec + yrange=[0.01,max(model) + 1] + chi_label=min(chisq_results) +ENDIF ELSE IF (type eq 'aia') THEN BEGIN + model=aia_spec + yrange=[0.01,max(model) + 1] + chi_label=chisq_results[tloc,sigloc] +ENDIF ELSE IF (type eq 'combo') THEN BEGIN + model=combo_spec + yrange=[0.01,max(model) + 1] + chi_label=chisq_results[pos[0],pos[1]] +ENDIF ELSE BEGIN + print,' ' + print,'-----------------' + print,'Unknown value of TYPE keyword. Aborting.' + return +ENDELSE + +IF keyword_set(ps) THEN BEGIN + set_plot,'ps' + IF keyword_set(epstein) THEN BEGIN + device,encaps=1,color=1,filename='replot_rhessi_count_spectrum_vs_model_'+type+'_epstein.ps' + ENDIF ELSE BEGIN + device,encaps=1,color=1,filename='replot_rhessi_count_spectrum_vs_model_'+type+'.ps' + ENDELSE +ENDIF + +loadct,39 + +plot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],/xlog,/ylog,thick=3,xthick=3,ythick=3,xrange=[3,12],yrange=yrange,linestyle=3,charsize=1.5, $ +xtitle='energy (keV)',ytitle='counts s!U-1!N cm!U-2!N kev!U-1!N',xstyle=1,ystyle=1,charthick=3,/nodata +oplot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],thick=3,color=50,linestyle=3 +oplot,a.axis[0,*],model,thick=3,color=240 + +;show the fitting range on the plot +oplot,(findgen(10000)*0. + 4),(findgen(10000)*0.01),linestyle=1,thick=2 +oplot,(findgen(10000)*0. + 8),(findgen(10000)*0.01),linestyle=1,thick=2 + +xyouts,0.75,0.8,textoidl('\chi^2_{hsi} = ' + num2str(chi_label,length=4)),/norm,charsize=1.5 +ssw_legend,['RHESSI count flux','Model count flux'],linestyle=[3,0],color=[50,240],thick=[3,3],/bottom,/left,charsize=1.2,charthick=3 + + +IF keyword_set(ps) THEN BEGIN + device,/close + set_plot,'x' +ENDIF + +END From 83e4d02676f7d1c2b6842aa94e0987094e80ca3a Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 10 Jan 2013 11:57:49 -0500 Subject: [PATCH 20/44] bug fixes for redo_analysis.pro --- redo_analysis.pro | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/redo_analysis.pro b/redo_analysis.pro index 193c6d1..1aefac4 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -32,6 +32,14 @@ get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_fi r=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +read,tmp1,prompt='Input first index for best combined fit:' +read,tmp2,prompt='Input second index for best combined fit:' +combobest=[tmp1,tmp2] + +replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps +replot_aia_flux_ratios,combobest=combobest,/outps +replot_combo_dem,n=1,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results + ;DO EPSTEIN RECALCULATIONS ;-------------------------------------------------------------------------------------- @@ -51,6 +59,27 @@ get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_fi re=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +read,tmp1,prompt='Input first index for best combined fit:' +read,tmp2,prompt='Input second index for best combined fit:' +combobest=[tmp1,tmp2] + +replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps +replot_aia_flux_ratios,/epstein,combobest=combobest,/outps +replot_combo_dem,n=10,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results + + +;DO SOME PLOTTING +;--------------------------------------------------------------------------------------- +;c=min(re,loc) +;combobest=array_indices(re,loc) + +;replot,hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor +;replot_aia_flux_ratios,/epstein,combobest=[12,45],/outps +;c=min(r,loc) +;combobest=array_indices(r,loc) +;epstein=0 +;replot,hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor +;replot_aia_flux_ratios,combobest=[12,45],/outps END \ No newline at end of file From 08a7ef752a6992fa6785d08b22f2263b9b8a394a Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 11:13:11 -0500 Subject: [PATCH 21/44] added utility to check for saturation in AIA images by counting the number of pixels where DN > 16,000. --- test_saturation.pro | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test_saturation.pro diff --git a/test_saturation.pro b/test_saturation.pro new file mode 100644 index 0000000..1950b21 --- /dev/null +++ b/test_saturation.pro @@ -0,0 +1,37 @@ +PRO test_saturation,filename,sat_num,tot_num,xrange=xrange,yrange=yrange + + +read_sdo,filename,index,data + + +IF keyword_set(xrange) OR keyword_set(yrange) THEN BEGIN + index2map,index,data,map + sub_map,map,smap,xrange=xrange,yrange=yrange + data=smap.data +ENDIF + +e=size(data) + +i1=e[1] +j1=e[2] + +saturation_array=fltarr(i1,j1) +saturation_array[*,*]=0 + +for i=0,i1-1 do begin + for j=0,j1-1 do begin + if (data[i,j] gt 16000.) THEN saturation_array[i,j]=1 + endfor +endfor + +tot_num=e[4] +sat_num=total(saturation_array) + +sat_percent=(sat_num/tot_num) * 100. +print,' ' +print,'number of saturated pixels in image is: ',sat_num +print,'total number of pixels in image is: ',tot_num +print,'percentage of saturated pixels in image is: ',sat_percent +print,' ' + +END \ No newline at end of file From e7ae1667f02cd4e3d692926e9a9287188e51be13 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 12:18:21 -0500 Subject: [PATCH 22/44] changed test_saturation.pro to accept a file list instead of a single file. Also added HSI_IMAGE keyword to test only the region under a RHESSI contour. --- test_saturation.pro | 90 +++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/test_saturation.pro b/test_saturation.pro index 1950b21..fa2aec6 100644 --- a/test_saturation.pro +++ b/test_saturation.pro @@ -1,37 +1,79 @@ -PRO test_saturation,filename,sat_num,tot_num,xrange=xrange,yrange=yrange +PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,xrange=xrange,yrange=yrange,hsi_image=hsi_image +length=n_elements(filenames) +sat_nums=fltarr(length) +tot_nums=fltarr(length) +sat_percents=fltarr(length) +t=fltarr(length) -read_sdo,filename,index,data +FOR n=0,length-1 do begin - -IF keyword_set(xrange) OR keyword_set(yrange) THEN BEGIN + read_sdo,filenames[n],index,data index2map,index,data,map - sub_map,map,smap,xrange=xrange,yrange=yrange - data=smap.data -ENDIF -e=size(data) + IF keyword_set(xrange) OR keyword_set(yrange) THEN BEGIN + sub_map,map,smap,xrange=xrange,yrange=yrange + data=smap.data + ENDIF + + IF keyword_set(hsi_image) THEN BEGIN + IF keyword_set(xrange) OR keyword_set(yrange) THEN BEGIN + aiamap=smap + ENDIF ELSE BEGIN + aiamap=map + ENDELSE + fits2map, hsi_image, hsimap + ; interpolate the rhessi map to the aia map + + mask_map = inter_map(hsimap,aiamap) + ;need to check if the source is on the disk, if so run drot, if not + ;do not! + ;mask_map = drot_map(mask_map, time = aiamap.time) + m = max(mask_map.data, mindex) + ; set the mask at everything above 50% contour + ind = where(mask_map.data LE m*0.5, complement = complement) + mask_map.data[ind] = 0 + mask_map.data[complement] = 1 + + ENDIF ELSE BEGIN + ;if no RHESSI image, then by default entire AIA map is used + IF keyword_set(xrange) OR keyword_set(yrange) THEN BEGIN + mask_map = smap + ENDIF ELSE BEGIN + mask_map = map + ENDELSE + mask_map.data[*] = 1 + ENDELSE + + e=size(data) -i1=e[1] -j1=e[2] + i1=e[1] + j1=e[2] -saturation_array=fltarr(i1,j1) -saturation_array[*,*]=0 + saturation_array=fltarr(i1,j1) + saturation_array[*,*]=0 -for i=0,i1-1 do begin - for j=0,j1-1 do begin - if (data[i,j] gt 16000.) THEN saturation_array[i,j]=1 + for i=0,i1-1 do begin + for j=0,j1-1 do begin + if (data[i,j] gt 16000.) THEN saturation_array[i,j]=1 + endfor endfor -endfor -tot_num=e[4] -sat_num=total(saturation_array) + tot_num=total(mask_map.data) + sat_num=total(saturation_array) + + sat_percent=(sat_num/tot_num) * 100. + print,' ' + print,'number of saturated pixels in image is: ',sat_num + print,'total number of pixels in image is: ',tot_num + print,'percentage of saturated pixels in image is: ',sat_percent + print,' ' + + sat_nums[n]=sat_num + tot_nums[n]=tot_num + sat_percents[n]=sat_percent + t[n]=anytim(index.date_obs) -sat_percent=(sat_num/tot_num) * 100. -print,' ' -print,'number of saturated pixels in image is: ',sat_num -print,'total number of pixels in image is: ',tot_num -print,'percentage of saturated pixels in image is: ',sat_percent -print,' ' +ENDFOR END \ No newline at end of file From f43ebad4d69b9371c09c4648a2d09f3574ea6219 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 13:59:05 -0500 Subject: [PATCH 23/44] added /QUIET keyword to test_saturation.pro --- test_saturation.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test_saturation.pro b/test_saturation.pro index fa2aec6..86d3b05 100644 --- a/test_saturation.pro +++ b/test_saturation.pro @@ -1,4 +1,4 @@ -PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,xrange=xrange,yrange=yrange,hsi_image=hsi_image +PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,xrange=xrange,yrange=yrange,hsi_image=hsi_image,quiet=quiet length=n_elements(filenames) sat_nums=fltarr(length) @@ -63,12 +63,14 @@ FOR n=0,length-1 do begin sat_num=total(saturation_array) sat_percent=(sat_num/tot_num) * 100. + IF NOT keyword_set(quiet) THEN BEGIN print,' ' print,'number of saturated pixels in image is: ',sat_num print,'total number of pixels in image is: ',tot_num print,'percentage of saturated pixels in image is: ',sat_percent print,' ' - + ENDIF + sat_nums[n]=sat_num tot_nums[n]=tot_num sat_percents[n]=sat_percent From c873304f24d390b076332ebc3e87bcd7801de8f4 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 13:59:29 -0500 Subject: [PATCH 24/44] added a wrapper to perform test_saturation.pro many times --- saturation_wrapper.pro | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 saturation_wrapper.pro diff --git a/saturation_wrapper.pro b/saturation_wrapper.pro new file mode 100644 index 0000000..a69f2b4 --- /dev/null +++ b/saturation_wrapper.pro @@ -0,0 +1,37 @@ +PRO saturation_wrapper,hsi_image + +spawn,'\ls *_0094.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0094 = max(sat_percents) + +spawn,'\ls *_0131.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0131 = max(sat_percents) + +spawn,'\ls *_0171.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0171 = max(sat_percents) + +spawn,'\ls *_0193.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0193 = max(sat_percents) + +spawn,'\ls *_0211.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0211 = max(sat_percents) + +spawn,'\ls *_0335.fits',files +test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet +sat_per_max_0335 = max(sat_percents) + +print,'Worst saturation percentage for each wavelength:' +print,'--------------------------------------------------' +print,'94A : ',sat_per_max_0094 +print,'131A: ',sat_per_max_0131 +print,'171A: ',sat_per_max_0171 +print,'193A: ',sat_per_max_0193 +print,'211A: ',sat_per_max_0211 +print,'335A: ',sat_per_max_0335 + + +END \ No newline at end of file From 27a7f6b54eec79230c13f3d59bcc6c92018e70fc Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 14:46:14 -0500 Subject: [PATCH 25/44] minor modifications to saturation test routines. --- saturation_wrapper.pro | 48 +++++++++++++++++++++++++----------------- test_saturation.pro | 2 +- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/saturation_wrapper.pro b/saturation_wrapper.pro index a69f2b4..439a6bf 100644 --- a/saturation_wrapper.pro +++ b/saturation_wrapper.pro @@ -1,37 +1,47 @@ PRO saturation_wrapper,hsi_image spawn,'\ls *_0094.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0094 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0094 = max(sat_percents,in) +t_max_0094=t[in] spawn,'\ls *_0131.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0131 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0131 = max(sat_percents,in) +t_max_0131=t[in] spawn,'\ls *_0171.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0171 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0171 = max(sat_percents,in) +t_max_0171=t[in] spawn,'\ls *_0193.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0193 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0193 = max(sat_percents,in) +t_max_0193=t[in] spawn,'\ls *_0211.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0211 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0211 = max(sat_percents,in) +t_max_0211=t[in] spawn,'\ls *_0335.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,hsi_image=hsi_image,/quiet -sat_per_max_0335 = max(sat_percents) +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +sat_per_max_0335 = max(sat_percents,in) +t_max_0335=t[in] print,'Worst saturation percentage for each wavelength:' print,'--------------------------------------------------' -print,'94A : ',sat_per_max_0094 -print,'131A: ',sat_per_max_0131 -print,'171A: ',sat_per_max_0171 -print,'193A: ',sat_per_max_0193 -print,'211A: ',sat_per_max_0211 -print,'335A: ',sat_per_max_0335 - +print,'94A : ',sat_per_max_0094,' located at: ',anytim(t_max_0094) +print,'131A: ',sat_per_max_0131,' located at: ',anytim(t_max_0131) +print,'171A: ',sat_per_max_0171,' located at: ',anytim(t_max_0171) +print,'193A: ',sat_per_max_0193,' located at: ',anytim(t_max_0193) +print,'211A: ',sat_per_max_0211,' located at: ',anytim(t_max_0211) +print,'335A: ',sat_per_max_0335,' located at: ',anytim(t_max_0335) + +SAVE,sat_per_max_0094,sat_per_max_0131,sat_per_max_0171,sat_per_max_0193,sat_per_max_0211,sat_per_max_0335, $ +t_max_0094,t_max_0131,t_max_0171,t_max_0193,t_max_0211,t_max_0335,filename='saturation_results.sav' +print,' ' +print,'Saved results in file: saturation_results.sav' END \ No newline at end of file diff --git a/test_saturation.pro b/test_saturation.pro index 86d3b05..e7ae9cc 100644 --- a/test_saturation.pro +++ b/test_saturation.pro @@ -1,4 +1,4 @@ -PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,xrange=xrange,yrange=yrange,hsi_image=hsi_image,quiet=quiet +PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,t,xrange=xrange,yrange=yrange,hsi_image=hsi_image,quiet=quiet length=n_elements(filenames) sat_nums=fltarr(length) From 9091b592c32d3437d3dd712c1422e968a82a283c Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 14:49:35 -0500 Subject: [PATCH 26/44] bug fix for saturation_wrapper.pro --- saturation_wrapper.pro | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/saturation_wrapper.pro b/saturation_wrapper.pro index 439a6bf..6f52940 100644 --- a/saturation_wrapper.pro +++ b/saturation_wrapper.pro @@ -32,12 +32,12 @@ t_max_0335=t[in] print,'Worst saturation percentage for each wavelength:' print,'--------------------------------------------------' -print,'94A : ',sat_per_max_0094,' located at: ',anytim(t_max_0094) -print,'131A: ',sat_per_max_0131,' located at: ',anytim(t_max_0131) -print,'171A: ',sat_per_max_0171,' located at: ',anytim(t_max_0171) -print,'193A: ',sat_per_max_0193,' located at: ',anytim(t_max_0193) -print,'211A: ',sat_per_max_0211,' located at: ',anytim(t_max_0211) -print,'335A: ',sat_per_max_0335,' located at: ',anytim(t_max_0335) +print,'94A : ',sat_per_max_0094,' located at: ',anytim(t_max_0094,/vms) +print,'131A: ',sat_per_max_0131,' located at: ',anytim(t_max_0131,/vms) +print,'171A: ',sat_per_max_0171,' located at: ',anytim(t_max_0171,/vms) +print,'193A: ',sat_per_max_0193,' located at: ',anytim(t_max_0193,/vms) +print,'211A: ',sat_per_max_0211,' located at: ',anytim(t_max_0211,/vms) +print,'335A: ',sat_per_max_0335,' located at: ',anytim(t_max_0335,/vms) SAVE,sat_per_max_0094,sat_per_max_0131,sat_per_max_0171,sat_per_max_0193,sat_per_max_0211,sat_per_max_0335, $ t_max_0094,t_max_0131,t_max_0171,t_max_0193,t_max_0211,t_max_0335,filename='saturation_results.sav' From 9332647c5cf70fab9e8b72fd9f7d5e70442281ac Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 15 Jan 2013 15:23:42 -0500 Subject: [PATCH 27/44] added FIT_TIME keyword to test_saturation.pro --- saturation_wrapper.pro | 14 +++++++------- test_saturation.pro | 43 +++++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/saturation_wrapper.pro b/saturation_wrapper.pro index 6f52940..13d5278 100644 --- a/saturation_wrapper.pro +++ b/saturation_wrapper.pro @@ -1,32 +1,32 @@ -PRO saturation_wrapper,hsi_image +PRO saturation_wrapper,hsi_image,fit_time spawn,'\ls *_0094.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0094 = max(sat_percents,in) t_max_0094=t[in] spawn,'\ls *_0131.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0131 = max(sat_percents,in) t_max_0131=t[in] spawn,'\ls *_0171.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0171 = max(sat_percents,in) t_max_0171=t[in] spawn,'\ls *_0193.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0193 = max(sat_percents,in) t_max_0193=t[in] spawn,'\ls *_0211.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0211 = max(sat_percents,in) t_max_0211=t[in] spawn,'\ls *_0335.fits',files -test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet +test_saturation,files,sat_nums,tot_nums,sat_percents,t,hsi_image=hsi_image,/quiet,fit_time=fit_time sat_per_max_0335 = max(sat_percents,in) t_max_0335=t[in] diff --git a/test_saturation.pro b/test_saturation.pro index e7ae9cc..9244385 100644 --- a/test_saturation.pro +++ b/test_saturation.pro @@ -1,12 +1,33 @@ -PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,t,xrange=xrange,yrange=yrange,hsi_image=hsi_image,quiet=quiet +PRO test_saturation,filenames,sat_nums,tot_nums,sat_percents,t,xrange=xrange,yrange=yrange,hsi_image=hsi_image,quiet=quiet,fit_time=fit_time -length=n_elements(filenames) -sat_nums=fltarr(length) -tot_nums=fltarr(length) -sat_percents=fltarr(length) -t=fltarr(length) +IF keyword_set(fit_time) THEN BEGIN + filetimes=anytim(aiafile_to_time(filenames[*], fileset='AIA'),/utime) + start_time=anytim(fit_time[0],/utime) + end_time=anytim(fit_time[1],/utime) -FOR n=0,length-1 do begin + start=value_locate(filetimes,start_time) + ende=value_locate(filetimes,end_time) + + + length=n_elements(filetimes[start:ende]) + sat_nums=fltarr(length) + tot_nums=fltarr(length) + sat_percents=fltarr(length) + t=fltarr(length) + +ENDIF ELSE BEGIN + length=n_elements(filenames) + start=0 + ende=length-1 + + sat_nums=fltarr(length) + tot_nums=fltarr(length) + sat_percents=fltarr(length) + t=fltarr(length) +ENDELSE + +;FOR n=0,length-1 do begin +FOR n=start,ende do begin read_sdo,filenames[n],index,data index2map,index,data,map @@ -71,10 +92,10 @@ FOR n=0,length-1 do begin print,' ' ENDIF - sat_nums[n]=sat_num - tot_nums[n]=tot_num - sat_percents[n]=sat_percent - t[n]=anytim(index.date_obs) + sat_nums[n-start]=sat_num + tot_nums[n-start]=tot_num + sat_percents[n-start]=sat_percent + t[n-start]=anytim(index.date_obs) ENDFOR From 16749db2d429edd3510efef8e241b211bdb59356 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Tue, 22 Jan 2013 17:36:14 -0500 Subject: [PATCH 28/44] fixed bug where error bars were displayed incorrectly. --- replot_aia_flux_ratios.pro | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/replot_aia_flux_ratios.pro b/replot_aia_flux_ratios.pro index 87a3055..fbba874 100644 --- a/replot_aia_flux_ratios.pro +++ b/replot_aia_flux_ratios.pro @@ -99,15 +99,19 @@ ENDIF device,encaps=1,color=1,filename=fname ENDIF loadct,39 + + error=(0.2* a.flux_obs) + frac_error=error/a.flux_obs + plot,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,psym=4,symsize=2,charsize=1.5,xrange=[0,7],xticks=7, $ - xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle=textoidl('flux_{model}/flux_{obs}'),yran=[0.0,2.5], charthick=2,thick=2,xthick=2,ythick=2 + xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle=textoidl('flux_{model}/flux_{obs}'),yran=[0.0,2.5], charthick=3,thick=3,xthick=3,ythick=3 - oploterr,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,findgen(6)*0 + 0.2,psym=4,symsize=2,thick=2 + oploterr,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,frac_error*(a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs),psym=4,symsize=2,thick=3 oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3,color=240 leg = [(textoidl('\chi^2_{aia} = ' + num2str(chi_label,length=4))), ('EM = '+ num2str(alog10(a.em_2d[pos[0],pos[1]]),length=4) $ +', log T = '+num2str(a.telog[pos[0]],length=4) + ', ' + textoidl('\sigma') + ' = ' + num2str(a.tsig[pos[1]],length=4))]; + '[' + num2str(alog10(ah.em_2d[pos[0],pos[1]])) +',' + num2str(ah.telog[pos[0]]) + ',' + num2str(ah.tsig[pos[1]]) + ']' - legend, leg,charsize=1.2,/top,/left,thick=2,charthick=2 + legend, leg,charsize=1.2,/top,/left,thick=3,charthick=3 IF keyword_set(OUTPS) THEN BEGIN device,/close From b520d34274e425742014c9bcec8688d3ab842ad0 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 24 Jan 2013 10:32:20 -0500 Subject: [PATCH 29/44] Changed noise calculation - added statistical uncertainty of AIA fluxes in quadtrature with fixed 20% error. --- aia_hsi_dem_analysis.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aia_hsi_dem_analysis.pro b/aia_hsi_dem_analysis.pro index 943b45a..b26e75e 100644 --- a/aia_hsi_dem_analysis.pro +++ b/aia_hsi_dem_analysis.pro @@ -340,7 +340,7 @@ nfree=3 counts = flux_obs*texp_ ;stop ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. - noise = 0.2*flux_obs;sqrt(counts)/texp_ + noise = sqrt((0.2*flux_obs)^2 + (sqrt(counts) /texp_)^2);sqrt(counts)/texp_ chimin = 9999. chi6min = 9999. From 612c9f4fffe00c81e7a805de686844b6e69038dd Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Fri, 25 Jan 2013 13:27:31 -0500 Subject: [PATCH 30/44] minor adjustments to replotting routines. --- redo_analysis.pro | 4 ++-- replot_aia_flux_ratios.pro | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/redo_analysis.pro b/redo_analysis.pro index 1aefac4..a2ce777 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -30,7 +30,7 @@ emfactor=a.em_2d[0,0]/ah.em_2d[0,0] get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor -r=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +r=get_combined_chisq(a.chi_2d^2,chisq_results,n_aia=6,n_hsi=12) read,tmp1,prompt='Input first index for best combined fit:' read,tmp2,prompt='Input second index for best combined fit:' @@ -57,7 +57,7 @@ emfactor=a.em_2d[0,0]/ah.em_2d[0,0] get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor -re=get_combined_chisq(a.chi_2d,chisq_results,n_aia=6,n_hsi=12) +re=get_combined_chisq(a.chi_2d^2,chisq_results,n_aia=6,n_hsi=12) read,tmp1,prompt='Input first index for best combined fit:' read,tmp2,prompt='Input second index for best combined fit:' diff --git a/replot_aia_flux_ratios.pro b/replot_aia_flux_ratios.pro index fbba874..d94af6f 100644 --- a/replot_aia_flux_ratios.pro +++ b/replot_aia_flux_ratios.pro @@ -23,7 +23,7 @@ PRO replot_aia_flux_ratios, epstein=epstein, OUTPS = outps, combobest=combobest ;device,/close ;set_plot,'x' - +texps=[2.9,2.9,2.0,2.0,2.9,2.9] IF keyword_set(epstein) THEN BEGIN restore,'aia_fit_results_epstein.sav' @@ -35,6 +35,9 @@ a=aia_fit_results fname='replot_aia_flux_ratios_for_aia_best.ps' ENDELSE +error=sqrt((0.2* a.flux_obs)^2 + (sqrt(a.flux_obs * texps)/texps)^2) +frac_error=error/a.flux_obs + tt=value_locate(a.telog,a.telog_best) ss=value_locate(a.tsig,a.sig_best) @@ -49,7 +52,7 @@ hsi_linecolors plot,findgen(6)+1,a.flux_dem_best,charsize=1.2,xrange = [0,7],xticks=7, $ xtickname=[' ','131A','171A','193A','211A','335A','94A',' '], ytitle='AIA DN Numbers', /nodata,xthick=3,ythick=3,thick=3,charthick=3 -oploterr,findgen(6)+1,a.flux_obs,a.flux_obs*0.2, psym = symcat(14),symsize=2, /nohat,thick=3 +oploterr,findgen(6)+1,a.flux_obs,a.flux_obs*error, psym = symcat(14),symsize=2, /nohat,thick=3 oplot, findgen(6)+1, a.flux_dem_best, psym = 7, symsize = 1,thick=3 ssw_legend, ['AIA observed', 'FIT'], psym = [symcat(14), 7], charsize = 1.0,charthick=3,thick=3 @@ -57,10 +60,10 @@ ssw_legend, ['AIA observed', 'FIT'], psym = [symcat(14), 7], charsize = 1.0,char plot,findgen(6)+1,a.flux_dem_best/a.flux_obs,psym=4,symsize=2,charsize=1.2,xrange=[0,7],xticks=7, $ xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle='flux_model/flux_obs',yran=[0.0,2.5],thick=3,xthick=3,ythick=3,charthick=3 -oploterr,findgen(6)+1,a.flux_dem_3d[tt,ss,*]/a.flux_obs,findgen(6)*0 + 0.2,psym=symcat(14),symsize=2,thick=3 +oploterr,findgen(6)+1,a.flux_dem_3d[tt,ss,*]/a.flux_obs,frac_error*(a.flux_dem_3d[tt,ss,*]/a.flux_obs),psym=symcat(14),symsize=2,thick=3 oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3 -leg = textoidl('\chi^2 = ') + num2str(a.chimin, length = 5) + ' [log(EM) = ' + num2str(a.em_best, length = 5) + ' cm!U-5!N, log(Tmax) = ' + num2str(a.telog_best, length = 5) + ' (' + num2str(10d^a.telog_best/1d6, length=5) + ' MK), sigma = ' + num2str(a.sig_best) + ']' +leg = textoidl('\chi^2 = ') + num2str(a.chimin^2, length = 5) + ' [log(EM) = ' + num2str(a.em_best, length = 5) + ' cm!U-5!N, log(Tmax) = ' + num2str(a.telog_best, length = 5) + ' (' + num2str(10d^a.telog_best/1d6, length=5) + ' MK), sigma = ' + num2str(a.sig_best) + ']' ssw_legend, leg, psym = symcat(14),charsize=0.75,charthick=3 !P.MULTI = 0 !y.margin=[4,2] @@ -93,21 +96,21 @@ ENDIF ;m= min(chi_combo,pos) ;pos=array_indices(chi_combo,pos) pos=combobest - chi_label=a.chi_2d[pos[0],pos[1]] + chi_label=a.chi_2d[pos[0],pos[1]]^2 IF keyword_set(OUTPS) THEN BEGIN set_plot,'ps' device,encaps=1,color=1,filename=fname ENDIF loadct,39 - error=(0.2* a.flux_obs) - frac_error=error/a.flux_obs + ;error=(0.2* a.flux_obs) + ;frac_error=error/a.flux_obs plot,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,psym=4,symsize=2,charsize=1.5,xrange=[0,7],xticks=7, $ xtickname=[' ','131A','171A','193A','211A','335A','94A',' '],ytitle=textoidl('flux_{model}/flux_{obs}'),yran=[0.0,2.5], charthick=3,thick=3,xthick=3,ythick=3 oploterr,findgen(6)+1,a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs,frac_error*(a.flux_dem_3d[pos[0],pos[1],*]/a.flux_obs),psym=4,symsize=2,thick=3 - oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3,color=240 + oplot,findgen(10),findgen(10)*0 + 1,linestyle=2,thick=3 leg = [(textoidl('\chi^2_{aia} = ' + num2str(chi_label,length=4))), ('EM = '+ num2str(alog10(a.em_2d[pos[0],pos[1]]),length=4) $ +', log T = '+num2str(a.telog[pos[0]],length=4) + ', ' + textoidl('\sigma') + ' = ' + num2str(a.tsig[pos[1]],length=4))]; + '[' + num2str(alog10(ah.em_2d[pos[0],pos[1]])) +',' + num2str(ah.telog[pos[0]]) + ',' + num2str(ah.tsig[pos[1]]) + ']' From b55c040f3346621fe4b2f581d18bd0c2f7b8bfd9 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Fri, 25 Jan 2013 13:31:59 -0500 Subject: [PATCH 31/44] added DIR keyword to redo_analysis.pro --- redo_analysis.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/redo_analysis.pro b/redo_analysis.pro index a2ce777..7f147fe 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -1,13 +1,13 @@ -PRO redo_analysis,event +PRO redo_analysis,event,dir=dir ;load the important information for the event in question all_events,event,image_file,spec_file,drm_file,fit_time,bkg_time - +default,dir,'' ;now redo the AIA analysis using averaged AIA data, for both the Gaussian and Epstein DEM functions -aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/aia_only +aia_hsi_dem_analysis,dir=dir,fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/aia_only -aia_hsi_dem_analysis,dir='',fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/epstein,/aia_only,n=10 +aia_hsi_dem_analysis,dir=dir,fileset='AIA',/force_table,hsi_image=image_file,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,/epstein,/aia_only,n=10 ;DO GAUSSIAN RECALCULATIONS ;-------------------------------------------------------------------------------------- From 2c60d12f5e2e611049f822079f50f1da4ebb4600 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Fri, 25 Jan 2013 17:35:01 -0500 Subject: [PATCH 32/44] added error bars to output from get_rhessi_chisq.pro --- get_rhessi_chisq.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/get_rhessi_chisq.pro b/get_rhessi_chisq.pro index a784773..1d17278 100644 --- a/get_rhessi_chisq.pro +++ b/get_rhessi_chisq.pro @@ -38,7 +38,7 @@ -PRO get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor +PRO get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor,sigma_array=sigma_array default,epstein,1 default,n,10 @@ -109,6 +109,7 @@ ltime=ltime.ltime[0] sz=size(model_flux_array) chisq_results=fltarr(sz[1],sz[2]) +sigma_array=fltarr(sz[1],sz[2],sz[3]) for i=0,sz[1] -1 do begin @@ -143,6 +144,7 @@ for i=0,sz[1] -1 do begin chisq_red = total(values)/(npoints-1) chisq_results[i,j]=chisq_red + sigma_array[i,j,*]=sigma_tot_rate/(summary.spex_summ_area * 0.353605) endfor endfor From 049f15315224f10cf27cf20b852f8b8030c9c3a8 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Mon, 28 Jan 2013 16:08:12 -0500 Subject: [PATCH 33/44] added sigma_array keyword to return RHESSI spectral errors. --- redo_analysis.pro | 26 ++++++++++++++++++++++---- replot_hsi_count_spectrum_from_dem.pro | 11 +++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/redo_analysis.pro b/redo_analysis.pro index 7f147fe..eb1f8a9 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -38,7 +38,7 @@ combobest=[tmp1,tmp2] replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps replot_aia_flux_ratios,combobest=combobest,/outps -replot_combo_dem,n=1,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results +replot_combo_dem,n=10,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results ;DO EPSTEIN RECALCULATIONS ;-------------------------------------------------------------------------------------- @@ -55,18 +55,36 @@ a=aia_fit_results ;find the ratio of EM_0 (new) / EM_0 (old) - use this to modify RHESSI model fluxes. emfactor=a.em_2d[0,0]/ah.em_2d[0,0] -get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor - +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor,sigma_array=sigma_array re=get_combined_chisq(a.chi_2d^2,chisq_results,n_aia=6,n_hsi=12) read,tmp1,prompt='Input first index for best combined fit:' read,tmp2,prompt='Input second index for best combined fit:' combobest=[tmp1,tmp2] -replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps +replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps,sigma_array=sigma_array replot_aia_flux_ratios,/epstein,combobest=combobest,/outps replot_combo_dem,n=10,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results +;make the files into an archive +CASE event OF +1: string='20110605' +2: string='20110606' +3: string='20110621' +4: string='20110716' +5: string='20110826' +6: string='20111011' +7: string='20120620' +8: string='20120910' +9: string='20120915' +10:string='20120927' +ENDCASE + +spawn,'rm replot*'+string+'.ps' +spawn,'\ls replot*.ps',list +file_appender,list,string + +spawn,'tar -czf replots_new_'+string+'.tar.gz replot*'+string+'.ps' ;DO SOME PLOTTING ;--------------------------------------------------------------------------------------- diff --git a/replot_hsi_count_spectrum_from_dem.pro b/replot_hsi_count_spectrum_from_dem.pro index 3bdadca..4f8b31c 100644 --- a/replot_hsi_count_spectrum_from_dem.pro +++ b/replot_hsi_count_spectrum_from_dem.pro @@ -1,4 +1,4 @@ -PRO replot_hsi_count_spectrum_from_dem,epstein=epstein,ps=ps,type=type,chisq_results=chisq_results,combobest=combobest,emfactor=emfactor +PRO replot_hsi_count_spectrum_from_dem,epstein=epstein,ps=ps,type=type,chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,sigma_array=sigma_array default,type,'combo' @@ -24,6 +24,7 @@ tloc=value_locate(f.telog,f.telog_best) sigloc=value_locate(f.tsig,f.sig_best) aia_spec=a.model_count_flux_hsi[tloc,sigloc,*]*emfactor +aia_sigma=sigma_array[tloc,sigloc] ;find the best-fit combo parameters and assign the model spectrum pos=[combobest[0],combobest[1]] @@ -31,11 +32,13 @@ pos=[combobest[0],combobest[1]] ;m=min(chi_combo,pos) ;pos=array_indices(chi_combo,pos) combo_spec=a.model_count_flux_hsi[pos[0],pos[1],*]*emfactor +combo_sigma=sigma_array[pos[0],pos[1]] ;find the best-fit RHESSI parameters and assign the model spectrum m=min(chisq_results,hsipos) hsipos=array_indices(chisq_results,hsipos) hsi_spec=a.model_count_flux_hsi[hsipos[0],hsipos[1],*] * emfactor +hsi_sigma=sigma_array[hsipos[0],hsipos[1]] ;xticks=[' ',' ','5',' ',' ',' ',' ','10'] @@ -43,14 +46,17 @@ IF (type eq 'hsi') THEN BEGIN model=hsi_spec yrange=[0.01,max(model) + 1] chi_label=min(chisq_results) + err=hsi_sigma ENDIF ELSE IF (type eq 'aia') THEN BEGIN model=aia_spec yrange=[0.01,max(model) + 1] chi_label=chisq_results[tloc,sigloc] + err=aia_sigma ENDIF ELSE IF (type eq 'combo') THEN BEGIN model=combo_spec yrange=[0.01,max(model) + 1] chi_label=chisq_results[pos[0],pos[1]] + err=combo_sigma ENDIF ELSE BEGIN print,' ' print,'-----------------' @@ -72,13 +78,14 @@ loadct,39 plot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],/xlog,/ylog,thick=3,xthick=3,ythick=3,xrange=[3,12],yrange=yrange,linestyle=3,charsize=1.5, $ xtitle='energy (keV)',ytitle='counts s!U-1!N cm!U-2!N kev!U-1!N',xstyle=1,ystyle=1,charthick=3,/nodata oplot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],thick=3,color=50,linestyle=3 +oploterr,a.axis[0,*],a.real_count_flux_hsi[1,1,*],err,psym=0,thick=3,linestyle=3,color=50,errcolor=50 oplot,a.axis[0,*],model,thick=3,color=240 ;show the fitting range on the plot oplot,(findgen(10000)*0. + 4),(findgen(10000)*0.01),linestyle=1,thick=2 oplot,(findgen(10000)*0. + 8),(findgen(10000)*0.01),linestyle=1,thick=2 -xyouts,0.75,0.8,textoidl('\chi^2_{hsi} = ' + num2str(chi_label,length=4)),/norm,charsize=1.5 +xyouts,0.75,0.8,textoidl('\chi^2_{hsi} = ' + num2str(chi_label,length=4)),/norm,charsize=1.5,charthick=3 ssw_legend,['RHESSI count flux','Model count flux'],linestyle=[3,0],color=[50,240],thick=[3,3],/bottom,/left,charsize=1.2,charthick=3 From b7250b6bc786bdf73169d14bd383fb1924d4d934 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Mon, 28 Jan 2013 16:09:36 -0500 Subject: [PATCH 34/44] bug fix for redo_analysis.pro --- redo_analysis.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redo_analysis.pro b/redo_analysis.pro index eb1f8a9..ec4083d 100644 --- a/redo_analysis.pro +++ b/redo_analysis.pro @@ -28,7 +28,7 @@ a=aia_fit_results ;find the ratio of EM_0 (new) / EM_0 (old) - use this to modify RHESSI model fluxes. emfactor=a.em_2d[0,0]/ah.em_2d[0,0] -get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor +get_rhessi_chisq,erange,chisq_results,epstein=epstein,spec_file=spec_file,drm_file=drm_file,fit_time=fit_time,bkg_time=bkg_time,n=n,uncert=uncert,emfactor=emfactor,sigma_array=sigma_array r=get_combined_chisq(a.chi_2d^2,chisq_results,n_aia=6,n_hsi=12) @@ -36,7 +36,7 @@ read,tmp1,prompt='Input first index for best combined fit:' read,tmp2,prompt='Input second index for best combined fit:' combobest=[tmp1,tmp2] -replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps +replot_hsi_count_spectrum_from_dem,epstein=epstein,type='combo',chisq_results=chisq_results,combobest=combobest,emfactor=emfactor,/ps,sigma_array=sigma_array replot_aia_flux_ratios,combobest=combobest,/outps replot_combo_dem,n=10,epstein=epstein,combobest=combobest,emfactor=emfactor,chisq_results=chisq_results From 5b9336af32013cae1434a897ab0b9829ccc77d07 Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Mon, 28 Jan 2013 16:42:51 -0500 Subject: [PATCH 35/44] bug fixes for replotting routines. --- replot_combo_dem.pro | 1 - replot_hsi_count_spectrum_from_dem.pro | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/replot_combo_dem.pro b/replot_combo_dem.pro index fb1f55b..0ed923d 100644 --- a/replot_combo_dem.pro +++ b/replot_combo_dem.pro @@ -40,7 +40,6 @@ telog_best_combo=telog(pos[0]) tsig_best_combo=tsig(pos[1]) em_best_combo=a.em_2d[pos[0],pos[1]] - ;plot the dems aia_dem=get_dem_from_params(telog,[(10^(a.em_best)),a.telog_best,a.sig_best],n=n,epstein=epstein) diff --git a/replot_hsi_count_spectrum_from_dem.pro b/replot_hsi_count_spectrum_from_dem.pro index 4f8b31c..344e764 100644 --- a/replot_hsi_count_spectrum_from_dem.pro +++ b/replot_hsi_count_spectrum_from_dem.pro @@ -24,7 +24,7 @@ tloc=value_locate(f.telog,f.telog_best) sigloc=value_locate(f.tsig,f.sig_best) aia_spec=a.model_count_flux_hsi[tloc,sigloc,*]*emfactor -aia_sigma=sigma_array[tloc,sigloc] +aia_sigma=sigma_array[tloc,sigloc,*] ;find the best-fit combo parameters and assign the model spectrum pos=[combobest[0],combobest[1]] @@ -32,13 +32,13 @@ pos=[combobest[0],combobest[1]] ;m=min(chi_combo,pos) ;pos=array_indices(chi_combo,pos) combo_spec=a.model_count_flux_hsi[pos[0],pos[1],*]*emfactor -combo_sigma=sigma_array[pos[0],pos[1]] +combo_sigma=sigma_array[pos[0],pos[1],*] ;find the best-fit RHESSI parameters and assign the model spectrum m=min(chisq_results,hsipos) hsipos=array_indices(chisq_results,hsipos) hsi_spec=a.model_count_flux_hsi[hsipos[0],hsipos[1],*] * emfactor -hsi_sigma=sigma_array[hsipos[0],hsipos[1]] +hsi_sigma=sigma_array[hsipos[0],hsipos[1],*] ;xticks=[' ',' ','5',' ',' ',' ',' ','10'] @@ -78,7 +78,7 @@ loadct,39 plot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],/xlog,/ylog,thick=3,xthick=3,ythick=3,xrange=[3,12],yrange=yrange,linestyle=3,charsize=1.5, $ xtitle='energy (keV)',ytitle='counts s!U-1!N cm!U-2!N kev!U-1!N',xstyle=1,ystyle=1,charthick=3,/nodata oplot,a.axis[0,*],a.real_count_flux_hsi[1,1,*],thick=3,color=50,linestyle=3 -oploterr,a.axis[0,*],a.real_count_flux_hsi[1,1,*],err,psym=0,thick=3,linestyle=3,color=50,errcolor=50 +oploterr,a.axis[0,*],a.real_count_flux_hsi[1,1,*],err,psym=3,thick=3,linestyle=3,color=50,errcolor=50 oplot,a.axis[0,*],model,thick=3,color=240 ;show the fitting range on the plot From e76759e5064720b116e365c60e1ccb9706e3382b Mon Sep 17 00:00:00 2001 From: aringlis Date: Wed, 6 Feb 2013 14:09:51 -0500 Subject: [PATCH 36/44] bug fix for get_energy_from_dem.pro --- get_energy_from_dem.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_energy_from_dem.pro b/get_energy_from_dem.pro index 2a47087..24ed37d 100644 --- a/get_energy_from_dem.pro +++ b/get_energy_from_dem.pro @@ -11,7 +11,7 @@ area=double(area) rad_loss,rad_temps,loss,density=1e11 ;interpolate the radiative loss function before performing integral -rlossfunction=interpol(rad_loss,rad_temps,temp_lin,/quadratic) +rlossfunction=interpol(loss,rad_temps,temp_lin,/quadratic) total_energy_per_sec=int_tabulated(temp_lin,(rlossfunction*dem*area)) From d88129b65a8f5e5579c2214fe2f56ec6c961016c Mon Sep 17 00:00:00 2001 From: aringlis Date: Wed, 6 Feb 2013 14:26:57 -0500 Subject: [PATCH 37/44] update to get_energy_from_dem.pro --- get_energy_from_dem.pro | 71 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/get_energy_from_dem.pro b/get_energy_from_dem.pro index 24ed37d..7883827 100644 --- a/get_energy_from_dem.pro +++ b/get_energy_from_dem.pro @@ -1,14 +1,75 @@ -FUNCTION get_energy_from_dem,temperatures,params,area,n=n,epstein=epstein +; +; NAME: GET_ENERGY_FROM_DEM +; +; PURPOSE: Utility function which performs an estimate of the total +; radiated energy of an event based on an input DEM. This is done by +; generating the radiative loss function from the Chianti database and +; performing an integral of dEM(T) x loss_func(T). +; +; CALLING SEQUENCE: +; result = get_energy_from_dem(temperatures, dem=dem,params=params,area=area,n=n,epstein=epstein) +; +; INPUTS: +; TEMPERATURES: an input temperature array +; +; KEYWORD INPUTS: +; PARAMS: the DEM fit parameters. Used to generate the DEM array +; over the range specified by temperatures. Assumed to consist of 3 +; components. +; params[0] - emission measure value at the DEM centre +; params[1] - temperature where the DEM centre is located +; params[2] - width parameter associated with the DEM +; distribution +; DEM: alternatively, the pre-constructed DEM array can be +; passed in using this keyword. +; AREA: the estimated area of the flare. Needed to convert to +; emission measure in terms of cm^-3 +; EPSTEIN: If set, the input DEM parameters are interpreted as +; an Epstein profile. Otherwise a Gaussian profile is +; assumed. +; n: The steepness parameter of the Epstein distribution. Needed +; if EPSTEIN keyword is set. +; +; WRITTEN: +; Andrew Inglis, 2012/11/27 +; -;params=[a0,a1,a2] +FUNCTION get_energy_from_dem,temperatures,dem=dem,params=params,area=area,n=n,epstein=epstein -dem=get_dem_from_params(temperatures,params,n=n,epstein=epstein) +IF not keyword_set(area) THEN BEGIN + print,' ' + print,'-------------------' + print,'Please provide a flare area estimate using the AREA keyword.' + print,'-------------------' + print,' ' + return, -1 +ENDIF + +IF keyword_set(params) THEN BEGIN + IF keyword_set(dem) THEN BEGIN + print,'Error: DEM and PARAMS are mutually exclusive.' + return, -1 + ENDIF + dem=get_dem_from_params(temperatures,params,n=n,epstein=epstein) +ENDIF temp_lin=10^temperatures area=double(area) -;get the radiative loss function -rad_loss,rad_temps,loss,density=1e11 +spawn,'\ls rad_loss.sav',rfile +IF (rfile ne '') THEN BEGIN + print,'-----------------' + print,'Restoring previously saved radiative loss function' + print,'-----------------' + restore,rfile,/verbose +ENDIF ELSE BEGIN + print,'-----------------' + print,'Generating the radiative loss function (user input is required)...' + print,'-----------------' + ;get the radiative loss function + rad_loss,rad_temps,loss,density=1e11 + SAVE,rad_temps,loss,filename='rad_loss.sav',/verbose +ENDELSE ;interpolate the radiative loss function before performing integral rlossfunction=interpol(loss,rad_temps,temp_lin,/quadratic) From d84509f71bf59805c9ba00dfa09cee87303e226b Mon Sep 17 00:00:00 2001 From: Andrew Inglis Date: Thu, 7 Feb 2013 15:03:40 -0500 Subject: [PATCH 38/44] removed HSI only lines and labels from DEM plots --- replot_combo_dem.pro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/replot_combo_dem.pro b/replot_combo_dem.pro index 0ed923d..bf57970 100644 --- a/replot_combo_dem.pro +++ b/replot_combo_dem.pro @@ -40,10 +40,11 @@ telog_best_combo=telog(pos[0]) tsig_best_combo=tsig(pos[1]) em_best_combo=a.em_2d[pos[0],pos[1]] +stop ;plot the dems aia_dem=get_dem_from_params(telog,[(10^(a.em_best)),a.telog_best,a.sig_best],n=n,epstein=epstein) -hsi_dem=get_dem_from_params(telog,[hsi_emconvert,hsi_telog,hsi_tsig],n=n,epstein=epstein) +;hsi_dem=get_dem_from_params(telog,[hsi_emconvert,hsi_telog,hsi_tsig],n=n,epstein=epstein) combo_dem=get_dem_from_params(telog,[(em_best_combo),telog_best_combo,tsig_best_combo],n=n,epstein=epstein) @@ -59,11 +60,11 @@ ENDELSE loadct,39 plot,telog,alog10(aia_dem),thick=3,xthick=3,ythick=3,charthick=3,charsize=1.5,linestyle=0,yrange=[18,23],ytitle='log EM (cm!U-5!N K!U-1!N)',xtitle = 'log T (K)',/nodata oplot,telog,alog10(aia_dem),thick=3,color=240 -oplot,telog,alog10(hsi_dem),thick=3,linestyle=2 +;oplot,telog,alog10(hsi_dem),thick=3,linestyle=2 oplot,telog,alog10(combo_dem),thick=3,linestyle=0,color=50 -ssw_legend,['AIA','HSI','AIA and HSI'],linestyle=[0,2,0],thick=[3,3,3],color=[240,0,50],/right,charsize=1.2,charthick=3 +ssw_legend,['AIA only','AIA and HSI'],linestyle=[0,0],thick=[3,3],color=[240,50],/right,charsize=1.2,charthick=3 device,/close ;set_plot,'x' From 0ddb2e2e41a49efeafd2cfe0de3e37b10ee4a36c Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 09:45:52 -0400 Subject: [PATCH 39/44] deleting unnecessary files from repo. --- aia_fits_to_gifs.pro | 60 --------- aia_teem_movie.pro | 259 ------------------------------------ plot_aia_lightcurve.pro | 95 ------------- rhessi12_science_script.pro | 54 -------- 4 files changed, 468 deletions(-) delete mode 100644 aia_fits_to_gifs.pro delete mode 100644 aia_teem_movie.pro delete mode 100644 plot_aia_lightcurve.pro delete mode 100644 rhessi12_science_script.pro diff --git a/aia_fits_to_gifs.pro b/aia_fits_to_gifs.pro deleted file mode 100644 index ff9bb5a..0000000 --- a/aia_fits_to_gifs.pro +++ /dev/null @@ -1,60 +0,0 @@ -PRO aia_fits_to_gifs, dir = dir, OUTPLOT = outplot - -dir = '/Volumes/sdo-aia/hsi_flare_20110716_/' -;fileset = file_search(dir + 'ssw_cutout_20110716_*') - -fileset = 'ssw_cutout' -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -FOR i = 0, nwave-1 DO BEGIN - files = file_search(dir + fileset + '*' + wave_[i] + '_.fts') - nfiles[i] = n_elements(files) -ENDFOR - -;the number of files need to be the same! -print, nfiles -file_list = strarr(nfiles[0], nwave) - -FOR i = 0, nwave-1 DO BEGIN - files = file_search(dir + fileset + '*' + wave_[i] + '_.fts') - nfiles[i] = n_elements(files) - times = anytim(aiacutout_to_time(files)) - s = sort(times) - files = files[s] - file_list[*,i] = files -ENDFOR - -FOR j = 0, nwave-1 DO BEGIN - - aia_lct, rr, gg, bb, wavelnth=wave_[j], /load - - FOR i = 0, nfiles[0]-1 DO BEGIN - - curfile = file_list[i,j] - - read_sdo, curfile, header, data - wcs = fitshead2wcs( header ) - wcs2map, data, wcs, map, id = header.wavelnth - - IF keyword_set(OUTPLOT) THEN BEGIN - set_plot, 'z' - device, set_resolution = [600, 600] - ENDIF - - cur_time = anytim(map.time) - plot_map, map, charsize = 1.5 - legend, wave_[j], box = 0, charsize = 1.5 - - IF keyword_set(OUTPLOT) THEN BEGIN - tvlct, r, g, b, /get - outfile = 'dem_' + wave_[j] + '_' + break_time(cur_time) + '_' + num2str(i, padchar = '0', length = 3) + '.png' - write_png, outfile, tvrd(), r,g,b - set_plot, 'x' - ENDIF - -ENDFOR -ENDFOR - -END diff --git a/aia_teem_movie.pro b/aia_teem_movie.pro deleted file mode 100644 index bebbc85..0000000 --- a/aia_teem_movie.pro +++ /dev/null @@ -1,259 +0,0 @@ -PRO aia_teem_movie, DIR = dir, istart = istart, HSI_FITS = hsi_fits, DEBUG = debug, OUTPLOT = outplot, XRAYSPEC = xrayspec, SAVE_DIR = save_dir, flare_num = FLARE_NUM, VERBOSE = verbose, ISTOP = istop, fileset = fileset, npix = npix, FORCE_TABLE = force_table, q94 = q94, xrange = xrange, yrange = yrange, macro_dem = macro_dem, HSI_IMAGE = hsi_image - -; -; -;KEYWORDS: -; SAVE_DIR - -; fov - deprecated use xrange and yrange instead -; xrange - set the xrange in arcsec of region of interest -; yrange - set the yrange in arcsec of region of interest -; fileset - choose either 'ssw_cutout' or 'AIA' -; -;EXAMPLES: -; aia_teem_movie, dir = '~/idlsave/aia_dem_flare/hsi_flare_20110603_071626/' -; -;WRITTEN: Steven Christe (11-Oct-2011) -;REVISION: Steven Christe (6-Jan-2011) -;REVISION: Steven Christe (3-Feb-2012) - -default, istart, 0 -default, dir, '~/idlpro/schriste/aia_deem/' -;default, hsi_fits, '~/Dropbox/idl/aia_deem/hsi_image_20110716_170350.fits' -default, save_fit, '' -default, hsi_image, '' -default, npix, 4 ;(macropixel size=4x4 pixels, yields 512x512 map) -default, q94, 1.0 ;(correction factor for low-temperature 94 A response) - -loadct,0 -hsi_linecolors - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -file_list = get_aia_file_list(dir, fileset = fileset) - -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;t_min = 5.0 -;t_max = 6.5 -;t_d = 0.1 -;telog1 = t_d * findgen((t_max - t_min)/t_d) + t_min - -t_min = 5.5 -t_max = 8.0 - -t_min = 5.5 -t_max = 7.5 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -;telog = [telog1,telog2] - -;te_range=[0.1,100]*1.e6 ; ([K], valid temperature range for DEM solutions) - -;tsig=0.1*(1+1*findgen(10)) ; (values of Gaussian logarithmic temperature widths) -tsig_min = 0.01 -tsig_max = 1.0 -tsig_d = 0.01 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -;not sure what the following does -vers='a' ; (version number of label in filenames used for full images) - -; Savefile that contains DEM loopup table -teem_table='teem_table.sav' -; Savefile that contains EM and Te maps -teem_map =fileset+vers+'_teem_map.sav' -; jpg-file that shows EM and Te maps -teem_jpeg=fileset+vers+'_teem_map.jpg' -; only need to do this once - -f = file_search(teem_table) - -area = aia_teem_pixel_area(file_list[0,0]) - -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area - -IF NOT keyword_set(istop) THEN istop = nfiles[0] - -; if a hsi_image was given then create a mask out of it -IF hsi_image[0] NE '' THEN BEGIN - fits2map, file_list[0,0], aiamap - fits2map, hsi_image, hsimap - ; interpolate the rhessi map to the aia map - - mask_map = inter_map(hsimap,aiamap) - mask_map = drot_map(mask_map, time = aiamap.time) - m = max(mask_map.data) - ; set the mask at everything above 50% contour - index = where(mask_map.data LE m*0.5, complement = complement) - mask_map.data[index] = 0 - mask_map.data[complement] = 1 - - ; now define the inverse mask - invmask_map = mask_map - invmask_map.data[index] = 1 - invmask_map.data[complement] = 0 -ENDIF - -FOR i = istart, nfiles[0]-1 DO BEGIN - - print, 'aia_teem_movie: processing map ' + num2str(i) - - IF fileset EQ 'ssw_cutout' THEN cur_time = anytim(aiacutout_to_time(file_list[i,0]),/yoh) - IF fileset EQ 'AIA' THEN cur_time = anytim(aiaprep_to_time(file_list[i,0]), /yoh) - print, cur_time - - ; name of Savefile that contains EM and Te maps - teem_map ='teem_data_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) + '.sav' - - teem_tot ='teem_tot_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) + '_q94_' + num2str(10*q94, length = 2) + '.sav' - filename_extra = '_' + num2str(i, padchar = '0', length = 3) - - aia_teem_map, wave_, npix, teem_table, teem_map, filelist = file_list[i,*], filename_extra = filename_extra , save_dir = save_dir, debug = debug, verbose = verbose, xrange = xrange, yrange = yrange - - IF keyword_set(DEBUG) THEN stop - - IF datatype(mask_map) EQ 'STC' THEN BEGIN - tx ='teem_tot_' + num2str(i, padchar = '0', length = 3) + break_time(cur_time) - teem_tot = [tx + '_mask_.sav',tx + '_invmask_.sav'] - - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot[0],filelist = file_list[i,*], mask_map = mask_map, /plot, save_dir = save_dir, xrange = xrange, yrange = yrange - - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot[1],filelist = file_list[i,*], mask_map = invmask_map, save_dir = save_dir, xrange = xrange, yrange = yrange - ENDIF ELSE BEGIN - aia_teem_total,npix,wave_,q94,teem_table,teem_map,teem_tot,filelist = file_list[i,*], xrange = xrange, yrange = yrange, macro_dem = macro_dem - ENDELSE - - IF keyword_set(OUTPLOT) THEN BEGIN - set_plot, 'z' - loadct,0 - hsi_linecolors - device, set_resolution = [800, 600] - ENDIF - - IF keyword_set(HSI_FITS) THEN BEGIN - - restore, save_dir + teem_tot[0] - telog_mask = telog - emlog_mask = emlog - emlog_err_mask = emlog_err - restore, save_dir + teem_tot[1] - - hsi_linecolors - yrange = [min([emlog_mask, emlog]), max([emlog_mask, emlog])] - plot, telog, emlog, xtitle = 'log(Temperature [MK])', ytitle = 'log(Emmission Measure [cm!U-5!N])', /nodata, yrange = yrange, /ystyle,title = cur_time, charsize = 2.0 - - oplot, telog, emlog, thick = 2.0, linestyle = 1, psym = symcat(16), color = 6 - oploterr, telog, emlog, emlog_err, /nohat, color = 6, errcolor = 6 - - oplot, telog_mask, emlog_mask, thick = 2.0, psym = symcat(16), color = 7 - oploterr, telog_mask, emlog_mask, emlog_err_mask, /nohat, color = 7, errcolor = 7 - - ;get the maxima - m = max(emlog, mindex) - max_t = telog[mindex] - - m = max(emlog_mask, mindex) - max_t_mask = telog_mask[mindex] - - ;text = ['Flare T!Lmax!N = ' + mynum2str(10^max_t_mask),'Background T!Lmax!N = ' + mynum2str(10^max_t)] - - ; now fit a line/power-law to the data above 5 MK - index = where(telog GE alog10(5e6)) - x = telog_mask[index] - y = emlog_mask[index] - eq_mask = linfit(x,y) - - oplot, [alog10(5e6), alog10(1e8)], eq_mask[1]*[alog10(5e6), alog10(1e8)] + eq_mask[0], color = 5 - - x = telog[index] - y = emlog[index] - eq_bkg = linfit(x,y) - - oplot, [alog10(5e6), alog10(1e8)], eq_bkg[1]*[alog10(5e6), alog10(1e8)] + eq_bkg[0], color = 6 - - IF keyword_set(HSI_FITS) THEN BEGIN - print, hsi_image - print, hsi_fits - fits2map, hsi_image, map - c = 0.5 - frac = n_elements(where(map.data/max(map.data) GE c))/float(n_elements(map.data)) - area = n_elements(map.data)*frac*map.dx*map.dy * 712e5^2.0 - - result = spex_read_fit_results(hsi_fits) - p = result.spex_summ_params - - ;now find the fit that is closest in time to time t - hsi_time = result.spex_summ_time_interval - ;con1 = anytim(t) LE anytim(hsi_time[1,*]) - ;con2 = anytim(t) GE anytim(hsi_time[0,*]) - - params = p[*,0] - - ;multi_therm_pow - ;DEM(T) = a[0] * (2/T)^a[3] - ;a[0] diff emission measure at T = 2 keV, 10^49 cm^(-3) keV^-1 - ;a[1] min plasma temperature (keV) - ;a[2] max plasma temperature (keV) - ;a[3] power law index - ;a[4] relative abundance - - hsi_telog = alog10([params[1], params[2]]*11.6d6) - hsi_emlog = alog10(1/11.6d6*1d49*params[0]*([2.0/params[1], 2.0/params[2]])^(params[3])) - - hsi_emlog = hsi_emlog - alog10(area) - oplot, hsi_telog, hsi_emlog, thick = 2.0, color = 4 - - ;legend, ['rhessi (' + textoidl('\alpha = ') + num2str(-params[3], length = 4) + ')', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ;legend, ['rhessi (' + textoidl('\alpha = ') + num2str(-params[3], length = 4) + ')', color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - - hsi_time_str = anytim(hsi_time, /yoh) - t = strmid(hsi_time_str[0], 0,10) + strmid(hsi_time_str[0], 10,8) + ' to ' + strmid(hsi_time_str[1], 10,8) - text = ['aia', 'aia (bkg)', 'rhessi (' + t + ')'] - - legend, text, linestyle = [0,1, 0], /left, box = 1, /bottom, charsize = 1.5, pspacing = 1, color = [7,6,4], textcolor = [7,6,4] - - text = textoidl('\alpha_{fit} = ') + [num2str(eq_bkg[1], length = 4), num2str(eq_mask[1], length = 4)] - text = [text, textoidl('\alpha_{hsi} = ') + num2str(-params[3], length = 4)] - legend, text, linestyle = [0,0,0], color = [5,6,4], charsize = 1.5, /top, /right, pspacing = 1, thick = [1,1,2] - - ENDIF ELSE BEGIN - text = ['aia', 'aia (bkg)'] - - legend, text, linestyle = [0,1], /left, box = 1, /bottom, charsize = 1.5, pspacing = 1, color = [7,6], textcolor = [7,6] - - text = textoidl('\alpha_{fit} = ') + [num2str(eq_bkg[1], length = 4), num2str(eq_mask[1], length = 4)] - legend, text, linestyle = [0,0], color = [5,6], charsize = 1.5, /top, /right, pspacing = 1 - - ;legend, ['rhessi', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ENDELSE - - IF keyword_set(OUTPLOT) THEN BEGIN - tvlct, r, g, b, /get - outfile = save_dir + 'dem_' + num2str(i, length = 3, padchar = '0') + '_' + break_time(cur_time) + '_' + num2str(i, padchar = '0', length = 3) + '.png' - write_png, outfile, tvrd(), r,g,b - set_plot, 'x' - ENDIF - -ENDIF - - IF keyword_set(XRAYSPEC) THEN BEGIN - ; now simulate the x-ray spectrum for this area - dem = [transpose(telog), transpose(emlog)] - help,dem - stop - result = chianti_spec_from_dem(reform(dem(0,*)),reform(dem(1,*)), /plot) - IF keyword_set(hsi_fits) THEN BEGIN - dem_mask = [transpose(telog_mask), transpose(emlog_mask)] - result_mask = chianti_spec_from_dem(reform(dem_mask(0,*)),reform(dem_mask(1,*))) - oplot, result_mask[0,*], result_mask[1,*] - ENDIF - ENDIF - - IF keyword_set(debug) THEN stop - -ENDFOR - -END \ No newline at end of file diff --git a/plot_aia_lightcurve.pro b/plot_aia_lightcurve.pro deleted file mode 100644 index 8209ea3..0000000 --- a/plot_aia_lightcurve.pro +++ /dev/null @@ -1,95 +0,0 @@ -PRO plot_aia_lightcurve, dir, FLARE_NUM = flare_num, index = index - -IF keyword_set(flare_num) THEN BEGIN - dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/'] - dir = dir[flare_num-1] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'ospex_*.fits') - hsi_fits = f[0] - - f = file_search(hsi_fits_dir + 'hsi_image*.fits') - hsi_image = f[0] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'hsi_spectrum*.fits') - hsi_spectrum = f[0] - - f = file_search(hsi_fits_dir + 'hsi_srm*.fits') - hsi_srm = f[0] - - ;['hsi_image_20110716_170350.fits', $ - ;'hsi_image_20110826_205258.fits', $ - ;'hsi_image_20110603_071626.fits', $ - ;'hsi_image_20110621_181902.fits'] - - print, dir - print, hsi_fits - print, hsi_image -ENDIF - -f = file_search(dir + 'teem_data_*.sav') - -ilist = strmid(filename(f), 10, 3) -time_list = unbreak_time(strmid(filename(f),13,15)) - -dim = n_elements(f) -!P.MULTI = [0,1,2] - -t = strarr(dim) -aia_lc = fltarr(5,dim) -dem_lc = fltarr(4,dim) - -restore, f[0], /verbose -fits2map, hsi_image, rmap -imap = inter_map(rmap,temperature_map) -m = max(imap.data) -index = where(imap.data LE m*0.5, complement = complement) - -FOR i = 0, dim-1 DO BEGIN - restore, f[i], /verbose - temperature_map.data[index] = 0 - - t[i] = temperature_map.time - dem_lc[0,i] = average(temperature_map.data[complement]) - dem_lc[1,i] = average(emission_map.data[complement]) - dem_lc[2,i] = average(sigma_map.data[complement]) - dem_lc[3,i] = average(chisq_map.data[complement]) - - FOR j = 0, 5-1 DO aia_lc[j,i] = average(aia_map_cube[j].data[complement]) - -ENDFOR - -charsize = 2.0 -!P.multi = [0,1,5] - -o = ospex(/no_gui) -o->set, spex_specfile = hsi_spectrum -o->set, spex_drmfile= hsi_srm -o->set, spex_eband=get_edge_products([4,15,25,50,100],/edges_2) - -o -> plot_time, /data, /no_plotman, this_band = [0,1], charsize = charsize, timerange = timerange, yrange = yrange, /ystyle - - -utplot, t, dem_lc[0,*], yrange = minmax(dem_lc[0,*]), ytitle = "log(Temperature [K])", /nodata, charsize = charsize -outplot, t, dem_lc[0,*], thick = 2 -utplot, t, dem_lc[1,*], yrange = minmax(dem_lc[1,*]), ytitle = "log(Emission Measure [cm!U-5!N])", charsize = charsize, /nodata -outplot, t, dem_lc[1,*], thick = 2 -utplot, t, dem_lc[2,*], yrange = minmax(dem_lc[2,*]), ytitle = "log(sigma [K])", charsize = charsize, /nodata -outplot, t, dem_lc[2,*], thick = 2 -utplot, t, dem_lc[3,*], yrange = minmax(dem_lc[3,*]), ytitle = textoidl('\chi^2'), charsize = charsize, /nodata -outplot, t, dem_lc[3,*], thick = 2 -stop - -!P.multi = [0,1,5] -FOR i = 0, 5-1 DO BEGIN - utplot, t, aia_lc[i,*], yrange = minmax(aia_lc[i,*]), ytitle = aia_map_cube[i].id, /nodata, charsize = charsize - outplot, t, aia_lc[i,*], thick = 2 -ENDFOR - -stop - -END \ No newline at end of file diff --git a/rhessi12_science_script.pro b/rhessi12_science_script.pro deleted file mode 100644 index edb03a2..0000000 --- a/rhessi12_science_script.pro +++ /dev/null @@ -1,54 +0,0 @@ - -;key -;flare 0 -;AIA files time ranges -;20110716_163301, 20110716_173259 -t0 = ['2011/07/16 16:33:01', '2011/07/16 17:32:59'] -;Flare 0: 11071604, B6.39, location = [-586, -437] -;16-jul-2011, 17:01, 17:03, 17:13 -;istart = 117, -; -;flare 1 - the limb -;AIA files time ranges -;20110826_202202, 20110826_212159 -t1 = ['2011/08/26 20:22:02', '2011/08/26 21:21:59'] -;Flare 1: 11082631, B4.16, location = [-908, -303] -;26-aug-2011, 20:51, 20:53, 20:58 -;istart = 130 -; -;flare 2 -;AIA files time ranges -;20110621_175201, 20110621_185159 -t2 = ['2011/06/21 17:52:01', '2011/06/21 18:51:59'] -;Flare 3: 11062114, B2.83, location [284, 263] -;21-Jun-2011, 18:19, 18:22, 18:24 -;istart = 113 -; - -;flare 3 -;AIA files time ranges -;20110603_064601, 20110603_074559 -t3 = ['2011/06/03 06:46:01', '2011/06/03 07:45:59'] -;Flare 3: 11060303, B3.69, location [19.04, -362.25] -;3-Jun-2011, 07:15, 07:16, 07:19 - -;flare 4 -; - -; TO DO, now do ospex fit -; 12 second integration -; do one time interval during impulsive phase of flare to compare -; multi_therm and a therm and bpow - -;need to create the dem for flare 3 -;make image for flare 3 -;plot light curves of slope for aia dem to compare with nonthermal HXR emission -;create light curves of "high temperature" filters of AIA to compare to rhessi - -;how does the area changes as a function of temperature? - -;to get goes lightcurves -lc = get_goes_lc(time_range) - -;to create plot overlays -plot_aia_dem_hist, flare_num = 1, index = 117, wave = 5 \ No newline at end of file From be24a216eb2074a4e6dc004e48db5aef654c96ea Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 09:49:08 -0400 Subject: [PATCH 40/44] deleting more old files. --- aia_hsi_dem_analysis_bksub.pro | 282 --------------------------- aia_hsi_dem_analysis_ratio_test.pro | 288 ---------------------------- aia_hsi_dem_results.pro | 40 ---- 3 files changed, 610 deletions(-) delete mode 100755 aia_hsi_dem_analysis_bksub.pro delete mode 100755 aia_hsi_dem_analysis_ratio_test.pro delete mode 100644 aia_hsi_dem_results.pro diff --git a/aia_hsi_dem_analysis_bksub.pro b/aia_hsi_dem_analysis_bksub.pro deleted file mode 100755 index be0ffab..0000000 --- a/aia_hsi_dem_analysis_bksub.pro +++ /dev/null @@ -1,282 +0,0 @@ -PRO aia_hsi_dem_analysis_bksub, DIR = dir, HSI_IMAGE = hsi_image, FILESET = fileset, FORCE_TABLE = force_table - -;first section should be to get the AIA fluxes based on the RHESSI image. Have some code that already does this. - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -teem_table='teem_table.sav' - - -file_list = get_aia_file_list(dir, fileset = fileset) -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;hardcoded this for 21 June 2011 flare -marker=120;120 - -;area of 1 AIA pixel in cm^2 -aia_pixel_area = 1.85589e+15 - - -t_min = 5.5 -t_max = 8.0 - -t_min = 6.0 -t_max = 7.5 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -tsig_min = 0.01 -tsig_max = 0.40 -tsig_d = 0.005 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -f = file_search(teem_table) - -area = aia_teem_pixel_area(file_list[0,0]) - -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area - - -; if a hsi_image was given then create a mask out of it -IF hsi_image[0] NE '' THEN BEGIN - fits2map, file_list[marker,0], aiamap - fits2map, hsi_image, hsimap - ; interpolate the rhessi map to the aia map - - mask_map = inter_map(hsimap,aiamap) - mask_map = drot_map(mask_map, time = aiamap.time) - m = max(mask_map.data) - ; set the mask at everything above 50% contour - index = where(mask_map.data LE m*0.5, complement = complement) - mask_map.data[index] = 0 - mask_map.data[complement] = 1 - - ; now define the inverse mask - invmask_map = mask_map - invmask_map.data[index] = 1 - invmask_map.data[complement] = 0 -ENDIF - -num_aia_pixels=total(mask_map.data) -print,num_aia_pixels - -flare_area=aia_pixel_area*num_aia_pixels -;stop - -;;;;;; - - - -default, save_dir, '' - -nwave = n_elements(wave_) -flux_ = fltarr(nwave) -texp_ = fltarr(nwave) - -file_iw = reform(file_list[marker,*]) - -file_bk_iw = reform(file_list(marker-70,*)) - -FOR iw = 0, nwave-1 DO BEGIN - - read_sdo,file_iw[iw],index,data - read_sdo,file_bk_iw[iw],index_bk,data_bk - - index2map,index,float(data),map - index2map,index_bk,float(data_bk),map_bk - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - sub_map, map_bk,smap_bk,xrange=xrange,yrange=yrange - map = smap - map_bk = smap_bk - data = smap.data - data_bk = smap_bk.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - image = data - texp = map.dur - texp_[iw]=texp - dateobs = map.time - - IF keyword_set(mask_map) then begin - mask = mask_map.data - ; zero out everything that is not in the mask - FOR k = 0, i2 DO BEGIN - FOR l = 0, j2 DO BEGIN - data[k,l] = data[k,l]*mask[k,l] - data_bk[k,l] = data_bk[k,l] * mask[k,l] - ENDFOR - ENDFOR - ENDIF - - flux_[iw] = total(data[i1:i2,j1:j2])/texp - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) - print,'Total flux in ', wave_(iw),flux_(iw) -ENDFOR - -;stop - -;then do the mapping using the AIA fluxes. Since RHESSI is basically 1 pixel for spectrum we only need one summed AIA pixel too. - - - - -restore, save_dir + teem_table, /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig - -nfree=3 - - -;flux_obs = reform(images[i,j,*]) - flux_obs = flux_ - counts = flux_obs*texp_ - ;stop - ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. - noise = 0.1*flux_obs;sqrt(counts)/texp_ - - chimin = 9999. - chi6min = 9999. - chimin_hsi=9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - chi2d_hsi = fltarr(nte,nsig) - em_2d = fltarr(nte,nsig) - em_2d_hsi = fltarr(nte,nsig) - model_count_flux_hsi = fltarr(nte,nsig,301) - real_count_flux_hsi = fltarr(nte,nsig,301) - - telog_err = [0,0] - sig_err = [0,0] - sig_errsymmetric = 0. - telog_errsymmetric = 0. - - FOR k=0, nte-1 DO BEGIN - FOR l = 0, nsig-1 DO BEGIN - flux_dem1 = reform(flux[k,l,*]) - em1 = total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - chi = sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - em_2d[k,l] = em1 - ;add in RHESSI - em_hsi=em1 /1e25 - em_hsi=em_hsi/1e24 ; - em_hsi=em_hsi*flare_area;39.*2e15 - IF (k eq 0) THEN BEGIN - em_hsi=em_hsi * (10^telog(1) - 10^telog(0)) - ENDIF ELSE BEGIN - em_hsi=em_hsi * (10^telog(k) - 10^telog(k-1)) - ENDELSE - em_2d_hsi[k,l]=em_hsi - get_hsi_table_entry,[em_hsi,telog(k),tsig(l)],model_count_flux,real_count_flux,axis,summary, obj=obj - - ;if the model function is all zeros then deal with this - typ=datatype(model_count_flux) - ;find the data type of model_count_flux. If there is no model flux at all then an integer of -1 will be - ;returned in place of the usual structure. - IF (typ eq 'INT') then begin - model_count_flux_hsi[k,l,*] = 0. - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = 9999. - ENDIF ELSE BEGIN - model_count_flux_hsi[k,l,*] = model_count_flux.yvals - real_count_flux_hsi[k,l,*] = real_count_flux - chi2d_hsi[k,l] = summary.spex_summ_chisq - ENDELSE - ;stop - IF (chi le chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[k] - sig_best = tsig[l] - flux_dem_best = flux_dem - - ENDIF - IF (chi2d_hsi[k,l] le chimin_hsi) THEN BEGIN - chimin_hsi=chi2d_hsi[k,l] - em_best_hsi=alog10(em1) - telog_best_hsi = telog[k] - sig_best_hsi = tsig[l] - model_count_flux_hsi_best=model_count_flux_hsi[k,l,*] - ENDIF - ENDFOR - ENDFOR - -; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin LT 9999.) THEN BEGIN - - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF - ENDIF - - - - ;window, 0 - ;loadct, 0 - ;hsi_linecolors - ;nlevels = 20 - ;levels = chimin * (findgen(nlevels)*0.1 + 1.0) - ;anot = strarr(20) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - ;oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - ;leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - ;legend, leg, psym = 4 - ;contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - ;window, 1 - ;emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - ;plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ;ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - - ; plot the RHESSI chi^2 map - ;hsi_levels = chimin_hsi * (findgen(nlevels)*0.1 + 1.0) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;window,5 - ;contour,chi_hsi,telog,tsig, levels = hsi_levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig',title='RHESSI X^2 map' - ;oplot, [telog_best_hsi], [sig_best_hsi], psym = symcat(16), color = 6 - ;leg = num2str(chimin_hsi) + '[' + num2str(telog_best_hsi) + ',' + num2str(sig_best_hsi) + ']' - ;legend, leg, psym = 4 - ;contour,chi_hsi,telog, tsig, levels=[chimin_hsi + 2.3],/over,thick=2, color = 6 - ;ENDIF - -;SAVE,chi2d,chi_hsi,axis,em_2d,em_2d_hsi,real_count_flux_hsi,model_count_flux_hsi,flux_dem_best,flux_dem,em_best,em_best_hsi,telog_best,$ -;telog_best_hsi,sig_best,sig_best_hsi,chimin,chimin_hsi,flare_area,filename='aia_hsi_fit_results_bk.sav',/verbose -; ;stop - -aia_hsi_fit_results=create_struct('chi_2d',chi2d,'chi2d_hsi',chi2d_hsi,'axis',axis,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ -'real_count_flux_hsi',real_count_flux_hsi,'model_count_flux_hsi',model_count_flux_hsi,'model_count_flux_hsi_best',model_count_flux_hsi_best,$ -'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'em_best_hsi',em_best_hsi,'telog_best',telog_best,'telog_best_hsi',telog_best_hsi,$ -'sig_best',sig_best,'sig_best_hsi',sig_best_hsi,'chimin',chimin,'chimin_hsi',chimin_hsi,'flare_area',flare_area,'telog',telog,'tsig',tsig) - -SAVE,aia_hsi_fit_results,filename='aia_hsi_fit_results_bksub.sav',/verbose - - - - - -END \ No newline at end of file diff --git a/aia_hsi_dem_analysis_ratio_test.pro b/aia_hsi_dem_analysis_ratio_test.pro deleted file mode 100755 index 72e9d2d..0000000 --- a/aia_hsi_dem_analysis_ratio_test.pro +++ /dev/null @@ -1,288 +0,0 @@ -PRO aia_hsi_dem_analysis_ratio_test, DIR = dir, HSI_IMAGE = hsi_image, FILESET = fileset, FORCE_TABLE = force_table - -;first section should be to get the AIA fluxes based on the RHESSI image. Have some code that already does this. - -;restore,'hsi_teem_table.sav',/verbose -;h=hsi_teem_table -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -teem_table='teem_table.sav' - - -file_list = get_aia_file_list(dir, fileset = fileset) -FOR i = 0, nwave-1 DO nfiles[i] = n_elements(file_list[*,i]) - -;hardcoded this for 21 June 2011 flare -marker=120;120 - -;area of 1 AIA pixel in cm^2 -aia_pixel_area = 1.85589e+15 - - -t_min = 5.5 -t_max = 8.0 - -t_min = 6.0 -t_max = 7.5 -t_d = 0.05 -telog = t_d * findgen((t_max - t_min)/t_d) + t_min - -tsig_min = 0.01 -tsig_max = 0.40 -tsig_d = 0.005 -tsig = tsig_d * findgen((tsig_max - tsig_min)/tsig_d) + tsig_min - -f = file_search(teem_table) - -area = aia_teem_pixel_area(file_list[0,0]) - -IF f[0] EQ '' OR keyword_set(FORCE_TABLE) THEN aia_teem_table, wave_, tsig, telog = telog, q94 = q94, teem_table, save_dir = save_dir, area = area - - -; if a hsi_image was given then create a mask out of it -IF hsi_image[0] NE '' THEN BEGIN - fits2map, file_list[marker,0], aiamap - fits2map, hsi_image, hsimap - ; interpolate the rhessi map to the aia map - - mask_map = inter_map(hsimap,aiamap) - mask_map = drot_map(mask_map, time = aiamap.time) - m = max(mask_map.data) - ; set the mask at everything above 50% contour - index = where(mask_map.data LE m*0.5, complement = complement) - mask_map.data[index] = 0 - mask_map.data[complement] = 1 - - ; now define the inverse mask - invmask_map = mask_map - invmask_map.data[index] = 1 - invmask_map.data[complement] = 0 -ENDIF - -num_aia_pixels=total(mask_map.data) -print,num_aia_pixels - -flare_area=aia_pixel_area*num_aia_pixels -;stop - -;;;;;; - - - -default, save_dir, '' - -nwave = n_elements(wave_) -flux_ = fltarr(nwave) -texp_ = fltarr(nwave) - -file_iw = reform(file_list[marker,*]) - -;file_bk_iw = reform(file_list(marker-100,*)) - -FOR iw = 0, nwave-1 DO BEGIN - - read_sdo,file_iw[iw],index,data -; read_sdo,file_bk_iw[iw],index_bk,data_bk - - index2map,index,float(data),map -; index2map,index_bk,float(data_bk),map_bk - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange -; sub_map, map_bk,smap_bk,xrange=xrange,yrange=yrange - map = smap -; map_bk = smap_bk - data = smap.data - ; data_bk = smap_bk.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - image = data - texp = map.dur - texp_[iw]=texp - dateobs = map.time - - IF keyword_set(mask_map) then begin - mask = mask_map.data - ; zero out everything that is not in the mask - FOR k = 0, i2 DO BEGIN - FOR l = 0, j2 DO BEGIN - data[k,l] = data[k,l]*mask[k,l] -; data_bk[k,l] = data_bk[k,l] * mask[k,l] - ENDFOR - ENDFOR - ENDIF - - flux_[iw] = total(data[i1:i2,j1:j2])/texp; - (total(data_bk[i1:i2,j1:j2])/map_bk.dur) - print,'Total flux in ', wave_(iw),flux_(iw) -ENDFOR - -;stop - -;then do the mapping using the AIA fluxes. Since RHESSI is basically 1 pixel for spectrum we only need one summed AIA pixel too. - - - - -restore, save_dir + teem_table, /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig - -nfree=3 - - -;flux_obs = reform(images[i,j,*]) - flux_obs = flux_ - counts = flux_obs*texp_ - ;stop - ;when we sum pixels up the noise level gets very low - but not realistic, due to uncertainty in T response functions. Set a baseline uncertainty level. - noise = 0.1*flux_obs;sqrt(counts)/texp_ - - chimin = 9999. - chi6min = 9999. - chimin_hsi=9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - chi2d_hsi = fltarr(nte,nsig) - em_2d = fltarr(nte,nsig) - em_2d_hsi = fltarr(nte,nsig) - model_count_flux_hsi = fltarr(nte,nsig,301) - real_count_flux_hsi = fltarr(nte,nsig,301) - ratio_test=fltarr(nte,nsig,6) - - telog_err = [0,0] - sig_err = [0,0] - sig_errsymmetric = 0. - telog_errsymmetric = 0. - - FOR k=0, nte-1 DO BEGIN - FOR l = 0, nsig-1 DO BEGIN - flux_dem1 = reform(flux[k,l,*]) - em1 = total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - chi = sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - em_2d[k,l] = em1 - - ratio_test[k,l,*]=flux_obs/flux_dem - - ;add in RHESSI - ;em_hsi=em1 /1e25 - ;em_hsi=em_hsi/1e24 ; - ;em_hsi=em_hsi*flare_area;39.*2e15 - ;IF (k eq 0) THEN BEGIN - ;em_hsi=em_hsi * (10^telog(1) - 10^telog(0)) - ;ENDIF ELSE BEGIN - ;em_hsi=em_hsi * (10^telog(k) - 10^telog(k-1)) - ;ENDELSE - ;em_2d_hsi[k,l]=h.em_best_hsi[k,l] - ;get_hsi_table_entry,[em_hsi,telog(k),tsig(l)],model_count_flux,real_count_flux,axis,summary, obj=obj - - ;if the model function is all zeros then deal with this - ;typ=datatype(model_count_flux) - ;find the data type of model_count_flux. If there is no model flux at all then an integer of -1 will be - ;returned in place of the usual structure. - ;IF (typ eq 'INT') then begin - ; model_count_flux_hsi[k,l,*] = 0. - ; real_count_flux_hsi[k,l,*] = real_count_flux - ; chi2d_hsi[k,l] = 9999. - ;ENDIF ELSE BEGIN - ; model_count_flux_hsi[k,l,*] = model_count_flux.yvals - ; real_count_flux_hsi[k,l,*] = real_count_flux - ; chi2d_hsi[k,l] = summary.spex_summ_chisq - ;ENDELSE - ;stop - IF (chi le chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[k] - sig_best = tsig[l] - flux_dem_best = flux_dem - - ENDIF - ;IF (chi2d_hsi[k,l] le chimin_hsi) THEN BEGIN - ; chimin_hsi=chi2d_hsi[k,l] - ; em_best_hsi=alog10(em1) - ; telog_best_hsi = telog[k] - ; sig_best_hsi = tsig[l] - ; model_count_flux_hsi_best=model_count_flux_hsi[k,l,*] - ;ENDIF - ENDFOR - ENDFOR - -; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin LT 9999.) THEN BEGIN - - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF - ENDIF - - - - ;window, 0 - ;loadct, 0 - ;hsi_linecolors - ;nlevels = 20 - ;levels = chimin * (findgen(nlevels)*0.1 + 1.0) - ;anot = strarr(20) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - ;oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - ;leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - ;legend, leg, psym = 4 - ;contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - ;window, 1 - ;emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - ;plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ;ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - - ; plot the RHESSI chi^2 map - ;hsi_levels = chimin_hsi * (findgen(nlevels)*0.1 + 1.0) - ;FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - ;window,5 - ;contour,chi_hsi,telog,tsig, levels = hsi_levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig',title='RHESSI X^2 map' - ;oplot, [telog_best_hsi], [sig_best_hsi], psym = symcat(16), color = 6 - ;leg = num2str(chimin_hsi) + '[' + num2str(telog_best_hsi) + ',' + num2str(sig_best_hsi) + ']' - ;legend, leg, psym = 4 - ;contour,chi_hsi,telog, tsig, levels=[chimin_hsi + 2.3],/over,thick=2, color = 6 - ;ENDIF - -;SAVE,chi2d,chi_hsi,axis,em_2d,em_2d_hsi,real_count_flux_hsi,model_count_flux_hsi,flux_dem_best,flux_dem,em_best,em_best_hsi,telog_best,$ -;telog_best_hsi,sig_best,sig_best_hsi,chimin,chimin_hsi,flare_area,filename='aia_hsi_fit_results_bk.sav',/verbose -; ;stop - -aia_hsi_fit_results=create_struct('chi_2d',chi2d,'chi2d_hsi',chi2d_hsi,'em_2d',em_2d,'em_2d_hsi',em_2d_hsi,$ -$ -'flux_dem_best',flux_dem_best,'flux_dem',flux_dem,'em_best',em_best,'telog_best',telog_best,$ -'sig_best',sig_best,'chimin',chimin,'chimin_hsi',chimin_hsi,'flare_area',flare_area,'ratio_test',ratio_test) - -SAVE,aia_hsi_fit_results,filename='aia_hsi_fit_results_ratio_test.sav',/verbose - -SAVE,wave_,flux_obs,num_aia_pixels,filename='aia_fluxes_from_20110621_182200.sav' - - - -END \ No newline at end of file diff --git a/aia_hsi_dem_results.pro b/aia_hsi_dem_results.pro deleted file mode 100644 index 8bed702..0000000 --- a/aia_hsi_dem_results.pro +++ /dev/null @@ -1,40 +0,0 @@ -PRO aia_hsi_dem_results, filename - -;FUNCTION to plot results from aia_hsi_dem_analysis - -restore, filename -res = aia_fit_results - -print, 'Analysis Summary' -print, '================' -print, '' -print, 'Model = ' + res.model -print, 'Fit Results' -print, '-----------' -print, 'log(Te) = ' + num2str(res.telog_best, length = 5) + ' (' + num2str(10^res.telog_best/1d6, length = 5) + ' MK)' -print, 'sigma = ' + num2str(res.sig_best, length = 5) -print, 'Tmin = ' + num2str(res.telog_best - res.sig_best, length = 5) + ' (' + num2str(10^(res.telog_best - res.sig_best)/1d6, length = 5) + ' MK)' -print, 'Tmax = ' + num2str(res.telog_best + res.sig_best, length = 5) + ' (' + num2str(10^(res.telog_best + res.sig_best)/1d6, length = 5) + ' MK)' -print, 'Emission measure = ' + num2str(10d^res.em_best) + ' cm^5' -print, 'chi^2 = ' + num2str(res.chimin, length = 5) - -window, 0 -plot_aia_flux_ratios, /epstein - -window, 1 -plot_dem_result, /epstein - -plot_xray_spectrum_from_dem, res.em_best, res.telog_best, res.sig_best, n=10, flare_area=res.flare_area, /epstein, eph = eph, photons = ph - -oplot, e.mean, ph_flux - -ssw_legend, leg - -foxsi_area = get_foxsi_effarea(energy_arr = e.mean, /per_module, /plot) - -cts = ph_flux*foxsi_area.eff_area_cm2 - -plot, e.mean, ph_flux, xrange = [5,20], psym = 10, ytitle = 'FOXSI Count rate', yrange = [0,50] - -END - From 92ffb232a658d3cb0088fed49304d26d849ec5d4 Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 09:55:58 -0400 Subject: [PATCH 41/44] deleting more files. --- aia_lightcurve.pro | 73 ----------------- analysis_script.pro | 58 ------------- plot_surfaces.pro | 158 ------------------------------------ plot_xray_spectra_pixel.pro | 118 --------------------------- 4 files changed, 407 deletions(-) delete mode 100644 aia_lightcurve.pro delete mode 100644 analysis_script.pro delete mode 100755 plot_surfaces.pro delete mode 100644 plot_xray_spectra_pixel.pro diff --git a/aia_lightcurve.pro b/aia_lightcurve.pro deleted file mode 100644 index 226735e..0000000 --- a/aia_lightcurve.pro +++ /dev/null @@ -1,73 +0,0 @@ -FUNCTION aia_lightcurve, DIR = dir, HSI_FITS = hsi_fits, DEBUG = debug, PLOT = plot, ISTART = istart, IEND = iend, MASK_LEVEL = mask_level, WAVE_LIST = wave_list - -; PURPOSE: Given a directory full of AIA images, generate a light curve -; of the integrated flux over the image. -; -; KEYWORDS: HSI_FITS - defines a mask. Only includes pixels above masklevel -; MASK_LEVEL - defines the level (in percent of max) above which -; pixels will be included if using a mask -; ISTART - begin the light curve from the istart file (to speed up) -; IEND - end the light curve at the iend file (to speed up) -; WAVE_LIST - set the wavelength -; -; WRITTEN: Steven Christe (8-Oct-2011) -; MODIFIED: Steven Christe (26-Oct-2011) - -default, dir, '/Users/schriste/Desktop/flare_0_aia/' -;fileset = file_search(dir + 'ssw_cutout_20110716_*') -default, hsi_fits, '/Users/schriste/Desktop/flare_0_rhessi/hsi_image_20110716_170350.fits' -default, istart, 0 -default, mask_level, 50 - -IF NOT KEYWORD_SET(WAVE_LIST) THEN wave_list =['131','171','193','211','335','94'] -nwave = n_elements(wave_list) - -file_list = get_aia_file_list(dir, wave_list = wave_list) -nfiles = n_elements(file_list[*,0]) - -IF keyword_set(HSI_FITS) THEN BEGIN - fits2map, file_list[0,0], aiamap - fits2map, hsi_fits, map - ; interpolate the rhessi map to the aia map - imap = inter_map(map,aiamap) - m = max(imap.data) - ; set the mask at everything above 50% contour - index = where(imap.data LE m*mask_level/100.0, complement = complement) - imap.data[index] = 0 - imap.data[complement] = 1 - mask = imap.data - inverse_mask = NOT mask -ENDIF - -result = dblarr(nwave,2,nfiles) - -IF NOT keyword_set(iend) THEN iend = nfiles - -FOR j = 0, nwave-1 DO BEGIN - FOR i = istart, iend-1 DO BEGIN - fits2map, file_list[i,j], aiamap - result[j,0,i] = anytim(aiamap.time) - IF keyword_set(hsi_fits) THEN BEGIN - imap_rot = drot_map(imap, ref_map = aiamap) - aiamap.data = aiamap.data * imap_rot.data - ENDIF - result[j,1,i] = total(aiamap.data) - ENDFOR -ENDFOR - -IF keyword_set(PLOT) THEN BEGIN - loadct,0 - hsi_linecolors - P.MULTI = [0,1,nwave] - charsize = 1.5 - FOR j = 0, nwave-1 DO BEGIN - yrange = minmax(result[j,1,*]) - utplot, anytim(result[j,0,*],/yoh), result[j,1,*], /nodata, yrange = yrange, charsize = charsize - outplot, anytim(result[j,0,*],/yoh), result[j,1,*], color = 6, thick = 2.0 - legend, wave_list[j] + ' A', /right, charsize = charsize, color = 6 - ENDFOR -ENDIF - -IF keyword_set(DEBUG) THEN stop - -END \ No newline at end of file diff --git a/analysis_script.pro b/analysis_script.pro deleted file mode 100644 index c292f03..0000000 --- a/analysis_script.pro +++ /dev/null @@ -1,58 +0,0 @@ -PRO - -aia_dir = '/Users/schriste/Desktop/foxsi_aia_data/' -dir = '/Users/schriste/Dropbox/idl/schriste/foxsi_obs/' - -file_list = file_search(aia_dir + 'ssw_cutout_20121102_18034*') - -hsi_image = dir + 'hsi_image_20121102_175924.fits - -fits2map, hsi_image, rmap - -fileset = 'ssw_cutout' -fit_time = ['2012/11/02 18:00:00', '2012/11/02 18:05:00'] -bkg_time = fit_time - -aia_hsi_dem_analysis, fit_time = fit_time, bkg_time = bkg_time, dir = aia_dir, FILESET = fileset, /force_table, /aia_only, /epstein, hsi_image = hsi_image - -filename = 'aia_fit_results_epstein.sav' -aia_hsi_dem_results, filename - - - - - - - -aia_hsi_dem_analysis, dir = aia_dir, HSI_IMAGE = hsi_image, FILESET = fileset, /force_table, /aia_only, /epstein - -!P.multi = [0,2,3] - -xrange = [850,1050] -yrange = [-300,-100] - -ps, 'aia_rhessi.ps', /color, /portrait - -wavelength = ['94', '131', '171', '193', '211', '304', '335'] -dmin = [50,50,50,50,50,50,50] -dmax = [400,400,3000,5000,4000,400] - -FOR i = 0, n_elements(file_list)-1 DO BEGIN - - fits2map, file_list[i], aia_map - fname = file_basename(file_list[i]) - w = str_replace(strmid(fname,7,3, /reverse_offset), '_', '') - - index = where(wavelength EQ w) - print, w[index] - aia_lct, r, g, b, wavelnth = w, /load - hsi_linecolors - - plot_map, aia_map, bottom = 13, xrange = xrange, yrange = yrange, title = strmid(aia_map.time,0,20), dmin = dmin[index], dmax = dmax[index], grid = 10, /limb, charsize = 1.5 - plot_map, rmap, /over, levels = [50,60,70,80,90], /percent, color = 6 - legend, w, textcolor = 1 -ENDFOR - -psclose - -END \ No newline at end of file diff --git a/plot_surfaces.pro b/plot_surfaces.pro deleted file mode 100755 index 4078a9f..0000000 --- a/plot_surfaces.pro +++ /dev/null @@ -1,158 +0,0 @@ -PRO plot_surfaces,ps=ps - -restore,'aia_hsi_fit_results_fineres.sav',/verbose - -restore,'hsi_teem_table.sav',/verbose - -a=aia_hsi_fit_results - -h=hsi_teem_table - -loadct,3 - - -IF keyword_set(ps) THEN BEGIN -set_plot,'ps' -device,encaps=1,color=1,bits_per_pixel=16,xsize=30,ysize=25,filename='surfaces1.ps' -ENDIF ELSE BEGIN -window,1,xsize=1024,ysize=1024 -ENDELSE -!p.multi=[0,2,2] - -shade_surf,a.chi2d_hsi,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,/zlog,az=50,ax=30,xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='RHESSI chi^2 map' -shade_surf,a.chi2d_hsi,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,/zlog,az=-130,ax=30,xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='RHESSI chi^2 map' - -shade_surf,a.chi_2d,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=30,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='AIA chi^2 map' -shade_surf,a.chi_2d,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=-130,ax=30,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='AIA chi^2 map' - -xyouts,0.43,0.95,'RHESSI chi^2 map',/norm,charsize=2 -xyouts,0.43,0.45,'AIA chi^2 map',/norm,charsize=2 - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=16,xsize=30,ysize=25,filename='surfaces2.ps' -ENDIF ELSE BEGIN -window,2,xsize=1024,ysize=1024 -ENDELSE - -shade_surf,h.chi_best_hsi,h.telog,h.tsig,charsize=3,az=50,ax=30,zrange=[20,80],xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='RHESSI chi^2 map' -shade_surf,h.chi_best_hsi,h.telog,h.tsig,charsize=3,az=-130,ax=30,zrange=[20,80],xtitle='log T (K)',ytitle='sigma',ztitle='chi^2';,title='RHESSI chi^2 map' - -shade_surf,h.em_best_hsi,h.telog,h.tsig,charsize=3,az=50,ax=30,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='EM (cm^-3)';,title='RHESSI EM map' -shade_surf,h.em_best_hsi,h.telog,h.tsig,charsize=3,az=-130,ax=30,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='EM (cm^-3)';,title='RHESSI EM map' - -xyouts,0.43,0.95,'RHESSI chi^2 map',/norm,charsize=2 -xyouts,0.43,0.45,'RHESSI EM map',/norm,charsize=2 - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=16,xsize=25,ysize=15,filename='surfaces3.ps' -ENDIF ELSE BEGIN -window,3,xsize=1024,ysize=512 -ENDELSE - - -!p.multi=[0,2,1] - -loadct,39 -nlevels = 50 -levels = a.chimin_hsi * (findgen(nlevels)*0.2 + 1.0) -contour, a.chi2d_hsi,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,levels=levels,xtitle='log T (K)',ytitle='sigma',title='RHESSI chi^2 map' -oplot, [a.telog_best_hsi], [a.sig_best_hsi], psym = 2, color = 240,symsize=2 -contour,a.chi2d_hsi,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01, levels=[a.chimin_hsi + 2.3],/over,thick=2, color = 240 - -levels = a.chimin * (findgen(nlevels)*0.2 + 1.0) -contour, a.chi_2d,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,levels=levels,xtitle='log T (K)',ytitle='sigma',title='AIA chi^2 map' -oplot, [a.telog_best], [a.sig_best], psym = 2, color = 240,symsize=2 -contour,a.chi_2d,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01, levels=[a.chimin + 2.3],/over,thick=2, color = 240 - - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=16,xsize=20,ysize=15,filename='surfaces4.ps' -ENDIF ELSE BEGIN -window,4 -ENDELSE - - -nlevels = 50 -levels = MIN(h.chi_best_hsi,pos) * (findgen(nlevels)*0.2 + 1.0) -contour, h.chi_best_hsi,h.telog,h.tsig,levels=levels,xtitle='log T (K)',ytitle='sigma',title='RHESSI chi^2 map' -pos=array_indices(h.chi_best_hsi,pos) -oplot, [h.telog[pos[0]]], [h.tsig[pos[1]]], psym = 2, color = 240,symsize=2 -contour, h.chi_best_hsi,h.telog,h.tsig,levels=[MIN(h.chi_best_hsi) + 2.3],/over,thick=2, color = 240 - -nlevels = 50 -levels = MIN(h.em_best_hsi,pos) * (findgen(nlevels)*0.2 + 1.0) -contour, h.em_best_hsi,h.telog,h.tsig,levels=levels,xtitle='log T (K)',ytitle='sigma',title='RHESSI EM map' -pos=array_indices(h.em_best_hsi,pos) -;oplot, [h.telog[pos[0]]], [h.tsig[pos[1]]], psym = 2, color = 240,symsize=2 -;contour, h.em_best_hsi,h.telog,h.tsig,levels=[a.chimin_hsi + 2.3],/over,thick=2, color = 240 - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=16,xsize=20,ysize=15,filename='surfaces5.ps' -ENDIF ELSE BEGIN -window,5 -ENDELSE - -loadct,3 -!p.multi=[0,1,1] -shade_surf,a.em_2d_hsi/h.em_best_hsi,findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=30,/zlog,zrange=[1e-2,1e4] - -xyouts,0.43,0.95,'AIA / RHESSI EM ratio',/norm,charsize=2 - - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=25,xsize=30,ysize=15,filename='surfaces6.ps' -ENDIF ELSE BEGIN -window,5 -ENDELSE -restore,'aia_hsi_fit_results_ratio_test.sav',/verbose -r=aia_hsi_fit_results - - -!p.multi=[0,3,2] -shade_surf,r.ratio_test[*,*,0],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' -shade_surf,r.ratio_test[*,*,1],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' -shade_surf,r.ratio_test[*,*,2],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' -shade_surf,r.ratio_test[*,*,3],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' -shade_surf,r.ratio_test[*,*,4],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' -shade_surf,r.ratio_test[*,*,5],findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,charsize=3,az=50,ax=40,/zlog,xtitle='log T (K)',ytitle='sigma',ztitle='FLUX_OBS/FLUX_MOD' - -xyouts,0.2,0.95,'131A',/norm,charsize=1.5 -xyouts,0.5,0.95,'171A',/norm,charsize=1.5 -xyouts,0.8,0.95,'193A',/norm,charsize=1.5 -xyouts,0.2,0.45,'211A',/norm,charsize=1.5 -xyouts,0.5,0.45,'335A',/norm,charsize=1.5 -xyouts,0.8,0.45,'94A',/norm,charsize=1.5 - -IF keyword_set(ps) THEN BEGIN -device,/close -device,encaps=1,color=1,bits_per_pixel=25,xsize=30,ysize=15,filename='surfaces7.ps' -ENDIF ELSE BEGIN -window,5 -ENDELSE -;restore,'aia_hsi_fit_results_ratio_test.sav',/verbose -;r=aia_hsi_fit_results - - -contour,alog10(r.ratio_test[*,*,0]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'131A',/right -contour,alog10(r.ratio_test[*,*,1]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'171A',/right -contour,alog10(r.ratio_test[*,*,2]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'193A',/right -contour,alog10(r.ratio_test[*,*,3]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'211A',/right -contour,alog10(r.ratio_test[*,*,4]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'335A',/right -contour,alog10(r.ratio_test[*,*,5]),findgen(30)*0.05 + 6.,findgen(78)*0.005 + 0.01,xtitle='log T (K)',ytitle='sigma',title='FLUX_OBS/FLUX_MOD',nlevels=100 -ssw_legend,'94A',/right -IF keyword_set(ps) THEN BEGIN -device,/close -set_plot,'x' -ENDIF - -END \ No newline at end of file diff --git a/plot_xray_spectra_pixel.pro b/plot_xray_spectra_pixel.pro deleted file mode 100644 index 963cd87..0000000 --- a/plot_xray_spectra_pixel.pro +++ /dev/null @@ -1,118 +0,0 @@ -PRO plot_xray_spectra_pixel, files = files, OUTPS = outps - -IF keyword_set(OUTPS) THEN BEGIN - loadct, 0 - hsi_linecolors - popen, 'plot_xray_spectra_pixel', xsize = 7, ysize = 6 -ENDIF - -default, dir, '/Users/schriste/Dropbox/idl/aia_deem/' - -restore, dir + 'teem_data_00020110215_000009_innercore_npix10.sav', /verbose - -IF NOT keyword_set(files) THEN BEGIN - s = size(te_map) - dimx = s[1] - dimy = s[2] -ENDIF ELSE BEGIN - dimx = 1 - dimy = n_elements(files) -ENDELSE - -fexxi_fexvii_data = te_map -fexxiii_data = te_map -ni_vi_data = te_map - -FOR i = 0, dimx-1 DO BEGIN - FOR j = 0, dimy-1 DO BEGIN - - IF NOT keyword_set(files) THEN fname = dir + 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' $ - ELSE fname = files[j] - - print, 'Search for ', fname - f = file_search(fname) - IF f[0] NE '' THEN BEGIN - - restore, f[0], /verbose - - !P.MULTI = [0,1,4] - - plot, telog, emlog, xtitle = 'log(Temperature [K]', ytitle = 'log(Emission measure)', /nodata, charsize = 2.0, ytickf = 'exp1', title = 'i = ' + num2str(i) + ', j = ' + num2str(j) - oplot, telog, emlog, thick = 1.0 - - plot, r[0,*], r[1,*], /nodata, xtitle = 'Energy [keV]', ytitle = 'Flux', /ylog, charsize = 2.0 - oplot, r[0,*], r[1,*] - - xrange = [0.95, 1.15] - con1 = r[0,*] GE xrange[0] - con2 = r[0,*] LE xrange[1] - index = where(con1 AND con2) - - plot, r[0,index], r[1,index], /nodata, xtitle = 'Energy [keV]', ytitle = 'Flux', /ylog, charsize = 2.0 - oplot, r[0,index], r[1,index], psym = 10 - - xrange = [6.0, 7.0] - con1 = r[0,*] GE xrange[0] - con2 = r[0,*] LE xrange[1] - index = where(con1 AND con2) - - plot, r[0,index], r[1,index], /nodata, xtitle = 'Energy [keV]', ytitle = 'Flux', /ylog, charsize = 2.0 - oplot, r[0,index], r[1,index], psym = 10 - - fexxi_fexvii = [1.020, 1.024] - fexxiii = [1.008, 1.014] - ni_vi = [0.41, 0.44] - - xrange = fexxi_fexvii - con1 = r[0,*] GE xrange[0] - con2 = r[0,*] LE xrange[1] - index = where(con1 AND con2) - fexxi_fexvii_data[i,j] = total(r[1,index]) - - xrange = fexxiii - con1 = r[0,*] GE xrange[0] - con2 = r[0,*] LE xrange[1] - index = where(con1 AND con2) - fexxiii_data[i,j] = total(r[1,index]) - - xrange = ni_vi - con1 = r[0,*] GE xrange[0] - con2 = r[0,*] LE xrange[1] - index = where(con1 AND con2) - ni_vi_data[i,j] = total(r[1,index]) - - - ENDIF - ENDFOR -ENDFOR -loadct, 0 - - -!P.multi = 0 - -plot_map, emission_map, dmin = 22 -plot_map, temperature_map, dmin = 6 - -map_fexxi_fexvii = aia_map_cube[0] -map_fexxi_fexvii.data = fexxi_fexvii_data -map_fexxi_fexvii.id = 'Fe XXI, FeXVII' - -plot_map, map_fexxi_fexvii - -map_fexxiii = aia_map_cube[0] -map_fexxiii.data = fexxiii_data -map_fexxiii.id = 'Fe XXIII' - -plot_map, map_fexxiii - -ni_vi = aia_map_cube[0] -ni_vi.data = ni_vi_data -ni_vi.id = 'Ni VI' - -plot_map, ni_vi - -stop - -IF keyword_set(OUTPS) THEN pclose - -END \ No newline at end of file From 2e37b5f1579aad44576184805f1f6774d7199b93 Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 10:01:39 -0400 Subject: [PATCH 42/44] more deleting files. --- aia_teem_stats.pro | 115 ------------------------------ ar_script.pro | 58 --------------- fig_aia_deem_overview_imaging.pro | 115 ------------------------------ fig_rhessi_lc_overview.pro | 56 --------------- oct162011_analyze_deem.pro | 88 ----------------------- temp_flareteem_info.pro | 33 --------- 6 files changed, 465 deletions(-) delete mode 100644 aia_teem_stats.pro delete mode 100644 ar_script.pro delete mode 100644 fig_aia_deem_overview_imaging.pro delete mode 100644 fig_rhessi_lc_overview.pro delete mode 100644 oct162011_analyze_deem.pro delete mode 100644 temp_flareteem_info.pro diff --git a/aia_teem_stats.pro b/aia_teem_stats.pro deleted file mode 100644 index 388ca16..0000000 --- a/aia_teem_stats.pro +++ /dev/null @@ -1,115 +0,0 @@ -PRO aia_teem_stats, filename, OUTPLOT = outplot, outfile = outfile, totfile = totfile - -default, filename, '/Users/schriste/Dropbox/idl/aia_deem/tempmap_000.sav' -default, wave_, ['131','171','193','211','335','94'] -default, charsize, 1.5 -default, outfile, 'aia_teem_stats' -default, totfile, '/Users/schriste/Dropbox/idl/aia_deem/teem_tot_00020110803_182309.sav' -nwave =n_elements(wave_) - -;dir = '/Users/schriste/data/sdo/aia/ar11263/' -;fileset = 'AIA' -;fov = [-198.857, 200.000, 50.0, 350.000] - -;aia_teem_movie, dir = dir, fileset = fileset, fov = fov, npix = 4 - -restore, filename - -IF keyword_set(OUTPLOT) THEN popen, outfile, xsize = 4, ysize = 6 - -!P.MULTI = [0,2,6] -FOR i = 0, nwave-1 DO BEGIN - aia_lct, rr, gg, bb, wavelnth=wave_[i], /load - plot_map, aia_map_cube[i] - dmap = diff_map(aia_map_cube[i], aia_simul_map_cube[i]) - plot_map, dmap, title = 'obs - simul' -ENDFOR - -!P.MULTI = 0 - -loadct, 5 -plot_map, temperature_map, charsize = charsize, /cbar -loadct, 0 -plot_map, emission_map, charsize = charsize, /cbar -plot_map, sigma_map, charsize = charsize, /cbar - -loadct, 0 -plot_map, chisq_map, dmin = 0, dmax = 10, /cbar - -loadct, 0 -plot_map, TSIG_ERROR_MAP_MINUS, charsize = 1.0 -plot_map, TSIG_ERROR_MAP_PLUS, charsize = 1.0 -plot_map, TELOG_ERROR_MAP_MINUS, charsize = 1.0 -plot_map, TELOG_ERROR_MAP_PLUS, charsize = 1.0 - -!P.MULTI = [0,1,2] - -;look at the statistics of the fits - -ratio_map = aia_map_cube -FOR i = 0, nwave-1 DO BEGIN - newdata = (aia_map_cube[i].data - aia_simul_map_cube[i].data)/(aia_map_cube[i].data) - ratio_map[i].data = newdata -ENDFOR - -;plot_map, ratio_map[0], dmin = -2.0, dmax = 2.0,/cbar -hist = histogram(ratio_map[0].data, binsize = 0.1, min = -2.0, max =2.0, locations = loc) -plot, loc, hist, psym = 10, /nodata, xtitle = 'ratio (obs-fit)/obs', charsize = 1.5 - -loadct, 0 -hsi_linecolors -colors = findgen(nwave)+2 -FOR i = 0, nwave-1 DO BEGIN - hist = histogram(ratio_map[i].data, binsize = 0.1, min = -2.0, max =2.0, locations = loc) - oplot, loc, hist, psym = 10, linestyle = 0, color = colors[i], thick = 2.0 -ENDFOR - -legend, wave_, color = colors, linestyle = 0, pspacing = 0.5 - -hist = histogram(aia_map_cube[0].data, binsize = 1, min = 0, max = 150, locations = loc) - -plot, loc, hist, psym = 10, /nodata, xtitle = 'obs flux', charsize = charsize - -loadct, 0 -hsi_linecolors -colors = findgen(nwave)+1 -FOR i = 0, nwave-1 DO BEGIN - hist = histogram(aia_map_cube[i].data, binsize = 1, min = 0, max = 150, locations = loc) - oplot, loc, hist, psym = 10, linestyle = 0, color = colors[i] -ENDFOR - -legend, wave_, color = colors, linestyle = 0, pspacing = 0.5 - -hist = histogram(temperature_map[0].data, binsize = 0.1, min = 5.5, max = 7.0 , locations = loc) -plot, loc, hist, psym = 10, /nodata, xtitle = 'log(temperature)', charsize = charsize -oplot, loc, hist, psym = 10, linestyle = 0 - -hist = histogram(emission_map[0].data, binsize = 0.1, min = min(emission_map[0].data), max = max(emission_map[0].data) , locations = loc) -plot, loc, hist, psym = 10, /nodata, xtitle = 'log(emission measure)', charsize = charsize -oplot, loc, hist, psym = 10, linestyle = 0 - -hist = histogram(sigma_map[0].data, binsize = 0.1, min = 0, max = 1.0, locations = loc) -plot, loc, hist, psym = 10, /nodata, xtitle = 'sigma map', charsize = charsize -oplot, loc, hist, psym = 10, linestyle = 0 - -hist = histogram(chisq_map[0].data, binsize = 0.1, min = 0, max = 10 , locations = loc) -plot, loc, hist, psym = 10, /nodata, xtitle = 'chi sq', charsize = charsize -oplot, loc, hist, psym = 10, linestyle = 0 -oplot, [1,1], [0,1d10], linestyle = 1 - -f = file_search(totfile) -!P.multi = 0 -IF keyword_set(totfile) AND f[0] NE '' THEN BEGIN - restore, totfile - hsi_linecolors - - yrange = [min(emlog), max(emlog)] - plot, telog, emlog, xtitle = 'log(Temperature [MK])', ytitle = 'log(Emmission Measure [cm!U-5!N])', /nodata, yrange = yrange, /ystyle,title = cur_time, charsize = 2.0 - - oplot, telog, emlog, thick = 2.0, linestyle = 1, psym = symcat(16), color = 6 - oploterr, telog, emlog, emlog_err, /nohat, color = 6, errcolor = 6 -ENDIF - -IF keyword_set(OUTPLOT) THEN pclose - -END \ No newline at end of file diff --git a/ar_script.pro b/ar_script.pro deleted file mode 100644 index 6364ef1..0000000 --- a/ar_script.pro +++ /dev/null @@ -1,58 +0,0 @@ - -;standard AR - -xrange = [-28.5000, 571.500] -yrange = [-508.5, 121.500] - -aia_teem_movie, xrange = xrange, yrange = yrange, fileset = 'AIA', npix = 1, macro_dem = 10 - -restore, '/Users/schriste/Dropbox/idl/aia_deem/teem_data_00020110215_000009_npix1.sav', /verbose - -wave_ =['131','171','193','211','335','94'] - -aia_lct, rr, gg, bb, wavelnth=wave_[0], /load -plot_map, AIA_MAP_CUBE[0], /limb, /log - -aia_lct, rr, gg, bb, wavelnth=wave_[1], /load -plot_map, AIA_MAP_CUBE[1], /limb, /log - -aia_lct, rr, gg, bb, wavelnth=wave_[2], /load -plot_map, AIA_MAP_CUBE[2], /limb, /log - -aia_lct, rr, gg, bb, wavelnth=wave_[3], /load -plot_map, AIA_MAP_CUBE[3], /limb, /log - -aia_lct, rr, gg, bb, wavelnth=wave_[4], /load -plot_map, AIA_MAP_CUBE[4], /limb, /log - -aia_lct, rr, gg, bb, wavelnth=wave_[5], /load -plot_map, AIA_MAP_CUBE[5], /limb, /log - -loadct, 5 -plot_map, temperature_map, dmin = 6, /cbar -loadct, 1 -plot_map, emission_map, /cbar, dmin = 20 - - - -aia_teem_movie, xrange = xrange, yrange = yrange, fileset = 'AIA', npix = 10, /verbose - -restore, '/Users/schriste/Dropbox/idl/aia_deem/teem_data_00020110215_000009_npix10.sav', /verbose - -restore, '/Users/schriste/Dropbox/idl/aia_deem/teem_tot_00020110215_000009_q94_67.sav' -r = chianti_spec_from_dem(telog, emlog, /plot) - -xrange = [274.20, 280.20] -yrange = [-283.80, -277.80] - -aia_teem_movie, xrange = xrange, yrange = yrange, fileset = 'AIA', npix = 1 - -xrange = [130, 190] -yrange = [-283.80, -187.80] - -aia_teem_movie, xrange = xrange, yrange = yrange, fileset = 'AIA', npix = 10, /verbose, /force_table - -oplot, [xrange[0], xrange[0]], [yrange[0], yrange[1]] -oplot, [xrange[1], xrange[1]], [yrange[0], yrange[1]] -oplot, [xrange[0], xrange[1]], [yrange[0], yrange[0]] -oplot, [xrange[0], xrange[1]], [yrange[1], yrange[1]] \ No newline at end of file diff --git a/fig_aia_deem_overview_imaging.pro b/fig_aia_deem_overview_imaging.pro deleted file mode 100644 index b9f6873..0000000 --- a/fig_aia_deem_overview_imaging.pro +++ /dev/null @@ -1,115 +0,0 @@ -PRO fig_aia_deem_overview_imaging, FORCE = force, OUTPS = outps, filename = filename, image_algo = image_algo, image_wave = image_wave, energy_range = energy_range, _EXTRA = _EXTRA - -default, filename, 'fig_aia_deem_overview_imaging' -default, charsize, 1.5 -default, thick, 2.0 -default, image_algo, 'clean' -default, image_wave, 5 -default, energy_range, [4,10] - -;example fig_aia_deem_overview_imaging, dmin = 6, /log - -;vis fwdfit -;mem njit -;uv_smooth - -;energy_range = [[4.0000000D, 10.000000D], [15.000000D, 30.000000D]] -wave = ['131','171','193','211','335','94'] - -!P.MULTI = [0,2,2] -;flare 0 - -image_wave = 5 - -tr0 = [['03-jun-2011 07:16', '03-jun-2011 07:17'], $ - ['21-jun-2011 18:22', '21-jun-2011 18:23'], $ - ['16-Jul-2011 17:02:01.424', '16-Jul-2011 17:02:56.116'], $ - ['26-aug-2011 20:52', '26-aug-2011 20:53']] - -dir_aia = '/Users/schriste/Desktop/' + ['hsi_flare_20110603_071626/', 'hsi_flare_20110621_182202/', 'hsi_flare_20110716_170350/', 'hsi_flare_20110826_205258/'] - -aia_image_index = [123,121,120,120] - -IF keyword_set(OUTPS) THEN BEGIN - charsize = 1.0 - popen, filename, xsize = 6, ysize = 6 -ENDIF - -FOR i = 0, 4-1 DO BEGIN - - tr0_str = break_time(tr0[0,i]) - hsi_image_fname = 'hsi_image_' + tr0_str + '_' + image_algo + '.fits' - - file_list = get_aia_file_list(dir_aia[i]) - aia_times = aiacutout_to_time(file_list[*,image_wave]) - - aia_file = file_list[aia_image_index[i], image_wave] - aia_bkg_file = file_list[0,image_wave] - - f = file_search(hsi_image_fname) - - IF f[0] EQ '' OR keyword_set(force) THEN BEGIN - obj = hsi_image() - obj-> set, det_index_mask= [0B, 1B, 1B, 1B, 1B, 1B, 0B, 0B, 0B] - obj-> set, im_energy_binning= energy_range[*,0] - obj-> set, im_time_interval= tr0[*,i] - ;obj-> set, image_algorithm= 'VIS FWDFIT' - obj-> set, image_algorithm = image_algo - obj-> set, clean_show_maps= 0 -obj-> set, clean_progress_bar= 0 - obj-> set, image_dim= [128, 128] - obj-> set, pixel_size= [1.00000, 1.00000] - obj-> set, time_bin_def= [1.00000, 2.00000, 4.00000, 4.00000, 8.00000, 16.0000, 32.0000, $ - 64.0000, 64.0000] - obj-> set, time_bin_min= 256L - obj-> set, use_phz_stacker= 1L - obj-> set, vf_loop= 1 - obj-> set, vis_plotfit= 0B - obj-> set, profile_show_plot= 0 - obj-> set, profile_plot_rate= 0 - obj-> set, profile_plot_resid= 0 - data = obj-> getdata() - obj->fitswrite, this_out_filename = hsi_image_fname - ENDIF - - fits2map, hsi_image_fname, hsi_map - fits2map, aia_file, aia_map - fits2map, aia_bkg_file, aia_bkg_map - - aia_bkg_drot_map = drot_map(aia_bkg_map, ref_map = aia_map) - - r = get_map_center(hsi_map) - dr = 40 - xrange = r[0] + dr*[-1,1] - yrange = r[1] + dr*[-1,1] - - aia_lct,r,g,b,wavelnth=wave[5],/load - tmp = [r[n_elements(r)-1], g[n_elements(r)-1], b[n_elements(r)-1]] - r = reverse(r) - g = reverse(g) - b = reverse(b) - r[n_elements(r)-1] = tmp[0] - g[n_elements(r)-1] = tmp[1] - b[n_elements(r)-1] = tmp[2] - tvlct,r,g,b - hsi_linecolors - - dmap = diff_map(aia_map, aia_bkg_drot_map) - - title = strmid(dmap.time, 0,20) - - plot_map, dmap, xrange = xrange, yrange = yrange, charsize = charsize, /limb, grid_spacing = 2, title = title, bottom = 13, _EXTRA = _EXTRA, dmin = 30 - - text = '' + image_algo + ' ' + num2str(energy_range[0]) + '-' + num2str(energy_range[1]) + ' keV' - - plot_map, hsi_map, /over, /percent, levels = [50,60,70,80,90], color = 6, thick = thick - legend, text, linestyle = 0, charsize = charsize, color = 6, thick = thick, pspacing = 1 - legend, wave[image_wave] + ' A ', box = 0, /bottom, /right, charsize = charsize - -ENDFOR - -IF keyword_set(OUTPS) THEN pclose - -stop - -END \ No newline at end of file diff --git a/fig_rhessi_lc_overview.pro b/fig_rhessi_lc_overview.pro deleted file mode 100644 index ae09742..0000000 --- a/fig_rhessi_lc_overview.pro +++ /dev/null @@ -1,56 +0,0 @@ -PRO fig_rhessi_lc_overview, OUTPS = outps - -IF keyword_set(OUTPS) THEN BEGIN - charsize = 1.0 - popen, filename, xsize = 8, ysize = 5 -ENDIF - -!P.MULTI = [0,2,2] - -;flare 3 -;AIA files time ranges -;20110603_064601, 20110603_074559 -t3 = ['2011/06/03 07:00:01', '2011/06/03 07:30:59'] -;Flare 3: 11060303, B3.69, location [19.04, -362.25] -;3-Jun-2011, 07:15, 07:16, 07:19 - -lc = get_rhessi_lc(t3, /corr, /plot) - -;flare 2 -;AIA files time ranges -;20110621_175201, 20110621_185159 -t2 = ['2011/06/21 18:10:01', '2011/06/21 18:41:59'] -;Flare 3: 11062114, B2.83, location [284, 263] -;21-Jun-2011, 18:19, 18:22, 18:24 -;istart = -; - -lc = get_rhessi_lc(t2, /corr, /plot) - -;key -;flare 0 -;AIA files time ranges -;20110716_163301, 20110716_173259 -t0 = ['2011/07/16 16:50:01', '2011/07/16 17:32:59'] -;Flare 0: 11071604, B6.39, location = [-586, -437] -;16-jul-2011, 17:01, 17:03, 17:13 -;istart = 117, - -lc = get_rhessi_lc(t0, /corr, /plot) - -;flare 1 - the limb -;AIA files time ranges -;20110826_202202, 20110826_212159 -t1 = ['2011/08/26 20:35:02', '2011/08/26 21:21:59'] -;Flare 1: 11082631, B4.16, location = [-908, -303] -;26-aug-2011, 20:51, 20:53, 20:58 -;istart = 130 - -lc = get_rhessi_lc(t1, /corr, /plot) - - - -IF keyword_set(OUTPS) THEN pclose - - -END \ No newline at end of file diff --git a/oct162011_analyze_deem.pro b/oct162011_analyze_deem.pro deleted file mode 100644 index 95fc45f..0000000 --- a/oct162011_analyze_deem.pro +++ /dev/null @@ -1,88 +0,0 @@ -PRO oct162011_analyze_deem - -workdir ='~/idlpro/schriste/aiatest/' - -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) - -files = file_search(workdir + 'aia_test*') - -fileset = 'ssw_cutout' - -te_range=[0.5,20]*1.e6 ; ([K], valid temperature range for DEM solutions) -tsig=0.1*(1+1*findgen(10)) ; (values of Gaussian logarithmic temperature widths) -q94=6.7 ; (correction factor for low-temperature 94 A response) - -fov=[0,0,4095,4095] ; (pixel range [i1,j1,i2,j2] of full image) - -npix=4 ; (macropixel size=4x4 pixels, yields 512x512 map) - -;not sure what the following does -vers='a' ; (version number of label in filenames used for full images) - -; Savefile that contains DEM loopup table -teem_table='teem_table.sav' -; Savefile that contains EM and Te maps -teem_map =fileset+vers+'_teem_map.sav' -; jpg-file that shows EM and Te maps -teem_jpeg=fileset+vers+'_teem_map.jpg' - -aia_teem_table,wave_,tsig,te_range,q94,fileset=fileset, teem_table -for u=0,150 do begin -aia_teem_map,wave_,npix,teem_table,teem_map,fileset='ssw_cutout',u -print,u - -;aia_teem_disp,teem_map,te_range,t1,teem_jpeg - -restore, teem_map, /verbose - -restore, 'ssw_cutouta_teem_map.sav', /verbose - -hist = histogram(te_map, binsize = 0.01, min = 5.5, max = 7, locations = loc) -plot, loc, hist, psym = 10, xtitle = 'log(Temperature [K])', title = 'Histogram' - - -hist = histogram(em_map, binsize = 0.01, min = 18, max = 22, locations = loc) -plot, loc, hist, psym = 10, xtitle = 'log(Emission Measure [cm!U-3!N])', title = 'Histogram' - -!P.MULTI = [0,2,1] - -plot_map, temperature_map, dmin = 5.5, dmax = 7, /cbar, /limb -plot_map, emission_map, dmin = 18, dmax = 22, /cbar, /limb - -xrange = [350, 700] -yrange = [-500, -300] - -sub_map, temperature_map, stemmap, xrange = xrange, yrange = yrange -sub_map, emission_map, semmap, xrange = xrange, yrange = yrange -sub_map, aia_map_cube, saia_map_cube, xrange = xrange, yrange = yrange - -plot_map, stemmap, /cbar, /limb, grid = 10 -plot_map, semmap, /cbar, /limb, grid = 10 -plot_map, saia_map_cube[0], /limb, grid = 10, /log - -xrange = [475, 750] -yrange = [-450, -300] - -sub_map, temperature_map, stemmap, xrange = xrange, yrange = yrange -sub_map, emission_map, semmap, xrange = xrange, yrange = yrange -sub_map, aia_map_cube, saia_map_cube, xrange = xrange, yrange = yrange - -plot_map, stemmap, /cbar, /limb, grid = 10 -plot_map, semmap, /cbar, /limb, grid = 10 -plot_map, saia_map_cube[0], /limb, grid = 10, /log - -roi = findgen(n_elements(stemmap)) - -; savefile that contains total DEM distribution -teem_tot=fileset+vers+'_teem_tot.sav' - -mask_map = oct162011_ribbon_mask() -help,mask_map -;imap=inter_map(mask_map,temperature_map) -;stop -aia_teem_total,'ssw_cutout',npix,wave_,q94,teem_table,teem_map,teem_tot,mask=mask_map,u -endfor -stop - -END \ No newline at end of file diff --git a/temp_flareteem_info.pro b/temp_flareteem_info.pro deleted file mode 100644 index ce4e9aa..0000000 --- a/temp_flareteem_info.pro +++ /dev/null @@ -1,33 +0,0 @@ -PRO temp_flareteem_info - -dir = ['hsi_flare_20110716_170350', $ - 'hsi_flare_20110826_205258', $ - 'hsi_flare_20110603_071626', $ - 'hsi_flare_20110621_182202'] - -hsi_fits = ['hsi_image_20110716_170350.fits', $ - 'hsi_image_20110826_205258.fits', $ - 'hsi_image_20110603_071626.fits', $ - 'hsi_image_20110621_181902.fits'] - -FOR i = 0, n_elements(dir) DO BEGIN - f = file_search('~/Desktop/' + dir[i] + '/*.fts') - times = anytim(aiacutout_to_time(f)) - - time_range = minmax(times) - flares = hsi_whichflare(time_range) - flare_str = hsi_whichflare(time_range, /only_one, /structure) - flare_str = hsi_whichflare(time_range, /closest, /structure) - - print, 'start_time:', anytim(flare_str.start_time,/yoh) - print, 'peak_time:', anytim(flare_str.peak_time,/yoh) - print, 'end_time:', anytim(flare_str.end_time, /yoh) - print, 'flare_id:', flare_str.id_number - - print, get_goes_class([flare_str.start_time, flare_str.end_time]) - - stop -ENDFOR - - -END From 036d605c9c778cefb7ac34a51387cd82a85f8c41 Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 16:55:25 -0400 Subject: [PATCH 43/44] yet more deleted files. --- aia_teem_map_test.pro | 263 ---------------------------------------- aia_teem_total_test.pro | 158 ------------------------ plot_aia_dem_hist.pro | 114 ----------------- plot_aia_dem_pow_lc.pro | 54 --------- 4 files changed, 589 deletions(-) delete mode 100644 aia_teem_map_test.pro delete mode 100644 aia_teem_total_test.pro delete mode 100644 plot_aia_dem_hist.pro delete mode 100644 plot_aia_dem_pow_lc.pro diff --git a/aia_teem_map_test.pro b/aia_teem_map_test.pro deleted file mode 100644 index 49d8199..0000000 --- a/aia_teem_map_test.pro +++ /dev/null @@ -1,263 +0,0 @@ -pro aia_teem_map,fileset = fileset,FOV = fov,wave_,npix,teem_table,teem_map, FILElist = filelist, VERBOSE = verbose,u - -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates EM and Te temperature maps -; based on single-Gaussian fits in each macropixel -; -; Syntax : IDL>aia_teem_map,fileset,fov,wave_,npix,teem_table,teem_map -; -; Inputs : fileset = common filename part of 6 wavelength FITS images -; wave_ = strarr(6) with wavelengths in Angstroem -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = size of macropixel (spatial resolution) -; teem_table = filename of DEM lookup table -; (calculated previously with AIA_TEEM_TABLE.PRO) -; teem_map = savefile containing EM and Te maps -; -; Outputs : postscript file _col.ps (if io=2) -; -; History : 3-Mar-2011, Version 1 written by Markus J. Aschwanden -; 16-May-2011, made fov optional. If not given, uses the -; whole images. -; made fileset optional. Added filelist keyword to just give a list of files. -; : 5-Oct-2011 - Added search for 1 sigma contour in chi^2 space to calculate errors in telog and tsig - A. Inglis -; -; Contact : aschwanden@lmsal.com -;- - -;_________________________________________________________________________ -t1 = systime(0,/seconds) -nwave = n_elements(wave_) - -IF keyword_set(fileset) THEN BEGIN - files = strarr(6) - FOR iw = 0, nwave-1 DO BEGIN - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - searchstring=fileset+'*'+wave_[iw]+'_.fts' - file_iw = file_search(searchstring, count=nfiles) - files[iw]=file_iw[u] - ENDFOR -ENDIF ELSE BEGIN - ;need to sort the files in the proper order - files = filelist - s = fltarr(nwave) - FOR i = 0, n_elements(wave_)-1 DO s[i] = where(strmatch(files,'*' + num2str(wave_[i]) + '*') EQ 1) - files = files[s] -ENDELSE -;_____________________REBINNING IMAGES___________________________________ - -texp_ =fltarr(nwave) -for iw=0,nwave-1 do begin - read_sdo,files(iw),index,data - - ; schriste (16-may-2011) - ; If Keyword FOV not given then determine the FOV - ; of the whole image automatically - IF keyword_set(fov) THEN BEGIN - i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ENDIF ELSE BEGIN - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ENDELSE - - dim =size(data) - nx0 =dim[1] - ny0 =dim[2] - if (i1 ge nx0) or (i2 ge nx0) or (j1 ge ny0) or (j2 ge ny0) then begin - print,'FOV=',i1,i2,j1,j2 - print,'image size=',nx0,ny0 - stop,'ERROR in subimage range i1,i2,j1,j2 for image with size nx0,ny0 - endif - image =data[i1:i2,j1:j2] - texp =index.exptime - dateobs=index.date_obs - if (iw eq 0) then begin - dim =size(image) - nx =dim[1] - ny =dim[2] - nxx =(nx/npix) - nyy =(ny/npix) - i3 =nxx*npix-1 - j3 =nyy*npix-1 - x =i1+(npix*findgen(nxx)+0.5) - y =j1+(npix*findgen(nyy)+0.5) - images=fltarr(nxx,nyy,nwave) - endif - if (npix eq 1) then images(*,*,iw)=float(image)/texp - if (npix gt 1) then images(*,*,iw)=rebin(float(image[0:i3,0:j3]),nxx,nyy)/texp - texp_(iw)=texp - - ;PLOT the image as a MAP - id = strmid(index.TELESCOP,0,3) + '/' + strmid(index.instrume,0,3) - aia_lct, rr, gg, bb, wavelnth=index.WAVELNTH, /load - a = index.CROTA2 - xcen = index.CRVAL1 + index.CDELT1*cos(a)*(0.5*(index.NAXIS1+1)- index.CRPIX1)-index.CDELT2*sin(a)*((index.NAXIS2+1)/2-index.CRPIX2) - ycen = index.CRVAL2 + index.CDELT1*sin(a)*((index.NAXIS1+1)*0.5-index.CRPIX1) + index.CDELT2*cos(a)*((index.NAXIS2+1)*0.5-index.CRPIX2) - map = make_map(data, time = index.t_obs, id = id, dur = index.exptime, xc = xcen, yc = ycen, dx = index.cdelt1, dy = index.cdelt2) - plot_map, map, /limb - -endfor - -;________________________TEMPERATURE MAP_________________________________ -restore,teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -dim =size(flux) -nte =dim[1] -nsig =dim[2] -nwave =dim[3] -ntot =nte*nsig -te_map =fltarr(nxx,nyy) -em_map =fltarr(nxx,nyy) -sig_map =fltarr(nxx,nyy) -chi_map =fltarr(nxx,nyy) -telog_errmap=fltarr(nxx,nyy,2) -tsig_errmap=fltarr(nxx,nyy,2) -telog_errmap_symmetric=fltarr(nxx,nyy) -tsig_errmap_symmetric=fltarr(nxx,nyy) -chi_map6=fltarr(nxx,nyy,6) -te_best =0. -em_best =0. -sig_best=0. -r0 =0.95*(4096/2) -x0 =4096/2 -y0 =4096/2 -nfree =3 - -FOR j = 0, nyy-1 DO BEGIN - if (nx eq 4096) then ind=where(sqrt((x-x0)^2+(y(j)-y0)^2) le r0,nind) - if (nx lt 4096) then ind=findgen(nxx) - i1 = min(ind) > 0 - i2 = max(ind) < (nxx-1) - for i = i1, i2 do begin - flux_obs=reform(images[i,j,*]) - counts=flux_obs*texp_ - noise=sqrt(counts)/texp_ - chimin=9999. - chi6min=9999. - chi2d = fltarr(nte,nsig) - for k=0,nte-1 do begin - for l=0,nsig-1 do begin - flux_dem1=reform(flux(k,l,*)) - em1 =total(flux_obs)/total(flux_dem1) - flux_dem=flux_dem1*em1 - chi =sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6=abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - if (chi le chimin) then begin - chimin =chi - chi6min =chi6 - em_best =alog10(em1) - te_best =telog(k) - sig_best =tsig(l) - endif - endfor - endfor - -; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 -IF (chimin ne 9999.) THEN BEGIN - ;chimin defaults to 9999. if bad pixel (i.e. no data), so skip those - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +1.0],path_xy=path_xy,path_info=path_info,/path_data_coords,closed=0 - testxmax=MAX(path_xy(0,*)) - testxmin=MIN(path_xy(0,*)) - testymax=MAX(path_xy(1,*)) - testymin=MIN(path_xy(1,*)) - - telog_err=[testxmin,testxmax] - te_best - ;error bars are asymmetric - symmetrise! - telog_errsymmetric=sqrt(telog_err(0)^2 + telog_err(1)^2) - - tsig_err=[testymin,testymax] - sig_best - ;error bars are asymmetric - symmetrise! - tsig_errsymmetric=sqrt(tsig_err(0)^2 + tsig_err(1)^2) - ;print,telog_errsymmetric - ;print,tsig_errsymmetric - ;print,telog_err - ;print,tsig_err - ENDIF ELSE BEGIN - ;contingency statements in case bad pixel - telog_err=[0,0] - tsig_err=[0,0] - tsig_errsymmetric=0. - telog_errsymmetric=0. -ENDELSE - - IF keyword_set(VERBOSE) THEN BEGIN - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR y = 0, nlevels-1 DO anot[y] = num2str(levels[y]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 't_sig' - oplot, [te_best], [sig_best], psym = 4 - leg = num2str(chimin) + '[' + num2str(te_best) + ',' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog,tsig,levels=[chimin + 1.],/over,thick=2 - stop - - ENDIF - em_map(i,j)=em_best - te_map(i,j)=te_best - sig_map(i,j)=sig_best - chi_map(i,j)=chimin - chi_map6(i,j,*)=chi6min - telog_errmap(i,j,0:1)=telog_err[0:1] - tsig_errmap(i,j,0:1)=tsig_err[0:1] - telog_errmap_symmetric(i,j)=telog_errsymmetric - tsig_errmap_symmetric(i,j)=tsig_errsymmetric - ;telog_errmap(i,j,*)=telog_err - ;tsig_errmap(i,j,*)=tsig_err - endfor - if (j mod 10) eq 0 then print,j,nyy -endfor - -help,telog_errmap_symmetric -help,tsig_errmap_symmetric - -print,telog_errmap_symmetric(50:70,50:70) -print,tsig_errmap_symmetric(50:70,50:70) - -aia_map_cube = make_map( images[*,*,0], xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = '', time = dateobs) -aia_map_cube = replicate(aia_map_cube, 6) - -FOR i = 0, n_elements(wave_)-1 DO BEGIN - aia_map_cube[i].data = images[*,*,i] - aia_map_cube[i].id = 'SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -temperature_map = make_map( te_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Temperature [MK])', time = dateobs) - -emission_map = make_map( em_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'log(Emission Measure [cm!U-3!N]', time = dateobs) - -sigma_map = make_map( sig_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = 'Sigma', time = dateobs) - -chisq_map = make_map( chi_map, xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -tsig_error_map_minus = make_map( tsig_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -telog_error_map_minus = make_map( telog_errmap(*,*,0), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -tsig_error_map_plus = make_map( tsig_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -telog_error_map_plus = make_map( telog_errmap(*,*,1), xc = xcen, yc = ycen, dx = index.cdelt1*npix, dy = index.cdelt2*npix, id = textoidl('\chi^2'), time = dateobs) - -;________________________STATISTICS OF CHI-2 FITS_________________ -print,'Statistics of chi2=' -statistic,chi_map -print,'Statistics of chi2 (94 A)' -statistic,chi_map6(*,*,5) -print,'log(EM)-range = ',minmax(em_map) - -;________________________SAVE MAPS________________________________ -;save,filename=teem_map,te_map,em_map,sig_map,chi_map,dateobs -save,filename=teem_map,te_map,em_map,sig_map,chi_map,tsig_errmap_symmetric,telog_errmap_symmetric,temperature_map,emission_map,sigma_map,chisq_map,aia_map_cube, dateobs -save,temperature_map,emission_map,sigma_map,chisq_map,tsig_error_map_minus,tsig_error_map_plus,telog_error_map_minus,telog_error_map_plus,filename='andy_tempmaptesting' + strtrim(string(u),2) + '.sav',/verbose -print,'TE+EM maps saved in file : ',teem_map -t2 =systime(0,/seconds) -cpu =t2-t1 -print,'Computation time = ',cpu,' s' -end diff --git a/aia_teem_total_test.pro b/aia_teem_total_test.pro deleted file mode 100644 index b0a1408..0000000 --- a/aia_teem_total_test.pro +++ /dev/null @@ -1,158 +0,0 @@ -pro aia_teem_total,fileset,fov = fov,npix,wave_,q94,teem_table,teem_map,teem_tot, mask = mask, u -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates temperature map -; based on single-Gaussian fit -; -; Syntax : IDL>aia_teem_total,fileset,fov,wave_,teem_map -; -; Inputs : fileset = strarr(6) with filenames of 6 wavelength FITS images -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = macropixel size -; wave_ = strarr(6) with wavelengths in Angstroem -; q94 = empirical correction factor of 94 A response -; teem_table = savefile containing DEM lookup table -; teem_map = savefile containing EM and Te maps -; mask = given a mask, return the dem only from within it. -; -; Outputs : teem_tot = savefile containing total DEM and fluxes -; -; History : 9-Mar-2011, Version 1 written by Markus J. Aschwanden -; : 10-May-2011, Version 2 added mask keyword by S. Christe -; : 5-Oct-2011 Added error calculations for em_tot based on errors in telog and sig - A. Inglis -; -; Contact : aschwanden@lmsal.com -;- - -;_____________________TOTAL FLUX_________________________________________ -nwave =n_elements(wave_) -flux_ =fltarr(nwave) - -for iw=0,nwave-1 do begin - ;searchstring=fileset+'*'+wave_(iw)+'.fits' - ;file_iw=findfile(searchstring,count=nfiles) - searchstring=fileset+'*'+wave_(iw)+'_.fts' - file_iw=file_search(searchstring,count=nfiles) - - read_sdo,file_iw(u),index,data - IF keyword_set(fov) THEN BEGIN - i1=fov[0] & j1=fov[1] & i2=fov[2] & j2=fov[3] - ENDIF ELSE BEGIN - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - ENDELSE -masktotal=0. -IF keyword_set(mask) then begin -tempmask=congrid(mask,i2+1,j2+1) - -print,total(data) -for k=0,i2 do begin -for l=0,j2 do begin -data(k,l)=data(k,l)*tempmask(k,l) -IF (tempmask(k,l) eq 1) then masktotal=masktotal+1 -endfor -endfor -endif - texp =index.exptime - flux_(iw)=total(data(i1:i2,j1:j2))/texp - ;flux_(iw)=total(data)/texp -print,wave_(iw),flux_(iw) -endfor -mask_frac=masktotal/(i2*j2) - - -;_____________________AIA RESPONSE FUNCTION________________________ -restore,teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -nte =n_elements(telog) - -;_____________________READ DEM PER PIXEL__________________________ -restore,teem_map ;-->te_map,em_map,sig_map,chi_map,dateobs -dim =size(em_map) -nx =dim(1) -ny =dim(2) -print,telog_errmap_symmetric(50:70,50:70) -print,tsig_errmap_symmetric(50:70,50:70) -IF NOT keyword_set(mask) THEN mask = replicate(1,nx,ny) -em_tot =fltarr(nte) -em_errtot=fltarr(nte) -error_array=fltarr(nx,ny,nte) -em =fltarr(nte) -te =fltarr(nte) -sig =fltarr(nte) -nmacro =float(nx)*float(ny) -for j=0,ny-1 do begin - for i=0,nx-1 do begin - em(*) =mask[i,j]*10.^em_map[i,j] ;log(EM)-->EM - te(*) =te_map[i,j]*mask[i,j] ;log(te) - sig(*) =sig_map[i,j]*mask[i,j] - em_tot =em_tot+em*exp(-(telog-te)^2/(2.*sig^2))/nmacro - - ;estimate the error in em_tot based on the error in telog and tsig - ARI 2011/09/30 - ;IF statement makes sure we don't count pixels where mask = 0. - IF (sig(0) gt 0.) THEN begin - error1=double(tsig_errmap_symmetric(i,j)) - error2=double(telog_errmap_symmetric(i,j)) - error3=(2.*(error2/telog-te)*(-(telog-te)^2.)) ; error in -(telog-te)^2 - careful with minus sign. - error4=2.*(error1/sig)*(sig^2.) ; error in sig^2 - error5=2.*error4 ; error in 2sig^2 - error6=sqrt( (error3/(telog-te)^2.) + (error5/(2.*sig^2.)) ) * ((telog-te)^2. / (2.*sig^2.)) ;error in exponent: {(telog-te)^2/(2*sig^2)} - error7=error6 * exp(-(telog-te)^2./(2.*sig^2.)) ;error once the exp is done. - error8=error7*(em/nmacro) ; final error in em at i,j - ;check for -NaN values - p=finite(error8) - index = WHERE (p gt 0,count,complement=index_c) - ;replace NaN values with 0. - error8(index_c)=0. - ;store the error for this i,j in an array. - error_array(i,j,*)=error8 - - ENDIF ELSE begin - error_array(i,j,*)=0. - ;em_errtot = em_errtot + 0. - ENDELSE - ;DEBUGGING STATEMENTS - ;help,error1,error2,error3,error4,error5,error6,error7,error8 - ;print,error1,error2,error3,error4,error5,error6,error7,error8 - ;print,error8 - ;print,em_errtot - ;IF (total(sig) gt 0.) THEN print,sig - ;IF (total(sig) gt 0.) THEN print,error3(0),error4(0),error5(0),error6(0),error7(0),error8(0),em_errtot(0) - endfor -endfor -emlog =alog10(em_tot) - -for v=0,32 do begin - ;get sum of the squares for each element of em_errtot = fltarr(nte). This gives the final error in em_tot summed over all the pixels. - em_errtot(v)=reform(sqrt(total(error_array(*,*,v)^2.))) -endfor -;get error in em_log rather than em_tot -emlog_err = (em_errtot/em_tot) -;MORE DEBUGGING STATEMENTS -;help,emlog -;help,emlog_err -;print,emlog -;print,emlog_err -;stop -clearplot -window,0,xsize=756,ysize=756 -plot,telog,emlog,yrange=[min(emlog)-max(emlog_err),max(emlog)+max(emlog_err)],xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' -;overplot the error bars -oploterr, telog, emlog, emlog_err -;______________________TOTAL FLUX FROM DEM________________________ -flux_dem=fltarr(nwave) -qflux =fltarr(nwave) -for iw=0,nwave-1 do begin - flux_dem(iw)=total(resp_corr(*,iw)*em_tot*dte)*nmacro*npix^2; * mask_frac - qflux(iw) =flux_dem(iw)/flux_(iw) - print,flux_(iw),flux_dem(iw),qflux(iw) -endfor - -;______________________SAVE RESULTS_______________________________ -save,filename='teem_tot_test'+strtrim(string(u),2)+'.sav',telog,emlog,emlog_err,flux_,flux_dem,qflux -end diff --git a/plot_aia_dem_hist.pro b/plot_aia_dem_hist.pro deleted file mode 100644 index 173b75e..0000000 --- a/plot_aia_dem_hist.pro +++ /dev/null @@ -1,114 +0,0 @@ -PRO plot_aia_dem_hist, dir, FLARE_NUM = flare_num, index = index, wave = wave - -default, wave, 5 - -wave_ =['131','171','193','211','335','94'] - -IF keyword_set(flare_num) THEN BEGIN - dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/'] - dir = dir[flare_num-1] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'ospex_*.fits') - hsi_fits = f[0] - - f = file_search(hsi_fits_dir + 'hsi_image*.fits') - hsi_image = f[0] - - ;['hsi_image_20110716_170350.fits', $ - ;'hsi_image_20110826_205258.fits', $ - ;'hsi_image_20110603_071626.fits', $ - ;'hsi_image_20110621_181902.fits'] - - dir_aia = '~/Desktop/' + ['flare_0_aia/', $ - 'flare_1_aia/', $ - 'flare_2_aia/', $ - 'flare_3_aia/'] - - dir_aia = dir_aia[flare_num-1] - - print, dir - print, hsi_fits - print, hsi_image -ENDIF - -f = file_search(dir + 'teem_data_*.sav') - -file_list = get_aia_file_list(dir_aia) - -fits2map, file_list[index, *], aiamap - -ilist = strmid(filename(f), 10, 3) -time_list = unbreak_time(strmid(filename(f),13,15)) - -restore, f[index], /verbose -fits2map, hsi_image, rmap - -min_logtemperature = 5.5 -max_logtemperature = 7.0 -nbins = 20 - -!P.MULTI = 0 -loadct, 5 -cen = get_map_center(rmap) -charsize = 1.5 -xrange = cen[0] + [-75,75] -yrange = cen[1] + [-75,75] -plot_map, temperature_map, /cbar, dmin = min_logtemperature, dmax = max_logtemperature, yrange = yrange, xrange = xrange, charsize = 1.5 - -plot_map, emission_map, /cbar, dmin = min_logtemperature, dmax = max_logtemperature, yrange = yrange, xrange = xrange, charsize = 1.5 - -;plot_map, rmap, /over, /percent, levels = [50,60,70,80,90] - -stop - -loadct, 0 -!P.MULTI = 0 - -aia_lct,r,g,b,wavelnth=wave_[wave],/load - -cen = get_map_center(rmap) -charsize = 1.5 -xrange = cen[0] + [-75,75] -yrange = cen[1] + [-75,75] -plot_map, aiamap[wave], xrange = xrange, yrange = yrange, /log, charsize = charsize, /cbar -plot_map, rmap, /over, /percent, levels = [50,60,70,80,90] -legend, 'RHESSI 4-10 keV', linestyle = 0, charsize = charsize - -stop - -imap = inter_map(rmap,temperature_map) -m = max(imap.data) -; set the mask at everything above 50% contour -l = where(imap.data LE m*0.5, complement = complement) -temperature_map.data[l] = 0 -yrange_t = minmax(temperature_map.data[complement]) -EMISSION_MAP.data[l] = 0 -;yrange_em = minmax(EMISSION_MAP.data[complement]) -yrange_em = [21,22.5] -SIGMA_MAP.data[l] = 0 -;yrange_sig = minmax(SIGMA_MAP.data[complement]) -yrange_sig = [0,1] - -hist = histogram(temperature_map.data, min = min_logtemperature, max = max_logtemperature, locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(Temperature [K])', /nodata, title = time_list[index] -oplot, loc, hist, thick = 2.0, psym = 10 - -hist = histogram(EMISSION_MAP.data, min = yrange_em[0], max = yrange_em[1], locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(Emission measure [cm!U-5!N])', /nodata, title = time_list[index] -oplot, loc, hist, thick = 2.0, psym = 10 - -hist = histogram(SIGMA_MAP.data, min = yrange_sig[0], max = yrange_sig[1], locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(sigma [K])', /nodata, title = time_list[index], /ylog, yrange = [1,max(hist)] -oplot, loc, hist, thick = 2.0, psym = 10 - - -stop - -END \ No newline at end of file diff --git a/plot_aia_dem_pow_lc.pro b/plot_aia_dem_pow_lc.pro deleted file mode 100644 index 1c7b689..0000000 --- a/plot_aia_dem_pow_lc.pro +++ /dev/null @@ -1,54 +0,0 @@ -PRO plot_aia_dem_pow_lc, file, flare_num = flare_num - - - -IF keyword_set(flare_num) THEN BEGIN - dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/'] - dir = dir[flare_num-1] - f = file_search(dir + 'aia_dem_slope_*.sav') - file = f[0] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'hsi_spectrum*.fits') - hsi_spectrum = f[0] - - f = file_search(hsi_fits_dir + 'hsi_srm*.fits') - hsi_srm = f[0] - - - ;['hsi_image_20110716_170350.fits', $ - ;'hsi_image_20110826_205258.fits', $ - ;'hsi_image_20110603_071626.fits', $ - ;'hsi_image_20110621_181902.fits'] - if flare_num eq 1 then timerange = ['16-Jul-11 17:00:11.000','16-Jul-11 17:20:00.000'] - ;dir_aia = dir_aia[flare_num-1] -ENDIF -yrange = [50,20000] -print, file -restore, file, /verbose -!P.multi = [0,1,2] - -if not exist(timerange) then timerange = anytim(minmax(fit_result[*,0])) -fit_yrange = minmax([fit_result[*,2],fit_result[*,1]] ) - -hsi_linecolors -colors = [7,8] -charsize = 1.5 -utplot, anytim(fit_result[*,0],/yoh), fit_result[*,1], /nodata, charsize = charsize, timerange = timerange, ytitle = textoidl('\alpha_{fit}'), yrange = fit_yrange -outplot, anytim(fit_result[*,0],/yoh), fit_result[*,1], thick = 2.0, color = colors[0] -outplot, anytim(fit_result[*,0],/yoh), fit_result[*,2], thick = 2.0, color = colors[1] -legend, ['flare', 'background'], color = colors, charsize = charsize, linestyle = [0,0], thick = [2,2], /right - -o = ospex(/no_gui) -o->set, spex_specfile = hsi_spectrum -o->set, spex_drmfile= hsi_srm -o->set, spex_eband=get_edge_products([4,15,25,50,100],/edges_2) - -o -> plot_time, /data, /no_plotman, this_band = [0,1], charsize = charsize, timerange = timerange, yrange = yrange, /ystyle - -stop - -END \ No newline at end of file From 4a90a811cc02221cb9d73405745c779efd716c23 Mon Sep 17 00:00:00 2001 From: aringlis Date: Mon, 21 Jul 2014 17:02:18 -0400 Subject: [PATCH 44/44] deleting files. --- aia_make_gifs.pro | 57 ------ aia_teem_fit.pro | 120 ------------- aia_teem_integrate.pro | 26 --- aia_teem_map.pro | 346 ------------------------------------- aia_teem_total.pro | 178 ------------------- aia_tempmap_movie.pro | 82 --------- ospex_multi_therm_test.pro | 27 --- plot_aia_dem.pro | 100 ----------- plot_many_aia_dem.pro | 61 ------- 9 files changed, 997 deletions(-) delete mode 100644 aia_make_gifs.pro delete mode 100644 aia_teem_fit.pro delete mode 100644 aia_teem_integrate.pro delete mode 100644 aia_teem_map.pro delete mode 100644 aia_teem_total.pro delete mode 100644 aia_tempmap_movie.pro delete mode 100644 ospex_multi_therm_test.pro delete mode 100644 plot_aia_dem.pro delete mode 100644 plot_many_aia_dem.pro diff --git a/aia_make_gifs.pro b/aia_make_gifs.pro deleted file mode 100644 index 36c9981..0000000 --- a/aia_make_gifs.pro +++ /dev/null @@ -1,57 +0,0 @@ -PRO aia_make_gifs, dir = dir - -dir = '/Volumes/sdo-aia/hsi_flare_20110716_/' -;fileset = file_search(dir + 'ssw_cutout_20110716_*') - -hsi_fits = '/Users/schriste/idlpro/schriste/aia_deem/hsi_image_20110716_170350.fits' - -fileset = 'ssw_cutout' -wave_ =['131','171','193','211','335','94'] -nwave =n_elements(wave_) -nfiles = fltarr(nwave) - -FOR i = 0, nwave-1 DO BEGIN - files = file_search(dir + fileset + '*' + wave_[i] + '_.fts') - nfiles[i] = n_elements(files) -ENDFOR - -;the number of files need to be the same! -print, nfiles -file_list = strarr(nfiles[0], nwave) - -FOR i = 0, nwave-1 DO BEGIN - files = file_search(dir + fileset + '*' + wave_[i] + '_.fts') - nfiles[i] = n_elements(files) - times = anytim(aiacutout_to_time(files)) - s = sort(times) - files = files[s] - file_list[*,i] = files -ENDFOR - -FOR i = 0, nfiles DO BEGIN - - FOR j = 0, nwave-1 DO BEGIN - - - fits2map, curfile, map - - IF keyword_set(OUTPLOT) THEN BEGIN - set_plot, 'z' - loadct,0 - hsi_linecolors - device, set_resolution = [800, 600] - ENDIF - - plot_map, map, charsize = 1.5, grid = 10 - - IF keyword_set(OUTPLOT) THEN BEGIN - tvlct, r, g, b, /get - outfile = 'dem_' + break_time(cur_time) + '_' + num2str(i, padchar = '0', length = 3) + '.png' - write_png, outfile, tvrd(), r,g,b - set_plot, 'x' - ENDIF - - -ENDFOR - -END diff --git a/aia_teem_fit.pro b/aia_teem_fit.pro deleted file mode 100644 index 497bb00..0000000 --- a/aia_teem_fit.pro +++ /dev/null @@ -1,120 +0,0 @@ -FUNCTION aia_teem_fit, flux_obs, flux_obs_error, FLUX_fit = flux_fit, fit_params = fit_params, PLOT = plot - -restore, 'teem_table.sav', /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig -nfree = 3 - -chi2d = fltarr(nte,nsig) -chimin = 9999. -chi6min = 9999. -flux_dem_best = 9999. - -FOR i = 0, nte-1 DO BEGIN - FOR j = 0, nsig-1 DO BEGIN - - flux_dem1 = reform(flux[i,j,*]) - - em1 = total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(flux_obs_error^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - - chi = sqrt(total((flux_obs-flux_dem)^2/flux_obs_error^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/flux_obs_error - chi2d[i,j] = chi - - IF (chi LE chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[i] - sig_best = tsig[j] - flux_dem_best = flux_dem - ENDIF - - print, chi - ENDFOR -ENDFOR - -flux_fit = flux_dem_best -residuals = flux_obs - flux_fit - -;calculate the error on the parameters -IF (chimin LT 9999.) THEN BEGIN - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF -ENDIF - -IF keyword_set(PLOT) THEN BEGIN - print, 'chimin = ', chimin - print, 'EM = ', em_best - print, 'Log(Temp) = ' + num2str(telog_best) + ' +/- ' + num2str(telog_errsymmetric) - print, 'Sigma = ' + num2str(sig_best) + ' +/- ' + num2str(sig_errsymmetric) - - print, 'Wavelength: ', float(wave_) - print, '---------- ', replicate('-------------', nwave) - print, 'Observed flux: ', flux_obs - print, 'Fitted flux: ', flux_dem_best - print, '---------- ', replicate('-------------', nwave) - print, 'Fitted/Obs flux:', flux_dem_best/flux_obs - - window, 0 - loadct, 0 - hsi_linecolors - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - window, 1 - emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - - window, 2 - !p.multi= 0 - - plot,indgen(nwave),flux_obs,/ylog,psym=6,$ - xrange=[-1,nwave],xtickf='(a1)',xticks=nwave+1,ystyle=16,thick=3,$ - ytit='DN s!U-1!N',/nodata,$ - yrange=[0.9*min(flux_obs),1.1*max(flux_obs)], xtickn=[' ', wave_, ' '], xtitle = 'Filter' - oplot,indgen(nwave),flux_obs,psym=6,color=5,thick=1 - oplot,indgen(nwave),flux_fit,psym=7,color=2,thick=2 - for i=0, nwave-1 do oplot, [i,i], flux_obs[i] + [-flux_obs_error[i], flux_obs_error[i]], thick=5,color=5 - legend, ['flux_obs', 'flux_fit'], psym = [6,7], color = [5,2] - legend, 'chisq='+num2str(chimin), /right - print, wave_ - ;maxr=1.1*max(abs(residuals)) - ;plot,indgen(nwave),residuals,xrange=[-1,nwave],xtickn=[' ',wave_,' '],$ - ;xticks=nwave+1,ystyle=17,thick=1,yrange=maxr*[-1,1],psym=6,$ - ;ytit='Residuals',xtit='Filter' - ;oplot,[-2,nwave],[0,0],lines=1 - ;legend, 'chisq='+num2str(chimin) -ENDIF - -fit_params = [em_best, telog_best, sig_best] -dem =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - -RETURN, [transpose(telog), transpose(dem)] - -END diff --git a/aia_teem_integrate.pro b/aia_teem_integrate.pro deleted file mode 100644 index 75fdae3..0000000 --- a/aia_teem_integrate.pro +++ /dev/null @@ -1,26 +0,0 @@ -PRO aia_teem_integrate, dir, HSI_FITS = hsi_fits, time_range = time_range - -; PURPOSE: Integrate (avearge) a set of DEM measurements from AIA (to match the integration -; time of RHESSI for example) -; -; KEYWORDS: Give it a time range of a hsi_fits file which will be used to figure out the -; time range. -; -; WRITTEN: Steven Christe (20-Dec-2011) - -default, dir, '~/Desktop/' + 'flare0_deem/' -default, hsi_fits, '/Users/schriste/Desktop/flare_0_rhessi/ospex_results_20110603_071556_071656_mtherm.fits' - -IF keyword_set(HSI_FITS) THEN BEGIN - result = spex_read_fit_results(hsi_fits) - p = result.spex_summ_params - - ;now find the fit that is closest in time to time t - time_range = result.spex_summ_time_interval -ENDIF - -f = file_search(dir + 'teem_tot_*.sav') - -fname = filename(f) - -times = unbreak_time(strmid(fname, 12,18)) \ No newline at end of file diff --git a/aia_teem_map.pro b/aia_teem_map.pro deleted file mode 100644 index f206a58..0000000 --- a/aia_teem_map.pro +++ /dev/null @@ -1,346 +0,0 @@ -pro aia_teem_map,fileset = fileset,wave_,npix,teem_table,teem_map, FILElist = filelist, VERBOSE = verbose, filename_extra = FILENAME_extra, SAVE_DIR = save_dir, DEBUG = debug, XRANGE = xrange, YRANGE = yrange - -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates EM and Te temperature maps -; based on single-Gaussian fits in each macropixel -; -; Syntax : IDL> aia_teem_map,fileset,fov,wave_,npix,teem_table,teem_map -; -; Inputs : fileset = common filename part of 6 wavelength FITS images -; wave_ = strarr(6) with wavelengths in Angstroem -; /// fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view - deprecated -; xrange = fltarr(2) the xrange in arcsec for the subimage -; yrange = fltarr(2) the yrange in arcsec for the subimage -; npix = size of macropixel (spatial resolution) -; teem_table = filename of DEM lookup table -; (calculated previously with AIA_TEEM_TABLE.PRO) -; teem_map = savefile containing EM and Te maps -; -; Outputs : postscript file _col.ps (if io=2) -; -; History : 3-Mar-2011, Version 1 written by Markus J. Aschwanden -; 16-May-2011, made fov optional. If not given, uses the -; whole images. -; made fileset optional. Added filelist keyword to just give a list of files. -; : 5-Oct-2011 - Added search for 1 sigma contour in chi^2 space to calculate errors in telog and tsig - A. Inglis -; : 1-Feb-2011 - Changed definition of files (see lines 51-55) so that files = filelist directly. Solves issues with AIA2011xxx file formats. -; -; Contact : aschwanden@lmsal.com -;- - -default, save_dir, '' - -;_________________________________________________________________________ -t1 = systime(0,/seconds) -nwave = n_elements(wave_) -default, filename_extra, '' - -files = filelist -texp_ = fltarr(nwave) - -FOR iw = 0, nwave-1 DO BEGIN - read_sdo,files[iw],index,data - index2map,index,float(data),map - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - map = smap - data = smap.data - ENDIF - - image = map.data - texp = map.dur - texp_[iw]=texp - dateobs = map.time - - IF (iw EQ 0) THEN BEGIN - dim = size(image) - nx = dim[1] - ny = dim[2] - nxx = (nx/npix) - nyy = (ny/npix) - i3 = nxx*npix-1 - j3 = nyy*npix-1 - images = fltarr(nxx,nyy,nwave) - x = get_map_xp(map, /oned) - y = get_map_yp(map, /oned) - ENDIF - - IF (npix EQ 1) THEN images[*,*,iw] = float(image)/texp - - IF (npix GT 1) THEN BEGIN - ; units of image are in dn/s - images[*,*,iw] = rebin(float(image[0:i3,0:j3]),nxx,nyy)/texp - sub_map, map, smap, xrange = [0,i3], yrange = [0,j3], /pixel - rmap = rebin_map(smap, nxx, nyy) - x = get_map_xp(rmap, /oned) - y = get_map_yp(rmap, /oned) - map = rmap - ENDIF - - ;map.data=(map.data/texp) - IF iw EQ 0 THEN aia_map_cube = replicate(map, nwave) ELSE aia_map_cube[iw] = map - - IF keyword_set(PLOT) THEN BEGIN - aia_lct, rr, gg, bb, wavelnth=wave_[iw], /load - plot_map, map, /limb, /log - ENDIF -ENDFOR - -;________________________TEMPERATURE MAP_________________________________ -restore, save_dir + teem_table, /verbose - -dim = size(flux) -nte = dim[1] -nsig = dim[2] -nwave = dim[3] -ntot = nte*nsig - -; result arrays -telog_map = fltarr(nxx,nyy) -em_map = fltarr(nxx,nyy) -sig_map = fltarr(nxx,nyy) -flux_dem_map = fltarr(nxx, nyy, nwave) -chi_map = fltarr(nxx,nyy) -em_errmap = fltarr(nxx,nyy) -telog_errmap = fltarr(nxx,nyy,2) -sig_errmap = fltarr(nxx,nyy,2) -telog_errmap_symmetric = fltarr(nxx,nyy) -sig_errmap_symmetric = fltarr(nxx,nyy) -chi_map6 = fltarr(nxx,nyy,6) - -chi_map_hsi = fltarr(nxx,nyy) -telog_map_hsi = fltarr(nxx,nyy) -sig_map_hsi = fltarr(nxx,nyy) - -telog_best = 0. -em_best = 0. -sig_best = 0. - -telog_best_hsi = 0. -em_best_hsi = 0. -sig_best_hsi = 0. - -; the number of fit parameters -nfree = 3 - -temp = get_sun(dateobs, sd = solar_radius) - -FOR j = 0, nyy-1 DO BEGIN - - ; the following code makes sure that regions with radial distance beyond r0 - ; are not considered. - ry = sqrt(x^2 + y[j]^2) - index = where(ry LE solar_radius, count) - - if count NE 0 THEN BEGIN - i1 = min(index) - i2 = max(index) - ENDIF ELSE continue - - FOR i = i1, i2-1 DO BEGIN - - flux_obs = reform(images[i,j,*]) - counts = flux_obs*texp_ - ;stop - noise = sqrt(counts)/texp_ - - chimin = 9999. - chi6min = 9999. - chimin_hsi=9999. - flux_dem_best = 9999. - chi2d = fltarr(nte,nsig) - chi_hsi = fltarr(nte,nsig) - - telog_err = [0,0] - sig_err = [0,0] - sig_errsymmetric = 0. - telog_errsymmetric = 0. - - FOR k=0, nte-1 DO BEGIN - FOR l = 0, nsig-1 DO BEGIN - flux_dem1 = reform(flux[k,l,*]) - em1 = total(flux_obs)/total(flux_dem1) - em1_err = sqrt(total(noise^2)) / total(flux_dem1) - flux_dem = flux_dem1 * em1 - chi = sqrt(total((flux_obs-flux_dem)^2/noise^2)/(nwave-nfree)) - chi6 = abs(flux_obs-flux_dem)/noise - chi2d[k,l] = chi - ;add in RHESSI - em_hsi=em1 /1e25 - em_hsi=em_hsi/1e24 ; - em_hsi=em_hsi*39.*1e15 - IF (k eq 0) THEN BEGIN - em_hsi=em_hsi * (10^telog(1) - 10^telog(0)) - ENDIF ELSE BEGIN - em_hsi=em_hsi * (10^telog(k) - 10^telog(k-1)) - ENDELSE - - get_hsi_table_entry,[em_hsi,telog(k),tsig(l)],model_count_flux,real_count_flux,axis,summary, obj=obj - chi_hsi[k,l] = summary.spex_summ_chisq - IF (chi le chimin) THEN BEGIN - chimin = chi - chi6min = chi6 - em_best = alog10(em1) - em_best_err = em1_err/em_best - telog_best = telog[k] - sig_best = tsig[l] - flux_dem_best = flux_dem - ENDIF - IF (chi_hsi[k,l] le chimin_hsi) THEN BEGIN - chimin_hsi=chi_hsi[k,l] - em_best_hsi=alog10(em1) - telog_best_hsi = telog[k] - sig_best_hsi = tsig[l] - ENDIF - ENDFOR - ENDFOR - - ; find errors in tsig and telog by finding the 1 sigma contour in chi^2 space for each pixel - A. Inglis 5-Oct-2011 - IF (chimin LT 9999.) THEN BEGIN - - ;find the 1 sigma contour in chi^2-space to get errors in tsig and telog - contour, chi2d, telog, tsig, levels = [chimin +2.3], path_xy=path_xy, path_info=path_info, /path_data_coords, closed=0 - IF exist(path_xy) THEN BEGIN - telog_err = [telog_best - min(path_xy[0,*]), max(path_xy[0,*]) - telog_best] - sig_err = [sig_best - min(path_xy[1,*]), max(path_xy[1,*]) - sig_best] - - ;error bars are asymmetric - symmetrise! - telog_errsymmetric = max(abs(telog_err)) - sig_errsymmetric = max(abs(sig_err)) - ENDIF - ENDIF - - IF ((keyword_set(VERBOSE)) AND (chimin LT 9999.)) THEN BEGIN - print, 'i, j = ', float(i), float(j) - print, 'chimin = ', chimin - print, 'EM = ', em_best - print, 'Log(Temp) = ' + num2str(telog_best) + ' +/- ' + num2str(telog_errsymmetric) - print, 'Sigma = ' + num2str(sig_best) + ' +/- ' + num2str(sig_errsymmetric) - - print, 'Wavelength: ', float(wave_) - print, '---------- ', replicate('-------------', nwave) - print, 'Observed flux: ', flux_obs - print, 'Fitted flux: ', flux_dem_best - print, '---------- ', replicate('-------------', nwave) - print, 'Fitted/Obs flux:', flux_dem_best/flux_obs - - window, 0 - loadct, 0 - hsi_linecolors - nlevels = 20 - levels = chimin * (findgen(nlevels)*0.1 + 1.0) - anot = strarr(20) - FOR k = 0, nlevels-1 DO anot[k] = num2str(levels[k]) - contour, chi2d, telog, tsig, levels = levels, c_annotation = anot, xtitle = 'log[Temp]', ytitle = 'sig' - oplot, [telog_best], [sig_best], psym = symcat(16), color = 6 - leg = num2str(chimin) + '[' + num2str(telog_best) + ',' + num2str(sig_best) + ']' - legend, leg, psym = 4 - contour,chi2d,telog, tsig, levels=[chimin + 2.3],/over,thick=2, color = 6 - - window, 1 - emlog =em_best*exp(-(telog-telog_best)^2/(2.*sig_best^2)) - plot, telog, emlog, yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - ;r = chianti_spec_from_dem(telog, emlog, /plot) - ;save, emlog, telog, r, filename = 'xray_spectrum_i' + num2str(i) + '_j' + num2str(j) + '.sav' - ENDIF - - flux_dem_map[i,j,*] = flux_dem_best - em_map[i,j] = em_best - telog_map[i,j] = telog_best - sig_map[i,j] = sig_best - chi_map[i,j] = chimin - chi_map6[i,j,*] = chi6min - telog_errmap[i,j,0:1] = telog_err[0:1] - sig_errmap[i,j,0:1] = sig_err[0:1] - telog_errmap_symmetric[i,j] = telog_errsymmetric - sig_errmap_symmetric[i,j] = sig_errsymmetric - - chi_map_hsi[i,j] = chimin_hsi - telog_map_hsi[i,j] = telog_best_hsi - sig_map_hsi[i,j] = sig_best_hsi - ENDFOR - - t2 = systime(0,/seconds) - elapsed_time_min = (t2-t1)/60.0 - percent_done = float(j)/nyy * 100 - percent_rate = percent_done/elapsed_time_min - remaining_time = (100 - percent_done)/percent_rate - IF (j mod 10) eq 0 THEN print, num2str(percent_done, length = 2) + '% done. ' + num2str(elapsed_time_min) + ' min elapsed, ' + num2str(remaining_time) + ' min left' -ENDFOR - -aia_simul_map_cube = aia_map_cube - -FOR i = 0, nwave-1 DO BEGIN - aia_simul_map_cube[i].data = flux_dem_map[*,*,i] - aia_simul_map_cube[i].id = 'Simulated SDO/AIA ' + num2str(wave_[i]) + ' A' -ENDFOR - -temperature_map = map -temperature_map.data = telog_map -temperature_map.id = 'log(Temperature [MK])' -temperature_map.time = dateobs - -emission_map = map -emission_map.data = em_map -emission_map.id = 'log(Emission Measure [cm!U-3!N]' -emission_map.time = dateobs - -sigma_map = map -sigma_map.data = sig_map -sigma_map.id = 'Sigma' -sigma_map.time = dateobs - -chisq_map = map -chisq_map.data = chi_map -chisq_map.id = textoidl('\chi^2') -chisq_map.time = dateobs - -sig_error_map_minus = map -sig_error_map_minus.data = sig_errmap[*,*,0] -sig_error_map_minus.id = 'Temp sigma err -' -sig_error_map_minus.time = dateobs - -telog_error_map_minus = map -telog_error_map_minus.data = telog_errmap[*,*,0] -telog_error_map_minus.id = 'log(Temp) err -' -telog_error_map_minus.time = dateobs - -sig_error_map_plus = map -sig_error_map_plus.data = sig_errmap[*,*,1] -sig_error_map_plus.id = 'Temp sigma err +' -sig_error_map_plus.time = dateobs - -telog_error_map_plus = map -telog_error_map_plus.data = telog_errmap[*,*,1] -telog_error_map_plus.id = 'log(Temp) err +' -telog_error_map_plus.time = dateobs - -;________________________STATISTICS OF CHI-2 FITS_________________ -print,'Statistics of chi2=' -statistic,chi_map -print,'Statistics of chi2 (94 A)' -statistic,chi_map6(*,*,5) -print,'log(EM)-range = ',minmax(em_map) - -;________________________SAVE MAPS________________________________ -;save,filename=teem_map,telog_map,em_map,sig_map,chi_map,dateobs -save,filename=save_dir + teem_map,telog_map,em_map,sig_map,chi_map,sig_errmap_symmetric,telog_errmap_symmetric,temperature_map,emission_map,sigma_map,chisq_map,aia_map_cube, $ -dateobs , aia_simul_map_cube, chi_map_hsi, telog_best_hsi, sig_best_hsi -save,temperature_map,emission_map,sigma_map,chisq_map,sig_error_map_minus,sig_error_map_plus,telog_error_map_minus,telog_error_map_plus,aia_simul_map_cube, filename=save_dir + 'tempmap' + filename_extra + '.sav' - -print,'TE+EM maps saved in file : ',teem_map -t2 =systime(0,/seconds) - -print,'Computation time = ',(t2-t1)/60.0,' min' - -IF keyword_set(DEBUG) THEN stop - -END diff --git a/aia_teem_total.pro b/aia_teem_total.pro deleted file mode 100644 index ff31cb1..0000000 --- a/aia_teem_total.pro +++ /dev/null @@ -1,178 +0,0 @@ -pro aia_teem_total,fileset = fileset,npix,wave_,q94,teem_table,teem_map,teem_tot, mask_map = mask_map, filelist = filelist, PLOT = plot, SAVE_DIR = save_dir, XRANGE = xrange, YRANGE = yrange, macro_dem = macro_dem -;+ -; Project : AIA/SDO -; -; Name : AIA_TEMPMAP -; -; Category : Data analysis -; -; Explanation : calculates temperature map -; based on single-Gaussian fit -; -; Syntax : IDL>aia_teem_total,fileset,fov,wave_,teem_map -; -; Inputs : fileset = strarr(6) with filenames of 6 wavelength FITS images -; fov(4) = [i1,j1,i2,j2] pixel ranges of field-of-view -; npix = macropixel size -; wave_ = strarr(6) with wavelengths in Angstroem -; q94 = empirical correction factor of 94 A response -; teem_table = savefile containing DEM lookup table -; teem_map = savefile containing EM and Te maps -; mask_map = given a mask as a map, return the dem only where it equals 1. -; -; Outputs : teem_tot = savefile containing total DEM and fluxes -; -; History : 9-Mar-2011, Version 1 written by Markus J. Aschwanden -; : 10-May-2011, Version 2 added mask keyword by S. Christe -; :1-Feb-2012 Version 2 - fixed outstanding bugs in code - A. Inglis -; a) Lines 44-50 did not handle the AIA2011xxxx file format and have been replaced by setting -; file_iw=filelist directly (filelist is now in correct handling order already). -; b)Error calculation was missing mask_frac on the denominator when error 8 is calculated (line 113) -; c)mask_frac is now calculated correctly! See line 79. -; :3-Feb-2012 fixed energy calculation, and now generates an energy_map with the energy in each pixel. Saved in teem_tot.....sav file -; -; Contact : aschwanden@lmsal.com -;- -; -default, save_dir, '' -;_____________________TOTAL FLUX_________________________________________ -nwave = n_elements(wave_) -flux_ = fltarr(nwave) - -file_iw = filelist - -FOR iw = 0, nwave-1 DO BEGIN - - read_sdo,file_iw[iw],index,data - index2map,index,float(data),map - - IF keyword_set(xrange) AND keyword_set(yrange) THEN BEGIN - sub_map, map, smap, xrange = xrange, yrange = yrange - map = smap - data = smap.data - ENDIF - - s = size(data) - i1=0 & j1=0 & i2=s[1]-1 & j2=s[2]-1 - - image = data - texp = map.dur - dateobs = map.time - - IF keyword_set(mask_map) then begin - mask = mask_map.data - ; zero out everything that is not in the mask - FOR k = 0, i2 DO BEGIN - FOR l = 0, j2 DO BEGIN - data[k,l] = data[k,l]*mask[k,l] - ENDFOR - ENDFOR - ENDIF - - flux_[iw] = total(data[i1:i2,j1:j2])/texp - print,'Total flux in ', wave_(iw),flux_(iw) -ENDFOR - -IF keyword_set(mask_map) THEN mask_frac=total(mask)/n_elements(data) ELSE mask_frac = 1. - -;_____________________AIA RESPONSE FUNCTION________________________ -restore,save_dir + teem_table ;-->wave_,q94,area,resp_corr,telog,dte,tsig,flux -nte =n_elements(telog) - -;_____________________READ DEM PER PIXEL__________________________ -restore,save_dir + teem_map ;-->te_map,em_map,sig_map,chi_map,dateobs -dim =size(em_map) -nx =dim(1) -ny =dim(2) -IF NOT keyword_set(mask_map) THEN tempmask = replicate(1,nx,ny) ELSE tempmask = congrid(mask,nx,ny) -em_tot =dblarr(nte) -em =dblarr(nte) -te =dblarr(nte) -sig =dblarr(nte) -em_errtot=dblarr(nte) -error_array=dblarr(nx,ny,nte) -energy=fltarr(nx,ny) -kb=1.3806503e-16 -nmacro = float(nx)*float(ny) - -FOR j=0,ny-1 do begin - FOR i=0,nx-1 do begin - em[*] = tempmask[i,j]*10.^em_map[i,j] ;log(EM)-->EM - te[*] =telog_map[i,j]*tempmask[i,j] ;log(te) - sig[*] =sig_map[i,j]*tempmask[i,j] - em_tot =em_tot+em*exp(-(telog-te)^2/(2.*sig^2))/(nmacro * mask_frac) - IF keyword_set(macro_dem) THEN BEGIN - if ((i EQ 0) AND (j EQ 0)) THEN cnt = 0 - if cnt mod macro_dem THEN stop - ENDIF - - IF (sig[0] gt 0.) THEN begin - error1=double(sig_errmap_symmetric[i,j]) - error2=double(telog_errmap_symmetric[i,j]) - error3=(2.*(error2/telog-te)*(-(telog-te)^2.)) ; error in -(telog-te)^2 - careful with minus sign. - error4=2.*(error1/sig)*(sig^2.) ; error in sig^2 - error5=2.*error4 ; error in 2sig^2 - error6=sqrt( (error3/(telog-te)^2.) + (error5/(2.*sig^2.)) ) * ((telog-te)^2. / (2.*sig^2.)) ;error in exponent: {(telog-te)^2/(2*sig^2)} - error7=error6 * exp(-(telog-te)^2./(2.*sig^2.)) ;error once the exp is done. - error8=error7*(em/(nmacro*mask_frac)) ; final error in em at i,j 01/27/12 - added mask_frac - ARI - ;check FOR -NaN values - p=finite(error8) - index = WHERE (p gt 0,count,complement=index_c) - ;replace NaN values with 0. - error8(index_c)=0. - ;store the error FOR this i,j in an array. - error_array[i,j,*]=error8 - - ;calculate the energy in each pixel by integrating the emission measure. ARI 2011/11/18 - ;1.8805014e11 converts from pixels to cm^2 - ;Assume V=A^1.5 - - ;Energy = 1.5k * V^1/2 * Integral(EM ^ 1/2 dT) - - ;integrate the square root of emission measure. Need to convert to cm^-5 hence the /1.8805013e15 - area=1.8805013e15*npix^2 - emgaussian=em*exp(-(telog-te)^2/(2.*sig^2))/(nmacro * mask_frac) - em_integral=int_tabulated((10^telog),sqrt(emgaussian*area),/double) - energy(i,j)=1.5 * em_integral * sqrt((area)^1.5) * kb - ;print,'test numbers: ',total(sqrt(em)),em_integral, sqrt((nmacro*npix^2*mask_frac*1.8805014e15)^1.5), kb, energy(i,j) - - ENDIF ELSE begin - error_array[i,j,*]=0. - ;em_errtot = em_errtot + 0. - ENDELSE - ;print,em,error1,error2,error3,error4,error5,error6,error7,error8 - ;stop - ENDFOR -ENDFOR -emlog = alog10(em_tot) - - -;get sum of the squares FOR each element of em_errtot = fltarr(nte). This gives the final error in em_tot summed over all the pixels. -FOR j = 0,nte-1 DO em_errtot[j] = reform(sqrt(total(error_array[*,*,j]^2.))) - -;get error in em_log rather than em_tot -emlog_err = (em_errtot/em_tot) -energy_map=temperature_map -energy_map.data = energy -energy_map.id = 'Energy [erg]' -clearplot - -IF keyword_set(PLOT) THEN BEGIN - plot,telog,emlog,yrange=minmax(emlog),xtitle='Temperature log(T)',$ - ytitle='Emission measure log(EM [cm!U-5!N K!U-1!N])' - oploterr, telog, emlog, emlog_err -ENDIF -;______________________TOTAL FLUX FROM DEM________________________ -flux_dem=fltarr(nwave) -qflux =fltarr(nwave) -FOR iw=0,nwave-1 do begin - flux_dem[iw]=total(resp_corr[*,iw] * em_tot*dte) * nmacro*npix^2 * mask_frac - qflux[iw] = flux_dem[iw]/flux_[iw] - print,flux_(iw),flux_dem(iw),qflux(iw) -ENDFOR - -;______________________SAVE RESULTS_______________________________ -save,filename=save_dir + teem_tot,telog,emlog,flux_,flux_dem,qflux, emlog_err, error_array, energy_map -;save,filename='teem_tot_test'+strtrim(string(u),2)+'.sav',telog,emlog,emlog_err,flux_,flux_dem,qflux - -END diff --git a/aia_tempmap_movie.pro b/aia_tempmap_movie.pro deleted file mode 100644 index 4c29d7a..0000000 --- a/aia_tempmap_movie.pro +++ /dev/null @@ -1,82 +0,0 @@ -PRO aia_tempmap_movie, dir, FLARE_NUM = flare_num, index = index - -IF keyword_set(flare_num) THEN BEGIN - dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/'] - dir = dir[flare_num-1] - - dir_aia = '~/Desktop/' + ['hsi_flare_20110716_170350/', $ - 'hsi_flare_20110826_205258/', $ - 'hsi_flare_20110603_071626/', $ - 'hsi_flare_20110621_182202/'] - - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'ospex_*.fits') - hsi_fits = f[0] - - f = file_search(hsi_fits_dir + 'hsi_image*.fits') - hsi_image = f[0] - - ;['hsi_image_20110716_170350.fits', $ - ;'hsi_image_20110826_205258.fits', $ - ;'hsi_image_20110603_071626.fits', $ - ;'hsi_image_20110621_181902.fits'] - dir_aia = dir_aia[flare_num-1] - - print, dir - print, hsi_fits - print, hsi_image -ENDIF - -f = file_search(dir + 'teem_data_*.sav') - -ilist = strmid(filename(f), 10, 3) -time_list = unbreak_time(strmid(filename(f),13,15)) - -restore, f[index], /verbose -fits2map, hsi_image, rmap - -min_logtemperature = 5.5 -max_logtemperature = 7.0 -nbins = 20 - -!P.MULTI = [0,2,2] - -plot_map, temperature_map, /cbar, dmin = min_logtemperature, dmax = max_logtemperature -plot_map, rmap, /over, /percent, levels = [50,60,70,80,90] - -imap = inter_map(rmap,temperature_map) -m = max(imap.data) -; set the mask at everything above 50% contour -l = where(imap.data LE m*0.5, complement = complement) -temperature_map.data[l] = 0 -yrange_t = minmax(temperature_map.data[complement]) -EMISSION_MAP.data[l] = 0 -;yrange_em = minmax(EMISSION_MAP.data[complement]) -yrange_em = [21,22.5] -SIGMA_MAP.data[l] = 0 -;yrange_sig = minmax(SIGMA_MAP.data[complement]) -yrange_sig = [0,1] - -hist = histogram(temperature_map.data, min = min_logtemperature, max = max_logtemperature, locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(Temperature [K])', /nodata, title = time_list[index] -oplot, loc, hist, thick = 2.0, psym = 10 - -hist = histogram(EMISSION_MAP.data, min = yrange_em[0], max = yrange_em[1], locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(Emission measure [cm!U-5!N])', /nodata, title = time_list[index] -oplot, loc, hist, thick = 2.0, psym = 10 - -hist = histogram(SIGMA_MAP.data, min = yrange_sig[0], max = yrange_sig[1], locations = loc, nbins = nbins) - -plot, loc, hist, psym = 10, ytitle = 'Number of pixels', xtitle = 'log(sigma [K])', /nodata, title = time_list[index], /ylog, yrange = [1,max(hist)] -oplot, loc, hist, thick = 2.0, psym = 10 - - -stop - -END \ No newline at end of file diff --git a/ospex_multi_therm_test.pro b/ospex_multi_therm_test.pro deleted file mode 100644 index 00fe08f..0000000 --- a/ospex_multi_therm_test.pro +++ /dev/null @@ -1,27 +0,0 @@ -.r ~/idlpro/schriste/f_multi_therm - -e1 = findgen(300)/10.0 + 5 - -edge_products, e1, edges_2=e2, gmean= em - -rel_abun = [26,28] - -low_t = 0.02 -high_t = 2 -dt = 0.01 - -hsi_linecolors - -emission_measure = 1 - -alpha = 10.0 -params = [emission_measure, low_t, high_t, alpha] - -flux1 = f_multi_therm(e2, params, /pow, /cont) -flux2 = f_multi_therm(e2, params, anydem = [transpose(telog), transpose(emlog)], /cont) - -plot, em, flux1, psy=10, xrange=[3,100.], ytitle = ytitle, charsize=1.5, /xstyle, ytickf = "exp1", xtickf = "exp1", /ylog, /xlog, /nodata, xtitle = 'Energy [keV]' - -oplot, em, flux1, color = 2, psym = 10 -oplot, em, flux2, color = 3, psym = 10 - diff --git a/plot_aia_dem.pro b/plot_aia_dem.pro deleted file mode 100644 index 6724d78..0000000 --- a/plot_aia_dem.pro +++ /dev/null @@ -1,100 +0,0 @@ -PRO plot_aia_dem, file, HSI_FITS = hsi_fits, HSI_IMAGE = hsi_image, BKG_FILE = bkg_file, FIT = fit - -default, file, '/Users/schriste/Desktop/flare2_deem/teem_tot_00020110603_064611_mask_.sav' -default, hsi_fits, '~/Dropbox/idl/aia_deem/ospex_results_8_oct_2011.fits' -default, hsi_image, '~/Dropbox/idl/aia_deem/hsi_image_20110826_205258.fits' - -hsi_linecolors - -;parse the time out of the filename -f = filename(file) -t = anytim(unbreak_time(strmid(f,12,15)),/yoh) - -IF keyword_set(BKG_FILE) THEN BEGIN - bkg_file = str_replace(file, 'mask', 'invmask') - f = file_search(bkg_file) - IF f[0] EQ '' THEN stop - restore, bkg_file - - emlog_bkg = emlog - telog_bkg = telog -ENDIF - -f = file_search(bkg_file) -IF f[0] EQ '' THEN stop -restore, file - -yrange = minmax(emlog) - -title = t - -plot, telog, emlog, xtitle = 'log(Temperature [K])', ytitle = 'Emission measure log(EM [cm!U-5!N K!U-1!N])', /nodata, yrange = yrange, /ystyle, charsize = 1.5, title = title -oplot, telog, emlog, thick = 2.0, linestyle = 1 - -IF keyword_set(BKG_FILE) THEN oplot, telog_bkg, emlog_bkg, thick = 2.0, linestyle = 2 - -;text = ['Flare T!Lmax!N = ' + mynum2str(10^max_t_mask),'Background T!Lmax!N = ' + mynum2str(10^max_t)] - -;legend, text, linestyle = [0,1], /right, box = 0, charsize = 1.5, /bottom - -; now fit a line/power-law to the data above 5 MK -index = where(telog GE alog10(5e6)) - -x = telog[index] -y = emlog[index] -res0 = linfit(x,y) - -oplot, [alog10(5e6), alog10(1e8)], res0[1]*[alog10(5e6), alog10(1e8)] + res0[0], color = 6 - -x = telog_bkg[index] -y = emlog_bkg[index] -res1 = linfit(x,y) - -fit = [anytim(t), res0[1], res1[1]] - -oplot, [alog10(5e6), alog10(1e8)], res1[1]*[alog10(5e6), alog10(1e8)] + res1[0], color = 7 - -text = [textoidl('\alpha_{fit} = ') + num2str(res0[1], length = 4), textoidl('\alpha_{fit} = ') + num2str(res1[1], length = 4)] -legend, text, linestyle = 0, color = [6,7], charsize = 1.5, /bottom, pspacing = 1 - -IF keyword_set(HSI_FITS) THEN BEGIN - print, hsi_image - print, hsi_fits - fits2map, hsi_image, map - c = 0.5 - frac = n_elements(where(map.data/max(map.data) GE c))/float(n_elements(map.data)) - area = n_elements(map.data)*frac*map.dx*map.dy * 712e5^2.0 - - result = spex_read_fit_results(hsi_fits) - p = result.spex_summ_params - - ;now find the fit that is closest in time to time t - hsi_time = result.spex_summ_time_interval - con1 = anytim(t) LE anytim(hsi_time[1,*]) - con2 = anytim(t) GE anytim(hsi_time[0,*]) - - IF con1 AND con2 THEN BEGIN - params = p[*,0] - - ;multi_therm_pow - ;DEM(T) = a[0] * (2/T)^a[3] - ;a[0] diff emission measure at T = 2 keV, 10^49 cm^(-3) keV^-1 - ;a[1] min plasma temperature (keV) - ;a[2] max plasma temperature (keV) - ;a[3] power law index - ;a[4] relative abundance - - hsi_telog = alog10([params[1], params[2]]*11.6d6) - hsi_emlog = alog10(1/11.6d6*1d49*params[0]*([2.0/params[1], 2.0/params[2]])^(params[3])) - - hsi_emlog = hsi_emlog - alog10(area) - oplot, hsi_telog, hsi_emlog, thick = 2.0, color = 4 - - legend, ['rhessi (' + textoidl('\alpha = ') + num2str(-params[3], length = 4) + ')', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ENDIF ELSE BEGIN - legend, ['rhessi', 'aia', 'aia (bkg)'], color = [4,1,1], linestyle = [0,1,2], pspacing = 1, charsize = 1.3 - ENDELSE - -ENDIF - -END \ No newline at end of file diff --git a/plot_many_aia_dem.pro b/plot_many_aia_dem.pro deleted file mode 100644 index 98ee7a1..0000000 --- a/plot_many_aia_dem.pro +++ /dev/null @@ -1,61 +0,0 @@ -PRO plot_many_aia_dem, dir, istart = istart, hsi_fits = hsi_fits, hsi_image = hsi_image, OUTPLOT = outplot, DEBUG = debug, FLARE_NUM = flare_num - -default, istart, 0 -default, dir, '/Users/schriste/Desktop/flare2_deem/' -default, hsi_fits, '~/Dropbox/idl/aia_deem/ospex_results_8_oct_2011.fits' -default, hsi_image, '~/Dropbox/idl/aia_deem/hsi_image_20110826_205258.fits' - -IF keyword_set(flare_num) THEN BEGIN - dir = '~/Desktop/' + ['flare0_deem/', $ - 'flare1_deem/', $ - 'flare2_deem/', $ - 'flare3_deem/'] - - hsi_fits_dir = '/Users/schriste/Desktop/flare_' + num2str(flare_num-1) + '_rhessi/' - f = file_search(hsi_fits_dir + 'ospex_*.fits') - hsi_fits = f[0] - - f = file_search(hsi_fits_dir + 'hsi_image*.fits') - hsi_image = f[0] - - ;['hsi_image_20110716_170350.fits', $ - ;'hsi_image_20110826_205258.fits', $ - ;'hsi_image_20110603_071626.fits', $ - ;'hsi_image_20110621_181902.fits'] - - dir = dir[flare_num-1] - print, dir - print, hsi_fits - print, hsi_image -ENDIF - -f = file_search(dir + 'teem_tot*_mask_.sav') - -dim = n_elements(f) - -fit_result = dblarr(dim,3) - -FOR i = istart, dim-1 DO BEGIN - - IF keyword_set(OUTPLOT) THEN BEGIN - set_plot, 'z' - loadct,0 - hsi_linecolors - device, set_resolution = [800, 600] - ENDIF - - plot_aia_dem, f[i], hsi_fits = hsi_fits, hsi_image = hsi_image, /bkg_file, fit = fit - fit_result[i,*] = fit - IF keyword_set(OUTPLOT) THEN BEGIN - tvlct, r, g, b, /get - outfile = 'dem_' + num2str(i, padchar = '0', length = 4) + '_' + break_time(anytim(fit[0],/yoh)) + '.png' - write_png, outfile, tvrd(), r,g,b - set_plot, 'x' - ENDIF - IF keyword_set(DEBUG) THEN stop - -ENDFOR - -save, fit_result, filename = 'aia_dem_slope_' + num2str(flare_num) + '.sav' - -END \ No newline at end of file