Пример #1
0
    def test_attenuation_coefficient(self):
        """Test data is all at an air pressure of one standard atmosphere, 101.325 Pa."""
        data = np.loadtxt(data_path() + 'absorption_coefficient.csv',
                          skiprows=1,
                          delimiter=',')

        f = np.array([
            50.0, 63.0, 80.0, 100.0, 125.0, 160.0, 200.0, 250.0, 315.0, 400.0,
            500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, 2000.0, 2500.0,
            3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0
        ])

        for row in data:
            temperature = 273.15 + row[0]  # Degrees Celsius to Kelvin
            relative_humidity = row[1]
            alpha = row[
                2:] / 1000.0  # Given in dB/km while we calculate in dB/m.

            assert (f.shape == alpha.shape)

            a = Atmosphere(temperature=temperature,
                           relative_humidity=relative_humidity)
            calculated_alpha = a.attenuation_coefficient(f)

            np.testing.assert_array_almost_equal(alpha,
                                                 calculated_alpha,
                                                 decimal=2)
 def test_ir_attenuation_coefficient(self):
     
     a = Atmosphere()
     
     N = 1024
     
     assert(len(a.ir_attenuation_coefficient(d=100.0, N=N))==N) 
Пример #3
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument('target', type=str)
    args = parser.parse_args()

    # Frequency vector
    f = np.logspace(1.0, 4.0, 100)
    # Flow resistivity for grass
    res = 200000.
    # Angle of incidence vector
    angles = np.linspace(0.0, 90.0, 100)

    # Impedance Delany and Bazely
    #imp = impedance_delany_and_bazley(f, res)
    #fig = plt.figure()
    #ax = fig.add_subplot(111)
    #ax.semilogx(f, imp.real, label="Real")
    #ax.semilogx(f, imp.imag, label="Imaginery{}", linestyle='-.')
    #ax.legend()
    #ax.set_xlabel(r'$f$ in Hz')
    #ax.set_ylabel(r'$Z$ in -')
    #fig.tight_layout()
    #fig.savefig(os.path.join(args.target, "impedance.eps"))

    # Reflection
    #r = reflection_factor_plane_wave(imp, (angles/180.*np.pi)[...,None])

    #fig = plt.figure()
    #ax = fig.add_subplot(111)
    #im = ax.pcolormesh(f, angles, np.abs(r))
    #ax.set_xlabel(r'$f$ in Hz')
    #ax.set_ylabel(r'$\theta$ in \textdegree')
    #cb = ax.get_figure().colorbar(mappable=im)
    #cb.set_label(r'$|R|$ in -')
    #fig.tight_layout()
    #fig.savefig(os.path.join(args.target, "reflection-abs.eps"))

    #fig = plt.figure()
    #ax = fig.add_subplot(111)
    #im = ax.pcolormesh(f, angles, np.angle(r)*180/np.pi)
    #ax.set_xlabel(r'$f$ in Hz')
    #ax.set_ylabel(r'$\theta$ in \textdegree')
    #cb = ax.get_figure().colorbar(mappable=im)
    #cb.set_label(r'$\angle R$ in \textdegree')
    #fig.tight_layout()
    #fig.savefig(os.path.join(args.target, "reflection-angle.eps"))

    # Atmospheric attenuation
    a = Atmosphere()
    fig = a.plot_attenuation_coefficient(f)
    fig.tight_layout()
    fig.savefig(os.path.join(args.target, "attenuation.eps"))
Пример #4
0
    def test_attenuation_coefficient(self):
        
        """Test data is all at an air pressure of one standard atmosphere, 101.325 Pa."""
        data = np.loadtxt(data_path() + 'absorption_coefficient.csv', skiprows=1, delimiter=',')

        f = np.array([50.0, 63.0, 80.0, 100.0, 125.0, 160.0, 200.0, 250.0, 315.0, 400.0, 500.0, 630.0, 800.0, 1000.0, 1250.0, 1600.0, 2000.0, 2500.0, 3150.0, 4000.0, 5000.0, 6300.0, 8000.0, 10000.0])
        
        for row in data:
            temperature = 273.15 + row[0]   # Degrees Celsius to Kelvin
            relative_humidity = row[1]
            alpha = row[2:] / 1000.0    # Given in dB/km while we calculate in dB/m.
            
            assert(f.shape==alpha.shape)
            
            a = Atmosphere(temperature=temperature, relative_humidity=relative_humidity)
            calculated_alpha = a.attenuation_coefficient(f)
            
            np.testing.assert_array_almost_equal(alpha, calculated_alpha, decimal=2)
Пример #5
0
    def test_standard_atmosphere(self):

        a = Atmosphere()
        """Default values."""
        assert (a.temperature == 293.15)
        assert (a.pressure == 101.325)
        assert (a.relative_humidity == 0.0)
        """Calculated values belonging to default values."""
        assert (abs(a.soundspeed - 343.2) < 1.0e-9)
        assert (abs(a.saturation_pressure - 2.33663045) < 1.0e-8)
        assert (abs(a.molar_concentration_water_vapour - 0.0) < 1.0e-9)
        assert (abs(a.relaxation_frequency_nitrogen - 9.0) < 1.0e-9)
        assert (abs(a.relaxation_frequency_oxygen - 24.0) < 1.0e-9)