Skip to content

Commit

Permalink
Removed unnecessary branching between FH135
Browse files Browse the repository at this point in the history
  • Loading branch information
zhafen committed May 25, 2024
1 parent 41bf658 commit 4811605
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 68 deletions.
16 changes: 3 additions & 13 deletions night_horizons/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
54 changes: 0 additions & 54 deletions night_horizons/transformers/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion test/test_transformers/test_preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 4811605

Please sign in to comment.