Commit db1a9ab4 authored by Giorgio Calderone's avatar Giorgio Calderone
Browse files

Updated

parents 6c819449 2d524f3a
Loading
Loading
Loading
Loading
+63 −65
Original line number Diff line number Diff line
@@ -11,9 +11,9 @@ uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[ArrayInterface]]
deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"]
git-tree-sha1 = "045ff5e1bc8c6fb1ecb28694abba0a0d55b5f4f5"
git-tree-sha1 = "a71d224f61475b93c9e196e83c17c6ac4dedacfa"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1.17"
version = "3.1.18"

[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
@@ -41,9 +41,9 @@ version = "0.3.3"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "ea05cadc30c15f9185b61ea418b9d47d53b55bc2"
git-tree-sha1 = "f53ca8d41e4753c41cdafa6ec5f7ce914b34be54"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.10.8"
version = "0.10.13"

[[CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
@@ -59,9 +59,9 @@ version = "0.7.0"

[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
git-tree-sha1 = "c8fd01e4b736013bc61b704871d20503b33ea402"
git-tree-sha1 = "ed268efe58512df8c7e224d2e170afd76dd6a417"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.12.1"
version = "3.13.0"

[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
@@ -115,9 +115,15 @@ uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2"
version = "0.7.2"

[[DataAPI]]
git-tree-sha1 = "dfb3b7e89e395be1e25c2ad6d7690dc29cc53b1d"
git-tree-sha1 = "ee400abb2298bd13bfc3df1c412ed228061a2385"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.6.0"
version = "1.7.0"

[[DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "a19645616f37a2c2c3077a44bc0d3e73e13441d7"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.2.1"

[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
@@ -174,9 +180,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[Distributions]]
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "62e1ac52e9adf4234285cd88c94954924aa3f9ef"
git-tree-sha1 = "3889f646423ce91dd1055a76317e9a1d3a23fff1"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.5"
version = "0.25.11"

[[DocStringExtensions]]
deps = ["LibGit2"]
@@ -185,25 +191,19 @@ uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.5"

[[DoubleFloats]]
deps = ["GenericLinearAlgebra", "GenericSchur", "LinearAlgebra", "Polynomials", "Printf", "Quadmath", "Random", "Requires", "SpecialFunctions"]
git-tree-sha1 = "cfc5657a37c2881a728d76bd14ad808ca096d601"
deps = ["GenericLinearAlgebra", "LinearAlgebra", "Polynomials", "Printf", "Quadmath", "Random", "Requires", "SpecialFunctions"]
git-tree-sha1 = "1c962cf7e75c09a5f1fbf504df7d6a06447a1129"
uuid = "497a8b3b-efae-58df-a0af-a86822472b78"
version = "1.1.22"
version = "1.1.23"

[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[ExprTools]]
git-tree-sha1 = "10407a39b87f29d47ebaca8edbc75d7c302ff93e"
git-tree-sha1 = "b7e3d17636b348f005f11040025ae8c6f645fe92"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.3"

[[EzXML]]
deps = ["Printf", "XML2_jll"]
git-tree-sha1 = "0fa3b52a04a4e210aeb1626def9c90df3ae65268"
uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
version = "1.1.0"
version = "0.1.6"

[[FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"]
@@ -213,9 +213,9 @@ version = "1.4.3"

[[FFTW_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "5a0d4b6a22a34d17d53543bd124f4b08ed78e8b0"
git-tree-sha1 = "3676abafff7e4ff07bbd2c42b3d8201f31653dcc"
uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
version = "3.3.9+7"
version = "3.3.9+8"

[[FITSIO]]
deps = ["CFITSIO", "Printf", "Reexport", "Tables"]
@@ -234,15 +234,15 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays"]
git-tree-sha1 = "31939159aeb8ffad1d4d8ee44d07f8558273120a"
git-tree-sha1 = "25b9cc23ba3303de0ad2eac03f840de9104c9253"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.11.7"
version = "0.12.0"

[[FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"]
git-tree-sha1 = "f6f80c8f934efd49a286bb5315360be66956dfc4"
git-tree-sha1 = "8b3c09b56acaf3c0e581c66638b85c8650ee9dca"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.8.0"
version = "2.8.1"

[[FixedPointNumbers]]
deps = ["Statistics"]
@@ -262,6 +262,10 @@ git-tree-sha1 = "e2af66012e08966366a43251e1fd421522908be6"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.18"

[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[GFit]]
deps = ["CMPFit", "DataStructures", "Dates", "Dierckx", "Distributions", "LsqFit", "MacroTools", "PrettyTables", "Printf", "ProgressMeter", "QuadGK", "Random", "Statistics"]
path = "/home/gcalderone/.julia/dev/GFit"
@@ -269,7 +273,7 @@ uuid = "ac42e6ba-c0bf-4fcf-827d-deea44b16255"
version = "0.1.0"

[[GFitViewer]]
deps = ["DataStructures", "DefaultApplication", "GFit", "JSON", "Pkg", "Statistics"]
deps = ["DataStructures", "DefaultApplication", "GFit", "Gnuplot", "JLD2", "JSON", "Pkg", "Statistics"]
path = "/home/gcalderone/.julia/dev/GFitViewer"
uuid = "5d93b50e-5cc7-4feb-a740-ec85257caa01"
version = "0.1.0"
@@ -280,15 +284,9 @@ git-tree-sha1 = "ff291c1827030ffaacaf53e3c83ed92d4d5e6fb6"
uuid = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
version = "0.2.5"

[[GenericSchur]]
deps = ["LinearAlgebra", "Printf"]
git-tree-sha1 = "372e48d7f3ced17fdc888a841bcce77be417ce57"
uuid = "c145ed77-6b09-5dd9-b285-bf645a82121e"
version = "0.5.0"

[[Gnuplot]]
deps = ["ColorSchemes", "ColorTypes", "Colors", "DataStructures", "REPL", "ReplMaker", "StatsBase", "StructC14N", "Test"]
git-tree-sha1 = "637ee67f78c4adb222ee11c590bd1d0a1a50ba88"
path = "/home/gcalderone/.julia/dev/Gnuplot"
uuid = "dc211083-a33a-5b79-959f-2ff34033469d"
version = "1.4.0"

@@ -313,6 +311,12 @@ git-tree-sha1 = "323a38ed1952d30586d0fe03412cde9399d3618b"
uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
version = "1.5.0"

[[InvertedIndices]]
deps = ["Test"]
git-tree-sha1 = "15732c475062348b0165684ffe28e85ea8396afc"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.0.0"

[[IterTools]]
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
@@ -325,9 +329,9 @@ version = "1.0.0"

[[JLD2]]
deps = ["DataStructures", "FileIO", "MacroTools", "Mmap", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "a605ca7aac73ccbba3208c49ca4d5eb78c8f4c74"
git-tree-sha1 = "4813826871754cf52607e76ad37acb36ccf52719"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.10"
version = "0.4.11"

[[JLLWrappers]]
deps = ["Preferences"]
@@ -370,21 +374,15 @@ uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.16.1+1"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[LogExpFunctions]]
deps = ["DocStringExtensions", "LinearAlgebra"]
git-tree-sha1 = "1ba664552f1ef15325e68dc4c05c3ef8c2d5d885"
git-tree-sha1 = "7bd5f6565d80b6bf753738d2bc40a5dfea072070"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.2.4"
version = "0.2.5"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
@@ -499,9 +497,15 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Polynomials]]
deps = ["Intervals", "LinearAlgebra", "MutableArithmetics", "RecipesBase"]
git-tree-sha1 = "3685cb1e2ccbbb9973684774f956f5c6e4673bc9"
git-tree-sha1 = "0bbfdcd8cda81b8144de4be8a67f5717e959a005"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "2.0.12"
version = "2.0.14"

[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "cde4ce9d6f33219465b55162811d8de8139c0414"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.2.1"

[[Preferences]]
deps = ["TOML"]
@@ -526,7 +530,7 @@ uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.7.1"

[[QSFit]]
deps = ["CMPFit", "Cosmology", "DSP", "DataStructures", "Dates", "DelimitedFiles", "Dierckx", "FITSIO", "GFit", "GFitViewer", "Pkg", "Printf", "Statistics", "Unitful", "UnitfulAstro"]
deps = ["CMPFit", "Cosmology", "DSP", "DataFrames", "DataStructures", "Dates", "DelimitedFiles", "Dierckx", "FITSIO", "GFit", "GFitViewer", "Gnuplot", "Pkg", "Printf", "REPL", "Statistics", "TextParse", "Unitful", "UnitfulAstro"]
path = "/home/gcalderone/.julia/dev/QSFit"
uuid = "fea25315-b951-4667-83c9-50e53efab241"
version = "0.1.0"
@@ -606,9 +610,9 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures"]
git-tree-sha1 = "2ec1962eba973f383239da22e75218565c390a96"
git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.0.0"
version = "1.0.1"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
@@ -622,15 +626,15 @@ version = "1.5.1"

[[Static]]
deps = ["IfElse"]
git-tree-sha1 = "2740ea27b66a41f9d213561a04573da5d3823d4b"
git-tree-sha1 = "62701892d172a2fa41a1f829f66d2b0db94a9a63"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.2.5"
version = "0.3.0"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "745914ebcd610da69f3cb6bf76cb7bb83dcb8c9a"
git-tree-sha1 = "1b9a0f17ee0adde9e538227de093467348992397"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.4"
version = "1.2.7"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
@@ -694,10 +698,10 @@ uuid = "e0df1984-e451-5cb5-8b61-797a481e67e3"
version = "1.0.1"

[[TimeZones]]
deps = ["Dates", "EzXML", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "960099aed321e05ac649c90d583d59c9309faee1"
deps = ["Dates", "Future", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "81753f400872e5074768c9a77d4c44e70d409ef0"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.5.5"
version = "1.5.6"

[[TranscodingStreams]]
deps = ["Random", "Test"]
@@ -714,9 +718,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[Unitful]]
deps = ["ConstructionBase", "Dates", "LinearAlgebra", "Random"]
git-tree-sha1 = "b3682a0559219355f1e3c8024e9f97adce2d4623"
git-tree-sha1 = "a981a8ef8714cba2fd9780b22fd7a469e7aaf56d"
uuid = "1986cc42-f94f-5a68-af5c-568840ba703d"
version = "1.8.0"
version = "1.9.0"

[[UnitfulAngles]]
deps = ["Dates", "Unitful"]
@@ -736,12 +740,6 @@ git-tree-sha1 = "28807f85197eaad3cbd2330386fac1dcb9e7e11d"
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
version = "0.6.2"

[[XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "1acf5bdf07aa0907e0a37d3718bb88d4b687b74a"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.9.12+0"

[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
+58 −54
Original line number Diff line number Diff line
@@ -4,13 +4,15 @@ Pkg.activate(".")
Z = 0.019422
EBV = 0.077

using Revise, Statistics, Serialization, Dierckx, DataFrames
using Revise, Statistics, Dierckx, DataFrames
using QSFit, GFit, Gnuplot, GFitViewer, MyAstroUtils
using CL_1ES_1927p654
using Dates
using TextParse
import StatsBase, JLD2

mkdir("output")
path = "output-" * readlines(`git branch --show-current`)[1]
mkdir("$(path)")
epoch_filenames = Vector{String}()
for (root, dirs, files) in walkdir("AT2018zf")
    for file in files
@@ -30,8 +32,8 @@ function read_spec(epoch_id; kw...)
	spec = Spectrum(Val(:ASCII), file, columns=[1,2]; label="$epoch_id: $file", kw...);
    if isa(epoch_id, Number)
        spec.flux ./= all_scale[epoch_id]
        spec.err  ./= all_scale[epoch_id]
    end
    spec.err .= 0.05 .* median(spec.flux);
    return spec
end

@@ -46,17 +48,17 @@ I tried 180, 200 and 250, and the [OIII] luminosity do not change
=#
spec = read_spec("B03", resolution=200.)
add_spec!(source, spec);
res = fit(source);
res = qsfit(source);
viewer(res, showcomps=[:qso_cont, :galaxy, :balmer],
       filename="output/results_boller.html")
println(res.bestfit[:OIII_5007].norm.val )
# 0.00029085925218136
println(res.bestfit[:OIII_5007].norm.val / res.bestfit[:galaxy].norm.val )
# 59.406476855719376
       filename="$(path)/results_boller.html")
println(res.model[:OIII_5007].norm.val )
# 0.0002913095378291511
println(res.model[:OIII_5007].norm.val / res.model[:galaxy].norm.val )
# 61.34678931179987



if !isfile("output/scale_fwhm.dat")
if !isfile("$(path)/scale_fwhm.dat")
    all_scale = fill(1., length(epoch_filenames))
    all_fwhm  = fill(NaN,length(epoch_filenames))
    for id in 1:length(epoch_filenames)
@@ -69,27 +71,27 @@ if !isfile("output/scale_fwhm.dat")
            # source.options[:host_template] = "/home/gcalderone/Mbi1.30Zm1.49T00.0700_iTp0.00_baseFe_linear_FWHM_2.51"
            spec = read_spec(id)
            add_spec!(source, spec);
            res = fit(source);
            res = qsfit(source);
            viewer(res, showcomps=[:qso_cont, :galaxy, :balmer],
                   filename="output/results_$(id).html")
                   filename="$(path)/results_$(id).html")

            # Update all_scale and store FWHM
            @info res.bestfit[:OIII_5007].norm.val
            all_scale[id] *= res.bestfit[:OIII_5007].norm.val
            all_fwhm[ id]  = res.bestfit[:OIII_5007].fwhm.val
            @info res.model[:OIII_5007].norm.val
            all_scale[id] *= res.model[:OIII_5007].norm.val
            all_fwhm[ id]  = res.model[:OIII_5007].fwhm.val
        catch
        end
    end
    all_scale[.!isfinite.(all_fwhm)] .= NaN
    serialize("output/scale_fwhm.dat", (all_scale, all_fwhm))
    JLD2.save_object("$(path)/scale_fwhm.dat", (all_scale, all_fwhm))
else
    (all_scale, all_fwhm) = deserialize("output/scale_fwhm.dat")
    (all_scale, all_fwhm) = JLD2.load_object("$(path)/scale_fwhm.dat")
end

@gp :prenorm "set key bottom right" "set grid" xlab="Epoch" ylab="Value" :-
@gp :- :prenorm all_scale./1e-18 "w lp t '[OIII] norm.'" :-
@gp :- :prenorm  all_fwhm./1000 "w lp t '[OIII] FWHM (x1000 km/s)"
save(:prenorm, term="png size 800,600", output="output/oiii_norm_fwhm.png")
save(:prenorm, term="png size 800,600", output="$(path)/oiii_norm_fwhm.png")

w = 10 .^(2:0.01:log10(400));
r = sqrt.(400^2 .- w.^2) ./ 2.355;
@@ -113,9 +115,9 @@ for id in 1:length(epoch_filenames)
    @gp :- :allepochs x./(1+Z) y "u 1:(\$2+$id):($id) w l notit lc pal" :-
end
@gp :- :allepochs yr=[1, 29]
save(:allepochs, term="png size 800,600", output="output/all_epochs.png")
save(:allepochs, term="png size 800,600", output="$(path)/all_epochs.png")
@gp :- :allepochs xr=[4900, 5100]
save(:allepochs, term="png size 800,2000", output="output/all_epochs_zoom.png")
save(:allepochs, term="png size 800,2000", output="$(path)/all_epochs_zoom.png")



@@ -129,64 +131,66 @@ dict_chosen_epochs = Dict(

# Can't use resolution smaller than 150 km / s otherwise some line
# will be neglected because of spectral coverage
resolution = Dict(
    :lowres  => 350.,
    :highres => 150.)
resolution = Dict()
#    :lowres  => 350.,
#    :highres => 150.)

job = :all
chosen_epochs = dict_chosen_epochs[job]
Nloop = 6
(all_scale, all_fwhm) = deserialize("output/scale_fwhm.dat")
(all_scale, all_fwhm) = JLD2.load_object("$(path)/scale_fwhm.dat")
for loop in 1:Nloop
    file = "output/results_$(job)_$(loop).dat"
    file = "$(path)/results_$(job)_$(loop).dat"
    if !isfile(file)
        source = QSO{q1927p654}("1ES 1927+654", Z, ebv=EBV);
        source.options[:min_spectral_coverage][:OIII_5007] = 0.5
        source.options[:wavelength_range] = [3500, 6900]
        @gp :zoom "set grid" :-
        for id in chosen_epochs
            spec = read_spec(id, resolution=get(resolution, job, NaN))
            add_spec!(source, spec);
            @gp :- :zoom xr=[4750,5150] spec.λ ./ (1 + source.z) spec.flux "w l t '$(id)'"
        end
        res = multi_fit(source);
        viewer(res, showcomps=[:qso_cont, :galaxy, :balmer],
               filename="output/results_$(job)_$(loop).html")
        viewer(res, showcomps=[:qso_cont, :galaxy, :balmer],
               filename="output/results_$(job)_$(loop)_rebin4.html", rebin=4)
        res = qsfit_multi(source);
        JLD2.jldsave(file; res)
        viewer(res, showcomps=[:qso_cont, :galaxy, :balmer], filename="$(path)/results_$(job)_$(loop).html")
        viewer(res, showcomps=[:qso_cont, :galaxy, :balmer], filename="$(path)/results_$(job)_$(loop)_rebin4.html", rebin=4)

        # Find best normalization for [OIII]
        model2 = deepcopy(res.model);
        multi2 = deepcopy(res.multi);
        for id in 1:length(chosen_epochs)
            for cname in collect(keys(model2[id]))
            for cname in collect(keys(multi2[id]))
                if cname == :OIII_5007
                    model2[id][cname].norm.fixed = false
                    multi2[id][cname].norm.fixed = false
                    multi2[id][cname].fwhm.fixed = true  # degenerate with norm
                else
                    freeze(model2[id], cname)
                    freeze(multi2[id], cname)
                end
            end
        end
        mzer = GFit.cmpfit()
        mzer.config.ftol = mzer.config.gtol = mzer.config.xtol = 1.e-6
        bestfit2 = fit!(model2, source.data, minimizer=mzer);
        bestfit2 = fit!(res.source, multi2, res.pspecs)
        
        OIII_norm = fill(0., length(chosen_epochs))
        for id in 1:length(chosen_epochs)
            OIII_norm[id] = bestfit2[id][:OIII_5007].norm.val
            all_scale[chosen_epochs[id]] *= bestfit2[id][:OIII_5007].norm.val
            OIII_norm[id] = multi2[id][:OIII_5007].norm.val
            all_scale[chosen_epochs[id]] *= ((1 + multi2[id][:OIII_5007].norm.val) / 2)
        end
        serialize(file, (res, all_scale, OIII_norm))
        JLD2.jldsave(file; res, all_scale, OIII_norm)
    else
        (res, all_scale, OIII_norm) = deserialize(file);
        # res       = JLD2.load(file, "res")
        # all_scale = JLD2.load(file, "all_scale")
        # OIII_norm = JLD2.load(file, "OIII_norm")
        res, all_scale, OIII_norm = values(JLD2.load(file));
    end
end


OIII_norm_evol = fill(NaN, length(chosen_epochs))
for loop in 1:Nloop
    file = "output/results_$(job)_$(loop).dat"
    (res, all_scale, OIII_norm) = deserialize(file);
    file = "$(path)/results_$(job)_$(loop).dat"
    res, all_scale, OIII_norm = values(JLD2.load(file))
    OIII_norm_evol = hcat(OIII_norm_evol, OIII_norm)
    println(res.bestfit.cost / res.bestfit.dof)
    println(res.fitres.fitstat / res.fitres.dof)
end
OIII_norm_evol = OIII_norm_evol[:,2:end]
@gp "set grid" :-
@@ -231,7 +235,7 @@ tab = DataFrame(epoch=Int[], date=String[], instr=String[], galaxy=Float64[],
                na_Hb_norm=Float64[], na_Hb_fwhm=Float64[], na_Hb_voff=Float64[],
                oiii_fwhm=Float64[],  oiii_voff=Float64[])

for id in 1:length(res.bestfit.preds)
for id in 1:length(res.bestfit.models)
    push!(tab,
          (id, epoch_filenames[chosen_epochs[id]][27:end-4], "",
           res.bestfit[id][:galaxy].norm.val,
@@ -247,8 +251,8 @@ for id in 1:length(res.bestfit.preds)
           res.bestfit[id][:OIII_5007].fwhm.patched, res.bestfit[id][:OIII_5007].voff.patched))
end

tab[!, :l3500] .= [3500 .* Spline1D(domain(res.model[id])[:], res.model[id]())(3500.) for id in 1:length(chosen_epochs)]
tab[!, :l5100] .= [5100 .* Spline1D(domain(res.model[id])[:], res.model[id]())(5100.) for id in 1:length(chosen_epochs)]
tab[!, :l3500] .= [3500 .* Spline1D(domain(res.multi[id])[:], res.multi[id]())(3500.) for id in 1:length(chosen_epochs)]
tab[!, :l5100] .= [5100 .* Spline1D(domain(res.multi[id])[:], res.multi[id]())(5100.) for id in 1:length(chosen_epochs)]
tab[!, :Ha] .= tab.br_Ha_norm .+ tab.bb_Ha_norm .+ tab.na_Ha_norm
tab[!, :Hb] .= tab.br_Hb_norm .+ tab.bb_Hb_norm .+ tab.na_Hb_norm

@@ -267,7 +271,7 @@ for i in 1:nrow(tab)
    tab[i, :instr] = tmp[j, :Inst]
end

f = FITS("1ES_1927p654_results_$(job).fits", "w")
f = FITS("$(path)/1ES_1927p654_results_$(job).fits", "w")
write(f, tab)
close(f)

@@ -278,7 +282,7 @@ for i in 1:nrow(tab)
    isnothing(j)  &&  continue
    tab[i, :pt] = j
end
cm = countmap(tab.instr)
cm = StatsBase.countmap(tab.instr)
setindex!.(Ref(cm), 1:length(cm), collect(keys(cm))[sortperm(collect(values(cm)), rev=true)])
tab.pt .= getindex.(Ref(cm), tab.instr)

@@ -309,16 +313,16 @@ for i in 1:nrow(tab)
    ss = "w l t '$(tab[i, :date])' dt $(tab[i, :pt]) lw 2"
    @gp :- domain(res.model[i])[:] res.model[i](:qso_cont) ss
end
save(:prenorm, term="png size 800,600", output="output/evolution.png")
save(:prenorm, term="png size 800,600", output="$(path)/evolution.png")


@gp "set grid"
for i in 1:length(chosen_epochs)
    println(res.bestfit[i][:OIII_5007])
    x  = domain(res.model[i])[:]
    y  = res.model[i]()
    y0 = y .- res.model[i](:OIII_5007)
    x  = domain(res.multi[i])[:]
    y  = res.multi[i]()
    y0 = y .- res.multi[i](:OIII_5007)
    ss = "w l t '$(tab[i, :date])' dt $(tab[i, :pt]) lw 2"
    @gp :- x y  .- Spline1D(x, y0)(5007.) ss
end
save(:prenorm, term="png size 800,600", output="output/evolution_oiii_norm.png")
save(:prenorm, term="png size 800,600", output="$(path)/evolution_oiii_norm.png")
+224 −52

File changed.

Preview size limit exceeded, changes collapsed.

+211 −193

File changed.

Preview size limit exceeded, changes collapsed.

+259 −263

File changed.

Preview size limit exceeded, changes collapsed.