Exemplo n.º 1
0
Arquivo: hdf5.py Projeto: xyt556/argos
 def __getitem__(self, index):
     """ Called when using the RTI with an index (e.g. rti[0]).
         Passes the index through to the underlying dataset.
         Converts to a masked array using the missing data value as fill_value
     """
     return maskedEqual(self._h5Dataset.__getitem__(index),
                        self.missingDataValue)
Exemplo n.º 2
0
    def __getitem__(self, index):
        """ Called when using the RTI with an index (e.g. rti[0]).
            The scalar will be wrapped in an array with one element so it can be inspected.
        """
        array = np.array([self._h5Dataset[()]]) # slice with empty tuple
        maskedArray = maskedEqual(array, self.missingDataValue)

        assert maskedArray.shape == (1, ), "Scalar wrapper shape mismatch: {}".format(array.shape)
        return maskedArray[index] # Use the index to ensure the slice has the correct shape
Exemplo n.º 3
0
Arquivo: hdf5.py Projeto: xyt556/argos
    def __getitem__(self, index):
        """ Called when using the RTI with an index (e.g. rti[0]).
            Applies the index on the HDF dataset that contain this field and then selects the
            current field. In pseudo-code, it returns: self.ncVar[index][self.nodeName].

            If the field itself contains a sub-array it returns:
                self.ncVar[mainArrayIndex][self.nodeName][subArrayIndex]
        """
        mainArrayNumDims = len(self._h5Dataset.shape)
        mainIndex = index[:mainArrayNumDims]
        mainArray = self._h5Dataset.__getitem__(mainIndex)
        fieldArray = mainArray[self.nodeName]
        subIndex = tuple([Ellipsis]) + index[mainArrayNumDims:]
        slicedArray = fieldArray[subIndex]

        return maskedEqual(slicedArray, self.missingDataValue)
Exemplo n.º 4
0
    def __getitem__(self, index):
        """ Called when using the RTI with an index (e.g. rti[0]).
            Applies the index on the NCDF variable that contain this field and then selects the
            current field. In pseudo-code, it returns: self.ncVar[index][self.nodeName].

            If the field itself contains a sub-array it returns:
                self.ncVar[mainArrayIndex][self.nodeName][subArrayIndex]
        """
        mainArrayNumDims = len(self._h5Dataset.shape)
        mainIndex = index[:mainArrayNumDims]
        mainArray = self._h5Dataset.__getitem__(mainIndex)
        fieldArray = mainArray[self.nodeName]
        subIndex = tuple([Ellipsis]) + index[mainArrayNumDims:]
        slicedArray = fieldArray[subIndex]

        return maskedEqual(slicedArray, self.missingDataValue)
Exemplo n.º 5
0
 def __getitem__(self, index):
     """ Called when using the RTI with an index (e.g. rti[0]).
         Passes the index through to the underlying dataset.
         Converts to a masked array using the missing data value as fill_value
     """
     return maskedEqual(self._h5Dataset.__getitem__(index), self.missingDataValue)