Skip to content

Period recalculation has a bug #3

@MeriDK

Description

@MeriDK

Error:

UnboundLocalError Traceback (most recent call last)
Cell In[43], line 1
----> 1 ds_train[1]

File ~/AML/AstroML/notebooks/../core/dataset_multimodal.py:504, in ASASSNVarStarDataset.getitem(self, idx)
492 t, y, dy, _, P_best, _, _, _ = clip_outliers(
493 t,
494 y,
(...)
499 max_iter=2,
500 )
501 # print(f" ({P_best}) ", flush=True, end="")
502 # we may have found a harmonic. Fix it.
503 if (
--> 504 abs((P_best - band_periods[band]) / band_periods[band])
505 > 0.01
506 and P_best < band_periods[band]
507 ):
508 P_best *= 2
509 elif (
510 abs(P_best - 1) < 0.01
511 or abs(P_best - 2) < 0.01
512 or abs(P_best - 3) < 0.01
513 ):
514 # keep the original P if we're too close to 1 or 2 or 3 day Periods

UnboundLocalError: local variable 'P_best' referenced before assignment
ds_train.df.iloc[[1]][['Period', 'period']]

To replicate:

datapath = Path('../data/asaasn')
ds_train = ASASSNVarStarDataset(datapath, mode='train', verbose=True, only_periodic=True,
                                merge_type='inner', recalc_period=True, prime=True, use_bands=['v', 'g'],
                                only_sources_with_spectra=False)
print(ds_train[1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions