Skip to content
README.md 2.61 KiB
Newer Older
Giorgio Calderone's avatar
Giorgio Calderone committed
# CL_1ES_1927p654

Giorgio Calderone's avatar
Giorgio Calderone committed
## Pre-requisites

Giorgio Calderone's avatar
Giorgio Calderone committed
Install [Julia](https://julialang.org/downloads/) (version > 1.5), and prepare the `AT2018zf` directory with spectral data.
Giorgio Calderone's avatar
Giorgio Calderone committed


## Installation

```
git clone https://www.ict.inaf.it/gitlab/giorgio.calderone/cl_1es_1927p654
cd cl_1es_1927p654
```

Start Julia, then:
```julia
using Pkg
Pkg.activate(".")
Pkg.instantiate()
```

## Usage

### Load packages and read spectrum file names (one for each epoch):
```julia
using Pkg
Pkg.activate(".")
#Pkg.update() # ensure code is up to date

using Revise
using QSFit, Gnuplot, GFitViewer
using CL_1ES_1927p654

epochs = Vector{String}()
for (root, dirs, files) in walkdir("AT2018zf")
    for file in files
        if file[end-3:end] == ".dat"
            push!(epochs, root * "/" * file)
        end
    end
end
```


### Plot spectrum at all epochs
([gnuplot](http://www.gnuplot.info/) is required to display the plot)

```julia
@gp ylog=true xr=[3e3,1e4] yr=[1e-16, 1e-13] cbr=[1,26] :-
@gp :- cblabel="Epoch" xlab="Rest frame wavelength[A]" ylab="Flux density"
for ii in 1:length(epochs)
    file = epochs[ii]
    println(file)
    l = readlines(file)
    @gp :- l "u (\$1/1.017):2:($ii) w l notit lc pal"
    #(readline() == "q")  &&  break
end
```

### Run analysis on a specific epoch
```julia
chosen_epoch = 10
file = epochs[chosen_epoch]
source = QSO{q1927p654}("1ES 1927+654 ($chosen_epoch)", 0.019422, ebv=0.077);
add_spec!(source, Spectrum(Val(:ASCII), file, columns=[1,2]));
source.data[1].val .*= 1e17;
source.data[1].unc .= 0.05 .* source.data[1].val;
(model, bestfit) = fit(source);
Giorgio Calderone's avatar
Giorgio Calderone committed
viewer(model, source.data, bestfit, selcomps=[:qso_cont, :galaxy, :balmer])
Giorgio Calderone's avatar
Giorgio Calderone committed
```

### Multiepoch analysis
```julia
source = QSO{q1927p654}("1ES 1927+654", 0.019422, ebv=0.077);
add_spec!(source, Spectrum(Val(:ASCII), "AT2018zf/AT2018zf_optspec_20180811.dat", columns=[1,2]));
add_spec!(source, Spectrum(Val(:ASCII), "AT2018zf/AT2018zf_optspec_20180812.dat", columns=[1,2]));
for id in 1:length(source.domain)
    source.data[id].val .*= 1e17;
    source.data[id].unc .= 0.05 .* source.data[id].val;
end
(model, bestfit) = multiepoch_fit(source);
Giorgio Calderone's avatar
Giorgio Calderone committed
viewer(model, source.data, bestfit,
Giorgio Calderone's avatar
Giorgio Calderone committed
       selcomps=[Symbol.(:T1_, [:qso_cont, :galaxy, :balmer])
                 Symbol.(:T2_, [:qso_cont, :galaxy, :balmer])])
```
Giorgio Calderone's avatar
Giorgio Calderone committed


## Analysis recipes

The default QSFit analysis recipes are implemented here:
- [single epoch](https://github.com/gcalderone/QSFit.jl/blob/master/src/DefaultRecipe.jl)
- [multi epoch](https://github.com/gcalderone/QSFit.jl/blob/master/src/DefaultRecipe_multiepoch.jl)

This package implements a custom recipe named `q1927p654` whose code is available in `src/CL_1ES_1927p654.jl`.