@@ -142,21 +142,20 @@ def clean_data(
142142 flux_ = flux [nan_mask ]
143143 flux_error_ = flux_error [nan_mask ]
144144 time_ = time [nan_mask ]
145- logging .info (f "Deleted { len (flux ) - len (flux_ )} NaN entries." )
145+ logging .info ("Deleted %s NaN entries." , len (flux ) - len (flux_ ))
146146
147147 # Remove duplicate times (keep first occurrence)
148148 time_unique , time_unique_id = np .unique (time_ , return_index = True )
149149 flux_clean = flux_ [time_unique_id ]
150150 flux_error_clean = flux_error_ [time_unique_id ]
151- logging .info (f "Deleted { len (time_ ) - len (time_unique )} time duplicates" )
151+ logging .info ("Deleted %s time duplicates" , {len (time_ ) - len (time_unique )})
152152 if ts is not None :
153153 ts_ = ts [nan_mask ]
154154 ts_clean = ts_ [time_unique_id ]
155155 return (time_unique , flux_clean , flux_error_clean , ts_clean )
156- if ts is None :
156+ else :
157157 return (time_unique , flux_clean , flux_error_clean , None )
158158
159-
160159def get_gti_iis (
161160 time : np .ndarray , n_gaps : int , n_pick : int | None
162161) -> tuple [np .ndarray , np .ndarray ]:
@@ -203,7 +202,7 @@ def get_gti_iis(
203202 return GTI_start_ii , GTI_end_ii
204203
205204
206- def make_gti_lcs (lc : LightCurve , n_gaps : int , n_pick : int = None ) -> np .ndarray :
205+ def make_gti_lcs (lc : LightCurve , n_gaps : int , n_pick : int | None = None ) -> np .ndarray :
207206 """
208207 Divide LC into several LCs (Good Time Intervals = GTIs) based on largest
209208 time gaps. Optionally only pick largest GTIs.
@@ -314,11 +313,14 @@ def __init__(
314313 self .telescope = telescope
315314 self .cadence = cadence
316315 if len (time ) != len (flux ) or len (time ) != len (flux_error ):
317- raise ValueError ("Input arrays do not have same length" )
316+ friendly_error = "Input arrays do not have same length"
317+ raise ValueError (friendly_error )
318318 if len (flux [np .isnan (flux )]) > 0 or len (flux_error [np .isnan (flux_error )]) > 0 :
319- raise TypeError ("flux or flux_error contain np.nan values" )
319+ friendly_error = "flux or flux_error contain np.nan values"
320+ raise TypeError (friendly_error )
320321 if len (time ) != len (np .unique (time )):
321- raise ValueError ("time contains duplicate values" )
322+ friendly_error = "time contains duplicate values"
323+ raise ValueError (friendly_error )
322324 if time_format :
323325 """ format of the astropy.time.Time object """
324326 self .astropy_time = astropy .time .Time (time , format = time_format )
@@ -383,7 +385,8 @@ def __getitem__(self, inbr: int | slice | list[int]) -> np.ndarray | LightCurve:
383385 if isinstance (inbr , list ):
384386 # can't be implemented with 'int or list' -> confusion with slice
385387 return np .array ([self .time [inbr ], self .flux [inbr ], self .flux_error [inbr ]])
386- raise TypeError ("Index must be int, slice, or list of ints." )
388+ friendly_error = "Index must be int, slice, or list of ints."
389+ raise TypeError (friendly_error )
387390
388391 def select_by_time (self , t_min : float , t_max : float ) -> LightCurve :
389392 """
@@ -407,7 +410,7 @@ def select_by_time(self, t_min: float, t_max: float) -> LightCurve:
407410
408411 def save_npy (self , path : str ) -> None :
409412 """
410- Save light curve object as .npy file using pickle.
413+ Save light curve object using pickle.
411414
412415 Parameters
413416 ----------
@@ -418,8 +421,11 @@ def save_npy(self, path: str) -> None:
418421 -----
419422 Use `load_lc_npy()` to read this file.
420423 This does not update `LC.py`, it saves current object state.
424+ TBD: actaully since this is an object it just saves a pickle that could be called .npy
425+ the save npy business needs to be revisited I think it might be nonesense
421426 """
422- with open (path , "wb" ) as pickle_file :
427+ path = Path (path )
428+ with path .open ("wb" ) as pickle_file :
423429 pickle .dump (self , pickle_file )
424430
425431 def save_csv (self , path : str , bblocks : bool = False ) -> None :
@@ -502,7 +508,7 @@ def plot_lc(
502508 axtop .set_xbound (ax .get_xbound ())
503509 axtop .set_xlim (ax .get_xlim ())
504510 format_labels = astropy .time .Time (
505- [ t for t in ax .get_xticks ()] , format = self .time_format
511+ list ( t for t in ax .get_xticks ()) , format = self .time_format
506512 )
507513 if new_time_format == "isot" :
508514 new_labels = [
0 commit comments