How to use the pysat._meta.Meta function in pysat

To help you get started, we’ve selected a few pysat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pysat / pysat / pysat / _instrument.py View on Github external
data = self._null_data.copy()
                mdata = _meta.Meta(units_label=self.units_label,
                                   name_label=self.name_label,
                                   notes_label=self.notes_label,
                                   desc_label=self.desc_label,
                                   plot_label=self.plot_label,
                                   axis_label=self.axis_label,
                                   scale_label=self.scale_label,
                                   min_label=self.min_label,
                                   max_label=self.max_label,
                                   fill_label=self.fill_label)

        else:
            bad_datetime = False
            data = self._null_data.copy()
            mdata = _meta.Meta(units_label=self.units_label,
                               name_label=self.name_label,
                               notes_label=self.notes_label,
                               desc_label=self.desc_label,
                               plot_label=self.plot_label,
                               axis_label=self.axis_label,
                               scale_label=self.scale_label,
                               min_label=self.min_label,
                               max_label=self.max_label,
                               fill_label=self.fill_label)

        output_str = '{platform} {name} {tag} {sat_id}'
        output_str = output_str.format(platform=self.platform,
                                       name=self.name, tag=self.tag,
                                       sat_id=self.sat_id)
        # check that data and metadata are the data types we expect
        if not isinstance(data, self._data_library):
github pysat / pysat / pysat / _meta.py View on Github external
elif len(key) == 3:
                new_index = self.var_case_name(key[0])
                new_child_index = self.var_case_name(key[1])
                new_name = self.attr_case_name(key[2])
                return self._ho_data[new_index].data.loc[new_child_index, new_name]
        else:
            # ensure variable is present somewhere
            if key in self:
                # get case preserved string for variable name
                new_key = self.var_case_name(key)
                if new_key in self.keys():
                    meta_row = self.data.loc[new_key]
                    if new_key in self.keys_nD():
                        meta_row.at['children'] = self.ho_data[new_key]
                    else:
                        empty_meta = Meta()
                        meta_row.at['children'] = empty_meta
                    return meta_row
                else:
                    return pds.Series([self.ho_data[new_key]], index=['children'])
            else:
                raise KeyError('Key not found in MetaData')
github pysat / pysat / pysat / _meta.py View on Github external
def __eq__(self, other):
        """
        Check equality between Meta instances.
        
        Checks if variable names, attribute names, and metadata values
        are all equal between to Meta objects. Note that this comparison
        treats np.NaN == np.NaN as True.
        
        Name comparison is case-sensitive.
        
        """
        
        if isinstance(other, Meta):
            # check first if variables and attributes are the same
            # quick check on length
            keys1 = [i for i in self.keys()]
            keys2 = [i for i in other.keys()]
            if len(keys1) != len(keys2):
                return False
            # now iterate over each of the keys in the first one
            # don't need to iterate over second one, if all of the first
            # in the second we are good. No more or less items in second from 
            # check earlier.
            for key in keys1:
                if key not in keys2:
                    return False
            # do same checks on attributes 
            attrs1 = [i for i in self.attrs()]
            attrs2 = [i for i in other.attrs()]
github pysat / pysat / pysat / _instrument.py View on Github external
else:
            raise ValueError('Must supply either a date or file id number.')

        if len(fname) > 0:
            load_fname = [os.path.join(self.files.data_path, f) for f in fname]
            try:
                data, mdata = self._load_rtn(load_fname, tag=self.tag,
                                             sat_id=self.sat_id, **self.kwargs)
                # ensure units and name are named consistently in new Meta
                # object as specified by user upon Instrument instantiation
                mdata.accept_default_labels(self)
                bad_datetime = False
            except pds.errors.OutOfBoundsDatetime:
                bad_datetime = True
                data = self._null_data.copy()
                mdata = _meta.Meta(units_label=self.units_label,
                                   name_label=self.name_label,
                                   notes_label=self.notes_label,
                                   desc_label=self.desc_label,
                                   plot_label=self.plot_label,
                                   axis_label=self.axis_label,
                                   scale_label=self.scale_label,
                                   min_label=self.min_label,
                                   max_label=self.max_label,
                                   fill_label=self.fill_label)

        else:
            bad_datetime = False
            data = self._null_data.copy()
            mdata = _meta.Meta(units_label=self.units_label,
                               name_label=self.name_label,
                               notes_label=self.notes_label,
github pysat / pysat / pysat / _instrument.py View on Github external
self._data_library = xr.Dataset
        # assign null data for user selected data type
        self.data = self._null_data.copy()

        # create Meta instance with appropriate labels
        self.units_label = units_label
        self.name_label = name_label
        self.notes_label = notes_label
        self.desc_label = desc_label
        self.plot_label = plot_label
        self.axis_label = axis_label
        self.scale_label = scale_label
        self.min_label = min_label
        self.max_label = max_label
        self.fill_label = fill_label
        self.meta = _meta.Meta(units_label=self.units_label,
                               name_label=self.name_label,
                               notes_label=self.notes_label,
                               desc_label=self.desc_label,
                               plot_label=self.plot_label,
                               axis_label=self.axis_label,
                               scale_label=self.scale_label,
                               min_label=self.min_label,
                               max_label=self.max_label,
                               fill_label=self.fill_label)

        # function processing class, processes data on load
        self.custom = _custom.Custom()
        # create arrays to store data around loaded day
        # enables padding across day breaks with minimal loads
        self._next_data = self._null_data.copy()
        self._next_data_track = []
github pysat / pysat / pysat / _meta.py View on Github external
def __eq__(self, other):
        """
        Check equality between Meta instances. Good for testing.

        Checks if variable names, attribute names, and metadata values
        are all equal between to Meta objects. Note that this comparison
        treats np.NaN == np.NaN as True.

        Name comparison is case-sensitive.

        """

        if isinstance(other, Meta):
            # check first if variables and attributes are the same
            # quick check on length
            keys1 = [i for i in self.keys()]
            keys2 = [i for i in other.keys()]
            if len(keys1) != len(keys2):
                return False
            # now iterate over each of the keys in the first one
            # don't need to iterate over second one, if all of the first
            # in the second we are good. No more or less items in second from
            # check earlier.
            for key in keys1:
                if key not in keys2:
                    return False
            # do same checks on attributes
            attrs1 = [i for i in self.attrs()]
            attrs2 = [i for i in other.attrs()]
github pysat / pysat / pysat / _instrument.py View on Github external
self._data_library = xr.Dataset
        # assign null data for user selected data type
        self.data = self._null_data.copy()

        # create Meta instance with appropriate labels
        self.units_label = units_label
        self.name_label = name_label
        self.notes_label = notes_label
        self.desc_label = desc_label
        self.plot_label = plot_label
        self.axis_label = axis_label
        self.scale_label = scale_label
        self.min_label = min_label
        self.max_label = max_label
        self.fill_label = fill_label
        self.meta = _meta.Meta(units_label=self.units_label,
                               name_label=self.name_label,
                               notes_label=self.notes_label,
                               desc_label=self.desc_label,
                               plot_label=self.plot_label,
                               axis_label=self.axis_label,
                               scale_label=self.scale_label,
                               min_label=self.min_label,
                               max_label=self.max_label,
                               fill_label=self.fill_label)

        # function processing class, processes data on load
        self.custom = _custom.Custom()
        # create arrays to store data around loaded day
        # enables padding across day breaks with minimal loads
        self._next_data = self._null_data.copy()
        self._next_data_track = []