Exemplo n.º 1
0
 def test_pad_data_vertically_bad_shape(self):
     """Test the error handling for the vertical hrv padding."""
     data = xr.DataArray(data=np.zeros((10, 1)), dims=('y', 'x'))
     south_bound = 5
     north_bound = 10
     final_size = (20, 1)
     with self.assertRaises(IndexError):
         pad_data_vertically(data, final_size, south_bound, north_bound)
Exemplo n.º 2
0
 def test_pad_data_vertically():
     """Test the vertical hrv padding."""
     data = xr.DataArray(data=np.zeros((10, 1)), dims=('y', 'x'))
     south_bound = 4
     north_bound = 13
     final_size = (20, 1)
     res = pad_data_vertically(data, final_size, south_bound, north_bound)
     expected = np.zeros(final_size)
     expected[:] = np.nan
     expected[south_bound-1:north_bound] = 0.
     np.testing.assert_equal(res, expected)
Exemplo n.º 3
0
    def pad_data(self, dataset):
        """Pad data to full disk with empty pixels."""
        logger.debug('Padding data to full disk')

        data_list = []
        for south_bound, north_bound, east_bound, west_bound in zip(
                *self._img_bounds.values()):
            nlines = north_bound - south_bound + 1
            data = self._extract_data_to_pad(dataset, south_bound, north_bound)
            padded_data = pad_data_horizontally(data,
                                                (nlines, self._final_shape[1]),
                                                east_bound, west_bound)
            data_list.append(padded_data)

        padded_data = da.vstack(data_list)

        # If we're dealing with RSS or ROI data, we also need to pad vertically in order to form a full disk array
        if not self._is_full_disk:
            padded_data = pad_data_vertically(padded_data, self._final_shape,
                                              south_bound, north_bound)

        return xr.DataArray(padded_data,
                            dims=('y', 'x'),
                            attrs=dataset.attrs.copy())