From ba322c864a5b5505fe56e8e18ca8f4785efd2c46 Mon Sep 17 00:00:00 2001 From: jgieseler Date: Wed, 14 Dec 2022 16:48:13 +0200 Subject: [PATCH 1/2] code linting --- seppy/tools/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/seppy/tools/__init__.py b/seppy/tools/__init__.py index 0022b87..4e0df35 100644 --- a/seppy/tools/__init__.py +++ b/seppy/tools/__init__.py @@ -220,14 +220,14 @@ def load_data(self, spacecraft, sensor, viewing, data_level, self.update_viewing(viewing) return df, meta - + if self.sensor in ("ephin-5", "ephin-15"): dataset = "ephin_flux_2020-2022.csv" datacols = ["date", "E5", "E15"] df = pd.read_csv(f"{self.data_path}{os.sep}{dataset}", usecols=datacols, - index_col="date", parse_dates=True) + index_col="date", parse_dates=True) meta = {"E5": "0.45 - 0.50 MeV", "E15": "0.70 - 1.10 MeV"} @@ -390,7 +390,6 @@ def load_all_viewing(self): self.current_df_e = self.df self.current_energies = self.meta - if self.spacecraft.lower() == 'wind': if self.sensor.lower() == '3dp': self.df_omni_i, self.df_omni_e, self.df_i, self.df_e, self.meta_i, self.meta_e = \ @@ -2156,7 +2155,7 @@ def print_energies(self): if self.sensor == "ephin": channel_numbers = np.array([int(name.split('E')[-1]) for name in channel_names]) - + if self.sensor in ["ephin-5", "ephin-15"]: channel_numbers = [5, 15] From 4eb3c92b142539eb168cfdda4eec2a665907c33a Mon Sep 17 00:00:00 2001 From: jgieseler Date: Wed, 14 Dec 2022 17:03:05 +0200 Subject: [PATCH 2/2] catch missing ephin-5/15 file --- seppy/tools/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/seppy/tools/__init__.py b/seppy/tools/__init__.py index 4e0df35..f18efb4 100644 --- a/seppy/tools/__init__.py +++ b/seppy/tools/__init__.py @@ -226,8 +226,11 @@ def load_data(self, spacecraft, sensor, viewing, data_level, dataset = "ephin_flux_2020-2022.csv" datacols = ["date", "E5", "E15"] - df = pd.read_csv(f"{self.data_path}{os.sep}{dataset}", usecols=datacols, - index_col="date", parse_dates=True) + if os.path.isfile(f"{self.data_path}{dataset}"): + df = pd.read_csv(f"{self.data_path}{dataset}", usecols=datacols, + index_col="date", parse_dates=True) + else: + raise Warning(f"File {dataset} not found at {self.data_path}! Please verify that 'data_path' is correct.") meta = {"E5": "0.45 - 0.50 MeV", "E15": "0.70 - 1.10 MeV"}