-
Notifications
You must be signed in to change notification settings - Fork 0
/
09_generate_training_data.py
93 lines (60 loc) · 2.7 KB
/
09_generate_training_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""
Python3 - UTF-8
Ekaterina Ilin
MIT License (2022)
Script to generate training data. Takes the time stamp of the planned
run as a first argument. The second argument is the number of light curves
to generate. The third argument is the path to the output file. The fourth
argument is either "train" or "validate" to indicate whether the data is
for training or validation.
"""
import numpy as np
import pandas as pd
from altaipony.flarelc import FlareLightCurve
from flares.flares import get_flares
from flares.__init__ import LOG_DATA_OVERVIEW_PATH
import sys
if __name__ == "__main__":
# ---------------- COMMAND LINE INPUT PARAMETERS ---------------------------
# timestamp for this dataset
tstamp = sys.argv[1]
# number of lcs in batch
n_lcs = int(sys.argv[2])
# table of flares to store the results in
outpath = sys.argv[3]
# either train or validate
typ = sys.argv[4]
# ---------------- COMMAND LINE INPUT PARAMETERS END -----------------------
# -------------------- LOG FILE INPUT PARAMETERS ---------------------------
# read log file with input parameters
df = pd.read_csv(LOG_DATA_OVERVIEW_PATH)
# pick the right row and make sure all identifiers fit!
# only n_lcs does not fit because we are dealing with batches here
row = df[(df.typ == typ) &
(df.tstamp == tstamp) &
(df.outpath == outpath)].iloc[0]
# ------------------ LOG FILE INPUT PARAMETERS END -------------------------
# --------------------- DERIVED INPUT PARAMETERS ---------------------------
# time series in rad
t = np.arange(0, 2 * np.pi, 2 * np.pi / row.size_lc)
# define flare light curve
flc = FlareLightCurve(time=t)
# error series kept constant to save computational time
# is correct per definition, even somewhat more correct
# than doable in practice
err = np.full_like(t, row.errval)
flc.detrended_flux_err = err
# the quiescent median is one
itmed = np.ones_like(t)
flc.it_med = itmed
# generate only one lc per iteration to make code less complicated
n_inclinations = 1
# ------------------- DERIVED INPUT PARAMETERS END -------------------------
# ---------------------- RUN LOOP WITH INPUTS ------------------------------
inputs = ((row.u_ld_0, row.u_ld_1), flc, row.emin, row.emax, row.errval,
row.spot_radius, n_inclinations,row.alphamin, row.alphamax,
row.betamin, row.betamax, row.n_spots_min, row.n_spots_max,
row.midlat, row.latwidth, row.decomposeed, outpath)
for i in range(n_lcs):
get_flares(*inputs)
# --------------------- RUN LOOP WITH INPUTS END ---------------------------