Skip to content

Commit

Permalink
fix a recursive import issue and complete the interface to
Browse files Browse the repository at this point in the history
build features as a list of pairs (metadata, features) for
a list of light curve objects passed as input.
  • Loading branch information
Johann Cohen-Tanugi committed Jul 25, 2023
1 parent e2fceb6 commit 8460c93
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions resspect/feature_extractors/bazin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class BazinFeatureExtractor(LightCurve):
def __init__(self):
super().__init__()
def __init__(self, lc=None):
super().__init__(lc)
self.features_names = ['a', 'b', 't0', 'tfall', 'trise']

def evaluate(self, time: np.array) -> dict:
Expand Down
4 changes: 2 additions & 2 deletions resspect/feature_extractors/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


class BumpFeatureExtractor(LightCurve):
def __init__(self):
super().__init__()
def __init__(self, lc=None):
super().__init__(lc)
self.features_names = ['p1', 'p2', 'p3', 'time_shift', 'max_flux']

def evaluate(self, time: np.array) -> dict:
Expand Down
14 changes: 1 addition & 13 deletions resspect/feature_extractors/light_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _copy_constructor(self, lc):
self.last_mag = lc.last_mag
self.photometry = lc.photometry
self.redshift = lc.redshift
self.sample = ls.sample
self.sample = lc.sample
self.sim_peakmag = lc.sim_peakmag
self.sim_pkmjd = lc.sim_pkmjd
self.sncode = lc.sncode
Expand All @@ -166,18 +166,6 @@ def from_file(filename: str) -> list:
light_curves.append(lc)
return light_curves

@staticmethod
def compute_feature(feature_type: str, allLC: list) -> list:
feature_list = []
if feature_type == 'bazin':
extractor = BazinFeatureExtractor
elif feature_extractor == 'bump':
extractor = BumpFeatureExtractor
for lc in allLC:
ex = extractor(lc)
ex.fit_all()
feature_list.appen(ex)

def _get_snpcc_photometry_raw_and_header(
self, lc_data: np.ndarray,
sntype_test_value: str = "-9") -> Tuple[np.ndarray, list]:
Expand Down
11 changes: 11 additions & 0 deletions resspect/fit_lightcurves.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
}



def compute_features(feature_type: str, allLC: list) -> list:
feature_list = []
extractor = FEATURE_EXTRACTOR_MAPPING[feature_type]
for lc in allLC:
ex = extractor(lc)
ex.fit_all()
ex.metadata = [ex.id, ex.redshift, ex.sntype, ex.sncode, ex.sample]
feature_list.append((ex.metadata, ex.features))
return feature_list

def _get_features_to_write(light_curve_data) -> list:
"""
Returns features list to write
Expand Down

0 comments on commit 8460c93

Please sign in to comment.