<commit_before># -*- coding: utf-8 -*-
"""
This module contains atmospheric constands and standards.

@author: Hagen
"""

import numpy as np
from scipy.interpolate import interp1d


def standard_atmosphere_international(value, quantity='altitude'):
    """Returns pressure, temperature, and/or altitude as a function of pressure, or altitude for the standard international atmosphere

    Arguments
    ---------
    value: float or ndarray.
        Depending on the keyword "quantity" this is:
        - altitude in meters.
        - pressure in mbar.

    quantity: 'altitude' or 'pressure'.
        quantaty of the argument value.

    Returns
    -------
    tuple of two floats or two ndarrays depending on type of h:
        First quantaty in the first tuple is pressure in mbar or altitude in meter, second is temperatur in Kelvin.
    """

    alt = np.array([-610, 11000, 20000, 32000, 47000, 51000, 71000, 84852]).astype(float)
    pressure = np.array([108900, 22632, 5474.9, 868.02, 110.91, 66.939, 3.9564, 0.3734]) / 100.
    tmp = np.array([19, -56.5, -56.5, -44.5, -2.5, -2.5, -58.5, -86.28]) + 273.15
<commit_msg>new: US standard improved functionality<commit_after># -*- coding: utf-8 -*-
"""
This module contains atmospheric constands and standards.

@author: Hagen
"""

import numpy as np
import pandas as pd
from scipy.interpolate import interp1d


def standard_atmosphere(value, quantity='altitude', standard='international', return_standard=False):
    """Returns pressure, temperature, and/or altitude as a function of pressure, or altitude for the standard international atmosphere

    Arguments
    ---------
    value: float or ndarray.
        Depending on the keyword "quantity" this is:
        - altitude in meters.
        - pressure in mbar.

    quantity: 'altitude' or 'pressure'.
        quantaty of the argument value.

    standard: 'US' or 'international'.
        defines which standard is used.

    return_standard: bool, optional.
        if True argument "value" and "quantity" are ignored and a pandas dataTable with the standard is returned.

    Returns
    -------
    tuple of two floats or two ndarrays depending on type of h:
        First quantaty the tuple is pressure in mbar or altitude in meter, second is temperatur in Kelvin.



    """
    if standard == 'international':
        alt = np.array([-610, 11000, 20000, 32000, 47000, 51000, 71000, 84852]).astype(float)
        pressure = np.array([108900, 22632, 5474.9, 868.02, 110.91, 66.939, 3.9564, 0.3734]) / 100.
        tmp = np.array([19, -56.5, -56.5, -44.5, -2.5, -2.5, -58.5, -86.28]) + 273.15

    elif standard == 'US':
        alt = np.array([0, 11000, 20000, 32000, 47000, 51000, 71000]).astype(float)
        pressure = np.array([101325, 22632.1, 5474.89, 868.019, 110.906, 66.9389, 3.95642]) / 100.
        tmp = np.array([288.15, 216.65, 216.65, 228.65, 270.65, 270.65, 214.65])

    else:
        raise TypeError('No standard with the name "%s" is defined' % standard)

    if return_standard:
        return pd.DataFrame(np.array([alt, pressure, tmp]).transpose(),
                            columns=['Altitude_meter', 'Pressure_mbar', 'Temperature_K'])

{'fraction_non_alphanumeric': 0.12672955974842767, 'fraction_numerical': 0.10471698113207548, 'mean_word_length': 2.7644970414201184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1335990', 'n_tokens_mistral': 1245, 'n_tokens_neox': 975, 'n_words': 344}