Пример #1
0
def test_userhoriz():

    c1 = {
        'zmdl': 0.3,
        'h1': 0.3,
        'range_km': 1.,
        'wlshort': 200.,
        'wllong': 30000.,
        'wlstep': 20.,
    }

    atmos = {
        'p': 949.,
        't': 283.8,
        'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    }

    c1.update(atmos)

    TR = lowtran.userhoriztrans(c1)

    assert TR.wavelength_nm[[0, -1]].values == approx((30303.03, 200),
                                                      rel=0.001)
    assert TR['transmission'][0, [1000, 1200],
                              0].values == approx([0.982909, 0.9645],
                                                  rel=0.001)
Пример #2
0
def calculate_modern_transparency(co2: float,
                                  temp: float,
                                  relative_humidity: float,
                                  height: float,
                                  dist: float,
                                  pressure: float = 949.0) -> float:
    """
    Calculate the transparency of the atmosphere using LOWTRAN, a modern
    climate calculation model and tool.

    :param co2:
        The co2 in the atmosphere at the chosen height in ppmv
    :param temp:
        The temperature of the atmosphere at the chosen height in Kelvin
    :param relative_humidity:
        The relative humidity of the atmosphere at the chosen height
    :param height:
        The altitude at which the radiation is traveling, in km
    :param dist:
        The distance the radiation travels through the atmosphere, in km
    :param pressure:
        Optional parameter. The pressure of the atmosphere in millibars.
        Defaults to the Lowtran default of 949.0 if not explicitly specified.
    """
    h2o = calculate_water_vapor(temp, relative_humidity)
    p = calculate_mean_path(co2, h2o)

    # convert to ppmv
    adjusted_co2 = co2 * p * 300

    # convert to ppmv from g/m^3
    # adjusted_h2o = h2o * p * 10 * 1000 * .082057338 * temp / 18.01528

    # Dufresne's h2o adjustment
    adjusted_h2o = h2o * p * 20

    parameters = {
        'h1':
        height,
        'zmdl':
        height,
        'range_km':
        dist,
        'wlshort':
        200,
        'wllong':
        20000,
        'wlstep':
        200,
        'p':
        pressure,
        't':
        temp,
        'wmol':
        [adjusted_h2o, adjusted_co2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    }
    result = userhoriztrans(parameters)
    return float(result['transmission'].mean())
Пример #3
0
def main():
    p = ArgumentParser(description='Lowtran 7 interface')
    p.add_argument('-z',
                   '--obsalt',
                   help='altitude of bother observers on horizontal path [km]',
                   type=float,
                   default=0.3)
    p.add_argument('-r',
                   '--range_km',
                   help='range between observers on horizontal path [km]',
                   type=float,
                   default=1.0)
    p.add_argument(
        '-a',
        '--zenang',
        help='zenith angle [deg]  can be single value or list of values',
        type=float,
        default=0.)
    p.add_argument('-s',
                   '--short',
                   help='shortest wavelength nm ',
                   type=float,
                   default=200)
    p.add_argument('-l',
                   '--long',
                   help='longest wavelength nm ',
                   type=float,
                   default=30000)
    p.add_argument('-step',
                   help='wavelength step size cm^-1',
                   type=float,
                   default=20)
    P = p.parse_args()

    c1 = {
        'zmdl': P.obsalt,
        'h1': P.obsalt,
        'range_km': P.range_km,
        'wlshort': P.short,
        'wllong': P.long,
        'wlstep': P.step,
    }

    atmos = {
        'p': 949.,
        't': 283.8,
        'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    }

    c1.update(atmos)

    TR = lowtran.userhoriztrans(c1).squeeze()

    plothoriz(TR, c1)

    show()
Пример #4
0
def test_userfail():
    vlim = (200, 30000)
    c1 = {'zmdl': 0.3,
          'h1': 0.3,
          'range_km': 1.,
          'wlnmlim': vlim,
          }

    TR = lowtran.userhoriztrans(c1)

    assert np.isnan(TR['transmission']).all()
Пример #5
0
def test_userfail():
    c1 = {'zmdl': 0.3,
          'h1': 0.3,
          'range_km': 1.,
          'wlshort': 200.,
          'wllong': 30000.,
          'wlstep': 20.,
          }

    TR = lowtran.userhoriztrans(c1)

    assert np.isnan(TR['transmission']).all()
Пример #6
0
def main():
    p = ArgumentParser(description='Lowtran 7 interface')
    p.add_argument('-z',
                   '--obsalt',
                   help='altitude of bother observers on horizontal path [km]',
                   type=float,
                   default=0.3)
    p.add_argument('-r',
                   '--range_km',
                   help='range between observers on horizontal path [km]',
                   type=float,
                   default=1.0)
    p.add_argument(
        '-a',
        '--zenang',
        help='zenith angle [deg]  can be single value or list of values',
        type=float,
        default=0.)
    p.add_argument('-w',
                   '--wavelen',
                   help='wavelength range nm (start,stop)',
                   type=float,
                   nargs=2,
                   default=(200, 30000))
    P = p.parse_args()

    c1 = {
        'zmdl': P.obsalt,
        'h1': P.obsalt,
        'range_km': P.range_km,
        'wlnmlim': P.wavelen,
    }

    atmos = {
        'p': 949.,
        't': 283.8,
        'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    }

    c1.update(atmos)

    TR = lowtran.userhoriztrans(c1).squeeze()

    plothoriz(TR, c1)

    show()
Пример #7
0
def modern_transparency_dict(temp: float, height: float, dist: float, pressure: float = 949.0)\
        -> Dict[Tuple[float, float], float]:
    """
    Create a table of transparencies for rays of radiation leaving
    perpendicular to the Earth's surface. The transparencies correspond
    to the different co2 and h2o pairings found in Arrhenius' original tables.

    :param temp:
        The temperature of the atmosphere

    :param height:
        The height in the atmosphere at which the transparency values
        are calculated
    :param dist:
        The total length the radiation travels through the atmosphere
    :param pressure:
        The pressure of the atmosphere in millibars. Optional parameter
        defaults to 949.0, the Lowtran default.
    :return:
        A Dict of transparency values with keys of co2 and h2o pairings/tuples
    """
    co2_values = [1.0, 1.2, 1.5, 2.0, 2.5, 3.0, 4.0, 6.0, 10.0, 20.0, 40.0]
    h2o_values = [.3, .5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 10.0]
    parameters = {
        'h1': height,
        'zmdl': height,
        'range_km': dist,
        'wlshort': 200,
        'wllong': 20000,
        'wlstep': 200,
        'p': 949.0,
        't': temp,
    }
    final_table = {}

    for co2 in co2_values:
        for h2o in h2o_values:
            parameters['wmol'] = [
                co2, h2o, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.
            ]
            lowtran_result = userhoriztrans(parameters)
            final_table[(co2,
                         h2o)] = float(lowtran_result['transmission'].mean())

    return final_table
Пример #8
0
def test_userhoriz():
    vlim = (200, 30000)

    c1 = {'zmdl': 0.3,
          'h1': 0.3,
          'range_km': 1.,
          'wlnmlim': vlim,
          }

    atmos = {'p': 949., 't': 283.8, 'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]}

    c1.update(atmos)

    TR = lowtran.userhoriztrans(c1)

    assert_allclose(TR.wavelength_nm[[0, -1]],
                    (30303.03, 200), rtol=1e-6)
    assert_allclose(TR['transmission'][0, [1000, 1200], 0],
                    [3.395577e-04, 9.921151e-01], rtol=0.001)
        type=float,
        default=0.)
    p.add_argument('-w',
                   '--wavelen',
                   help='wavelength range nm (start,stop)',
                   type=float,
                   nargs=2,
                   default=(200, 30000))
    p = p.parse_args()

    c1 = {
        'zmdl': p.obsalt,
        'h1': p.obsalt,
        'range_km': p.range_km,
        'wlnmlim': p.wavelen,
    }

    atmos = {
        'p': 949.,
        't': 283.8,
        'wmol': [93.96, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]
    }

    c1.update(atmos)

    TR = lowtran.userhoriztrans(c1).squeeze()

    plothoriz(TR, c1)

    show()