예제 #1
0
    def grp_info(self, grp_name, print_out=True):
        """
        Print out and return information on any given group

        :param grp_name: group name, string
        :param print_out: print-out flag, boolean
        :return: count dimensions, dimensions, order, cell's name
        """
        error, cell_name, grp_count_dimensions, grp_dimensions, grp_order = nefis.inqgrp(self.fp, grp_name)
        self._print_error(error)
        if print_out:
            print('  Group count  : "%d"' % grp_count_dimensions)
            print('  Dimensions   : "%s"' % grp_dimensions)
            print('  Group order  : "%s"' % grp_order)
            print('  Cell name    : "%s"' % cell_name)
            # maximum used index of the free dimension of a data group
            error, ntimes = nefis.inqmxi (self.fp, grp_name)
            self._print_error(error)
            print('  Nb time step : "%d"' % ntimes)

        return grp_count_dimensions, grp_dimensions, grp_order, cell_name
예제 #2
0
    def _elm_list(self):
        """
        Read elements from the definition file.
        """
        nelm = 0
        while True:
            if nelm == 0:
                error, elm_name, elm_type, elm_quantity, elm_unit, elm_description, elm_single_bytes, elm_bytes, elm_count, elm_dimensions = nefis.inqfel(self.fp)
            else:
                error, elm_name, elm_type, elm_quantity, elm_unit, elm_description, elm_single_bytes, elm_bytes, elm_count, elm_dimensions = nefis.inqnel(self.fp)

            if error == -6024: # no more elements to read
                return self.elmlist
            elif not error == 0:  # some other error
                self._print_error(error)
                break
            else:
                nelm+=1
            self.elmlist.append(elm_name)

            # define dictionaries for each element name
            self.elm[elm_name]={}
            self.elm[elm_name]['info']={}
            info = self.elm[elm_name]['info']
            info['type'] = elm_type
            info['unit'] = elm_unit
            info['desc'] = elm_description
            info['bytesize'] = elm_single_bytes
            info['bytes'] = elm_bytes
            info['ndim'] = elm_count
            info['dims'] = elm_dimensions[::-1]  # reverse dimensions (C vs Fortran ??)

            elm_grp = self._find_elm(elm_name)[0]
            info['group'] = elm_grp

            # Give the maximum used index of the free dimension of a data group
            error, ntimes = nefis.inqmxi(self.fp, elm_grp)
            self._print_error(error)
            info['ntimes'] = ntimes
예제 #3
0
    def _grp_list(self):
        """
        Reads groups from definition file
        """
        ngrp = 0
        while True:
            if ngrp == 0:
                error, grp_name, cel_name, grp_count_dimensions, grp_dimensions, grp_order = nefis.inqfgr(self.fp)
            else:
                error, grp_name, cel_name, grp_count_dimensions, grp_dimensions, grp_order = nefis.inqngr(self.fp)

            if error == -6028: # no more groups to read
                return self.grplist
            elif not error == 0:  # some other error
                self._print_error(error)
                break
            else:
                ngrp += 1
            self.grplist.append(grp_name)
            # Give the maximum used index of the free dimension of a data group.
            error, ntimes = nefis.inqmxi(self.fp, grp_name)
            self._print_error(error)
            self.grp[grp_name]={}
            self.grp[grp_name]['ntimes'] = ntimes