From d1b03d28b1c851b31b1fd08886fa6b7bc6930f8a Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 10 Mar 2021 15:26:24 -0700 Subject: [PATCH] fix grid mask --- .../nshmp/netcdf/converters/convert_2018a.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/python/gov/usgs/earthquake/nshmp/netcdf/converters/convert_2018a.py b/src/main/python/gov/usgs/earthquake/nshmp/netcdf/converters/convert_2018a.py index f5e0ffd..34aa3fe 100644 --- a/src/main/python/gov/usgs/earthquake/nshmp/netcdf/converters/convert_2018a.py +++ b/src/main/python/gov/usgs/earthquake/nshmp/netcdf/converters/convert_2018a.py @@ -72,7 +72,7 @@ class Convert2018A: self._site_class_mask_array = np.zeros( [self._dimensions.lat.size, self._dimensions.lon.size], int ) - self._imt_mask_array = np.zeros([self._dimensions.lat.size, self._dimensions.lon.size], int) + # self._imt_mask_array = np.zeros([self._dimensions.lat.size, self._dimensions.lon.size], int) self._data_array = np.full( [ @@ -176,6 +176,7 @@ class Convert2018A: with ThreadPoolExecutor() as executor: for index, _info in enumerate(netcdf_info): + info: NetcdfInfo = _info futures.append( executor.submit( @@ -242,10 +243,12 @@ class Convert2018A: if not curves_file.exists: raise Exception(f"File ({curves_file}) not found") + imls = self.metadata.imls.get(netcdf_info.imt) imt_dir = curves_file.parent imt_index = self._get_imt_index(imt=netcdf_info.imt) + imt_mask_array = np.zeros([self._dimensions.lat.size, self._dimensions.lon.size], int) site_class_index = self._get_site_class_index(site_class=netcdf_info.site_class) - imls = self.metadata.imls.get(netcdf_info.imt) + print(f"\t Converting [{imt_dir.parent.name}/{imt_dir.name}/{curves_file.name}]") with open(curves_file, "r") as curves_reader: @@ -278,8 +281,8 @@ class Convert2018A: self._data_array[ site_class_index, imt_index, latitude_index, longitude_index, : ] = values - self._imt_mask_array[latitude_index, longitude_index] = 1 - self._site_class_mask_array += self._imt_mask_array + imt_mask_array[latitude_index, longitude_index] = 1 + self._site_class_mask_array += imt_mask_array def _set_imt_indices(self) -> dict[Imt, int]: imt_indices: dict[Imt, int] = dict() -- GitLab