Utils
JointConfig
- class vtspy.JointConfig(files=None, config_file='config.yaml', verbosity=1, **kwargs)
Bases:
objectThis is to generate the configuration file compatible to the Fermipy configuration. The input file is the VERITAS event file from EventDisplay. The format can be either `.root’ or `.fits’.
- Parameters
files (str) – a input file or directory containing root or fits files (root or fits)
config_file (str) – Fermi config filename (yaml) Default: config.yaml
verbosity (int) –
**kwargs – passed to JointConfig.init
- change_time_interval(tmin, tmax, scale='utc', instrument='all')
Change and update a time interval
Args: tmin (float or str): start time tmax (float or str): end time scale (str): “utc”, “mjd”, or “met”
Default: “utc”
- instrument (str): “fermi”, “veritas”, or “all”
Default: “all”
- static get_config(config_file='config.yaml')
Read a config file.
- Parameters
config_file (str) – Fermi config filename (yaml) Default: config.yaml
- init(files=None, config_file='config.yaml', **kwargs)
Generate a default configuration file :param files: a input file or directory containing :type files: str :param root or fits files: :type root or fits files: root or fits
- config_file (str): Fermi config filename (yaml)
Default: config.yaml fermi_outdir (str): path to the Fermi-LAT output directory Default: ./fermi/
- fermi_data (str): path to the Fermi-LAT data directory
Default: ./fermi/
- veritas_outdir (str): path to the VERITAS output directory
Default: ./veritas/ veritas_data (str): path to the VERITAS data directory Default: ./veritas/
- joint_outdir (str): path to the joint-fit output directory
Default: ./joint/
**kwargs
- classmethod print_config(config_file='config.yaml')
print a config file.
- Parameters
config_file (str) – Fermi config filename (yaml) Default: config.yaml
- static set_config(info, config_file='config.yaml')
Write inputs into a config file.
- Parameters
info (dict) – overwrite the input info into a config file
config_file (str) – Fermi config filename (yaml) Default: config.yaml
- classmethod update_config(info, instrument, config_file='config.yaml')
Update a config file.
- Parameters
info (dict) – update info in a config file
instrument (str) – either fermi or veritas
config_file (str) – Fermi config filename (yaml) Default: config.yaml
DownloadFermiData
Others
- vtspy.utils.CEL2GAL(ra, dec)
Convert CEL (celestial) coordinates to GAL (galactic) coordinates.
- Parameters
ra (float) – right ascension in degrees
dec (float) – declination in degrees
- Returns
deg, deg
- vtspy.utils.GAL2CEL(l, b)
Convert MJD (Modified Julian Day) to UTC.
- Parameters
mjd (astorpy.time) – MJD time
- Returns
UTC
- Return type
astropy.time
- vtspy.utils.LiMaSiginficance(N_on, N_off, alpha, type=1)
Calculate the Li&Ma significance
- Parameters
N_on (int) – the number of events from the ON region
N_off (int) – the number of events from the OFF region
alpha (float) – the relative exposure time
type (int) – method for calculating signficance 1: Li&MA, 2: chisq Default: 1
- Return
float: Li&Ma significance
- vtspy.utils.MET2UTC(met, return_astropy=False)
Convert Fermi MET (Mission Elapsed Time) to UTC (Coordinated Universal Time).
- Parameters
met (float) – MET time in seconds
return_astropy (bool) – return astropy.time
- Returns
UTC time
- Return type
str, astropy.time (optional)
- vtspy.utils.METnow()
Return the current MET.
- Returns
Fermi MET
- Return type
float
- vtspy.utils.MJD2UTC(mjd, return_astropy=False)
Convert MJD (Modified Julian Day) to UTC.
- Parameters
mjd (astorpy.time) – MJD time
return_astropy (bool) – return astropy.time
- Returns
UTC time
- Return type
str, astropy.time (optional)
- vtspy.utils.UTC2MET(utc)
Convert UTC to Fermi MET (mission elapsed time).
- Parameters
utc (astorpy.time) – UTC time
- Returns
MET
- Return type
float
- vtspy.utils.UTC2MJD(utc)
Convert UTC to MJD.
- Parameters
mjd (astorpy.time) – MJD time
- Returns
MJD
- Return type
float
- vtspy.utils.bright_source_list(source, save_npy=True)
- vtspy.utils.convertROOT2fits(files, eff, **kwargs)
- vtspy.utils.define_time_intervals(tmin, tmax, binsz=None, nbins=None)
Define time intervals by either a bin size or the number of bins
- Parameters
tmin (float) – minimum time
tmax (float) – maximum time
binsz (astropy.Quantity, optional) – bin size with astropy.units
nbins (int, optional) – the number of bins
- Returns
time interval (astropy.Time)
- Return type
list
- vtspy.utils.generatePHA(config)
- vtspy.utils.generatePSF(config)
- vtspy.utils.generateRSP(config)
- vtspy.utils.logger(verbosity=1)
Set a log level:
1: info, warning, error
2: debug, info, warning, error
0: warning, error
-1: error
- Parameters
verbosity (int) – Default: 1
- Returns
UTC time
- Return type
astorpy.time
- vtspy.utils.time_filter(obs, time, time_format=None)
Filter the observations by time
- Parameters
obs (gammapy.observations) – the list of observations
time (list) – the list of times
time_format (str, optional) – passed to astropy.Time