Exemplo n.º 1
0
def test_irradiance(start_wav, wav_step, final_wav, wavelength_norm, bt, tau_v,
                    ang_mus):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    tau_v = np.random.rand(len(wav))
    E0, E0S, E0N, E0SN = fn.irradiance(wav, wav_step, bt, tau_v, ang_mus)

    #check if the E0N and E0SN values are equals or smaller than 1
    assert (len(E0N[E0N <= 1]))
    assert (len(E0SN[E0SN <= 1]))
    #check if output is positive
    assert (len(E0[E0 <= 0]) == 0)
    assert (len(E0S[E0S <= 0]) == 0)
    assert (len(E0N[E0N <= 0]) == 0)
    assert (len(E0SN[E0SN <= 0]) == 0)
    #check if length of E0,E0S,E0N and E0SN are equals to length of wav
    assert (len(E0) == len(wav))
    assert (len(E0S) == len(wav))
    assert (len(E0N) == len(wav))
    assert (len(E0SN) == len(wav))

    #check if cosine has value out of the range [-1,1]
    with pytest.raises(ValueError):
        fn.irradiance(wav, wav_step, bt, tau_v, 5)
    #check the output if bt is negative
    with pytest.raises(ValueError):
        fn.irradiance(wav, wav_step, -50, tau_v, ang_mus)
Exemplo n.º 2
0
def test_scatter_coeff(Hv, start_wav, wav_step, final_wav, wavelength_norm,
                       maratio):

    wav, i_wav = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    tau_vertical = fn.RayOpticaldepth(wav)
    k_mol_scattering, k_aer_scattering, k_tot_scattering = fn.scatter_coeff(
        tau_vertical, Hv, wav, i_wav, maratio)

    #check if a ValueError arise if Hv is smaller or equal to 0
    with pytest.raises(ValueError):
        fn.scatter_coeff(tau_vertical, -5, wav, i_wav, 0)
    #check if a ValueError arise if maratio is negative
    with pytest.raises(ValueError):
        fn.scatter_coeff(tau_vertical, Hv, wav, i_wav, -10)

    #check if maratio is zero so k_aer_scattering have all zero elements
    if maratio == 0:
        assert (k_aer_scattering[k_aer_scattering == 0])

    #check if the output length is correct
    assert (len(k_mol_scattering) == len(tau_vertical))
    #check if the output length is correct
    assert (len(k_aer_scattering) == len(tau_vertical))
    #check if the output length is correct
    assert (len(k_tot_scattering) == len(tau_vertical))
Exemplo n.º 3
0
def test_ScatteringTot(k_mol_scattering, k_aer_scattering, start_wav, wav_step,
                       final_wav, wavelength_norm):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    k_mol_scattering = np.random.rand(len(wav))
    k_aer_scattering = np.random.rand(len(wav))
    Stot, ang, Ms, As = fn.ScatteringTot(k_mol_scattering, k_aer_scattering,
                                         wav, wav_step)

    #check if output is positive
    assert (len(Stot[Stot <= 0]) == 0)
    assert (len(ang[ang < 0]) == 0)
    assert (len(Ms[Ms <= 0]) == 0)
    assert (len(As[As <= 0]) == 0)

    #check if the output length are correct
    assert (len(Stot) == len(ang))
    assert (len(Ms) == len(ang))
    assert (len(As) == len(ang))

    #check if Stot is composed by zero elements like k_mol/k_aer_scattering
    assert (len(Stot[Stot == 0]) == len(
        k_mol_scattering[k_mol_scattering == 0]))
    assert (len(Stot[Stot == 0]) == len(
        k_aer_scattering[k_aer_scattering == 0]))
Exemplo n.º 4
0
def test_RayOpticaldepth(start_wav, wav_step, final_wav, wavelength_norm):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    tau_vertical = fn.RayOpticaldepth(wav)

    #check if the output length is the correct
    assert (len(tau_vertical) == len(wav))

    #check if the output is positive
    assert (len(tau_vertical[tau_vertical <= 0]) == 0)
Exemplo n.º 5
0
def test_wav_matrix(start_wav, wav_step, final_wav, wavelength_norm):

    wav, i_wav = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)

    #check if output of function is positive
    assert (i_wav >= 0)
    assert (len(wav[wav < 0]) == 0)

    #check if i_wav values is a correct and valid index
    assert (wav[i_wav] > 0)
    #check if i_wav is conteined in wav vector
    assert (i_wav <= (len(wav) - 1))

    #check if a ValueError arise if start_wav is smaller than 0
    with pytest.raises(ValueError):
        fn.wav_matrix(-1, 0.01, 5, 2)

    #check if ValueError arise if final_wav is smaller than start_wav
    with pytest.raises(ValueError):
        fn.wav_matrix(0.5, 0.1, 0.4, 0.3)
Exemplo n.º 6
0
def test_emittance(start_wav, wav_step, final_wav, wavelength_norm, bt):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    intensity = fn.emittance(wav, bt)

    #check if the output is positive
    assert (len(intensity[intensity <= 0]) == 0)

    #check the output if bt is negative
    with pytest.raises(ValueError):
        fn.emittance(wav, -1)

    #check if the output length is correct
    assert (len(intensity) == len(wav))
Exemplo n.º 7
0
def test_dir_scatteringTot(start_wav, wav_step, final_wav, wavelength_norm, Hv,
                           ang_mu):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    tau_vertical = fn.RayOpticaldepth(wav)
    dir_tot = fn.dir_scatteringTot(tau_vertical, Hv, ang_mu)

    #check if the output do not contain negative elements
    assert (len(dir_tot[dir_tot < 0]) == 0)
    #check if the output has the same length of input tau_vertical
    assert (len(dir_tot) == len(tau_vertical))

    #check if cosine has value out of the range [-1,1]
    with pytest.raises(ValueError):
        fn.dir_scatteringTot(tau_vertical, Hv, -5)
Exemplo n.º 8
0
def test_transmittance(start_wav, wav_step, final_wav, wavelength_norm, tau_v,
                       tau_h, ang_mus):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    tau_h = np.random.rand(len(wav))
    tau_v = np.random.rand(len(wav))
    Ts, Th = fn.transmittance(wav, tau_v, tau_h, ang_mus)

    #check if output is positive
    assert (len(Ts[Ts <= 0]) == 0)
    assert (len(Th[Th <= 0]) == 0)

    #check if length of Th and Ts are equals to length of wav
    assert (len(Ts) == len(wav))
    assert (len(Th) == len(wav))

    #check if cosine has value out of the range [-1,1]
    with pytest.raises(ValueError):
        fn.transmittance(wav, tau_v, tau_h, 10)
Exemplo n.º 9
0
def test_Opticaldepth(Hv, d, start_wav, wav_step, final_wav, wavelength_norm):

    wav, _ = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)
    k_tot_scattering = np.random.rand(len(wav))
    tau_h, tau_v = fn.Opticaldepth(k_tot_scattering, Hv, d)

    #check if the output length is correct
    assert (len(tau_v) == len(k_tot_scattering))

    #check if k_tot_scattering is composed by zero elements
    #so tau_v and tau_h also have all zero elements
    assert (len(tau_h[tau_h == 0]) == len(
        k_tot_scattering[k_tot_scattering == 0]))
    assert (len(tau_v[tau_v == 0]) == len(
        k_tot_scattering[k_tot_scattering == 0]))

    #check if a ValueError arise if d is zero
    with pytest.raises(ValueError):
        fn.Opticaldepth(k_tot_scattering, Hv, 0)
    #check if a ValueError arise if Hv is smaller or equal to 0
    with pytest.raises(ValueError):
        fn.Opticaldepth(k_tot_scattering, -10, d)
Exemplo n.º 10
0
                        'angstrom_coefficient_alpha',
                        fallback=1)
bt = parser.getfloat('General_Variables',
                     'brightnesstemperature_of_the_sun',
                     fallback=5800)
Hv = parser.getfloat('General_Variables',
                     'vertical_scale_Height',
                     fallback=7.7)
wavelength_norm = parser.getfloat('General_Variables',
                                  'wavelength_norm',
                                  fallback=0.52)
d = parser.getfloat('General_Variables',
                    'distance_from_black_wall',
                    fallback=25)

wav, i_wav = fn.wav_matrix(start_wav, wav_step, final_wav, wavelength_norm)

# FIGURE 1
tau_vertical = fn.RayOpticaldepth(wav)
ktot = fn.scatter_coeff(tau_vertical, Hv, wav, i_wav, maratio)
k_m = ktot[0]
k_a = ktot[1]
name_figure = 'Scattering coefficient trend'
fig = plt.figure()
plt.plot(wav, k_m, 'b-', label='k-mol.scattering', linewidth=2)
plt.plot(wav, k_a, 'r-', label='k-aer.scattering', linewidth=2)
fig.suptitle(name_figure)
plt.ylabel('Scattering coefficient [1/m]')
plt.xlabel('Wavelength [micron]')
# Definition of legend which is on the plot
leg = plt.legend()