API
Contents
- API
Supernovae Functions
Public Objects
Supernovae.main
— Methodmain(toml_path::AbstractString, verbose::Bool, profile::Bool)
Loads toml_path
, and sets up logging with verbosity based on verbose
. Runs run_Supernovae
and if profile
is true
, also profiles the code.
Arguments
toml_path::AbstractString
: Path to toml input file.verbose::Bool
: Set verbosity of logging
Supernovae.main
— Methodmain()
Read the args, prepare the input TOML and run the actual package functionality. Runs main(toml_path, verbose, profile)
.
Private Objects
Supernovae.get_args
— Methodget_args()
Helper function to get the ARGS passed to julia.
RunModule Functions
Public Objects
Supernovae.RunModule.run_Supernovae
— Methodrun_Supernovae(toml::Dict{String, Any})
Main entrance function for the package
Arguments
toml::Dict{String, Any}
: Input toml file containing all options for the package
Private Objects
FilterModule Functions
Public Objects
Supernovae.RunModule.FilterModule.Filter
— Typestruct Filter
Photometric filter transmission curve.
Fields
facility::String
: Name of the filter's facility (NewHorizons, Keper, Tess, etc...)instrument::String
: Name of the filter's instrument (Bessell, CTIO, Landolt, etc...)passband::String
: Name of the filter's passband (g, r, i, z, etc...)wavelength::Vector{Å}
: Transmission curve wavelengthtransmission::Vector{Float64}
: Transmission curve transmission
Supernovae.RunModule.FilterModule.Filter
— MethodFilter(facility::String, instrument::String, passband::String, filter_file::AbstractString)
Make Filter
object from filter_file
transmission curve.
Arguments
facility::String
: Name of the filter's facilityinstrument::String
: Name of the filter's instrumentpassband::String
: Name of the filter's passbandfilter_file::AbstractString
: Path to transmission curve file. Assumed to be a comma delimited wavelength,transmission file.
Supernovae.RunModule.FilterModule.Filter
— MethodFilter(facility::String, instrument::String, passband::String, config::Dict{String, Any})
Make Filter
object from config
options. config
must include "FILTERPATH" => path/to/transmissioncurve. If this file exists, the transmission curve will be loaded via Filter(facility::String, instrument::String, passband::String, filter_file::AbstractString)
, otherwise attempt to create Filter via Filter(facility::String, instrument::String, passband::String, svo::PyCall.PyObject)
and the SVO FPS database.
Arguments
facility::String
: Name of the filter's facilityinstrument::String
: Name of the filter's instrumentpassband::String
: Name of the filter's passbandconfig::Dict{String, Any}
: Options for creating a Filter.
Supernovae.RunModule.FilterModule.Filter
— MethodFilter(facility::String, instrument::String, passband::String, svo::PyCall.PyObject)
Make Filter
object from svo
transmission curve.
Arguments
facility::String
: Name of the filter's facilityinstrument::String
: Name of the filter's instrumentpassband::String
: Name of the filter's passbandsvo::Pycall.PyObject
: SVO transmission curve
Supernovae.RunModule.FilterModule.planck
— Methodplanck(T::Unitful.Unitful.Temperature, λ::Unitful.Length)
Planck's law: Calculates the specral radiance of a blackbody at temperature T, emitting at wavelength λ
Arguments
T::Unitful.Temperature
: Temperature of blackbodyλ::Unitful.Length
: Wavelength of blackbody
Supernovae.RunModule.FilterModule.synthetic_flux
— Methodsynthetic_flux(filter::Filter, T::Unitful.Temperature)
Calculates the flux of a blackbody at temperature T
, as observed with the filter
Arguments
filter::Filter
: TheFilter
through which the blackbody is observedT::Unitful.Temperature
: The temperature of the blackbody
Private Objects
Supernovae.RunModule.FilterModule.save_filter
— Methodsave_filter(filter::Filter, filter_dir::AbstractString)
Save filter
to directory filter_dir
.
Arguments
filter::Filter
: TheFilter
to save.filter_dir::AbstractString
: The directory to savefilter
to.
Supernovae.RunModule.FilterModule.svo
— Methodsvo(facility::String, instrument::String, passband::String)
Attempt to get filter transmission curve from SVO. Uses the python package astroquery
via PyCall.
Arguments
facility::String
: SVO name for the filter's facilityinstrument::String
: SVO name for the filter's instrumentpassband::String
: SVO name for the filter's passband
PhotometryModule Functions
Public Objects
Supernovae.RunModule.PhotometryModule.Lightcurve
— Typemutable struct Lightcurve
A lightcurve is simply a collection of observations
Fields
observations::Vector{Observation}
: AVector
ofObservation
representing a supernova lightcurve.
Supernovae.RunModule.PhotometryModule.Lightcurve
— MethodLightcurve(observations::Vector{Dict{String,Any}}, zeropoint::Magnitude, redshift::Float64, config::Dict{String,Any}; max_flux_err::Flux=Inf * 1.0u"μJy", peak_time::Union{Bool,Float64}=false)
Create a Lightcurve from a Vector of observations, modelled as a Vector of Dicts. Each observation must contains the keys NAME
, and PATH
which specify the name of the supernovae, and a path to the photometry respectively. PATH
can either be absolute, or relative to DATA_PATH
as specified in [ GLOBAL ]
and is expected to be a delimited file of rows and columns, with a header row describing the content of each column, and a row for each individual photometric observation of the lightcurve. Each observation in PATH
must contain a time, flux, and flux error column. You can also optionally pescribe a seperate facility, instrument, passband, and upperlimit column. If any of these column exist, they will be read per row. If not, you must specify a global value. The keys DELIMITER::String=", "
, and COMMENT::String="#"
allow you to specify the delimiter and comment characters used by PATH
.
The rest of the keys in an observation are for reading or overwriting the photometry in PATH
. You can overwrite the facility (FACILITY
::String), instrument (INSTRUMENT
::String), passband (PASSBAND
::String), and whether the photometry is an upperlimit (UPPERLIMIT
::Union{Bool, String}). Specifying any overwrites will apply that overwrite to every row of PATH
. You can also specify a flux offset (FLUX_OFFSET
) assumed to be of the same unit as the flux measurements in PATH
. By default, the upplimit column / overwrite is assumed to be a string: upperlimit∈["T", "TRUE", "F", "FALSE"]
, if you instead want a different string identifier, you can specify UPPERLIMIT_TRUE::Union{String, Vector{String}}
, and UPPERLIMIT_FALSE::Union{String, Vector{String}}
.
Each column of PATH
, including the required time (TIME
), flux (FLUX
), and flux error (FLUX_ERR
), and the optional facility (FACILITY
), instrument (INSTRUMENT
), passband (PASSBAND
), and upperlimit (UPPERLIMIT
) columns, can have both an identifier of the column, and the unit of the values be specified (units must be recognisable by Unitful
. There are three ways to do this. All of these methods are described by specifying identifiers through HEADER.OBJECT_NAME.COL
and either HEADER.OBJECT_NAME.UNIT
or HEADER.OBJECT_NAME.UNIT_COL
. For example to given an identifier for time, you'd include HEADER.TIME.COL
and HEADER.TIME.UNIT
.
The first method is to simply assume the headers have the syntax name [unit]
, with time, flux, and flux error having the names time
, flux
, and flux_err
respectively. This is the default when no identifiers are given, but can also be used for the unit identifier by specifying HEADER.OBJECT_NAME.UNIT = "DEFAULT"
.
The next method involves specifying the name of the column containing data of the object in question. This is simply HEADER.OBJECT_NAME.COL = "col_name"
. For the unit you can either specify a global unit for the object via HEADER.OBJECT_NAME.UNIT = "unit"
, or you can specify a unit column by name via HEADER.OBJECT_NAME.UNIT_COL = "unit_col_name"
.
The final method is to specify the index of the column containing data of the object in questions. This is done via HEADER.OBJECT_NAME.COL = col_index
. Once again you can either specify a global unit or the index of the column containing unit information via HEADER.OBJECT_NAME.UNIT_COL = unit_col_index
. Your choice of identifer can be different for each object and unit, for instance you could specify the name of the time column, and the index of the time unit column.
As for the rest of the inputs, it is required to specify a zeropoint (in some magnitude unit), the redshift, and provide a global config. You can specify a maximum error on the flux via max_flux_err
, which will treat every observation with a flux error greater than this as an outlier which will not be included. Finally you can specify a peak time which all other time parameters will be relative to (i.e, the peak time will be 0 and all other times become time - peaktime). This can either be true
, in which case the peak time will be set to the time of maximum flux, or a float with units equal to the units of the time column. If you don't want relative times, set `peaktimeto
false`, which is the default.
Arguments
observations::Vector{Dict{String,Any}}
: AVector
ofDicts
containing information and overwrites for the file containing photometry of the supernova.zeropoint::Magnitude
: The zeropoint of the supernovaredshift::Float64
: The redshift of the supernovaconfig::Dict{String,Any}
: The global config, containing information about pathsmax_flux_err::Flux=Inf * 1.0u"μJy"
: An optional constrain on the maximum flux error. Any observation with flux error greater than this is considered an outlier and removed from the lightcurve.peak_time::Union{Bool, Float64}=false
: If notfalse
, times will be relative topeak_time
(i.e, will transform fromtime
totime - peak_time
). Iftrue
times a relative to the time of peak flux, otherwise times are relative topeak_time
, which is assumed to be of the same unit as the times.
Supernovae.RunModule.PhotometryModule.Observation
— Typemutable struct Observation
A single observation of a supernova, including time, flux, magnitude and filter information.
Fields
name::String
: The name of the supernovatime::typeof(1.0u"d")
: The time of the observation in MJDflux::typeof(1.0u"Jy")
: The flux of the observation in Janskyflux_err::typeof(1.0u"Jy")
: The flux error of the observation in Janskymag::typeof(1.0u"AB_mag")
: The magnitude of the observations in AB Magnitudemag_err::typeof(1.0u"AB_mag")
: The magnitude error of the observations in AB Magnitudeabsmag::typeof(1.0u"AB_mag")
: The absolute magnitude of the observations in AB Magnitudeabsmag_err::typeof(1.0u"AB_mag")
: The absolute magnitude error of the observations in AB Magnitudefilter::Filter
: TheFilter
used to observe the supernovais_upperlimit::Bool
: Whether the observation is an upperlimit
Supernovae.RunModule.PhotometryModule.flux_to_mag
— Methodflux_to_mag(flux::Unitful.Quantity{Float64}, zeropoint::Level)
Convert flux
to magnitudes. Calculates zeropoint - 2.5log10(flux)
. Returns AB_mag
units
Arguments
flux::Unitful.Quantity{Float64}
: The flux to convert, in units compatible with Jansky. If the flux is negative it will be set to 0.0 to avoidlog10
errorszeropoint::Level
: The assumed zeropoint, used to convert the flux to magnitudes.
Supernovae.RunModule.PhotometryModule.mag_to_absmag
— Methodmag_to_absmag(mag::Level, redshift::Float64; H0::Unitful.Quantity{Float64}=70.0u"km/s/Mpc")
Converts mag
to absolute magnitude. Calculates mag - 5 log10(c * redshift / (H0 * 10pc))
Arguments
mag::Level
: The magnitude to convertredshift::Float64
: The redshift, used to calculate the distance to the object;H0::Unitful.Quantity{Float64}=70.0u"km/s/Mpc
: The assumed value of H0, used to calculate the distance to the object
Private Objects
Supernovae.RunModule.PhotometryModule.flux_err_to_mag_err
— Methodflux_err_to_mag_err(flux::Unitful.Quantity{Float64}, flux_err::Unitful.Quantity{Float64})
Converts flux_err
to magnitude error. Calculates (2.5 / log(10)) * (flux_err / flux)
.
Arguments
flux::Unitful.Quantity{Float64}
: The flux associated with the error to be convertedflux_err::Unitful.Quantity{Float64}
: The flux error to be converted
Supernovae.RunModule.PhotometryModule.get_column_id
— Methodget_column_id(::Vector{String}, column_id::Int64)
Convenience function which simply returns the column_id
passed in.
Arguments
column_id::Int64
: Return this column id
Supernovae.RunModule.PhotometryModule.get_column_id
— Methodget_column_id(header::Vector{String}, column_id::String)
Find the column in header
which contains the given column_id
and return its index.
Arguments
header::Vector{String}
: The header, split by columncolumn_id::String
: The column title to search for inheader
Supernovae.RunModule.PhotometryModule.get_column_index
— Methodget_column_index(header::Vector{String}, header_keys::Dict{String,Any})
Determine the index of each column withing header
associated with header_keys
Arguments
header::Vector{String}
: The header, split by column namesheader_keys::Dict{String, Any}
: Determine the index of these parameters. Thekey::String
is the type of object stored in the column, for instance"TIME"
,"FLUX"
,"MAG_ERR"
, and so on. Thevalues::Any
can be anInt64
or aString
where the former indicates the column index (which is simply returned) and the latter represents the name of thekey
object insideheader
. For instancekey = "FLUX"
might map to a column in theheader
title"Flux"
,"F"
,"emmission"
, or"uJy"
.
Supernovae.RunModule.PhotometryModule.get_default_unit
— Methodgetdefaultunit(header::Vector{String}, columnid::String, columnindex::Int64)
If no unit is provided for a parameter, it is assumed that the unit is listed in the header via "paramater_name[unit]"
. Under this system you might have "time[d]"
, "flux[μJy]"
, or "mag[AB_mag]"
.
Arguments
header::Vector{String}
: The header, split by columncolumn_id::String
: The name of the parameter in the column titlecolumn_index::Int64
: The index of the column inheader
Supernovae.RunModule.PhotometryModule.parse_file
— Methodparse_file(lines::Vector{String}; delimiter::String=", ", comment::String="#")
Parse a file, splitting on delimiter
and removing comment
s.
Arguments
lines::Vector{String}
: A vector containing each line of the file to parse;delimiter::String=", "
: Whatdelimiter
to split on;comment::String="#"
: What comments to remove. Will remove everything from this comment onwards, allowing for inline comments
SupernovaModule Functions
Public Objects
Supernovae.RunModule.SupernovaModule.Supernova
— Typemutable struct Supernova
A Supernova
Fields
name::String
: Supernova namezeropoint::typeof(1.0u"AB_mag")
: Zeropoint of the supernovaredshift::Float64
: Redshift of the supernovalightcurve::[
Lightcurve](@ref)
: The lightcurve of the supernova
Supernovae.RunModule.SupernovaModule.Supernova
— MethodSupernova(data::Dict{String,Any}, config::Dict{String,Any})
Load in a supernova from data
, which has a number of keys containing supernova data and options.
NAME::String
: Name of the supernovaZEROPOINT::Float64
: Supernova zeropointZEROPOINT_UNIT::String
: Unitful unit of zeropoint, default to AB_magREDSHIFT::Float64
: Supernova redshiftMAX_FLUX_ERR::Float64
: Maximum allowed flux error, default to infMAX_FLUX_ERR_UNIT::String
: Unitful unit of maximum flux errorPEAK_TIME::Union{Bool, Float64}
: If bool, whether to set time relative to peak flux, if Float64, set time relative to PEAK_TIMEOBSERVATIONS::Vector{Dict{String,Any}}
: Data to be turned into aLightcurve
Private Objects
PlotModule Objects
Public Objects
Supernovae.RunModule.PlotModule.plot_lightcurve!
— Methodplot_lightcurve!(fig::Figure, ax::Axis, supernova::Supernova, plot_config::Dict{String, Any})
Add lightcurve plot to axis. plot_config contains plotting options.
DATATYPE = ["flux", "magnitude", "absmagnitude"]: The type of data to plot UNITS::Dict: Units for time, and flux, magnitude, or abs_magnitude NAMES::Vector: List of SupernovaModule.Observation
.name's to include in the plot. If nothing
, all observations are included RENAME::Dict: Convert FilterModule.Filter
.passband to new name FILTERS::Vector: List of FilterModule.Filter
.passband's to include MARKERSIZE::Int: Size of the markers MARKER::Dict: Marker to use for each SupernovaModule.Observation
.name. If a passband is missing, a default marker is used COLOUR::Dict: Marker to use for each FilterModule.Filter
.passband. If a passband is missing, a default marker is used LEGEND::Bool: Whether to include a legend
Arguments
fig::Figure
: Figure to plot toax::Axis
: Axis to plot tosupernova::Supernova
: Supernova to plotplot_config::Dict{String, Any}
: Details of the plot
Supernovae.RunModule.PlotModule.plot_lightcurve
— Methodplot_lightcurve(supernova::Supernova, plot_config::Dict{String,Any}, config::Dict{String,Any})
Set up Figure and Axis, then plot lightcurve using plot_lightcurve!
Arguments
supernova::Supernova
: The supernova to plotplot_config::Dict{String, Any}
: Plot options passed to plot_lightcurve!config::Dict{String, Any}
: Global options including where to save the plot