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

Start improving light curve scripts #42

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
18 changes: 15 additions & 3 deletions artistools/lightcurve/lightcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -236,9 +241,16 @@ 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))
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

Expand Down