Esempio n. 1
0
 def test__init__(self):
     self.oh = Occurrences(self.root)
     self.assertEqual(self.oh.root, self.root)
     self.assertEqual(self.oh.length, 0)
     self.assertEqual(self.oh.path, [])
     self.assertEqual(self.oh.name, [])
     self.assertEqual(self.oh.spec_dict, {})
Esempio n. 2
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)
Esempio n. 3
0
 def test_validate_occurrences(self):
     self.oh = Occurrences(self.root)
     self.oh.validate_occurrences()
     self.assertEqual(self.oh.length, 2)
     self.assertEqual(self.oh.path, [
         self.root + '/occurrences/arachis_duranensis.csv',
         self.root + '/occurrences/solanum_bukasovii.csv'
     ])
     self.assertEqual(self.oh.name,
                      ['arachis_duranensis', 'solanum_bukasovii'])
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
0
 def test_species_dictionary(self):
     self.oh = Occurrences(self.root)
     self.oh.validate_occurrences()
     self.oh.species_dictionary()
     self.assertIsInstance(self.oh.spec_dict, dict)
     self.assertEqual(list(self.oh.spec_dict.keys()),
                      ['arachis_duranensis', 'solanum_bukasovii'])
     self.assertEqual(list(self.oh.spec_dict['arachis_duranensis']),
                      ['dLon', 'dLat'])
     spec_dict_truth = pd.read_csv(self.root +
                                   '/occurrences/solanum_bukasovii.csv')[[
                                       'decimalLongitude', 'decimalLatitude'
                                   ]]
     self.assertEqual(
         self.oh.spec_dict['solanum_bukasovii'].values.tolist(),
         spec_dict_truth.to_numpy().tolist())
Esempio n. 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, 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)