Пример #1
0
def read_csv(fname, temperature_limits=(-20, -0.5)):
    """
    Arguments
    ---------
    temerature_limits: tuple.
        The temperature reading has false readings in it which can cause porblems later"""
    df = pd.read_csv(fname, sep='\t')

    pandas_tools.ensure_column_exists(df, 'DateTime', _date_time_alts)
    pandas_tools.ensure_column_exists(df, 'Pressure_Pa', _pressure_alt)
    pandas_tools.ensure_column_exists(df, 'Temperature', _temp_alt)
    pandas_tools.ensure_column_exists(df, 'Relative_humidity', _RH_alt)
    # return df
    df.index = pd.Series(
        pd.to_datetime(df.DateTime, format='%Y-%m-%d %H:%M:%S'))
    # df['Pressure_Pa'] = df.PRESS
    # df['Temperature'] = df.AT
    # df['Relative_humidity'] = df.RH
    # df = df.drop('PRESS', axis=1)
    # df = df.drop('AT', axis=1)
    # df = df.drop('RH', axis=1)
    df = df.drop('DateTime', axis=1)

    df = df.sort_index()

    if temperature_limits:
        df = df[df.Temperature > temperature_limits[0]]
        df = df[temperature_limits[1] > df.Temperature]

    hk = timeseries.TimeSeries(df)
    return hk
Пример #2
0
def read_csv(fname, temperature_limits=(-20, -0.5)):
    """
    Arguments
    ---------
    temerature_limits: tuple.
        The temperature reading has false readings in it which can cause porblems later"""
    df = pd.read_csv(fname, sep="\t")

    pandas_tools.ensure_column_exists(df, "DateTime", _date_time_alts)
    pandas_tools.ensure_column_exists(df, "Pressure_Pa", _pressure_alt)
    pandas_tools.ensure_column_exists(df, "Temperature", _temp_alt)
    pandas_tools.ensure_column_exists(df, "Relative_humidity", _RH_alt)
    # return df
    df.index = pd.Series(pd.to_datetime(df.DateTime, format="%Y-%m-%d %H:%M:%S"))
    # df['Pressure_Pa'] = df.PRESS
    # df['Temperature'] = df.AT
    # df['Relative_humidity'] = df.RH
    # df = df.drop('PRESS', axis=1)
    # df = df.drop('AT', axis=1)
    # df = df.drop('RH', axis=1)
    df = df.drop("DateTime", axis=1)

    df = df.sort_index()

    if temperature_limits:
        df = df[df.Temperature > temperature_limits[0]]
        df = df[temperature_limits[1] > df.Temperature]

    hk = timeseries.TimeSeries(df)
    return hk
Пример #3
0
 def convert2verticalprofile(self, alt_label = None, alt_timeseries = None):
     ts_tmp = self.copy()
 #     hk_tmp.data['Time'] = hk_tmp.data.index
 #     if alt_label:
 #         label = alt_label
 #     else:
 #         label = 'Altitude'
     if alt_timeseries:
         alt_timeseries = alt_timeseries.align_to(ts_tmp)
         _pandas_tools.ensure_column_exists(alt_timeseries.data, 'Altitude', col_alt=alt_label)
         ts_tmp.data.index = alt_timeseries.data['Altitude']
     else:
         _pandas_tools.ensure_column_exists(ts_tmp.data, 'Altitude', col_alt=alt_label)
         ts_tmp.data.index = ts_tmp.data['Altitude']
     out = atmPy.general.vertical_profile.VerticalProfile(ts_tmp.data)
     out._x_label = self._y_label
     return out
Пример #4
0
 def convert2verticalprofile(self, alt_label=None, alt_timeseries=None):
     ts_tmp = self.copy()
     #     hk_tmp.data['Time'] = hk_tmp.data.index
     #     if alt_label:
     #         label = alt_label
     #     else:
     #         label = 'Altitude'
     if alt_timeseries:
         alt_timeseries = alt_timeseries.align_to(ts_tmp)
         _pandas_tools.ensure_column_exists(alt_timeseries.data,
                                            'Altitude',
                                            col_alt=alt_label)
         ts_tmp.data.index = alt_timeseries.data['Altitude']
     else:
         _pandas_tools.ensure_column_exists(ts_tmp.data,
                                            'Altitude',
                                            col_alt=alt_label)
         ts_tmp.data.index = ts_tmp.data['Altitude']
     out = atmPy.general.vertical_profile.VerticalProfile(ts_tmp.data)
     out._x_label = self._y_label
     return out
Пример #5
0
def zdanovskii_stokes_robinson(data, which = 'refractive_Index'):
    """(Stokes and Robinson,1966)
    Arguments
    ---------
    data: pandas dataframe
        containing chemical composition data
    which: str
        which property to mix ['refractive_Index', 'density', 'kappa_chem']
        """
    materials = _properties.get_commen()
    materials.index = materials.species_name

    essential_elcts = ['ammonium_sulfate',
                                   'ammonium_nitrate',
                                   'ammonium_chloride',
                                   'sodium_chloride',
                                   'sodium_sulfate',
                                   'sodium_nitrate',
                                   'calcium_nitrate',
                                   'calcium_chloride',
                                   'organic_aerosol'
                                  ]

    electrolytes = materials.loc[essential_elcts]
    electrolytes = electrolytes[['refractive_Index', 'density', 'kappa_chem']]

    _pandas_tools.ensure_column_exists(data, 'organic_aerosol', col_alt = ['total_organics'] )

    for e in essential_elcts:
        _pandas_tools.ensure_column_exists(data, e)

    tobemixed = electrolytes[which]
    # _pdb.set_trace()
    numerator = (data * tobemixed / electrolytes.density).sum(axis=1)
    denominator = (data / electrolytes.density).sum(axis=1)
    mixed = numerator/denominator
    df = _pd.DataFrame(mixed, columns=[which])
    ts = _timeseries.TimeSeries(df)
    return ts
Пример #6
0
def read_csv(fname, temperature_limits=(-20, -0.5)):
    """
    Arguments
    ---------
    temerature_limits: tuple.
        The temperature reading has false readings in it which can cause porblems later"""
    df = _pd.read_csv(fname, sep='\t')



    _pandas_tools.ensure_column_exists(df, 'DateTime', _date_time_alts)
    _pandas_tools.ensure_column_exists(df, 'Pressure_Pa', _pressure_alt)
    _pandas_tools.ensure_column_exists(df, 'Temperature', _temp_alt)
    _pandas_tools.ensure_column_exists(df, 'Relative_humidity', _RH_alt)
    _pandas_tools.ensure_column_exists(df, 'Temperature_instrument', _temp_payload_alt, raise_error=False)
    try:
        df.Temperature_instrument = _pd.to_numeric(df.Temperature_instrument, errors='coerce')
    except AttributeError:
        pass

    # return df
    df.index = _pd.Series(_pd.to_datetime(df.DateTime, format='%Y-%m-%d %H:%M:%S'))


    df = df.drop('DateTime', axis=1)

    df = df.sort_index()

    if temperature_limits:
        df = df[df.Temperature > temperature_limits[0]]
        df = df[temperature_limits[1] > df.Temperature]

    # df.Temperature_payload = df.Temperature_payload.astype(float)
    hk = _timeseries.TimeSeries(df)
    hk._data_period = 2
    return hk
Пример #7
0
def read_csv(fname, temperature_limits=(-20, -0.5)):
    """
    Arguments
    ---------
    temerature_limits: tuple.
        The temperature reading has false readings in it which can cause porblems later"""
    df = _pd.read_csv(fname, sep='\t')



    _pandas_tools.ensure_column_exists(df, 'DateTime', _date_time_alts)
    _pandas_tools.ensure_column_exists(df, 'Pressure_Pa', _pressure_alt)
    _pandas_tools.ensure_column_exists(df, 'Temperature', _temp_alt)
    _pandas_tools.ensure_column_exists(df, 'Relative_humidity', _RH_alt)
    _pandas_tools.ensure_column_exists(df, 'Temperature_instrument', _temp_payload_alt, raise_error=False)
    _pandas_tools.ensure_column_exists(df, 'CN_concentration', _cn_concentration_alt, raise_error=False)
    try:
        # df.Temperature_payload = df.Temperature_payload.astype(float)
        df.Temperature_instrument = _pd.to_numeric(df.Temperature_instrument, errors='coerce')
        df.CN_concentration = _pd.to_numeric(df.CN_concentration, errors='coerce')

        df.CONCN = _pd.to_numeric(df.CONCN, errors='coerce')
        df.COUNT = _pd.to_numeric(df.COUNT, errors='coerce')
    except AttributeError:
        pass

    # return df
    df.index = _pd.Series(_pd.to_datetime(df.DateTime, format='%Y-%m-%d %H:%M:%S'))


    df = df.drop('DateTime', axis=1)

    df = df.sort_index()

    if temperature_limits:
        df = df[df.Temperature > temperature_limits[0]]
        df = df[temperature_limits[1] > df.Temperature]


    hk = _timeseries.TimeSeries(df)
    hk._data_period = 2
    return hk