-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.jl
More file actions
70 lines (57 loc) · 2.55 KB
/
Copy pathinterface.jl
File metadata and controls
70 lines (57 loc) · 2.55 KB
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
using CSV
using DataFrames
using Plots
using Printf
include("lightCurve.jl")
include("fourierFit.jl")
include("ocJulia.jl")
# gaston()
gr()
loc = Base.@__DIR__
source = DataFrame(CSV.File(joinpath(loc, "testFiles", "RRcOddList.csv")))
plotsDir = joinpath(loc, "Plots")
outputDataDir = joinpath(loc, "output")
for x in 1:size(source, 1)
name = source[x, "ID"]
df = DataFrame(CSV.File(joinpath(loc, "testFiles",name*".dat")))
time = df.HJD
signal = df.MAG
period = source[x, "PeriodOGLE"]
periodString = @sprintf("%.4f",period)
maskForTemplate = source[x, "TemplateStart"] .< time .< source[x, "TemplateEnd"]
lc = LightCurve(time, signal, period, median(time[maskForTemplate]))
curveForTemplate = LightCurve(time[maskForTemplate], signal[maskForTemplate], period, median(time[maskForTemplate]))
computePhase(curveForTemplate)
bins = createBins(lc, 30.) # using 30 days as default...
# saveDiagnoseHist(lc, bins, joinpath(plotsDir, name+"_histogram.png")) # In case you want to see some details related to the binning process
myFourier = fourierFit(curveForTemplate)
myOC = ocBase(lc, myFourier, bins)
allResults = runOC(myOC, 100) # At the moment the bootstrap does nothing
xInterp = allResults.representativeTimes[1]:1.:allResults.representativeTimes[end]
yInterp = @. allResults.interpolate(xInterp)
lcCorrection = @. allResults.interpolate(time)
correctedTime = @. time - lcCorrection
newCurve = LightCurve(correctedTime, signal, period)
computePhase(newCurve)
scatter(allResults.representativeTimes, allResults.computedOC, label = "O-C")
plot!(xInterp, yInterp, label = "Interpolation")
xlabel!("HJD-2,450,000")
ylabel!("O-C [d]")
title!(name*", P: "*periodString)
png(joinpath(plotsDir, name*"_oc.png"))
scatter(newCurve.phase.phase, newCurve.properties.signal)
xlabel!("Arbitrary Phase")
ylabel!("I-Mag")
yflip!()
title!(name*", P: "*periodString)
png(joinpath(plotsDir, name*"_corrected.png"))
exportOCasCSV(allResults, joinpath(outputDataDir, name*"_oc.dat"))
df[!, "HJD_New"] = correctedTime
CSV.write(joinpath(outputDataDir, name*"_new.dat"), df)
end
# add function to store values of corrected LC and O-C values
# gui()
# readline()
# O-C computation is working... TODO: make template creation automatic somehow. Implement bootstrap... make it depend on the number of points per bin?
# And then it should be done! for future: add lightCurve function to "join" LCs from different surveys.
# Not relevant right now as I will use OGLE only...