Run Regularized Inversion Code

Run the demreg code of HK12 to find the emission measure distribution from the intensities. Save the derived emission measure distributions because this calculation takes a long time.


In [1]:
import os

import numpy as np
import pandas
from scipy.optimize import curve_fit
import scipy.linalg
import scipy.stats
from scipy.interpolate import interp1d,splev,splrep
from scipy.ndimage import map_coordinates,gaussian_filter
import matplotlib.pyplot as plt
import matplotlib.colors
from matplotlib.ticker import LogFormatter
import seaborn as sns
import astropy.units as u
import astropy.constants as const
import hissw
from sunpy.map import Map,GenericMap
import h5py
from ChiantiPy.tools import filters as ch_filters

import synthesizAR
from synthesizAR.instruments import InstrumentHinodeEIS
from synthesizAR.util import EISCube,EMCube
from synthesizAR.atomic import EmissionModel

%matplotlib inline


/home/wtb2/anaconda3/envs/systematic-ar-study/lib/python3.5/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)
WARNING: AstropyDeprecationWarning: astropy.utils.compat.odict.OrderedDict is now deprecated - import OrderedDict from the collections module instead [astropy.utils.compat.odict]
/home/wtb2/anaconda3/envs/systematic-ar-study/lib/python3.5/site-packages/matplotlib/__init__.py:1401: UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)
 using cli
 using CLI for selections
 reading chiantirc file

In [2]:
eis = InstrumentHinodeEIS([7.5e3,1.25e4]*u.s)

In [3]:
frequencies = [250,750,'750-ion',2500,5000]

In [12]:
temperature_bin_edges = 10.**(np.arange(5.6, 7.0, 0.05))*u.K

First, load the emission model.


In [4]:
emission_model = EmissionModel.restore('/data/datadrive1/ar_forward_modeling/systematic_ar_study/emission_model1109_full/')


H I psplups file not found
He II psplups file not found
N VII psplups file not found
O VIII psplups file not found
Ne X psplups file not found
Na XI psplups file not found
Mg XII psplups file not found
Al XIII psplups file not found
Si XIV psplups file not found
P XV psplups file not found
S XVI psplups file not found
Cl XVII psplups file not found
Ar XVIII psplups file not found
K XIX psplups file not found
Ca XX psplups file not found
Fe XXVI psplups file not found
Ni XXVIII psplups file not found
He I psplups file not found
C V psplups file not found
N VI psplups file not found
O VII psplups file not found
Ne IX psplups file not found
Na X psplups file not found
Mg XI psplups file not found
Al XII psplups file not found
Si XIII psplups file not found
P XIV psplups file not found
S XV psplups file not found
Cl XVI psplups file not found
Ar XVII psplups file not found
K XVIII psplups file not found
Ca XIX psplups file not found
Fe XXV psplups file not found
Ni XXVII psplups file not found
Zn XXIX psplups file not found
C IV psplups file not found
N V psplups file not found
O VI psplups file not found
Ne VIII psplups file not found
Na IX psplups file not found
Mg X psplups file not found
Al XI psplups file not found
Si XII psplups file not found
P XIII psplups file not found
S XIV psplups file not found
Ar XVI psplups file not found
K XVII psplups file not found
Ca XVIII psplups file not found
Ti XX psplups file not found
Cr  XXII psplups file not found
Mn XXIII psplups file not found
Fe XXIV psplups file not found
Co XXV psplups file not found
Ni XXVI psplups file not found
Zn XXVIII psplups file not found
Na VIII psplups file not found
P XII psplups file not found
Cl XIV psplups file not found
K XVI psplups file not found
Mn  XXII psplups file not found
Co XXIV psplups file not found
Zn XXVII psplups file not found
Na VII psplups file not found
P XI psplups file not found
Cl XIII psplups file not found
K XV psplups file not found
Co XXIII psplups file not found
C I psplups file not found
Na VI psplups file not found
Al VIII psplups file not found
P X psplups file not found
Cl XII psplups file not found
K XIV psplups file not found
Mn XX psplups file not found
Co  XXII psplups file not found
Zn XXV psplups file not found
N I psplups file not found
O II psplups file not found
Ne IV psplups file not found
Na V psplups file not found
Al VII psplups file not found
P IX psplups file not found
Cl XI psplups file not found
Ar XII psplups file not found
K XIII psplups file not found
Ca XIV psplups file not found
Mn XIX psplups file not found
Co XXI psplups file not found
Zn XXIV psplups file not found
O I psplups file not found
Cl X psplups file not found
K XII psplups file not found
Mn XVIII psplups file not found
Co XX psplups file not found
Zn XXIII psplups file not found
K XI psplups file not found
Mn XVII psplups file not found
Co XIX psplups file not found
Na II psplups file not found
Mg III psplups file not found
Al IV psplups file not found
Si V psplups file not found
P VI psplups file not found
S VII psplups file not found
Ar IX psplups file not found
K X psplups file not found
Ca XI psplups file not found
Ti XIII psplups file not found
Cr XV psplups file not found
Mn XVI psplups file not found
Fe XVII psplups file not found
Co XVIII psplups file not found
Ni XIX psplups file not found
Zn XXI psplups file not found
Mg II psplups file not found
Al III psplups file not found
Si IV psplups file not found
P V psplups file not found
S VI psplups file not found
Ar VIII psplups file not found
K IX psplups file not found
Ca X psplups file not found
Ti XII psplups file not found
Cr XIV psplups file not found
Mn XV psplups file not found
Fe XVI psplups file not found
Co XVII psplups file not found
Ni XVIII psplups file not found
Zn XX psplups file not found
Al II psplups file not found
Ti XI psplups file not found
Cr XIII psplups file not found
Ni XVII psplups file not found
Ca VIII psplups file not found
S III psplups file not found
Cl IV psplups file not found
Ar V psplups file not found
K VI psplups file not found
Ca VII psplups file not found
S II psplups file not found
Cl III psplups file not found
Ar IV psplups file not found
K V psplups file not found
Ca VI psplups file not found
Ni XIV psplups file not found
S I psplups file not found
Cl II psplups file not found
Ar III psplups file not found
Ca V psplups file not found
Cr IX psplups file not found
Mn X psplups file not found
Cr VIII psplups file not found
Mn IX psplups file not found
Cr VII psplups file not found
Mn VIII psplups file not found
Fe IX psplups file not found
Ni XI psplups file not found
Ca II psplups file not found
Fe VIII psplups file not found
Fe VII psplups file not found
Fe VI psplups file not found
Fe V psplups file not found
Fe IV psplups file not found
Fe III psplups file not found
Fe II psplups file not found
Ni II psplups file not found

List the resolved wavelengths for convenience.


In [5]:
resolved_wavelengths = np.sort(u.Quantity([rw for ion in emission_model.ions for rw in ion.resolved_wavelengths]))

and calculate the contribution functions.


In [6]:
pressure_const = 1e15*u.K*u.cm**(-3)
class FakeLoop(object):
    electron_temperature = np.logspace(5.5,7.5,100)*u.K
    density = pressure_const/electron_temperature
    
fake_loop = FakeLoop()
i_temperature,i_density = emission_model.interpolate_to_mesh_indices(fake_loop)

In [7]:
contribution_functions = {}
line_names = {}
for ion in emission_model.ions:
    for rw in ion.resolved_wavelengths:
        i_rw = np.where(ion.wavelength==rw)[0][0]
        emiss = map_coordinates(ion.emissivity[:,:,i_rw].value,
                                np.vstack([i_temperature,i_density]),order=3)*ion.emissivity.unit
        ioneq = splev(fake_loop.electron_temperature.value,
                      splrep(emission_model.temperature_mesh[:,0].value,
                             ion.fractional_ionization[:,0].value,k=1),ext=1)
        line_names[rw] = '{} {}'.format(ion.chianti_ion.meta['name'],rw.value)
        contribution_functions[rw] = (1./(np.pi*4.*u.steradian)*0.83
                                           *ioneq*ion.chianti_ion.abundance*emiss/fake_loop.density
                                           *(const.h.cgs*const.c.cgs)/rw.to(u.cm)/u.photon)

Now, load the time-average intensities and slice in wavelength and integrate at the desired indicies corresponding to the resolved wavelength. This gives us a map of integrated intensity for each of the lines that we are interested in.


In [54]:
line_intensities = {'{}'.format(freq):{} for freq in frequencies}

In [55]:
for freq in frequencies:
    for channel in eis.channels:
        tmp = EISCube('../data/eis_intensity_{}_tn{}_t7500-12500.h5'.format(channel['name'],freq))
        if type(freq) == int:
            tmp.data = (gaussian_filter(tmp.data.value,(channel['gaussian_width']['y'].value,
                                                        channel['gaussian_width']['x'].value,0.)))*tmp.data.unit
        for rw in resolved_wavelengths:
            i_center = np.where(np.isclose(tmp.wavelength.value,rw.value,atol=1.1e-2,rtol=0.))[0]
            if len(i_center) == 0:
                continue
            line_intensities['{}'.format(freq)][rw] = tmp[i_center-5:i_center+5].integrated_intensity


WARNING: UnitsWarning: 'erg(1/2) g(1/2) / (Angstrom cm s2 sr)' contains multiple slashes, which is discouraged by the FITS standard [astropy.units.format.generic]
/home/wtb2/anaconda3/envs/systematic-ar-study/lib/python3.5/site-packages/astropy/units/quantity.py:1023: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future
  out = super(Quantity, self).__getitem__(key)

Peek at the integrated intensities.


In [57]:
fig = plt.figure(figsize=(17,15))
plt.subplots_adjust(right=0.85)
cax = fig.add_axes([0.88, 0.12, 0.025, 0.75])
for i,rw in enumerate(resolved_wavelengths):
    tmp = (line_intensities['750'][rw]
           .submap(u.Quantity((270,450),u.arcsec),u.Quantity((90,360),u.arcsec))
          )
    ax = fig.add_subplot(5,5,i+1,projection=tmp)
    im = tmp.plot(axes=ax,annotate=False,title=False,
                  norm=matplotlib.colors.SymLogNorm(1,vmin=1e2,vmax=1e5)
                 )
    ax.set_title(r'{:.3f} {}'.format(rw.value,rw.unit.to_string(format='latex')))
cbar = fig.colorbar(im,cax=cax)


Reshape the data so that it can be passed to the demreg script.


In [58]:
k_matrix = []
intensity_matrix = []
line_names = []
for rw in resolved_wavelengths:
    line_name = '{}_{}'.format(rw.value,rw.unit)
    line_names.append(line_name)
    k_matrix.append(contribution_functions[rw].value.tolist())
    for freq in frequencies:
        line_intensities['{}'.format(freq)][rw].save('../data/eis_integrated_intensity_{}_{}.fits'.format(freq,line_name))

Now run the inversion code.


In [59]:
demreg_runner = hissw.ScriptMaker(extra_paths=['/home/wtb2/Documents/codes/demreg/idl/'],
                                  ssw_path_list=['vobs','ontology'])
static_input_vars = {
                     'log_temperature':np.log10(fake_loop.electron_temperature.value).tolist(),
                     'temperature_bins':temperature_bin_edges.value.tolist(),
                     'k_matrix':k_matrix,
                     'names':line_names,
                     'error_ratio':0.25,
                     'gloci':1,'reg_tweak':1,'timed':1
                    }
save_vars = ['dem','edem','elogt','chisq','dn_reg']

In [60]:
demreg_script = """
; load intensity from each channel/line
names = {{ names }}
eis_file_list = find_file('{{ fits_file_glob }}')
read_sdo,eis_file_list,ind,intensity
; load the contribution functions or response functions (called K in Hannah and Kontar 2012)
k_matrix = {{ k_matrix }}
; load temperature array over which K is computed
log_temperature = {{ log_temperature }}

; temperature bins
temperature_bins = {{ temperature_bins }}

; crude estimate of intensity errors
intensity_errors = intensity*{{ error_ratio }}

; inversion method parameters
reg_tweak={{ reg_tweak }}
timed={{ timed }}
gloci={{ gloci }}

; run the inversion method
dn2dem_pos_nb,intensity,intensity_errors,$
              k_matrix,log_temperature,temperature_bins,$
              dem,edem,elogt,chisq,dn_reg,$
              timed=timed,gloci=gloci,reg_tweak=reg_tweak
"""

In [61]:
for freq in frequencies:
    input_vars = static_input_vars.copy()
    input_vars['fits_file_glob'] = '/home/wtb2/Documents/projects/loops-workshop-2017-talk/data/eis_integrated_intensity_{}_*.fits'.format(freq)
    tmp = demreg_runner.run([(demreg_script,input_vars)],save_vars=save_vars,cleanup=True,verbose=True)
    tmp_cube = EMCube(np.swapaxes(tmp['dem'].T,0,1)*np.diff(temperature_bin_edges.value)*(u.cm**(-5)),
                      (line_intensities['{}'.format(freq)][resolved_wavelengths[0]].meta),temperature_bin_edges)
    tmp_cube.save('../data/em_cubes_demreg_tn{}_t7500-12500.h5'.format(freq))


SSW  setup will include: <gen>

Type <sswidl> to start SSW IDL
--------------------------------------------------------
Running SSW, Last Updated: Wed Nov 2 22:22:51 GMT 2005
 
PROBLEMS? - e-mail TO: freeland@penumbra.nascom.nasa.gov
--------------------------------------------------------
IDL Version 8.5 (linux x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation.
Installation number: 401801-1.
Licensed for use by: Rice University

Executing SSW IDL_STARTUP for: GEN
Executing SSW IDL_STARTUP for: SITE
% Compiled module: SSW_PATH.
% Compiled module: SSW_INSTRUMENTS.
% Compiled module: WC_WHERE.
% Compiled module: PATHFIX.
% Compiled module: UNIQO.
% Compiled module: STRJUSTIFY.
% Compiled module: UNIQ.
% Compiled module: DEFAULT.
% Compiled module: PRSTR.
Including Paths:
 ---------------------------------
| $SSW/vobs/gen/idl               |
| $SSW/vobs/ontology/idl/jsoc     |
| $SSW/vobs/ontology/idl/gen_temp |
| $SSW/vobs/ontology/idl          |
 ---------------------------------
% SSW_PATH: Number of paths changed from 88 to 92
% Compiled module: FIND_FILE.
% Compiled module: READ_SDO.
% Compiled module: GET_FITS_NEXTEND.
% Compiled module: FITS_OPEN.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% Compiled module: SXDELPAR.
% Compiled module: REQUIRED_TAGS.
% Compiled module: MREADFITS_SHM.
% Compiled module: FILE_SIZE.
% Compiled module: WHERE_PATTERN.
% Compiled module: LAST_NELEM.
% Compiled module: ALPHAGEN.
% Compiled module: DELVARX.
% Compiled module: DELVARX2.
% Compiled module: DESTROY.
% Compiled module: IS_LENDIAN.
% Compiled module: GET_NBYTES.
% Compiled module: SWAP_ENDIAN_INPLACE.
% Compiled module: RELTIME.
% Compiled module: UT_TIME.
% Compiled module: UT_DIFF.
% Compiled module: SYSTIM.
% Compiled module: ANYTIM.
% Compiled module: IS_STRUCT.
% Compiled module: CHECKVAR.
% Compiled module: STR_LASTPOS.
% Compiled module: STR2UTC.
% Compiled module: BOOST_ARRAY.
% Compiled module: UTC2INT.
% Compiled module: TAG_EXIST.
% Compiled module: DATE2MJD.
% Compiled module: CHECK_INT_TIME.
% Compiled module: GET_LEAP_SEC.
% Compiled module: UTIME2STR.
% Compiled module: GETUTBASE.
% Compiled module: GETUT.
% Compiled module: INT2EX.
% Compiled module: DAYCNV.
% Compiled module: EX2INT.
% Compiled module: JDCNV.
% Compiled module: INT2SEC.
% Compiled module: ANYTIM2INTS.
% Compiled module: TIMSTR2EX.
% Compiled module: CHECK_TIME.
% Compiled module: FMT_TIM.
% Compiled module: GT_DAY.
% Compiled module: GT_TIME.
% Compiled module: ATIME.
% Compiled module: FCHECK.
% Compiled module: F_ATIME.
% Compiled module: TIMEGRID.
% Compiled module: CONCAT_STRUCT.
% Compiled module: INT2SECARR.
% Compiled module: MREADFITS_HEADER.
% Compiled module: HEADFITS.
% Compiled module: FXPOSIT.
% Compiled module: MRD_HREAD.
% Compiled module: FITSHEAD2STRUCT.
% Compiled module: FXADDPAR.
% Compiled module: FXPARPOS.
% Compiled module: FXPAR.
% Compiled module: FMT_TAG.
% Compiled module: DETABIFY.
% Compiled module: STRARRCOMPRESS.
% Compiled module: STRSPECIAL.
% Compiled module: STRLASTCHAR.
% Compiled module: SSW_STRSPLIT.
% Compiled module: ID_ESC.
% Compiled module: ISVALID.
% Compiled module: ID_ESC_INIT.
% Compiled module: SSW_UNIQ.
% Compiled module: ID_UNESC.
% Compiled module: MRD_STRUCT.
% Compiled module: IS_NUMBER.
% Compiled module: IS_NUMBER2.
% Compiled module: TAG_INDEX.
% Compiled module: STRMIDS.
% Compiled module: GT_TAGVAL.
% Compiled module: STR_TAGVAL.
% Compiled module: ALL_VALS.
% Compiled module: UPDATE_HISTORY.
% Compiled module: GET_CALLER.
% Compiled module: STR2NUMBER.
% Compiled module: BOOST_TAG.
% Compiled module: STRUP.
% Compiled module: GET_TAG_INDEX.
% Compiled module: IDL_RELEASE.
% Compiled module: REP_TAG_VALUE.
% Compiled module: REM_TAG.
% Compiled module: ADD_TAG.
% Compiled module: LAST_ITEM.
% Compiled module: COPY_VAR.
% Compiled module: COMP_FITS_CEN.
% Compiled module: REPLICATE2.
% Program caused arithmetic error: Floating underflow
% Compiled module: DN2DEM_POS_NB.
% Compiled module: GET_EDGES.
% Compiled module: EDGE_PRODUCTS.
% Compiled module: INTERPOL.
% Compiled module: DEMMAP_POS.
      0 of  116640,   0.0%
% Compiled module: DEM_INV_GSVDCSQ.
% Compiled module: DEM_INV_REG_PARAMETER_MAP.
   5000 of  116640,   4.3%
  10000 of  116640,   8.6%
  15000 of  116640,  12.9%
  20000 of  116640,  17.1%
  25000 of  116640,  21.4%
  30000 of  116640,  25.7%
  35000 of  116640,  30.0%
  40000 of  116640,  34.3%
  45000 of  116640,  38.6%
  50000 of  116640,  42.9%
  55000 of  116640,  47.2%
  60000 of  116640,  51.4%
  65000 of  116640,  55.7%
  70000 of  116640,  60.0%
  75000 of  116640,  64.3%
  80000 of  116640,  68.6%
  85000 of  116640,  72.9%
  90000 of  116640,  77.2%
  95000 of  116640,  81.4%
 100000 of  116640,  85.7%
 105000 of  116640,  90.0%
 110000 of  116640,  94.3%
 115000 of  116640,  98.6%
100% Done
    249.3 DEM/s
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating illegal operand

SSW  setup will include: <gen>

Type <sswidl> to start SSW IDL
--------------------------------------------------------
Running SSW, Last Updated: Wed Nov 2 22:22:51 GMT 2005
 
PROBLEMS? - e-mail TO: freeland@penumbra.nascom.nasa.gov
--------------------------------------------------------
IDL Version 8.5 (linux x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation.
Installation number: 401801-1.
Licensed for use by: Rice University

Executing SSW IDL_STARTUP for: GEN
Executing SSW IDL_STARTUP for: SITE
% Compiled module: SSW_PATH.
% Compiled module: SSW_INSTRUMENTS.
% Compiled module: WC_WHERE.
% Compiled module: PATHFIX.
% Compiled module: UNIQO.
% Compiled module: STRJUSTIFY.
% Compiled module: UNIQ.
% Compiled module: DEFAULT.
% Compiled module: PRSTR.
Including Paths:
 ---------------------------------
| $SSW/vobs/gen/idl               |
| $SSW/vobs/ontology/idl/jsoc     |
| $SSW/vobs/ontology/idl/gen_temp |
| $SSW/vobs/ontology/idl          |
 ---------------------------------
% SSW_PATH: Number of paths changed from 88 to 92
% Compiled module: FIND_FILE.
% Compiled module: READ_SDO.
% Compiled module: GET_FITS_NEXTEND.
% Compiled module: FITS_OPEN.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% Compiled module: SXDELPAR.
% Compiled module: REQUIRED_TAGS.
% Compiled module: MREADFITS_SHM.
% Compiled module: FILE_SIZE.
% Compiled module: WHERE_PATTERN.
% Compiled module: LAST_NELEM.
% Compiled module: ALPHAGEN.
% Compiled module: DELVARX.
% Compiled module: DELVARX2.
% Compiled module: DESTROY.
% Compiled module: IS_LENDIAN.
% Compiled module: GET_NBYTES.
% Compiled module: SWAP_ENDIAN_INPLACE.
% Compiled module: RELTIME.
% Compiled module: UT_TIME.
% Compiled module: UT_DIFF.
% Compiled module: SYSTIM.
% Compiled module: ANYTIM.
% Compiled module: IS_STRUCT.
% Compiled module: CHECKVAR.
% Compiled module: STR_LASTPOS.
% Compiled module: STR2UTC.
% Compiled module: BOOST_ARRAY.
% Compiled module: UTC2INT.
% Compiled module: TAG_EXIST.
% Compiled module: DATE2MJD.
% Compiled module: CHECK_INT_TIME.
% Compiled module: GET_LEAP_SEC.
% Compiled module: UTIME2STR.
% Compiled module: GETUTBASE.
% Compiled module: GETUT.
% Compiled module: INT2EX.
% Compiled module: DAYCNV.
% Compiled module: EX2INT.
% Compiled module: JDCNV.
% Compiled module: INT2SEC.
% Compiled module: ANYTIM2INTS.
% Compiled module: TIMSTR2EX.
% Compiled module: CHECK_TIME.
% Compiled module: FMT_TIM.
% Compiled module: GT_DAY.
% Compiled module: GT_TIME.
% Compiled module: ATIME.
% Compiled module: FCHECK.
% Compiled module: F_ATIME.
% Compiled module: TIMEGRID.
% Compiled module: CONCAT_STRUCT.
% Compiled module: INT2SECARR.
% Compiled module: MREADFITS_HEADER.
% Compiled module: HEADFITS.
% Compiled module: FXPOSIT.
% Compiled module: MRD_HREAD.
% Compiled module: FITSHEAD2STRUCT.
% Compiled module: FXADDPAR.
% Compiled module: FXPARPOS.
% Compiled module: FXPAR.
% Compiled module: FMT_TAG.
% Compiled module: DETABIFY.
% Compiled module: STRARRCOMPRESS.
% Compiled module: STRSPECIAL.
% Compiled module: STRLASTCHAR.
% Compiled module: SSW_STRSPLIT.
% Compiled module: ID_ESC.
% Compiled module: ISVALID.
% Compiled module: ID_ESC_INIT.
% Compiled module: SSW_UNIQ.
% Compiled module: ID_UNESC.
% Compiled module: MRD_STRUCT.
% Compiled module: IS_NUMBER.
% Compiled module: IS_NUMBER2.
% Compiled module: TAG_INDEX.
% Compiled module: STRMIDS.
% Compiled module: GT_TAGVAL.
% Compiled module: STR_TAGVAL.
% Compiled module: ALL_VALS.
% Compiled module: UPDATE_HISTORY.
% Compiled module: GET_CALLER.
% Compiled module: STR2NUMBER.
% Compiled module: BOOST_TAG.
% Compiled module: STRUP.
% Compiled module: GET_TAG_INDEX.
% Compiled module: IDL_RELEASE.
% Compiled module: REP_TAG_VALUE.
% Compiled module: REM_TAG.
% Compiled module: ADD_TAG.
% Compiled module: LAST_ITEM.
% Compiled module: COPY_VAR.
% Compiled module: COMP_FITS_CEN.
% Compiled module: REPLICATE2.
% Program caused arithmetic error: Floating underflow
% Compiled module: DN2DEM_POS_NB.
% Compiled module: GET_EDGES.
% Compiled module: EDGE_PRODUCTS.
% Compiled module: INTERPOL.
% Compiled module: DEMMAP_POS.
      0 of  116640,   0.0%
% Compiled module: DEM_INV_GSVDCSQ.
% Compiled module: DEM_INV_REG_PARAMETER_MAP.
   5000 of  116640,   4.3%
  10000 of  116640,   8.6%
  15000 of  116640,  12.9%
  20000 of  116640,  17.1%
  25000 of  116640,  21.4%
  30000 of  116640,  25.7%
  35000 of  116640,  30.0%
  40000 of  116640,  34.3%
  45000 of  116640,  38.6%
  50000 of  116640,  42.9%
  55000 of  116640,  47.2%
  60000 of  116640,  51.4%
  65000 of  116640,  55.7%
  70000 of  116640,  60.0%
  75000 of  116640,  64.3%
  80000 of  116640,  68.6%
  85000 of  116640,  72.9%
  90000 of  116640,  77.2%
  95000 of  116640,  81.4%
 100000 of  116640,  85.7%
 105000 of  116640,  90.0%
 110000 of  116640,  94.3%
 115000 of  116640,  98.6%
100% Done
    265.3 DEM/s
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating illegal operand

SSW  setup will include: <gen>

Type <sswidl> to start SSW IDL
--------------------------------------------------------
Running SSW, Last Updated: Wed Nov 2 22:22:51 GMT 2005
 
PROBLEMS? - e-mail TO: freeland@penumbra.nascom.nasa.gov
--------------------------------------------------------
IDL Version 8.5 (linux x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation.
Installation number: 401801-1.
Licensed for use by: Rice University

Executing SSW IDL_STARTUP for: GEN
Executing SSW IDL_STARTUP for: SITE
% Compiled module: SSW_PATH.
% Compiled module: SSW_INSTRUMENTS.
% Compiled module: WC_WHERE.
% Compiled module: PATHFIX.
% Compiled module: UNIQO.
% Compiled module: STRJUSTIFY.
% Compiled module: UNIQ.
% Compiled module: DEFAULT.
% Compiled module: PRSTR.
Including Paths:
 ---------------------------------
| $SSW/vobs/gen/idl               |
| $SSW/vobs/ontology/idl/jsoc     |
| $SSW/vobs/ontology/idl/gen_temp |
| $SSW/vobs/ontology/idl          |
 ---------------------------------
% SSW_PATH: Number of paths changed from 88 to 92
% Compiled module: FIND_FILE.
% Compiled module: READ_SDO.
% Compiled module: GET_FITS_NEXTEND.
% Compiled module: FITS_OPEN.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% Compiled module: SXDELPAR.
% Compiled module: REQUIRED_TAGS.
% Compiled module: MREADFITS_SHM.
% Compiled module: FILE_SIZE.
% Compiled module: WHERE_PATTERN.
% Compiled module: LAST_NELEM.
% Compiled module: ALPHAGEN.
% Compiled module: DELVARX.
% Compiled module: DELVARX2.
% Compiled module: DESTROY.
% Compiled module: IS_LENDIAN.
% Compiled module: GET_NBYTES.
% Compiled module: SWAP_ENDIAN_INPLACE.
% Compiled module: RELTIME.
% Compiled module: UT_TIME.
% Compiled module: UT_DIFF.
% Compiled module: SYSTIM.
% Compiled module: ANYTIM.
% Compiled module: IS_STRUCT.
% Compiled module: CHECKVAR.
% Compiled module: STR_LASTPOS.
% Compiled module: STR2UTC.
% Compiled module: BOOST_ARRAY.
% Compiled module: UTC2INT.
% Compiled module: TAG_EXIST.
% Compiled module: DATE2MJD.
% Compiled module: CHECK_INT_TIME.
% Compiled module: GET_LEAP_SEC.
% Compiled module: UTIME2STR.
% Compiled module: GETUTBASE.
% Compiled module: GETUT.
% Compiled module: INT2EX.
% Compiled module: DAYCNV.
% Compiled module: EX2INT.
% Compiled module: JDCNV.
% Compiled module: INT2SEC.
% Compiled module: ANYTIM2INTS.
% Compiled module: TIMSTR2EX.
% Compiled module: CHECK_TIME.
% Compiled module: FMT_TIM.
% Compiled module: GT_DAY.
% Compiled module: GT_TIME.
% Compiled module: ATIME.
% Compiled module: FCHECK.
% Compiled module: F_ATIME.
% Compiled module: TIMEGRID.
% Compiled module: CONCAT_STRUCT.
% Compiled module: INT2SECARR.
% Compiled module: MREADFITS_HEADER.
% Compiled module: HEADFITS.
% Compiled module: FXPOSIT.
% Compiled module: MRD_HREAD.
% Compiled module: FITSHEAD2STRUCT.
% Compiled module: FXADDPAR.
% Compiled module: FXPARPOS.
% Compiled module: FXPAR.
% Compiled module: FMT_TAG.
% Compiled module: DETABIFY.
% Compiled module: STRARRCOMPRESS.
% Compiled module: STRSPECIAL.
% Compiled module: STRLASTCHAR.
% Compiled module: SSW_STRSPLIT.
% Compiled module: ID_ESC.
% Compiled module: ISVALID.
% Compiled module: ID_ESC_INIT.
% Compiled module: SSW_UNIQ.
% Compiled module: ID_UNESC.
% Compiled module: MRD_STRUCT.
% Compiled module: IS_NUMBER.
% Compiled module: IS_NUMBER2.
% Compiled module: TAG_INDEX.
% Compiled module: STRMIDS.
% Compiled module: GT_TAGVAL.
% Compiled module: STR_TAGVAL.
% Compiled module: ALL_VALS.
% Compiled module: UPDATE_HISTORY.
% Compiled module: GET_CALLER.
% Compiled module: STR2NUMBER.
% Compiled module: BOOST_TAG.
% Compiled module: STRUP.
% Compiled module: GET_TAG_INDEX.
% Compiled module: IDL_RELEASE.
% Compiled module: REP_TAG_VALUE.
% Compiled module: REM_TAG.
% Compiled module: ADD_TAG.
% Compiled module: LAST_ITEM.
% Compiled module: COPY_VAR.
% Compiled module: COMP_FITS_CEN.
% Compiled module: REPLICATE2.
% Program caused arithmetic error: Floating underflow
% Compiled module: DN2DEM_POS_NB.
% Compiled module: GET_EDGES.
% Compiled module: EDGE_PRODUCTS.
% Compiled module: INTERPOL.
% Compiled module: DEMMAP_POS.
      0 of  116640,   0.0%
% Compiled module: DEM_INV_GSVDCSQ.
% Compiled module: DEM_INV_REG_PARAMETER_MAP.
   5000 of  116640,   4.3%
  10000 of  116640,   8.6%
  15000 of  116640,  12.9%
  20000 of  116640,  17.1%
  25000 of  116640,  21.4%
  30000 of  116640,  25.7%
  35000 of  116640,  30.0%
  40000 of  116640,  34.3%
  45000 of  116640,  38.6%
  50000 of  116640,  42.9%
  55000 of  116640,  47.2%
  60000 of  116640,  51.4%
  65000 of  116640,  55.7%
  70000 of  116640,  60.0%
  75000 of  116640,  64.3%
  80000 of  116640,  68.6%
  85000 of  116640,  72.9%
  90000 of  116640,  77.2%
  95000 of  116640,  81.4%
 100000 of  116640,  85.7%
 105000 of  116640,  90.0%
 110000 of  116640,  94.3%
 115000 of  116640,  98.6%
100% Done
    260.3 DEM/s
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating illegal operand

SSW  setup will include: <gen>

Type <sswidl> to start SSW IDL
--------------------------------------------------------
Running SSW, Last Updated: Wed Nov 2 22:22:51 GMT 2005
 
PROBLEMS? - e-mail TO: freeland@penumbra.nascom.nasa.gov
--------------------------------------------------------
IDL Version 8.5 (linux x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation.
Installation number: 401801-1.
Licensed for use by: Rice University

Executing SSW IDL_STARTUP for: GEN
Executing SSW IDL_STARTUP for: SITE
% Compiled module: SSW_PATH.
% Compiled module: SSW_INSTRUMENTS.
% Compiled module: WC_WHERE.
% Compiled module: PATHFIX.
% Compiled module: UNIQO.
% Compiled module: STRJUSTIFY.
% Compiled module: UNIQ.
% Compiled module: DEFAULT.
% Compiled module: PRSTR.
Including Paths:
 ---------------------------------
| $SSW/vobs/gen/idl               |
| $SSW/vobs/ontology/idl/jsoc     |
| $SSW/vobs/ontology/idl/gen_temp |
| $SSW/vobs/ontology/idl          |
 ---------------------------------
% SSW_PATH: Number of paths changed from 88 to 92
% Compiled module: FIND_FILE.
% Compiled module: READ_SDO.
% Compiled module: GET_FITS_NEXTEND.
% Compiled module: FITS_OPEN.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% Compiled module: SXDELPAR.
% Compiled module: REQUIRED_TAGS.
% Compiled module: MREADFITS_SHM.
% Compiled module: FILE_SIZE.
% Compiled module: WHERE_PATTERN.
% Compiled module: LAST_NELEM.
% Compiled module: ALPHAGEN.
% Compiled module: DELVARX.
% Compiled module: DELVARX2.
% Compiled module: DESTROY.
% Compiled module: IS_LENDIAN.
% Compiled module: GET_NBYTES.
% Compiled module: SWAP_ENDIAN_INPLACE.
% Compiled module: RELTIME.
% Compiled module: UT_TIME.
% Compiled module: UT_DIFF.
% Compiled module: SYSTIM.
% Compiled module: ANYTIM.
% Compiled module: IS_STRUCT.
% Compiled module: CHECKVAR.
% Compiled module: STR_LASTPOS.
% Compiled module: STR2UTC.
% Compiled module: BOOST_ARRAY.
% Compiled module: UTC2INT.
% Compiled module: TAG_EXIST.
% Compiled module: DATE2MJD.
% Compiled module: CHECK_INT_TIME.
% Compiled module: GET_LEAP_SEC.
% Compiled module: UTIME2STR.
% Compiled module: GETUTBASE.
% Compiled module: GETUT.
% Compiled module: INT2EX.
% Compiled module: DAYCNV.
% Compiled module: EX2INT.
% Compiled module: JDCNV.
% Compiled module: INT2SEC.
% Compiled module: ANYTIM2INTS.
% Compiled module: TIMSTR2EX.
% Compiled module: CHECK_TIME.
% Compiled module: FMT_TIM.
% Compiled module: GT_DAY.
% Compiled module: GT_TIME.
% Compiled module: ATIME.
% Compiled module: FCHECK.
% Compiled module: F_ATIME.
% Compiled module: TIMEGRID.
% Compiled module: CONCAT_STRUCT.
% Compiled module: INT2SECARR.
% Compiled module: MREADFITS_HEADER.
% Compiled module: HEADFITS.
% Compiled module: FXPOSIT.
% Compiled module: MRD_HREAD.
% Compiled module: FITSHEAD2STRUCT.
% Compiled module: FXADDPAR.
% Compiled module: FXPARPOS.
% Compiled module: FXPAR.
% Compiled module: FMT_TAG.
% Compiled module: DETABIFY.
% Compiled module: STRARRCOMPRESS.
% Compiled module: STRSPECIAL.
% Compiled module: STRLASTCHAR.
% Compiled module: SSW_STRSPLIT.
% Compiled module: ID_ESC.
% Compiled module: ISVALID.
% Compiled module: ID_ESC_INIT.
% Compiled module: SSW_UNIQ.
% Compiled module: ID_UNESC.
% Compiled module: MRD_STRUCT.
% Compiled module: IS_NUMBER.
% Compiled module: IS_NUMBER2.
% Compiled module: TAG_INDEX.
% Compiled module: STRMIDS.
% Compiled module: GT_TAGVAL.
% Compiled module: STR_TAGVAL.
% Compiled module: ALL_VALS.
% Compiled module: UPDATE_HISTORY.
% Compiled module: GET_CALLER.
% Compiled module: STR2NUMBER.
% Compiled module: BOOST_TAG.
% Compiled module: STRUP.
% Compiled module: GET_TAG_INDEX.
% Compiled module: IDL_RELEASE.
% Compiled module: REP_TAG_VALUE.
% Compiled module: REM_TAG.
% Compiled module: ADD_TAG.
% Compiled module: LAST_ITEM.
% Compiled module: COPY_VAR.
% Compiled module: COMP_FITS_CEN.
% Compiled module: REPLICATE2.
% Program caused arithmetic error: Floating underflow
% Compiled module: DN2DEM_POS_NB.
% Compiled module: GET_EDGES.
% Compiled module: EDGE_PRODUCTS.
% Compiled module: INTERPOL.
% Compiled module: DEMMAP_POS.
      0 of  116640,   0.0%
% Compiled module: DEM_INV_GSVDCSQ.
% Compiled module: DEM_INV_REG_PARAMETER_MAP.
   5000 of  116640,   4.3%
  10000 of  116640,   8.6%
  15000 of  116640,  12.9%
  20000 of  116640,  17.1%
  25000 of  116640,  21.4%
  30000 of  116640,  25.7%
  35000 of  116640,  30.0%
  40000 of  116640,  34.3%
  45000 of  116640,  38.6%
  50000 of  116640,  42.9%
  55000 of  116640,  47.2%
  60000 of  116640,  51.4%
  65000 of  116640,  55.7%
  70000 of  116640,  60.0%
  75000 of  116640,  64.3%
  80000 of  116640,  68.6%
  85000 of  116640,  72.9%
  90000 of  116640,  77.2%
  95000 of  116640,  81.4%
 100000 of  116640,  85.7%
 105000 of  116640,  90.0%
 110000 of  116640,  94.3%
 115000 of  116640,  98.6%
100% Done
    298.8 DEM/s
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating illegal operand

SSW  setup will include: <gen>

Type <sswidl> to start SSW IDL
--------------------------------------------------------
Running SSW, Last Updated: Wed Nov 2 22:22:51 GMT 2005
 
PROBLEMS? - e-mail TO: freeland@penumbra.nascom.nasa.gov
--------------------------------------------------------
IDL Version 8.5 (linux x86_64 m64). (c) 2015, Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation.
Installation number: 401801-1.
Licensed for use by: Rice University

Executing SSW IDL_STARTUP for: GEN
Executing SSW IDL_STARTUP for: SITE
% Compiled module: SSW_PATH.
% Compiled module: SSW_INSTRUMENTS.
% Compiled module: WC_WHERE.
% Compiled module: PATHFIX.
% Compiled module: UNIQO.
% Compiled module: STRJUSTIFY.
% Compiled module: UNIQ.
% Compiled module: DEFAULT.
% Compiled module: PRSTR.
Including Paths:
 ---------------------------------
| $SSW/vobs/gen/idl               |
| $SSW/vobs/ontology/idl/jsoc     |
| $SSW/vobs/ontology/idl/gen_temp |
| $SSW/vobs/ontology/idl          |
 ---------------------------------
% SSW_PATH: Number of paths changed from 88 to 92
% Compiled module: FIND_FILE.
% Compiled module: READ_SDO.
% Compiled module: GET_FITS_NEXTEND.
% Compiled module: FITS_OPEN.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% Compiled module: SXDELPAR.
% Compiled module: REQUIRED_TAGS.
% Compiled module: MREADFITS_SHM.
% Compiled module: FILE_SIZE.
% Compiled module: WHERE_PATTERN.
% Compiled module: LAST_NELEM.
% Compiled module: ALPHAGEN.
% Compiled module: DELVARX.
% Compiled module: DELVARX2.
% Compiled module: DESTROY.
% Compiled module: IS_LENDIAN.
% Compiled module: GET_NBYTES.
% Compiled module: SWAP_ENDIAN_INPLACE.
% Compiled module: RELTIME.
% Compiled module: UT_TIME.
% Compiled module: UT_DIFF.
% Compiled module: SYSTIM.
% Compiled module: ANYTIM.
% Compiled module: IS_STRUCT.
% Compiled module: CHECKVAR.
% Compiled module: STR_LASTPOS.
% Compiled module: STR2UTC.
% Compiled module: BOOST_ARRAY.
% Compiled module: UTC2INT.
% Compiled module: TAG_EXIST.
% Compiled module: DATE2MJD.
% Compiled module: CHECK_INT_TIME.
% Compiled module: GET_LEAP_SEC.
% Compiled module: UTIME2STR.
% Compiled module: GETUTBASE.
% Compiled module: GETUT.
% Compiled module: INT2EX.
% Compiled module: DAYCNV.
% Compiled module: EX2INT.
% Compiled module: JDCNV.
% Compiled module: INT2SEC.
% Compiled module: ANYTIM2INTS.
% Compiled module: TIMSTR2EX.
% Compiled module: CHECK_TIME.
% Compiled module: FMT_TIM.
% Compiled module: GT_DAY.
% Compiled module: GT_TIME.
% Compiled module: ATIME.
% Compiled module: FCHECK.
% Compiled module: F_ATIME.
% Compiled module: TIMEGRID.
% Compiled module: CONCAT_STRUCT.
% Compiled module: INT2SECARR.
% Compiled module: MREADFITS_HEADER.
% Compiled module: HEADFITS.
% Compiled module: FXPOSIT.
% Compiled module: MRD_HREAD.
% Compiled module: FITSHEAD2STRUCT.
% Compiled module: FXADDPAR.
% Compiled module: FXPARPOS.
% Compiled module: FXPAR.
% Compiled module: FMT_TAG.
% Compiled module: DETABIFY.
% Compiled module: STRARRCOMPRESS.
% Compiled module: STRSPECIAL.
% Compiled module: STRLASTCHAR.
% Compiled module: SSW_STRSPLIT.
% Compiled module: ID_ESC.
% Compiled module: ISVALID.
% Compiled module: ID_ESC_INIT.
% Compiled module: SSW_UNIQ.
% Compiled module: ID_UNESC.
% Compiled module: MRD_STRUCT.
% Compiled module: IS_NUMBER.
% Compiled module: IS_NUMBER2.
% Compiled module: TAG_INDEX.
% Compiled module: STRMIDS.
% Compiled module: GT_TAGVAL.
% Compiled module: STR_TAGVAL.
% Compiled module: ALL_VALS.
% Compiled module: UPDATE_HISTORY.
% Compiled module: GET_CALLER.
% Compiled module: STR2NUMBER.
% Compiled module: BOOST_TAG.
% Compiled module: STRUP.
% Compiled module: GET_TAG_INDEX.
% Compiled module: IDL_RELEASE.
% Compiled module: REP_TAG_VALUE.
% Compiled module: REM_TAG.
% Compiled module: ADD_TAG.
% Compiled module: LAST_ITEM.
% Compiled module: COPY_VAR.
% Compiled module: COMP_FITS_CEN.
% Compiled module: REPLICATE2.
% Program caused arithmetic error: Floating underflow
% Compiled module: DN2DEM_POS_NB.
% Compiled module: GET_EDGES.
% Compiled module: EDGE_PRODUCTS.
% Compiled module: INTERPOL.
% Compiled module: DEMMAP_POS.
      0 of  116640,   0.0%
   5000 of  116640,   4.3%
% Compiled module: DEM_INV_GSVDCSQ.
% Compiled module: DEM_INV_REG_PARAMETER_MAP.
  10000 of  116640,   8.6%
  15000 of  116640,  12.9%
  20000 of  116640,  17.1%
  25000 of  116640,  21.4%
  30000 of  116640,  25.7%
  35000 of  116640,  30.0%
  40000 of  116640,  34.3%
  45000 of  116640,  38.6%
  50000 of  116640,  42.9%
  55000 of  116640,  47.2%
  60000 of  116640,  51.4%
  65000 of  116640,  55.7%
  70000 of  116640,  60.0%
  75000 of  116640,  64.3%
  80000 of  116640,  68.6%
  85000 of  116640,  72.9%
  90000 of  116640,  77.2%
  95000 of  116640,  81.4%
 100000 of  116640,  85.7%
 105000 of  116640,  90.0%
 110000 of  116640,  94.3%
 115000 of  116640,  98.6%
100% Done
    343.3 DEM/s
% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating illegal operand


In [64]:
foo = EMCube.restore('../data/em_cubes_demreg_tn750_t7500-12500.h5')

In [65]:
fig = plt.figure(figsize=(20,15))
plt.subplots_adjust(right=0.87)
cax = fig.add_axes([0.88, 0.12, 0.025, 0.75])
plt.subplots_adjust(hspace=0.1)
for i in range(foo.temperature_bin_edges.shape[0]-1):
    # apply a filter to the 
    tmp = foo[i].submap(u.Quantity([250,500],u.arcsec),u.Quantity([150,400],u.arcsec))
    #tmp.data = gaussian_filter(tmp.data,
    #                           eis.channels[0]['gaussian_width']['x'].value
    #                          )
    # set up axes properly and add plot
    ax = fig.add_subplot(6,5,i+1,projection=tmp)
    im = tmp.plot(axes=ax,
                  annotate=False,
                  cmap=matplotlib.cm.get_cmap('magma'),
                  norm=matplotlib.colors.SymLogNorm(1, vmin=1e25, vmax=1e29)
                 )
    # set title and labels
    ax.set_title(r'${t0:.2f}-{t1:.2f}$ {uni}'.format(t0=np.log10(tmp.meta['temp_a']),
                                                     t1=np.log10(tmp.meta['temp_b']),uni='K'))
    if i<25:
        ax.coords[0].set_ticklabel_visible(False)
    else:
        ax.set_xlabel(r'$x$ ({})'.format(u.Unit(tmp.meta['cunit1'])))
    if i%5==0:
        ax.set_ylabel(r'$y$ ({})'.format(u.Unit(tmp.meta['cunit2'])))
    else:
        ax.coords[1].set_ticklabel_visible(False)
cbar = fig.colorbar(im,cax=cax)



In [ ]: