Beispiel #1
0
    def test_get_n(self):
        ''' Shall return Nansat and Matrix '''
        n = get_n(self.testFiles[0], 'sigma0_HV', 0.5, 0.001, 0.013, False,
                  False)
        n = get_n(self.testFiles[0], 'sigma0_HV', 0.5, -20, -15, False, True)

        self.assertIsInstance(n, Nansat)
        self.assertEqual(n[1].dtype, np.uint8)
        self.assertEqual(n[1].min(), 0)
        self.assertEqual(n[1].max(), 255)
    def __init__(self, filename1, filename2, **kwargs):
        ''' Initialize from two file names:
        Open files with Nansat
        Read data from sigma0_HV or other band and convert to UInt8
        Parameters
        ----------
            filename1 : str, file name of the first Sentinel-1 image
            filename2 : str, file name of the second Sentinel-1 image
        '''
        self.filename1 = filename1
        self.filename2 = filename2

        # get Nansat
        self.n1 = get_n(self.filename1, **kwargs)
        self.n2 = get_n(self.filename2, **kwargs)
Beispiel #3
0
 def test_rotate_and_match(self):
     ''' shall rotate and match'''
     n1 = get_n(self.testFiles[0])
     n2 = get_n(self.testFiles[1])
     dx, dy, best_a, best_r, best_h, best_result, best_template = rotate_and_match(
                      n1[1], 300, 100, 50, n2[1], 0, [-3,-2,-1,0,1,2,3])
     plt.subplot(1,3,1)
     plt.imshow(n2[1], interpolation='nearest')
     plt.subplot(1,3,2)
     plt.imshow(best_result, interpolation='nearest', vmin=0)
     plt.subplot(1,3,3)
     plt.imshow(best_template, interpolation='nearest')
     plt.suptitle('%f %f %f %f %f' % (dx, dy, best_a, best_r, best_h))
     plt.savefig('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name,)
     plt.close('all')
Beispiel #4
0
    def test_get_n(self, mock_get_invalid_mask):
        invalid_mask = np.zeros((500, 500)).astype(bool)
        invalid_mask[:100, :100] = True
        mock_get_invalid_mask.return_value = invalid_mask
        n = get_n(self.testFiles[0],
                  bandName='sigma0_HV',
                  factor=0.5,
                  vmin=0.001,
                  vmax=0.013,
                  denoise=False,
                  dB=False)
        n = get_n(self.testFiles[0],
                  bandName='sigma0_HV',
                  factor=0.5,
                  vmin=-20,
                  vmax=-15,
                  denoise=False,
                  dB=True)

        self.assertIsInstance(n, Nansat)
        self.assertEqual(n[1].dtype, np.uint8)
        self.assertEqual(n[1].min(), 0)
        self.assertEqual(n[1].max(), 255)