예제 #1
0
    def test_get_uint8_image(self):
        ''' Shall scale image values from float (or any) to 0 - 255 [uint8] '''
        imageUint8 = get_uint8_image(self.n1['sigma0_HV'], self.imgMin, self.imgMax, 0, 0)
        plt.imsave('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name,
                    imageUint8, vmin=0, vmax=255)

        self.assertEqual(imageUint8.dtype, np.uint8)
        self.assertEqual(imageUint8.min(), 1)
        self.assertEqual(imageUint8.max(), 255)
예제 #2
0
 def setUp(self):
     ''' Load test data '''
     testDir = os.getenv('ICE_DRIFT_TEST_DATA_DIR')
     if testDir is None:
         sys.exit('ICE_DRIFT_TEST_DATA_DIR is not defined')
     testFiles = glob.glob(os.path.join(testDir, 'S1?_*tif'))
     if len(testFiles) < 2:
         sys.exit('Not enough test files in %s' % testDir)
     # sort by date
     dates = [os.path.basename(f).split('_')[4] for f in testFiles]
     self.testFiles = [str(f) for f in np.array(testFiles)[np.argsort(dates)]]
     self.n1 = Nansat(self.testFiles[0])
     self.n2 = Nansat(self.testFiles[1])
     self.imgMin = 0.001
     self.imgMax = 0.013
     self.nFeatures = 5000
     self.img1 = get_uint8_image(self.n1['sigma0_HV'], self.imgMin, self.imgMax, 0, 0)
     self.img2 = get_uint8_image(self.n2['sigma0_HV'], self.imgMin, self.imgMax, 0, 0)