def _build_exp(self): eai_exp = Exposures() eai_exp['value'] = self.eai_exp eai_exp['latitude'] = self.coord_exp[:, 0] eai_exp['longitude'] = self.coord_exp[:, 1] eai_exp.crs = self.crs eai_exp.value_unit = self.unit eai_exp.check() return eai_exp
def _build_exp(self): eai_exp = Exposures() eai_exp['value'] = self.eai_exp eai_exp['latitude'] = self.coord_exp[:, 0] eai_exp['longitude'] = self.coord_exp[:, 1] eai_exp.crs = self.crs eai_exp.value_unit = self.unit eai_exp.ref_year = 0 eai_exp.tag = Tag() eai_exp.meta = None return eai_exp
def test_assign_raster_pass(self): """ Test assign_centroids with raster hazard """ exp = Exposures() exp['longitude'] = np.array([-69.235, -69.2427, -72, -68.8016496, 30]) exp['latitude'] = np.array([10.235, 10.226, 2, 9.71272097, 50]) exp.crs = DEF_CRS haz = Hazard('FL') haz.set_raster([HAZ_DEMO_FL], window=Window(10, 20, 50, 60)) exp.assign_centroids(haz) self.assertEqual(exp[INDICATOR_CENTR + 'FL'][0], 51) self.assertEqual(exp[INDICATOR_CENTR + 'FL'][1], 100) self.assertEqual(exp[INDICATOR_CENTR + 'FL'][2], -1) self.assertEqual(exp[INDICATOR_CENTR + 'FL'][3], 3000 - 1) self.assertEqual(exp[INDICATOR_CENTR + 'FL'][4], -1)
def _build_exp_event(self, event_id): """Write impact of an event as Exposures Parameters: event_id(int): id of the event """ impact_csr_exp = Exposures() impact_csr_exp['value'] = self.imp_mat.toarray()[event_id - 1, :] impact_csr_exp['latitude'] = self.coord_exp[:, 0] impact_csr_exp['longitude'] = self.coord_exp[:, 1] impact_csr_exp.crs = self.crs impact_csr_exp.value_unit = self.unit impact_csr_exp.ref_year = 0 impact_csr_exp.tag = Tag() impact_csr_exp.meta = None return impact_csr_exp