コード例 #1
0
ファイル: test_rad.py プロジェクト: xhuang1121/hedp
 def test_iplanck(self):
     """
     Check that iBlambda(lmbda, Blambda(lmbda, x)) = x
     """
     Flux = rad.planck(lmbda * 1.0e9, Te_eV, 'lambda')
     Flux = Flux * 1.0e-9  #to W.m⁻².sr⁻¹.nm⁻¹
     Tout = rad.iplanck(lmbda * 1.0e9, Flux)
     assert_allclose(Tout, Te_eV)
コード例 #2
0
ファイル: test_rad.py プロジェクト: fimay/hedp
 def test_iplanck(self):
     """
     Check that iBlambda(lmbda, Blambda(lmbda, x)) = x
     """
     Flux = rad.planck(lmbda*1.0e9, Te_eV, 'lambda')
     Flux = Flux*1.0e-9 #to W.m⁻².sr⁻¹.nm⁻¹
     Tout = rad.iplanck(lmbda*1.0e9, Flux)
     assert_allclose(Tout, Te_eV)
コード例 #3
0
ファイル: sop.py プロジェクト: xhuang1121/hedp
def se_calibration(counts,
                   lmbda,
                   F,
                   transmission,
                   detectorsize,
                   method='explicit',
                   out='tele',
                   diag='sop',
                   **args):
    """
    Compute the calibration for a streaked self emission system.

    This function calculates the number of electrons ejected by the
    photocathode in a SOP configuration.

    Parameters:
    -----------
      General:
      --------
          - lmbda [ndarray]: wavelenght (nm) array
          - F  [float]:  F number of the first lens
          - transmission  [ndarray]:    Total transmission of the optical system, including the
                          filter (same shape as the nu) 
          - detectorsize  [float] Size of a pixel in spatial direction in μm
          - method [str]: method to use

      Streak only parameters:
      ----------------------

      - slitwidth  [float]   Size of the slit in px
      - sweepspeed        Sweep speed of the streak [100ns, 50ns, etc] in pixel/ns

      GOI relative:
      -------------

    Returns:
    --------
      - Flux or tele[eV], Flux_norm [float]: photon flux (W.m⁻².sr⁻¹.nm⁻¹.counts⁻¹)

    """
    args = locals()
    args.update(args['args'])
    if method not in ['implicit', 'explicit'] or\
            out not in ['tele', 'flux'] or\
            diag not in ['sop', 'goi']:
        raise ValueError('Wrong input arguments!')
    # deleting all the arguments we don't want to pass
    for key in ['counts', 'out', 'diag', 'args']:
        del args[key]

    cal_function = {'sop': _sop_calibration, 'goi': _se_calibration_goi}[diag]

    if method == 'explicit':
        Flux = cal_function(**args)
        if out == 'flux':
            return Flux * counts
        elif out == 'tele':
            max_idx = np.argmax(transmission)
            lmbda_max = lmbda[max_idx]
            return iplanck(lmbda_max, counts * Flux)

    elif method == "implicit":
        tele_max = np.array([0.1])  # staring temperature at 0.1 eV
        counts_max = 0
        # Upper bound for the temperature we would need to go to
        while counts_max < counts.max():
            tele_max *= 2
            counts_max = cal_function(tele=tele_max, **args)[0]
        tele_i = np.linspace(0, tele_max, 1000)
        counts_i = cal_function(tele=tele_i, **args)
        calibration_fit = interp1d(counts_i,
                                   tele_i,
                                   bounds_error=False,
                                   fill_value=0)
        return calibration_fit(counts)
コード例 #4
0
ファイル: sop.py プロジェクト: fimay/hedp
def se_calibration(counts, lmbda, F, transmission, detectorsize, method="explicit", out="tele", diag="sop", **args):
    """
    Compute the calibration for a streaked self emission system.

    This function calculates the number of electrons ejected by the
    photocathode in a SOP configuration.

    Parameters:
    -----------
      General:
      --------
          - lmbda [ndarray]: wavelenght (nm) array
          - F  [float]:  F number of the first lens
          - transmission  [ndarray]:    Total transmission of the optical system, including the
                          filter (same shape as the nu) 
          - detectorsize  [float] Size of a pixel in spatial direction in μm
          - method [str]: method to use

      Streak only parameters:
      ----------------------

      - slitwidth  [float]   Size of the slit in px
      - sweepspeed        Sweep speed of the streak [100ns, 50ns, etc] in pixel/ns

      GOI relative:
      -------------

    Returns:
    --------
      - Flux or tele[eV], Flux_norm [float]: photon flux (W.m⁻².sr⁻¹.nm⁻¹.counts⁻¹)

    """
    args = locals()
    args.update(args["args"])
    if method not in ["implicit", "explicit"] or out not in ["tele", "flux"] or diag not in ["sop", "goi"]:
        raise ValueError("Wrong input arguments!")
    # deleting all the arguments we don't want to pass
    for key in ["counts", "out", "diag", "args"]:
        del args[key]

    cal_function = {"sop": _sop_calibration, "goi": _se_calibration_goi}[diag]

    if method == "explicit":
        Flux = cal_function(**args)
        if out == "flux":
            return Flux * counts
        elif out == "tele":
            max_idx = np.argmax(transmission)
            lmbda_max = lmbda[max_idx]
            return iplanck(lmbda_max, counts * Flux)

    elif method == "implicit":
        tele_max = np.array([0.1])  # staring temperature at 0.1 eV
        counts_max = 0
        # Upper bound for the temperature we would need to go to
        while counts_max < counts.max():
            tele_max *= 2
            counts_max = cal_function(tele=tele_max, **args)[0]
        tele_i = np.linspace(0, tele_max, 1000)
        counts_i = cal_function(tele=tele_i, **args)
        calibration_fit = interp1d(counts_i, tele_i, bounds_error=False, fill_value=0)
        return calibration_fit(counts)