From 4811605923579a53968fea9a1529ed5d3598a847 Mon Sep 17 00:00:00 2001 From: Zach Hafen-Saavedra Date: Sat, 25 May 2024 21:19:30 +0000 Subject: [PATCH] Removed unnecessary branching between FH135 --- night_horizons/pipeline.py | 16 ++---- night_horizons/transformers/preprocessors.py | 54 -------------------- test/test_transformers/test_preprocessors.py | 2 +- 3 files changed, 4 insertions(+), 68 deletions(-) diff --git a/night_horizons/pipeline.py b/night_horizons/pipeline.py index 0fd515e..e76c674 100755 --- a/night_horizons/pipeline.py +++ b/night_horizons/pipeline.py @@ -91,24 +91,14 @@ def register_fundamental_services(self): ) # Processors for different formats of metadata - self.container.register_service("metadata_processor", constructor=None) self.container.register_service( - "fh135_metadata_processor", - lambda **kwargs: preprocessors.MetadataPreprocessor135( + "metadata_processor", + lambda **kwargs: preprocessors.MetadataPreprocessor( io_manager=self.container.get_service("io_manager"), crs=self.container.get_service("crs"), **kwargs, ), - wrapped_constructor=preprocessors.MetadataPreprocessor135, - ) - self.container.register_service( - "fh145_metadata_processor", - lambda **kwargs: preprocessors.MetadataPreprocessor145( - io_manager=self.container.get_service("io_manager"), - crs=self.container.get_service("crs"), - **kwargs, - ), - wrapped_constructor=preprocessors.MetadataPreprocessor145, + wrapped_constructor=preprocessors.MetadataPreprocessor, ) def register_default_services(self): diff --git a/night_horizons/transformers/preprocessors.py b/night_horizons/transformers/preprocessors.py index d345556..2b0cece 100644 --- a/night_horizons/transformers/preprocessors.py +++ b/night_horizons/transformers/preprocessors.py @@ -273,11 +273,6 @@ def get_logs(self) -> pd.DataFrame: return log_df - -class MetadataPreprocessor135(MetadataPreprocessor): - """Subclass of Metadata for working with Metadata formatted similar to how it was - formatted for FH135.""" - def load_img_log(self, img_log_fp: str = None) -> pd.DataFrame: """Load the images log. @@ -502,55 +497,6 @@ def load_gps_log( return gps_log_df -class MetadataPreprocessor145(MetadataPreprocessor): - - def load_img_log(self, img_log_fp: str = None) -> pd.DataFrame: - """Load the images log. - - Parameters - ---------- - img_log_fp: Location of the image log. - Defaults to the one provided at init. - """ - - return pd.DataFrame() - - def load_imu_log(self, imu_log_fp: str = None) -> pd.DataFrame: - """Load the IMU log. - - Args: - imu_log_fp: Location of the IMU log. - Defaults to the one provided at init. - """ - - imu_log_df = pd.read_csv(imu_log_fp, skipfooter=1) - - # dropping the last row (101571) its all NAN and breaking when trying - # to convert to_datetime - imu_log_df = imu_log_df[:-1] - imu_log_df = imu_log_df.drop(imu_log_df.columns[-1], axis=1) - # cleaning up columns that were all NaN - - def validateDate(objNum): - try: - date = pd.to_datetime(objNum) - return date - except ValueError: - return pd.NA - - time_series = imu_log_df["CurrTimestamp"] - new_time_series = time_series.apply(validateDate) - epoch_time = new_time_series.astype(int) / 10**9 - imu_log_df["CurrTimestamp"] = epoch_time - - return imu_log_df - - def load_gps_log( - self, gps_log_fp: str = None, latlon_crs: str = "EPSG:4326" - ) -> pd.DataFrame: - pass - - class GeoTIFFPreprocessor(TransformerMixin, BaseEstimator): """Class for getting geotransforms out from a list of GeoTIFF filepaths.""" diff --git a/test/test_transformers/test_preprocessors.py b/test/test_transformers/test_preprocessors.py index 9cd2fe8..ccf6fd7 100644 --- a/test/test_transformers/test_preprocessors.py +++ b/test/test_transformers/test_preprocessors.py @@ -35,7 +35,7 @@ def setUpFunction(self, local_options={}): # Preprocessor construction self.expected_cols = ["filepath", "sensor_x", "sensor_y"] - self.transformer = preprocessors.MetadataPreprocessor135( + self.transformer = preprocessors.MetadataPreprocessor( io_manager=self.io_manager, output_columns=self.expected_cols, crs=self.mapmaker.container.get_service("crs"),