Пример #1
0
    def test_validate_gis(self):
        self.gh = GIS(self.root)
        self.gh.validate_gis()
        self.assertEqual(self.gh.gis, self.root + '/gis')
        self.assertEqual(self.gh.scaled, self.gh.root + '/gis/layers/scaled')
        self.assertEqual(self.gh.non_scaled,
                         self.gh.root + '/gis/layers/non-scaled')
        self.assertEqual(self.gh.world_locations_to_predict,
                         self.root + '/gis/world_locations_to_predict.csv')
        self.assertEqual(self.gh.empty_map,
                         self.root + '/gis/layers/empty_land_map.tif')

        with self.assertRaises(IOError):
            self.gh = GIS(self.root + '/scaled')
            self.gh.validate_gis()
Пример #2
0
    def test_validate_tif(self):
        self.gh = GIS(self.root)
        self.gh.validate_gis()
        self.gh.validate_tif()
        f1, n1 = self.gh.variables_list(self.root + '/gis/layers/scaled')
        f2, n2 = self.gh.variables_list(self.root + '/gis/layers/non-scaled')
        variables_truth = sorted(f1) + sorted(f2)
        names_truth = sorted(n1) + sorted(n2)
        self.assertEqual(self.gh.variables, variables_truth)
        self.assertEqual(self.gh.names, names_truth)
        self.assertEqual(self.gh.length, 6)
        self.assertEqual(self.gh.scaled_len, 4)

        with self.assertRaises(IOError):
            self.gh = GIS(self.root + '/scaled')
            self.gh.validate_gis()
Пример #3
0
    def __init__(self, root, dat_root='/data', occ_root='/data/occurrences'):
        """sdmdl object initiation."""

        self.root = root
        self.occ_root = self.root + occ_root if occ_root == '/data/occurrences' else occ_root
        self.dat_root = self.root + dat_root if dat_root == '/data' else dat_root

        self.oh = Occurrences(self.occ_root)
        self.oh.validate_occurrences()
        self.oh.species_dictionary()

        self.gh = GIS(self.dat_root)
        self.gh.validate_gis()
        self.gh.validate_tif()
        self.gh.define_output()

        self.ch = Config(self.dat_root, self.oh, self.gh)
        self.ch.search_config()
        self.ch.read_yaml()

        self.verbose = self.ch.verbose
        if not self.verbose:
            # used to silence tensorflow backend deprecation warnings.
            os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
            logging.getLogger("tensorflow").setLevel(logging.ERROR)
Пример #4
0
 def setUp(self):
     self.root = os.path.abspath(os.path.join(
         os.path.dirname(__file__))) + '/test_data'
     self.gh = GIS(self.root + '/root')
     self.gh.validate_gis()
     self.gh.validate_tif()
     self.gh.define_output()
     self.verbose = False
     self.cbm = BandStatistics(self.gh, self.verbose)
Пример #5
0
 def setUp(self):
     self.root = (os.path.abspath(os.path.join(os.path.dirname(__file__))) +
                  '/test_data').replace('\\', '/')
     self.gh = GIS(self.root + '/root')
     self.gh.validate_gis()
     self.gh.validate_tif()
     self.gh.define_output()
     self.verbose = False
     self.crs = RasterStack(self.gh, self.verbose)
Пример #6
0
    def setUp(self):
        self.root = os.path.abspath(os.path.join(
            os.path.dirname(__file__))) + '/test_data'
        self.gh = GIS(self.root + '/root')
        self.gh.validate_gis()
        self.gh.validate_tif()
        self.gh.define_output()
        self.verbose = False

        self.cpd = PredictionData(self.gh, self.verbose)
Пример #7
0
 def test_define_output(self):
     self.gh = GIS(self.root)
     self.gh.validate_gis()
     self.gh.validate_tif()
     self.gh.define_output()
     self.assertEqual(self.gh.presence, (self.gh.non_scaled + '/presence'))
     self.assertEqual(self.gh.stack, (self.gh.gis + '/stack'))
     self.assertEqual(self.gh.stack_clip, (self.gh.gis + '/stack_clip'))
     self.assertEqual(self.gh.spec_ppa, (self.gh.root + '/spec_ppa'))
     self.assertEqual(self.gh.spec_ppa_env,
                      (self.gh.root + '/spec_ppa_env'))
Пример #8
0
    def setUp(self):
        self.root = (os.path.abspath(os.path.join(os.path.dirname(__file__))) +
                     '/test_data').replace('\\', '/')
        self.oh = Occurrences(self.root + '/root')
        self.oh.validate_occurrences()
        self.oh.species_dictionary()
        self.gh = GIS(self.root + '/root')
        self.gh.validate_gis()
        self.gh.validate_tif()
        self.gh.define_output()

        self.ch = Config(self.root + '/root', self.oh, self.gh)
Пример #9
0
    def setUp(self):
        self.root = os.path.abspath(os.path.join(
            os.path.dirname(__file__))) + '/test_data'
        self.oh = Occurrences(self.root + '/root')
        self.oh.validate_occurrences()
        self.oh.species_dictionary()
        self.gh = GIS(self.root + '/root')
        self.gh.validate_gis()
        self.gh.validate_tif()
        self.gh.define_output()
        self.verbose = False

        self.cpm = PresenceMap(self.oh, self.gh, self.verbose)
Пример #10
0
 def setUp(self):
     self.root = os.path.abspath(os.path.join(os.path.dirname(__file__))) + '/test_data'
     self.oh = Occurrences(self.root + '/root')
     self.oh.validate_occurrences()
     self.oh.species_dictionary()
     self.gh = GIS(self.root + '/root')
     self.gh.validate_gis()
     self.gh.validate_tif()
     self.gh.define_output()
     self.ch = Config(self.root + '/root', self.oh, self.gh)
     self.ch.search_config()
     self.ch.read_yaml()
     self.verbose = False
     self.t = Trainer(self.oh, self.gh, self.ch, self.verbose)
Пример #11
0
 def test_validate_list(self):
     self.gh = GIS(self.root)
     self.gh.validate_gis()
     test_root = self.root + '/gis/layers/scaled'
     f, n, = self.gh.variables_list(test_root)
     f_truth = []
     n_truth = []
     for a, b, c in sorted(os.walk(test_root)):
         for file in c:
             file_ext = file.split('.')[-1]
             fx = file_ext.lower()
             if fx == 'tif' or fx == 'tiff':
                 f_truth += [a.replace('\\', '/') + '/' + file]
                 n_truth += [file.replace('.%s' % file_ext, '')]
     self.assertEqual(f, f_truth)
     self.assertEqual(n, n_truth)
Пример #12
0
 def test__init__(self):
     self.gh = GIS(self.root)
     self.assertEqual(self.gh.root, self.root)
     self.assertEqual(self.gh.scaled, '')
     self.assertEqual(self.gh.non_scaled, '')
     self.assertEqual(self.gh.gis, '')
     self.assertEqual(self.gh.world_locations_to_predict, '')
     self.assertEqual(self.gh.empty_map, '')
     self.assertEqual(self.gh.variables, [])
     self.assertEqual(self.gh.names, [])
     self.assertEqual(self.gh.length, 0)
     self.assertEqual(self.gh.scaled_len, 0)
     self.assertEqual(self.gh.presence, '')
     self.assertEqual(self.gh.stack, '')
     self.assertEqual(self.gh.stack_clip, '')
     self.assertEqual(self.gh.spec_ppa, '')
     self.assertEqual(self.gh.spec_ppa_env, '')
Пример #13
0
    def setUp(self):
        self.root = (os.path.abspath(os.path.join(os.path.dirname(__file__))) +
                     '/test_data').replace('\\', '/')
        self.oh = Occurrences(self.root + '/root')
        self.oh.validate_occurrences()
        self.oh.species_dictionary()
        self.gh = GIS(self.root + '/root')
        self.gh.validate_gis()
        self.gh.validate_tif()
        self.gh.define_output()
        self.ch = Config(self.root, self.oh, self.gh)
        self.ch.search_config()
        self.ch.read_yaml()
        self.ch.random_seed = 1
        self.verbose = False

        self.ppa = PresencePseudoAbsence(self.oh, self.gh, self.ch,
                                         self.verbose)