JSpecAstro
Documentation for JSpecAstro.
JSpecAstro.Angstrom2KeVJSpecAstro.CreateDataSetJSpecAstro.FindRebinSchemaJSpecAstro.GenFullObsDataJSpecAstro.GenRebinJSpecAstro.GenResponseMatrixJSpecAstro.GetKnownInstrumentsJSpecAstro.IgnoreChannelsJSpecAstro.ImportDataJSpecAstro.ImportOtherDataJSpecAstro.JSpecAstroFuncJSpecAstro.Jy2PhFluxJSpecAstro.KeV2AngstromJSpecAstro.KeV2ChannelJSpecAstro.PlotRawJSpecAstro.PlotRebinnedJSpecAstro.RebinAncillaryDataJSpecAstro.RebinData
JSpecAstro.Angstrom2KeV — Method
Angstrom2KeV(wave)Convert wavelengths in Angstrom ($10^{-8}~m$) to $keV$.
#Arguments
wavethe input wavelengths.
Examples
Angstrom2KeV(5000:5005)
# output
6-element Vector{Float64}:
0.00248
0.002479504099180164
0.0024790083966413435
0.0024785128922646415
0.0024780175859312552
0.0024775224775224775JSpecAstro.CreateDataSet — Method
CreateDataSet(Name::String, Instrument::String; verbose=true)::DictCreate a JSpecAstro data set entry.
#Arguments
Nameis the arbitrary name of the dataset.Instrumentis one of supperted instrument by the package.verboseenables warning messages.
Examples
newdataset = CreateDataSet("XRTTest","Swift-XRT")
# output
Dict{Any, Any} with 3 entries:
"Name" => "XRTTest"
"Instrument" => "Swift-XRT"
"Created" => trueJSpecAstro.FindRebinSchema — Method
FindRebinSchema(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
xinput array.exuncertainties.
Examples
x = [1.,2.,3.,4.,]
ex = [0.1,0.5,0.6,0.05]
JSpecAstro.FindRebinSchema(x,ex)
# output
3-element Vector{Real}:
1
3
4
JSpecAstro.GenFullObsData — Method
GenFullObsData(datasets;verbose=true)Gneerate input data basing on the available datasets.
Arguments
datasetsarray of JSpecAstro dictionaries.verboseenable warning message.
It reports three arrays: inputdata, error on inputdata, input energies.
Examples
GenFullObsData([dataset1, dataset2])JSpecAstro.GenRebin — Method
GenRebin(x,rebs)::AbstractVector{Real}Rebin input data following a given rebin schema.
Arguments
xinput array.rebsarray with rebin schema.
Examples
x = [1.,2.,3.,4.,]
rbs = [1,3,4]
JSpecAstro.GenRebin(x,rbs)
# output
3-element Vector{Real}:
1.0
2.5
4.0JSpecAstro.GenResponseMatrix — Method
GenResponseMatrix(ds::Dict; verbose=true)Generate a rebinned response matrix following the rebin schema identified for input data.
Arguments
dsJSpecAstro data set dictionary.
Examples
GenResponseMatrix(newdataset)
JSpecAstro.GetKnownInstruments — Method
GetKnownInstruments()Returns the instruments currently supported by the JSpecAstro package.
Examples
@show GetKnownInstruments()JSpecAstro.IgnoreChannels — Method
IgnoreChannels(ds:Dict, chns; verbose=true)Ignore channels in the input data.
Arguments
dsJSpecAstro data set dictionary.chnsvector 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.verboseenables warning messages.
Examples
IgnoreChannels(newdataset,[0,1,2,3])JSpecAstro.ImportData — Method
ImportData(ds::Dict; rmffile::String="", arffile::String="", srcfile::String="", bckfile::String="", verbose=true)Import data from "multi-channel" instruments (e.g., Swift-XRT).
Arguments
ds` JSpecAstro data set dictionary.rmfile` RMF response matrix.arffileeffective area matrix.srcfilesource counts (or rate).bckfilebackground counts (or rate).verboseenables 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)JSpecAstro.ImportOtherData — Method
ImportOtherData(ds::Dict, energy, phflux, ephflux; bandwidth=1., verbose=true)Import data already in physical units.
Arguments
dsJSpecAstro dictionary.energyinput energy (KeV).phfluxphoton flux density ($photons~cm{^-2}~s{^-1}~KeV{^-1})$.ephfluxphoton flux density uncertainty.bandwidthband width (KeV).verboseenable 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])JSpecAstro.JSpecAstroFunc — Method
JSpecAstroFunc(pars,dts,inpfnc)
Convolve the output of the inpfnc function with the responce matrices of the imported data.
Arguments
parsparameters for theinpfncfunction.dtsarray of JSpecAstro dictionaries.inpfncfunction 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
JSpecAstroFunc([N,λ], [Optdt,XRTdt], Myfunc)JSpecAstro.Jy2PhFlux — Method
Jy2PhFlux(energy,jyspectrum)Convert an input sectrum in $Jy$ to $ph~s^{-1}~cm^{-2}~KeV^{-1}$.
Arguments
energyinput energy of the spectrum in $KeV$.jyspectruminput 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
JSpecAstro.KeV2Angstrom — Method
KeV2Angstrom(energy)Convert photon energy ($KeV$) to wavelengths in Angstrom ($10^{-8}~m$).
#Arguments
energythe input photon energy.
Examples
KeV2Angstrom(1:3)
# output
0.08064516129032258:0.08064516129032258:0.24193548387096775JSpecAstro.KeV2Channel — Method
KeV2Channel(ds::Dict, energy)Convert photon energy ($KeV$) to original detector channel.
#Arguments
dsJSpecAstro dictionary.energythe input photon energy.
It returns -1 if the energy is not in the covered range.
Examples
KeV2Channel(ds,1.2)
# output
11JSpecAstro.PlotRaw — Method
PlotRaw(ds:Dict; xlbl="Channels", ylbl="Counts", tlbl=ds.Name, verbose=true)::FigureDraw a plot of the raw input data.
Arguments
dsJSpecAstro data set dictionary.xlblx-axis label.ylbly-axis label.tlblplot title.verboseenables warning messages.
Examples
figraw = PlotRaw(newdataset)JSpecAstro.PlotRebinned — Method
PlotRebinned(ds:Dict; xlbl="Channels", ylbl="Counts", tlbl=ds.Name, verbose=true)::FigureDraw a plot of the rebinned input data.
Arguments
dsJSpecAstro data set dictionary.xlblx-axis label.ylbly-axis label.tlblplot title.verboseenables warning messages.
Examples
figreb = PlotRebinned(newdataset)JSpecAstro.RebinAncillaryData — Method
RebinAncillaryData(ds::Dict; verbose=true)Rebin ancillary data (channels, channel energy, etc.) with the rebin schema identified for input data.
Arguments
dsJSpecAstro data set disctionary.verboseenables warning messages.
Examples
RebinAncilaryData(newdataset)
JSpecAstro.RebinData — Method
RebinData(ds::Dict;minSN=5,verbose=true)Rebin input data with a mininum S/N per bin.
Arguments
dsJSpecAstro data set disctionary.minSNminimum S/N per bin.verboseenables warning messages.
Examples
RebinData(newdataset)