Пример #1
0
 def test_to_gdal(self):
     """
     Tests converting the matplotlib ColorMap to a gdal color table
     """
     if GDAL_INSTALLED:
         cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
         g_ct = cmap.to_gdal()
         self.assertIsInstance(g_ct, gdal.ColorTable)
Пример #2
0
 def test_convert2greyscale(self):
     """
     Tests conversion to a greyscale ColorMap
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap_grey = cmap.convert2greyscale()
     cmap_grey.show()
     self.assertIsInstance(cmap_grey._mpl_cm, col.LinearSegmentedColormap)
Пример #3
0
 def test_to_list(self):
     """
     Tests writing ColorMap colors to list
     """
     cmap = ColorMap.from_list(self.clist)
     clist_out = cmap.to_list()
     self.assertListEqual(self.clist, clist_out)
Пример #4
0
 def test_cmap_from_ctfile(self):
     """
     Tests creation of a ColorMap from a gdal ct file
     """
     ct_file = 'sgrt_ct_cont_ssm.ct'
     cmap = ColorMap.from_ctfile(os.path.join(self.data_path, ct_file), gradient=False)
     self.assertIsInstance(cmap, ColorMap)
Пример #5
0
 def test_to_matplotlib(self):
     """
     Tests creation of a matplotlib ColorMap object
     """
     cmap = ColorMap.from_list(self.clist)
     cmap = cmap.to_matplotlib()
     self.assertIsInstance(cmap, col.ListedColormap)
Пример #6
0
 def test_listed2segmented(self):
     """
     Tests conversion from a Listed ColorMap to a LinearSegmented ColorMap
     """
     cmap = ColorMap.from_list(self.clist)
     cmap = cmap.to_gradient()
     self.assertIsInstance(cmap._mpl_cm, col.LinearSegmentedColormap)
Пример #7
0
 def test_cmap_from_json(self):
     """
     Tests creation of a ColorMap from a json file
     """
     json_file = 'Rainbow.json'
     cmap = ColorMap.from_jsonfile(os.path.join(self.data_path, json_file))
     self.assertIsInstance(cmap, ColorMap)
Пример #8
0
 def test_cmap_from_cpt(self):
     """
     Tests creation of a ColorMap from a matplotlib ColorMap file
     """
     cpt_file = 'ETOPO1.cpt'
     cmap = ColorMap.from_cptfile(os.path.join(self.data_path, cpt_file), gradient=True)
     self.assertIsInstance(cmap, ColorMap)
Пример #9
0
 def test_to_dict(self):
     """
     Tests writing ColorMap colors to dictionary
     """
     cmap = ColorMap.from_dict(self.cdict)
     cdict_out = cmap.to_dict()
     self.assertEqual(self.cdict, cdict_out)
Пример #10
0
    def test_reverse(self):
        """
        Tests reversing ColorMap colors

        """
        cmap = ColorMap.from_list(self.clist)
        cmap_reverse = cmap.reverse(inplace=False)
        cmap = cmap_reverse.reverse(inplace=False)
        self.assertEqual(cmap._mpl_cm.colors, self.clist)
Пример #11
0
 def test_save_as_ct(self):
     """
     Tests save ColorMap as ct file
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()
     output_path = os.path.join(self.output_path, 'ct_test.ct')
     cmap.save_as_ct(output_path)
     if isinstance(cmap._mpl_cm, col.LinearSegmentedColormap):
         cmap_read = ColorMap.from_file(output_path, gradient=True)
     if isinstance(cmap._mpl_cm, col.ListedColormap):
         cmap_read = ColorMap.from_file(output_path, gradient=False)
     cmap_read.show()
     self.assertIsInstance(cmap_read, ColorMap)
Пример #12
0
 def test_save_as_json(self):
     """
     Tests save ColorMap as json file
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()
     output_path = os.path.join(self.output_path, 'json_test.json')
     cmap.save_as_json(output_path)
     cmap_read = ColorMap.from_jsonfile(output_path)
     cmap_read.show()
     self.assertIsInstance(cmap_read, ColorMap)
Пример #13
0
 def test_cc_cmap_from_name(self):
     """
     Tests creation of a ColorMap from a cc name
     """
     cmap = ColorMap('cc:{}'.format(self.default_cc_cm))
     self.assertIsInstance(cmap, ColorMap)
Пример #14
0
 def test_ml_cmap_from_name(self):
     """
     Tests creation of a ColorMap from mpl name
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     self.assertIsInstance(cmap, ColorMap)
Пример #15
0
 def test_view(self):
     """
     Tests ploting the ColorMap
     """
     cmap = ColorMap('mpl:{}'.format(self.default_mpl_cm))
     cmap.show()
Пример #16
0
 def test_cl_cmap_from_name(self):
     """
     Tests creation of a ColorMap from user colormap directory
     """
     cmap = ColorMap('cl:{}'.format('Rainbow'))
     self.assertIsInstance(cmap, ColorMap)
Пример #17
0
 def test_cmap_from_dict(self):
     """
     Tests creation of a ColorMap from a dictionary
     """
     cmap = ColorMap.from_dict(self.cdict)
     self.assertIsInstance(cmap, ColorMap)
Пример #18
0
 def test_cmap_from_list(self):
     """
     Tests creation of a ColorMap from a list
     """
     cmap = ColorMap.from_list(self.clist)
     self.assertIsInstance(cmap, ColorMap)