From 2af3eea964a7514d972508db588e1d98edeb97ab Mon Sep 17 00:00:00 2001 From: Sharon Fitzpatrick Date: Thu, 7 Nov 2024 16:39:33 -0800 Subject: [PATCH] sort the transect ids columns in raw_transect_time_series.csv --- src/coastseg/coastseg_map.py | 2 ++ src/coastseg/common.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/coastseg/coastseg_map.py b/src/coastseg/coastseg_map.py index 02a0b18..96db8de 100644 --- a/src/coastseg/coastseg_map.py +++ b/src/coastseg/coastseg_map.py @@ -1840,6 +1840,8 @@ def extract_all_shorelines(self,roi_ids:list=None) -> None: Returns: None """ + if isinstance(roi_ids, str): + roi_ids = [roi_ids] # 1. validate the inputs for shoreline extraction exist: ROIs, transects,shorelines and a downloaded data for each ROI self.validate_extract_shoreline_inputs(roi_ids) diff --git a/src/coastseg/common.py b/src/coastseg/common.py index 826c190..491c381 100644 --- a/src/coastseg/common.py +++ b/src/coastseg/common.py @@ -1921,8 +1921,13 @@ def save_transects( filepath = os.path.join(save_location, "raw_transect_time_series_merged.csv") merged_timeseries_df.to_csv(filepath, sep=",",index=False) + # sort the columns + sorted_columns = [timeseries_df.columns[0]] + sorted(timeseries_df.columns[1:], key=lambda x: int(''.join(filter(str.isdigit, x)))) + timeseries_df = timeseries_df[sorted_columns] + filepath = os.path.join(save_location, "raw_transect_time_series.csv") timeseries_df.to_csv(filepath, sep=",",index=False) + # save transect settings to file transect_settings = get_transect_settings(settings) transect_settings_path = os.path.join(save_location, "transects_settings.json")