Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SLSN] Catch convergence errors #362

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fink_science/agn/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pandas.testing import assert_frame_equal # noqa: F401
import fink_science.agn.kernel as k
import numpy as np
from numpy.linalg import LinAlgError
import pickle # noqa: F401
from scipy.optimize import curve_fit
import warnings
Expand Down Expand Up @@ -534,7 +535,7 @@ def parametric_bump(ps, band):
fit = curve_fit(mod.bump, ps[f"cjd_{band}"], ps[f"cflux_{band}"], sigma=ps[f"csigflux_{band}"],
p0=[0.225, -2.5, 0.038, get_min(ps[f"cflux_{band}"])], maxfev=k.MAXFEV)

except (RuntimeError, ValueError):
except (RuntimeError, ValueError, LinAlgError):
fit = [[0.225, -2.5, 0.038, -1]]

return fit[0]
Expand Down
15 changes: 9 additions & 6 deletions fink_science/slsn/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pickle # noqa: F401
import warnings
from scipy.optimize import curve_fit

import pandas as pd
import numpy as np
from numpy.linalg import LinAlgError

import fink_science.slsn.kernel as k
import fink_science.slsn.models as mod
import fink_science.agn.feature_extraction as fe_agn

from pandas.testing import assert_frame_equal # noqa: F401
import fink_science.slsn.kernel as k
import numpy as np
import pickle # noqa: F401
from scipy.optimize import curve_fit
import warnings


def transform_data(formated):
Expand Down Expand Up @@ -109,7 +112,7 @@ def parametric_func(ps, band):
try:
fit = curve_fit(mod.mvsr_right_transient, ps[f"cjd_{band}"], ps[f"cflux_{band}"], sigma=ps[f"csigflux_{band}"], p0=[-0.005, 0.015, 15], bounds=([-2, 0, -300], [0, 2, 300]), maxfev=k.MAXFEV)

except (RuntimeError, ValueError):
except (RuntimeError, ValueError, LinAlgError):
fit = [[0, 0, 0]]

return fit[0]
Expand Down
Loading