JSPEC
Documentation for JSPEC.
JSPEC.Angstrom2KeV
JSPEC.CreateDataSet
JSPEC.FindRebinSchema
JSPEC.GenFullObsData
JSPEC.GenRebin
JSPEC.GenResponseMatrix
JSPEC.GetKnownInstruments
JSPEC.IgnoreChannels
JSPEC.ImportData
JSPEC.ImportOtherData
JSPEC.JSPECFunc
JSPEC.Jy2PhFlux
JSPEC.KeV2Angstrom
JSPEC.KeV2Channel
JSPEC.PlotRaw
JSPEC.PlotRebinned
JSPEC.RebinAncillaryData
JSPEC.RebinData
JSPEC.Angstrom2KeV
— MethodAngstrom2KeV(wave)
Convert wavelengths in Angstrom ($10^{-8}~m$) to $keV$.
#Arguments
wave
the input wavelengths.
Examples
Angstrom2KeV(5000:5005)
# output
6-element Vector{Float64}:
0.00248
0.002479504099180164
0.0024790083966413435
0.0024785128922646415
0.0024780175859312552
0.0024775224775224775
JSPEC.CreateDataSet
— MethodCreateDataSet(Name::String, Instrument::String; verbose=true)::Dict
Create a JSPECDataSent entry.
#Arguments
Name
is the arbitrary name of the dataset.Instrument
is one of supperted instrument by the package.verbose
enables warning messages.
Examples
newdataset = CreateDataSet("XRTTest","Swift-XRT")
# output
Dict{Any, Any} with 3 entries:
"Name" => "XRTTest"
"Instrument" => "Swift-XRT"
"Created" => true
JSPEC.FindRebinSchema
— MethodFindRebinSchema(x,ey;minSN=5)::AbstractVector{Real}
Compute the rebin schema to guarantee that the S/N is at least minSN
in each bin (or channel).
Arguments
x
input array.ex
uncertainties.
Examples
x = [1.,2.,3.,4.,]
ex = [0.1,0.5,0.6,0.05]
JSPEC.FindRebinSchema(x,ex)
# output
3-element Vector{Real}:
1
3
4
JSPEC.GenFullObsData
— MethodGenFullObsData(datasets;verbose=true)
Gneerate input data basing on the available datasets.
Arguments
datasets
array of JSPEC dictionaries.verbose
enable warning message.
It reports three arrays: inputdata, error on inputdata, input energies.
Examples
GenFullObsData([dataset1, dataset2])
JSPEC.GenRebin
— MethodGenRebin(x,rebs)::AbstractVector{Real}
Rebin input data following a given rebin schema.
Arguments
x
input array.rebs
array with rebin schema.
Examples
x = [1.,2.,3.,4.,]
rbs = [1,3,4]
JSPEC.GenRebin(x,rbs)
# output
3-element Vector{Real}:
1.0
2.5
4.0
JSPEC.GenResponseMatrix
— MethodGenResponseMatrix(ds::Dict; verbose=true)
Generate a rebinned response matrix following the rebin schema identified for input data.
Arguments
ds
JSPEC data set dictionary.
Examples
GenResponseMatrix(newdataset)
JSPEC.GetKnownInstruments
— MethodGetKnownInstruments()
Returns the instruments currently supported by the JSPEC package.
Examples
@show GetKnownInstruments()
JSPEC.IgnoreChannels
— MethodIgnoreChannels(ds:Dict, chns; verbose=true)
Ignore channels in the input data.
Arguments
ds
JSPEC data set dictionary.chns
vector of channels to be ignored, e.g. [0,1,2,3] or even [0:4, 1000:1023]. Pay attention that channel numbering starts at 0.verbose
enables warning messages.
Examples
IgnoreChannels(newdataset,[0,1,2,3])
JSPEC.ImportData
— MethodImportData(ds::Dict; rmffile::String="", arffile::String="", srcfile::String="", bckfile::String="", verbose=true)
Import data from "multi-channel" instruments (e.g., Swift-XRT).
Arguments
ds
` JSPEC data set dictionary.rmfile
` RMF response matrix.arffile
effective area matrix.srcfile
source counts (or rate).bckfile
background counts (or rate).verbose
enables warning messages.
Examples
fnrmf = joinpath("data","wt.rmf")
fnarf = joinpath("data","wt.arf")
fnpisrc = joinpath("data","wtsource.pi")
fnpibck = joinpath("data","tback.pi");
ImportData(newdataset, rmffile=fnrmf,arffile=fnarf,srcfile=fnpisrc,bckfile=fnpibck)
JSPEC.ImportOtherData
— MethodImportOtherData(ds::Dict, energy, phflux, ephflux; bandwidth=1., verbose=true)
Import data already in physical units.
Arguments
ds
JSPEC dictionary.energy
input energy (KeV).phflux
photon flux density ($photons~cm{^-2}~s{^-1}~KeV{^-1})$.ephflux
photon flux density uncertainty.bandwidth
band width (KeV).verbose
enable warning message.
Bandwidth is needed only in case photon flux ($photons~cm{^-2}~s{^-1})$, rather then photon flux density, is provided.
Examples
ImportOtherData(newdataset, [1.,2.,3.,4], [0.1,0.2,0.3,0.4], [0.01,0.02,0.03,0.04])
JSPEC.JSPECFunc
— MethodJSPECFunc(pars,dts,inpfnc)
Convolve the output of the inpfnc
function with the responce matrices of the imported data.
Arguments
pars
parameters for theinpfnc
function.dts
array of JSPEC dictionaries.inpfnc
function to model the imported data.
inpfnc
can be any legal Julia
function. THe function should be declared as in the following example.
Examples
function Myfunc(pars,Energy)
N, λ = pars
return anyfunc(E,N,λ)
end
JSPECFunc([N,λ], [Optdt,XRTdt], Myfunc)
JSPEC.Jy2PhFlux
— MethodJy2PhFlux(energy,jyspectrum)
Convert an input sectrum in $Jy$ to $ph~s^{-1}~cm^{-2}~KeV^{-1}$.
Arguments
energy
input energy of the spectrum in $KeV$.jyspectrum
input spectrum in $Jy$.
Examples
```jldoctest
e = [1.,2.,3.,4.,] sp = [1e-3,3e-3,4e-3,5e-3]
Jy2PhFlux(e,sp)
output
4-element Vector{Float64}: 1.51 2.265 2.013333333333333 1.8875
JSPEC.KeV2Angstrom
— MethodKeV2Angstrom(energy)
Convert photon energy ($KeV$) to wavelengths in Angstrom ($10^{-8}~m$).
#Arguments
energy
the input photon energy.
Examples
KeV2Angstrom(1:3)
# output
0.08064516129032258:0.08064516129032258:0.24193548387096775
JSPEC.KeV2Channel
— MethodKeV2Channel(ds::Dict, energy)
Convert photon energy ($KeV$) to original detector channel.
#Arguments
ds
JSPEC dictionary.energy
the input photon energy.
It returns -1
if the energy is not in the covered range.
Examples
KeV2Channel(ds,1.2)
# output
11
JSPEC.PlotRaw
— MethodPlotRaw(ds:Dict; xlbl="Channels", ylbl="Counts", tlbl=ds.Name, verbose=true)::Figure
Draw a plot of the raw input data.
Arguments
ds
JSPEC data set dictionary.xlbl
x-axis label.ylbl
y-axis label.tlbl
plot title.verbose
enables warning messages.
Examples
figraw = PlotRaw(newdataset)
JSPEC.PlotRebinned
— MethodPlotRebinned(ds:Dict; xlbl="Channels", ylbl="Counts", tlbl=ds.Name, verbose=true)::Figure
Draw a plot of the rebinned input data.
Arguments
ds
JSPEC data set dictionary.xlbl
x-axis label.ylbl
y-axis label.tlbl
plot title.verbose
enables warning messages.
Examples
figreb = PlotRebinned(newdataset)
JSPEC.RebinAncillaryData
— MethodRebinAncillaryData(ds::Dict; verbose=true)
Rebin ancillary data (channels, channel energy, etc.) with the rebin schema identified for input data.
Arguments
ds
JSPEC data set disctionary.verbose
enables warning messages.
Examples
RebinAncilaryData(newdataset)
JSPEC.RebinData
— MethodRebinData(ds::Dict;minSN=5,verbose=true)
Rebin input data with a mininum S/N per bin.
Arguments
ds
JSPEC data set disctionary.minSN
minimum S/N per bin.verbose
enables warning messages.
Examples
RebinData(newdataset)