Beispiel #1
0
 def _get_opacity(self):
     sp_tr = np.empty((len(self.mat), len(self.nu)))
     sp_tr_filters = np.ones(self.nu.shape)
     for el, thick in self.filters.iteritems():
         sp_tr_filters *= np.exp(-cold_opacity(el, nu=self.nu)*thick)
     ip_sens = ip_sensitivity(self.nu)
     for k, el in enumerate(self.mat):
         sp_tr[k] = np.exp(-cold_opacity(el, nu=self.nu)*self.thick[k])\
                 * sp_tr_filters * ip_sens
     return sp_tr
Beispiel #2
0
 def _get_opacity(self):
     sp_tr = np.empty((len(self.mat), len(self.nu)))
     sp_tr_filters = np.ones(self.nu.shape)
     for el, thick in self.filters.iteritems():
         sp_tr_filters *= np.exp(-cold_opacity(el, nu=self.nu) * thick)
     ip_sens = ip_sensitivity(self.nu)
     for k, el in enumerate(self.mat):
         sp_tr[k] = np.exp(-cold_opacity(el, nu=self.nu)*self.thick[k])\
                 * sp_tr_filters * ip_sens
     return sp_tr
Beispiel #3
0
        def ofunc2(pars, thick, nu, el):
            spectra= compute_spectra(pars, nu)

            sp_tr_filters = np.ones(nu.shape)
            for filt_el, filt_thick in self.filters.iteritems():
                sp_tr_filters *= np.exp(-cold_opacity(filt_el, nu=nu)*filt_thick)
            ip_sens = ip_sensitivity(nu)
            comp_tr = []
            for this_thick in thick:
                sp_sens = np.exp(-cold_opacity(el, nu=nu)*this_thick)\
                        * sp_tr_filters * ip_sens * spectra
                comp_tr.append(np.trapz(sp_sens, nu, axis=0))

            return np.array(comp_tr).reshape((1,-1))
Beispiel #4
0
        def ofunc2(pars, thick, nu, el):
            spectra = compute_spectra(pars, nu)

            sp_tr_filters = np.ones(nu.shape)
            for filt_el, filt_thick in self.filters.iteritems():
                sp_tr_filters *= np.exp(-cold_opacity(filt_el, nu=nu) *
                                        filt_thick)
            ip_sens = ip_sensitivity(nu)
            comp_tr = []
            for this_thick in thick:
                sp_sens = np.exp(-cold_opacity(el, nu=nu)*this_thick)\
                        * sp_tr_filters * ip_sens * spectra
                comp_tr.append(np.trapz(sp_sens, nu, axis=0))

            return np.array(comp_tr).reshape((1, -1))
Beispiel #5
0
def xray_filter_transmission(nu, element=None, thickness=None, layers=None):
    """
    Computes filter transmission for solid foils

    Parameters:
    -----------
     - nu [ndarray] photon frequency array [eV]
     - element: [str] filter element, should be in matdb
     - thickness: [float] foil thickness [cm]
     - layers: [dict] dict of layers
         {'element1': thickness1, 'element2': thickness2, ...}
    """
    wrong_args = np.array(
        [arg is None for arg in [element, thickness, layers]])
    if wrong_args.all() or (~wrong_args).all():
        raise ValueError(
            'You should provide either element and thickness or layers dict!')
    if layers is None:
        op = cold_opacity(element,
                          hedp.matdb(element).solid_dens, nu, 'pickle')
        return np.exp(-op * thickness)
    else:
        Transmissions = [xray_filter_transmission(nu, el, thick)\
                for el, thick in layers.iteritems()]
        return np.prod(np.array(Transmissions), axis=0)
Beispiel #6
0
def xray_filter_transmission(nu, element=None, thickness=None,layers=None):
    """
    Computes filter transmission for solid foils

    Parameters:
    -----------
     - nu [ndarray] photon frequency array [eV]
     - element: [str] filter element, should be in matdb
     - thickness: [float] foil thickness [cm]
     - layers: [dict] dict of layers
         {'element1': thickness1, 'element2': thickness2, ...}
    """
    wrong_args = np.array([arg is None for arg in [element, thickness, layers]])
    if wrong_args.all() or (~wrong_args).all():
        raise ValueError('You should provide either element and thickness or layers dict!')
    if layers is None:
        op = cold_opacity(element, 
                        hedp.matdb(element).solid_dens,
                        nu, 'pickle')
        return np.exp(-op*thickness)
    else:
        Transmissions = [xray_filter_transmission(nu, el, thick)\
                for el, thick in layers.iteritems()]
        return np.prod(np.array(Transmissions), axis=0)