def test_switzerland(self): drought = Drought() drought.set_area(44.5, 5, 50, 12) hazard_set = drought.setup() imp_drought = Impact() dr_if = ImpactFuncSet() if_def = IFDrought() if_def.set_default() dr_if.append(if_def) exposure_agrar = SpamAgrar() exposure_agrar.init_spam_agrar(country='CHE') exposure_agrar.assign_centroids(hazard_set) imp_drought.calc(exposure_agrar, dr_if, hazard_set) index_event_start = imp_drought.event_name.index('2003') damages_drought = imp_drought.at_event[index_event_start] self.assertEqual(hazard_set.tag.haz_type, 'DR') self.assertEqual(hazard_set.size, 114) self.assertEqual(hazard_set.centroids.size, 130) self.assertEqual(exposure_agrar.latitude.values.size, 766 / 2) self.assertEqual(exposure_agrar.value[3], 1720024.4) self.assertEqual(damages_drought, 61995472.555223145)
def test(self): drought = Drought() drought.set_area(44.5, 5, 50, 12) hazard_set = drought.setup() self.assertEqual(hazard_set.tag.haz_type, 'DR') self.assertEqual(hazard_set.size, 114) self.assertEqual(hazard_set.centroids.size, 130) self.assertEqual(hazard_set.intensity[112, 111], -1.6286273002624512)
""" Initialize default threshold (default: -1)""" threshold = -1.5 #Threshold and intensity_definition to be defined only if not defalut values are used """To define only if no default data are used (spei06)""" #spei_file_dir = r'C:\Users\veron\Documents\ETH\HS18\PROJECT\GIT\climada_python\data\system' #spei_file_name = r'spei02.nc' #spei_file_url = r'http://digital.csic.es/bitstream/10261/153475/4' """To define if the data are not in default path \climada_python\data\system""" #file_path_spei = r'C:\Users\veron\Documents\ETH\HS18\PROJECT\GIT\climada_python\data\system\spei06.nc' """Initialize hazard Drought""" d = Drought() """Set area in latitudinal longitudinal coordinates""" #d.set_area(latmin, lonmin, latmax, lonmax) """Set if non default parameters are used""" d.set_threshold(threshold) d.set_intensity_def(intensity_definition) """Set link to download data if a non default data is needed (default: spei06)""" #d.set_file_name(spei_file_name) #d.set_file_url(spei_file_url) """Set path if the data are not in 'climada_python\data\system' """ #d.set_file_path(file_path_spei)