Exemplo n.º 1
0
    def _concat(self, arm_data_objs, close_gaps=True):
        for att in self._concatable:
            first_object = getattr(arm_data_objs[0], att)
            which_type = type(first_object).__name__
            data_period = first_object._data_period
            if which_type == 'TimeSeries_2D':
                value = _timeseries.TimeSeries_2D(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'TimeSeries':
                value = _timeseries.TimeSeries(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'AMS_Timeseries_lev01':
                value = _AMS.AMS_Timeseries_lev01(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'SizeDist_TS':
                # value = _AMS.AMS_Timeseries_lev01(pd.concat([getattr(i, att).data for i in arm_data_objs]))
                data = _pd.concat(
                    [getattr(i, att).data for i in arm_data_objs])
                value = _sizedistribution.SizeDist_TS(
                    data,
                    getattr(arm_data_objs[0], att).bins, 'dNdlogDp')
            elif which_type == 'TimeSeries_3D':
                value = _timeseries.TimeSeries_3D(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            else:
                raise TypeError(
                    '%s is not an allowed type here (TimeSeries_2D, TimeSeries)'
                    % which_type)

            value._data_period = data_period
            if close_gaps:
                setattr(self, att, value.close_gaps())
            else:
                setattr(self, att, value)
Exemplo n.º 2
0
    def _parse_netCDF(self):
        super(ArmDatasetSub, self)._parse_netCDF()
        mass_concentrations = _pd.DataFrame(index=self.time_stamps)
        mass_conc_keys = [
            'total_organics', 'ammonium', 'sulfate', 'nitrate', 'chloride'
        ]

        for k in mass_conc_keys:
            mass_concentrations[k] = _pd.Series(self._read_variable(
                k, reverse_qc_flag=4),
                                                index=self.time_stamps)

        mass_concentrations.columns.name = 'Mass conc. ug/m^3'
        mass_concentrations.index.name = 'Time'

        org_mx = self._read_variable('org_mx')
        org_mx = _pd.DataFrame(org_mx, index=self.time_stamps)
        org_mx.columns = self._read_variable('amus')
        org_mx.columns.name = 'amus (m/z)'

        self.mass_concentrations = _AMS.AMS_Timeseries_lev01(
            mass_concentrations)
        self.mass_concentrations.data[
            'total'] = self.mass_concentrations.data.sum(axis=1)
        self.mass_concentrations.data.rename(
            columns={'total_organics': 'organic_aerosol'}, inplace=True)
        self.mass_concentrations._data_period = self._data_period

        self.organic_mass_spectral_matrix = _timeseries.TimeSeries_2D(org_mx)
        self.organic_mass_spectral_matrix._data_period = self._data_period
        return
Exemplo n.º 3
0
    def _concat(self, arm_data_objs, close_gaps=True):
        for att in self._concatable:
            first_object = getattr(arm_data_objs[0], att)
            which_type = type(first_object).__name__
            data_period = first_object._data_period
            if which_type == 'TimeSeries_2D':
                value = _timeseries.TimeSeries_2D(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'TimeSeries':
                value = _timeseries.TimeSeries(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'AMS_Timeseries_lev01':
                value = _AMS.AMS_Timeseries_lev01(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            elif which_type == 'SizeDist_TS':
                # value = _AMS.AMS_Timeseries_lev01(pd.concat([getattr(i, att).data for i in arm_data_objs]))
                data = _pd.concat(
                    [getattr(i, att).data for i in arm_data_objs])
                value = _sizedistribution.SizeDist_TS(
                    data,
                    getattr(arm_data_objs[0], att).bins,
                    'dNdlogDp',
                    ignore_data_gap_error=True,
                )
            elif which_type == 'TimeSeries_3D':
                value = _timeseries.TimeSeries_3D(
                    _pd.concat([getattr(i, att).data for i in arm_data_objs]))
            else:
                raise TypeError(
                    '%s is not an allowed type here (TimeSeries_2D, TimeSeries)'
                    % which_type)

            if hasattr(first_object, 'availability'):
                try:
                    avail_concat = _pd.concat([
                        getattr(i, att).availability.availability
                        for i in arm_data_objs
                    ])
                    avail = Data_Quality(None, avail_concat, None,
                                         first_object.flag_info)
                    value.availability = avail
                except:
                    _warnings.warn(
                        'availability could not be concatinated make sure you converted it to a pandas frame at some point!'
                    )
            value._data_period = data_period
            if close_gaps:
                setattr(self, att, value.close_gaps())
            else:
                setattr(self, att, value)