From edbd33ad5c0f603c33cb94d06c450c1a0cbd8375 Mon Sep 17 00:00:00 2001 From: Christine Date: Fri, 23 Dec 2022 13:20:34 +0100 Subject: [PATCH 1/2] Fix if statement to always give a value for each light curve time. --- artistools/lightcurve/lightcurve.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artistools/lightcurve/lightcurve.py b/artistools/lightcurve/lightcurve.py index 41262a718..2004839fc 100644 --- a/artistools/lightcurve/lightcurve.py +++ b/artistools/lightcurve/lightcurve.py @@ -236,8 +236,8 @@ def generate_band_lightcurve_data( phot_filtobs_sn = evaluate_magnitudes(flux, transmission, wavelength_from_spectrum, zeropointenergyflux) # print(time, phot_filtobs_sn) - # if phot_filtobs_sn != 0.0: - phot_filtobs_sn = phot_filtobs_sn - 25 # Absolute magnitude + if phot_filtobs_sn != 0.0: + phot_filtobs_sn = phot_filtobs_sn - 25 # Absolute magnitude filters_dict[filter_name].append((time, phot_filtobs_sn)) return filters_dict From 2cc4fa486c1881054a045f7ed482cd3319cb501a Mon Sep 17 00:00:00 2001 From: Christine Date: Fri, 23 Dec 2022 13:48:53 +0100 Subject: [PATCH 2/2] Make a dataframe of light curve data --- artistools/lightcurve/lightcurve.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/artistools/lightcurve/lightcurve.py b/artistools/lightcurve/lightcurve.py index 2004839fc..951ce1fd4 100644 --- a/artistools/lightcurve/lightcurve.py +++ b/artistools/lightcurve/lightcurve.py @@ -170,6 +170,10 @@ def generate_band_lightcurve_data( timearray = specdata.columns.values[1:] filters_dict = {} + lightcurvedata = {} + lightcurvedata["time"] = [ + float(time) for time in timearray if (float(time) > args.timemin and float(time) < args.timemax) + ] if not args.filter: args.filter = ["B"] @@ -190,6 +194,7 @@ def generate_band_lightcurve_data( times, bol_magnitudes = bolometric_magnitude( modelpath, timearray, args, angle=angle, res_specdata=res_specdata ) + lightcurvedata["bol"] = bol_magnitudes filters_dict["bol"] = [ (time, bol_magnitude) for time, bol_magnitude in zip(times, bol_magnitudes) @@ -206,7 +211,7 @@ def generate_band_lightcurve_data( zeropointenergyflux, wavefilter, transmission, wavefilter_min, wavefilter_max = get_filter_data( filterdir, filter_name ) - + lightcurve = [] for timestep, time in enumerate(timearray): time = float(time) if args.timemin < time < args.timemax: @@ -239,6 +244,13 @@ def generate_band_lightcurve_data( if phot_filtobs_sn != 0.0: phot_filtobs_sn = phot_filtobs_sn - 25 # Absolute magnitude filters_dict[filter_name].append((time, phot_filtobs_sn)) + lightcurve.append(phot_filtobs_sn) + lightcurvedata[filter_name] = lightcurve + + df_lightcurvedata = pd.DataFrame.from_dict(lightcurvedata) + if args.write_data: + modelname = at.get_model_name(modelpath) + df_lightcurvedata.to_csv(f"bandlightcurves_{modelname}.txt", sep=" ", index=False, header=True) return filters_dict