repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
fermiPy/fermipy
fermipy/tsmap.py
TSMapGenerator.tsmap
def tsmap(self, prefix='', **kwargs): """Generate a spatial TS map for a source component with properties defined by the `model` argument. The TS map will have the same geometry as the ROI. The output of this method is a dictionary containing `~fermipy.skymap.Map` objects with ...
python
def tsmap(self, prefix='', **kwargs): """Generate a spatial TS map for a source component with properties defined by the `model` argument. The TS map will have the same geometry as the ROI. The output of this method is a dictionary containing `~fermipy.skymap.Map` objects with ...
[ "def", "tsmap", "(", "self", ",", "prefix", "=", "''", ",", "*", "*", "kwargs", ")", ":", "timer", "=", "Timer", ".", "create", "(", "start", "=", "True", ")", "schema", "=", "ConfigSchema", "(", "self", ".", "defaults", "[", "'tsmap'", "]", ")", ...
Generate a spatial TS map for a source component with properties defined by the `model` argument. The TS map will have the same geometry as the ROI. The output of this method is a dictionary containing `~fermipy.skymap.Map` objects with the TS and amplitude of the best-fit test source....
[ "Generate", "a", "spatial", "TS", "map", "for", "a", "source", "component", "with", "properties", "defined", "by", "the", "model", "argument", ".", "The", "TS", "map", "will", "have", "the", "same", "geometry", "as", "the", "ROI", ".", "The", "output", "...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L650-L725
fermiPy/fermipy
fermipy/tsmap.py
TSMapGenerator._make_tsmap_fast
def _make_tsmap_fast(self, prefix, **kwargs): """ Make a TS map from a GTAnalysis instance. This is a simplified implementation optimized for speed that only fits for the source normalization (all background components are kept fixed). The spectral/spatial characteristics of the...
python
def _make_tsmap_fast(self, prefix, **kwargs): """ Make a TS map from a GTAnalysis instance. This is a simplified implementation optimized for speed that only fits for the source normalization (all background components are kept fixed). The spectral/spatial characteristics of the...
[ "def", "_make_tsmap_fast", "(", "self", ",", "prefix", ",", "*", "*", "kwargs", ")", ":", "loglevel", "=", "kwargs", ".", "get", "(", "'loglevel'", ",", "self", ".", "loglevel", ")", "src_dict", "=", "copy", ".", "deepcopy", "(", "kwargs", ".", "setdef...
Make a TS map from a GTAnalysis instance. This is a simplified implementation optimized for speed that only fits for the source normalization (all background components are kept fixed). The spectral/spatial characteristics of the test source can be defined with the src_dict argument. B...
[ "Make", "a", "TS", "map", "from", "a", "GTAnalysis", "instance", ".", "This", "is", "a", "simplified", "implementation", "optimized", "for", "speed", "that", "only", "fits", "for", "the", "source", "normalization", "(", "all", "background", "components", "are"...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L751-L940
fermiPy/fermipy
fermipy/tsmap.py
TSCubeGenerator.tscube
def tscube(self, prefix='', **kwargs): """Generate a spatial TS map for a source component with properties defined by the `model` argument. This method uses the `gttscube` ST application for source fitting and will simultaneously fit the test source normalization as well as the...
python
def tscube(self, prefix='', **kwargs): """Generate a spatial TS map for a source component with properties defined by the `model` argument. This method uses the `gttscube` ST application for source fitting and will simultaneously fit the test source normalization as well as the...
[ "def", "tscube", "(", "self", ",", "prefix", "=", "''", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", ".", "info", "(", "'Generating TS cube'", ")", "schema", "=", "ConfigSchema", "(", "self", ".", "defaults", "[", "'tscube'", "]", ")", "...
Generate a spatial TS map for a source component with properties defined by the `model` argument. This method uses the `gttscube` ST application for source fitting and will simultaneously fit the test source normalization as well as the normalizations of any background components that a...
[ "Generate", "a", "spatial", "TS", "map", "for", "a", "source", "component", "with", "properties", "defined", "by", "the", "model", "argument", ".", "This", "method", "uses", "the", "gttscube", "ST", "application", "for", "source", "fitting", "and", "will", "...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L945-L1024
fermiPy/fermipy
fermipy/irfs.py
compute_ps_counts
def compute_ps_counts(ebins, exp, psf, bkg, fn, egy_dim=0, spatial_model='PointSource', spatial_size=1E-3): """Calculate the observed signal and background counts given models for the exposure, background intensity, PSF, and source flux. Parameters ---------- ebins : `~numpy.n...
python
def compute_ps_counts(ebins, exp, psf, bkg, fn, egy_dim=0, spatial_model='PointSource', spatial_size=1E-3): """Calculate the observed signal and background counts given models for the exposure, background intensity, PSF, and source flux. Parameters ---------- ebins : `~numpy.n...
[ "def", "compute_ps_counts", "(", "ebins", ",", "exp", ",", "psf", ",", "bkg", ",", "fn", ",", "egy_dim", "=", "0", ",", "spatial_model", "=", "'PointSource'", ",", "spatial_size", "=", "1E-3", ")", ":", "ewidth", "=", "utils", ".", "edge_to_width", "(", ...
Calculate the observed signal and background counts given models for the exposure, background intensity, PSF, and source flux. Parameters ---------- ebins : `~numpy.ndarray` Array of energy bin edges. exp : `~numpy.ndarray` Model for exposure. psf : `~fermipy.irfs.PSFModel` ...
[ "Calculate", "the", "observed", "signal", "and", "background", "counts", "given", "models", "for", "the", "exposure", "background", "intensity", "PSF", "and", "source", "flux", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L100-L157
fermiPy/fermipy
fermipy/irfs.py
compute_norm
def compute_norm(sig, bkg, ts_thresh, min_counts, sum_axes=None, bkg_fit=None, rebin_axes=None): """Solve for the normalization of the signal distribution at which the detection test statistic (twice delta-loglikelihood ratio) is >= ``ts_thresh`` AND the number of signal counts >= ``min_cou...
python
def compute_norm(sig, bkg, ts_thresh, min_counts, sum_axes=None, bkg_fit=None, rebin_axes=None): """Solve for the normalization of the signal distribution at which the detection test statistic (twice delta-loglikelihood ratio) is >= ``ts_thresh`` AND the number of signal counts >= ``min_cou...
[ "def", "compute_norm", "(", "sig", ",", "bkg", ",", "ts_thresh", ",", "min_counts", ",", "sum_axes", "=", "None", ",", "bkg_fit", "=", "None", ",", "rebin_axes", "=", "None", ")", ":", "if", "sum_axes", "is", "None", ":", "sum_axes", "=", "np", ".", ...
Solve for the normalization of the signal distribution at which the detection test statistic (twice delta-loglikelihood ratio) is >= ``ts_thresh`` AND the number of signal counts >= ``min_counts``. This function uses the Asimov method to calculate the median expected TS when the model for the background...
[ "Solve", "for", "the", "normalization", "of", "the", "signal", "distribution", "at", "which", "the", "detection", "test", "statistic", "(", "twice", "delta", "-", "loglikelihood", "ratio", ")", "is", ">", "=", "ts_thresh", "AND", "the", "number", "of", "sign...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L160-L242
fermiPy/fermipy
fermipy/irfs.py
create_psf
def create_psf(event_class, event_type, dtheta, egy, cth): """Create an array of PSF response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle. """ irf = create_...
python
def create_psf(event_class, event_type, dtheta, egy, cth): """Create an array of PSF response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle. """ irf = create_...
[ "def", "create_psf", "(", "event_class", ",", "event_type", ",", "dtheta", ",", "egy", ",", "cth", ")", ":", "irf", "=", "create_irf", "(", "event_class", ",", "event_type", ")", "theta", "=", "np", ".", "degrees", "(", "np", ".", "arccos", "(", "cth",...
Create an array of PSF response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle.
[ "Create", "an", "array", "of", "PSF", "response", "values", "versus", "energy", "and", "inclination", "angle", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L583-L604
fermiPy/fermipy
fermipy/irfs.py
create_edisp
def create_edisp(event_class, event_type, erec, egy, cth): """Create an array of energy response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle. """ irf = crea...
python
def create_edisp(event_class, event_type, erec, egy, cth): """Create an array of energy response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle. """ irf = crea...
[ "def", "create_edisp", "(", "event_class", ",", "event_type", ",", "erec", ",", "egy", ",", "cth", ")", ":", "irf", "=", "create_irf", "(", "event_class", ",", "event_type", ")", "theta", "=", "np", ".", "degrees", "(", "np", ".", "arccos", "(", "cth",...
Create an array of energy response values versus energy and inclination angle. Parameters ---------- egy : `~numpy.ndarray` Energy in MeV. cth : `~numpy.ndarray` Cosine of the incidence angle.
[ "Create", "an", "array", "of", "energy", "response", "values", "versus", "energy", "and", "inclination", "angle", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L607-L639
fermiPy/fermipy
fermipy/irfs.py
create_aeff
def create_aeff(event_class, event_type, egy, cth): """Create an array of effective areas versus energy and incidence angle. Binning in energy and incidence angle is controlled with the egy and cth input parameters. Parameters ---------- event_class : str Event class string (e.g. P8R2_...
python
def create_aeff(event_class, event_type, egy, cth): """Create an array of effective areas versus energy and incidence angle. Binning in energy and incidence angle is controlled with the egy and cth input parameters. Parameters ---------- event_class : str Event class string (e.g. P8R2_...
[ "def", "create_aeff", "(", "event_class", ",", "event_type", ",", "egy", ",", "cth", ")", ":", "irf", "=", "create_irf", "(", "event_class", ",", "event_type", ")", "irf", ".", "aeff", "(", ")", ".", "setPhiDependence", "(", "False", ")", "theta", "=", ...
Create an array of effective areas versus energy and incidence angle. Binning in energy and incidence angle is controlled with the egy and cth input parameters. Parameters ---------- event_class : str Event class string (e.g. P8R2_SOURCE_V6). event_type : list egy : array_like ...
[ "Create", "an", "array", "of", "effective", "areas", "versus", "energy", "and", "incidence", "angle", ".", "Binning", "in", "energy", "and", "incidence", "angle", "is", "controlled", "with", "the", "egy", "and", "cth", "input", "parameters", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L642-L673
fermiPy/fermipy
fermipy/irfs.py
calc_exp
def calc_exp(skydir, ltc, event_class, event_types, egy, cth_bins, npts=None): """Calculate the exposure on a 2D grid of energy and incidence angle. Parameters ---------- npts : int Number of points by which to sample the response in each incidence angle bin. If None t...
python
def calc_exp(skydir, ltc, event_class, event_types, egy, cth_bins, npts=None): """Calculate the exposure on a 2D grid of energy and incidence angle. Parameters ---------- npts : int Number of points by which to sample the response in each incidence angle bin. If None t...
[ "def", "calc_exp", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy", ",", "cth_bins", ",", "npts", "=", "None", ")", ":", "if", "npts", "is", "None", ":", "npts", "=", "int", "(", "np", ".", "ceil", "(", "np", ".", "m...
Calculate the exposure on a 2D grid of energy and incidence angle. Parameters ---------- npts : int Number of points by which to sample the response in each incidence angle bin. If None then npts will be automatically set such that incidence angle is sampled on intervals of < ...
[ "Calculate", "the", "exposure", "on", "a", "2D", "grid", "of", "energy", "and", "incidence", "angle", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L676-L707
fermiPy/fermipy
fermipy/irfs.py
create_avg_rsp
def create_avg_rsp(rsp_fn, skydir, ltc, event_class, event_types, x, egy, cth_bins, npts=None): """Calculate the weighted response function. """ if npts is None: npts = int(np.ceil(np.max(cth_bins[1:] - cth_bins[:-1]) / 0.05)) wrsp = np.zeros((len(x), len(egy), len(cth_bins) ...
python
def create_avg_rsp(rsp_fn, skydir, ltc, event_class, event_types, x, egy, cth_bins, npts=None): """Calculate the weighted response function. """ if npts is None: npts = int(np.ceil(np.max(cth_bins[1:] - cth_bins[:-1]) / 0.05)) wrsp = np.zeros((len(x), len(egy), len(cth_bins) ...
[ "def", "create_avg_rsp", "(", "rsp_fn", ",", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "x", ",", "egy", ",", "cth_bins", ",", "npts", "=", "None", ")", ":", "if", "npts", "is", "None", ":", "npts", "=", "int", "(", "np", "....
Calculate the weighted response function.
[ "Calculate", "the", "weighted", "response", "function", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L710-L737
fermiPy/fermipy
fermipy/irfs.py
create_avg_psf
def create_avg_psf(skydir, ltc, event_class, event_types, dtheta, egy, cth_bins, npts=None): """Generate model for exposure-weighted PSF averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` Energies in MeV. cth_bins : `~numpy.ndarray` B...
python
def create_avg_psf(skydir, ltc, event_class, event_types, dtheta, egy, cth_bins, npts=None): """Generate model for exposure-weighted PSF averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` Energies in MeV. cth_bins : `~numpy.ndarray` B...
[ "def", "create_avg_psf", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "dtheta", ",", "egy", ",", "cth_bins", ",", "npts", "=", "None", ")", ":", "return", "create_avg_rsp", "(", "create_psf", ",", "skydir", ",", "ltc", ",", "ev...
Generate model for exposure-weighted PSF averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` Energies in MeV. cth_bins : `~numpy.ndarray` Bin edges in cosine of the incidence angle.
[ "Generate", "model", "for", "exposure", "-", "weighted", "PSF", "averaged", "over", "incidence", "angle", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L740-L756
fermiPy/fermipy
fermipy/irfs.py
create_avg_edisp
def create_avg_edisp(skydir, ltc, event_class, event_types, erec, egy, cth_bins, npts=None): """Generate model for exposure-weighted DRM averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` True energies in MeV. cth_bins : `~numpy.ndarray` ...
python
def create_avg_edisp(skydir, ltc, event_class, event_types, erec, egy, cth_bins, npts=None): """Generate model for exposure-weighted DRM averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` True energies in MeV. cth_bins : `~numpy.ndarray` ...
[ "def", "create_avg_edisp", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "erec", ",", "egy", ",", "cth_bins", ",", "npts", "=", "None", ")", ":", "return", "create_avg_rsp", "(", "create_edisp", ",", "skydir", ",", "ltc", ",", "...
Generate model for exposure-weighted DRM averaged over incidence angle. Parameters ---------- egy : `~numpy.ndarray` True energies in MeV. cth_bins : `~numpy.ndarray` Bin edges in cosine of the incidence angle.
[ "Generate", "model", "for", "exposure", "-", "weighted", "DRM", "averaged", "over", "incidence", "angle", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L759-L774
fermiPy/fermipy
fermipy/irfs.py
create_wtd_psf
def create_wtd_psf(skydir, ltc, event_class, event_types, dtheta, egy_bins, cth_bins, fn, nbin=64, npts=1): """Create an exposure- and dispersion-weighted PSF model for a source with spectral parameterization ``fn``. The calculation performed by this method accounts for the influence of ...
python
def create_wtd_psf(skydir, ltc, event_class, event_types, dtheta, egy_bins, cth_bins, fn, nbin=64, npts=1): """Create an exposure- and dispersion-weighted PSF model for a source with spectral parameterization ``fn``. The calculation performed by this method accounts for the influence of ...
[ "def", "create_wtd_psf", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "dtheta", ",", "egy_bins", ",", "cth_bins", ",", "fn", ",", "nbin", "=", "64", ",", "npts", "=", "1", ")", ":", "#npts = int(np.ceil(32. / bins_per_dec(egy_bins)))...
Create an exposure- and dispersion-weighted PSF model for a source with spectral parameterization ``fn``. The calculation performed by this method accounts for the influence of energy dispersion on the PSF. Parameters ---------- dtheta : `~numpy.ndarray` egy_bins : `~numpy.ndarray` ...
[ "Create", "an", "exposure", "-", "and", "dispersion", "-", "weighted", "PSF", "model", "for", "a", "source", "with", "spectral", "parameterization", "fn", ".", "The", "calculation", "performed", "by", "this", "method", "accounts", "for", "the", "influence", "o...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L777-L826
fermiPy/fermipy
fermipy/irfs.py
calc_drm
def calc_drm(skydir, ltc, event_class, event_types, egy_bins, cth_bins, nbin=64): """Calculate the detector response matrix.""" npts = int(np.ceil(128. / bins_per_dec(egy_bins))) egy_bins = np.exp(utils.split_bin_edges(np.log(egy_bins), npts)) etrue_bins = 10**np.linspace(1.0, 6.5, nbin * ...
python
def calc_drm(skydir, ltc, event_class, event_types, egy_bins, cth_bins, nbin=64): """Calculate the detector response matrix.""" npts = int(np.ceil(128. / bins_per_dec(egy_bins))) egy_bins = np.exp(utils.split_bin_edges(np.log(egy_bins), npts)) etrue_bins = 10**np.linspace(1.0, 6.5, nbin * ...
[ "def", "calc_drm", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy_bins", ",", "cth_bins", ",", "nbin", "=", "64", ")", ":", "npts", "=", "int", "(", "np", ".", "ceil", "(", "128.", "/", "bins_per_dec", "(", "egy_bins", "...
Calculate the detector response matrix.
[ "Calculate", "the", "detector", "response", "matrix", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L829-L843
fermiPy/fermipy
fermipy/irfs.py
calc_counts
def calc_counts(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, npts=1): """Calculate the expected counts vs. true energy and incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `...
python
def calc_counts(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, npts=1): """Calculate the expected counts vs. true energy and incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `...
[ "def", "calc_counts", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy_bins", ",", "cth_bins", ",", "fn", ",", "npts", "=", "1", ")", ":", "#npts = int(np.ceil(32. / bins_per_dec(egy_bins)))", "egy_bins", "=", "np", ".", "exp", "(",...
Calculate the expected counts vs. true energy and incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `~fermipy.irfs.LTCube` egy_bins : `~numpy.ndarray` Bin edges in observed energy in MeV. cth_bi...
[ "Calculate", "the", "expected", "counts", "vs", ".", "true", "energy", "and", "incidence", "angle", "for", "a", "source", "with", "spectral", "parameterization", "fn", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L846-L873
fermiPy/fermipy
fermipy/irfs.py
calc_counts_edisp
def calc_counts_edisp(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, nbin=16, npts=1): """Calculate the expected counts vs. observed energy and true incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coo...
python
def calc_counts_edisp(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, nbin=16, npts=1): """Calculate the expected counts vs. observed energy and true incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coo...
[ "def", "calc_counts_edisp", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy_bins", ",", "cth_bins", ",", "fn", ",", "nbin", "=", "16", ",", "npts", "=", "1", ")", ":", "#npts = int(np.ceil(32. / bins_per_dec(egy_bins)))", "# Split en...
Calculate the expected counts vs. observed energy and true incidence angle for a source with spectral parameterization ``fn``. Parameters ---------- skydir : `~astropy.coordinate.SkyCoord` ltc : `~fermipy.irfs.LTCube` egy_bins : `~numpy.ndarray` Bin edges in observed energy in MeV. ...
[ "Calculate", "the", "expected", "counts", "vs", ".", "observed", "energy", "and", "true", "incidence", "angle", "for", "a", "source", "with", "spectral", "parameterization", "fn", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L876-L912
fermiPy/fermipy
fermipy/irfs.py
calc_wtd_exp
def calc_wtd_exp(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, nbin=16): """Calculate the effective exposure. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` ltc : `~fermipy.irfs.LTCube` nbin : int Number of points per decade with w...
python
def calc_wtd_exp(skydir, ltc, event_class, event_types, egy_bins, cth_bins, fn, nbin=16): """Calculate the effective exposure. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` ltc : `~fermipy.irfs.LTCube` nbin : int Number of points per decade with w...
[ "def", "calc_wtd_exp", "(", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "egy_bins", ",", "cth_bins", ",", "fn", ",", "nbin", "=", "16", ")", ":", "cnts", "=", "calc_counts_edisp", "(", "skydir", ",", "ltc", ",", "event_class", ",",...
Calculate the effective exposure. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` ltc : `~fermipy.irfs.LTCube` nbin : int Number of points per decade with which to sample true energy.
[ "Calculate", "the", "effective", "exposure", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L915-L932
fermiPy/fermipy
fermipy/irfs.py
ExposureMap.create
def create(cls, ltc, event_class, event_types, ebins): """Create an exposure map from a livetime cube. This method will generate an exposure map with the same geometry as the livetime cube (nside, etc.). Parameters ---------- ltc : `~fermipy.irfs.LTCube` Liv...
python
def create(cls, ltc, event_class, event_types, ebins): """Create an exposure map from a livetime cube. This method will generate an exposure map with the same geometry as the livetime cube (nside, etc.). Parameters ---------- ltc : `~fermipy.irfs.LTCube` Liv...
[ "def", "create", "(", "cls", ",", "ltc", ",", "event_class", ",", "event_types", ",", "ebins", ")", ":", "evals", "=", "np", ".", "sqrt", "(", "ebins", "[", "1", ":", "]", "*", "ebins", "[", ":", "-", "1", "]", ")", "exp", "=", "np", ".", "ze...
Create an exposure map from a livetime cube. This method will generate an exposure map with the same geometry as the livetime cube (nside, etc.). Parameters ---------- ltc : `~fermipy.irfs.LTCube` Livetime cube object. event_class : str Event cl...
[ "Create", "an", "exposure", "map", "from", "a", "livetime", "cube", ".", "This", "method", "will", "generate", "an", "exposure", "map", "with", "the", "same", "geometry", "as", "the", "livetime", "cube", "(", "nside", "etc", ".", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L273-L303
fermiPy/fermipy
fermipy/irfs.py
PSFModel.eval
def eval(self, ebin, dtheta, scale_fn=None): """Evaluate the PSF at the given energy bin index. Parameters ---------- ebin : int Index of energy bin. dtheta : array_like Array of angular separations in degrees. scale_fn : callable ...
python
def eval(self, ebin, dtheta, scale_fn=None): """Evaluate the PSF at the given energy bin index. Parameters ---------- ebin : int Index of energy bin. dtheta : array_like Array of angular separations in degrees. scale_fn : callable ...
[ "def", "eval", "(", "self", ",", "ebin", ",", "dtheta", ",", "scale_fn", "=", "None", ")", ":", "if", "scale_fn", "is", "None", "and", "self", ".", "scale_fn", "is", "not", "None", ":", "scale_fn", "=", "self", ".", "scale_fn", "if", "scale_fn", "is"...
Evaluate the PSF at the given energy bin index. Parameters ---------- ebin : int Index of energy bin. dtheta : array_like Array of angular separations in degrees. scale_fn : callable Function that evaluates the PSF scaling function. ...
[ "Evaluate", "the", "PSF", "at", "the", "given", "energy", "bin", "index", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L359-L385
fermiPy/fermipy
fermipy/irfs.py
PSFModel.interp
def interp(self, energies, dtheta, scale_fn=None): """Evaluate the PSF model at an array of energies and angular separations. Parameters ---------- energies : array_like Array of energies in MeV. dtheta : array_like Array of angular separations i...
python
def interp(self, energies, dtheta, scale_fn=None): """Evaluate the PSF model at an array of energies and angular separations. Parameters ---------- energies : array_like Array of energies in MeV. dtheta : array_like Array of angular separations i...
[ "def", "interp", "(", "self", ",", "energies", ",", "dtheta", ",", "scale_fn", "=", "None", ")", ":", "if", "scale_fn", "is", "None", "and", "self", ".", "scale_fn", ":", "scale_fn", "=", "self", ".", "scale_fn", "log_energies", "=", "np", ".", "log10"...
Evaluate the PSF model at an array of energies and angular separations. Parameters ---------- energies : array_like Array of energies in MeV. dtheta : array_like Array of angular separations in degrees. scale_fn : callable Fu...
[ "Evaluate", "the", "PSF", "model", "at", "an", "array", "of", "energies", "and", "angular", "separations", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L387-L417
fermiPy/fermipy
fermipy/irfs.py
PSFModel.interp_bin
def interp_bin(self, egy_bins, dtheta, scale_fn=None): """Evaluate the bin-averaged PSF model over the energy bins ``egy_bins``. Parameters ---------- egy_bins : array_like Energy bin edges in MeV. dtheta : array_like Array of angular separations in degr...
python
def interp_bin(self, egy_bins, dtheta, scale_fn=None): """Evaluate the bin-averaged PSF model over the energy bins ``egy_bins``. Parameters ---------- egy_bins : array_like Energy bin edges in MeV. dtheta : array_like Array of angular separations in degr...
[ "def", "interp_bin", "(", "self", ",", "egy_bins", ",", "dtheta", ",", "scale_fn", "=", "None", ")", ":", "npts", "=", "4", "egy_bins", "=", "np", ".", "exp", "(", "utils", ".", "split_bin_edges", "(", "np", ".", "log", "(", "egy_bins", ")", ",", "...
Evaluate the bin-averaged PSF model over the energy bins ``egy_bins``. Parameters ---------- egy_bins : array_like Energy bin edges in MeV. dtheta : array_like Array of angular separations in degrees. scale_fn : callable Function tha...
[ "Evaluate", "the", "bin", "-", "averaged", "PSF", "model", "over", "the", "energy", "bins", "egy_bins", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L419-L448
fermiPy/fermipy
fermipy/irfs.py
PSFModel.containment_angle
def containment_angle(self, energies=None, fraction=0.68, scale_fn=None): """Evaluate the PSF containment angle at a sequence of energies.""" if energies is None: energies = self.energies vals = self.interp(energies[np.newaxis, :], self.dtheta[:, np.newaxis], ...
python
def containment_angle(self, energies=None, fraction=0.68, scale_fn=None): """Evaluate the PSF containment angle at a sequence of energies.""" if energies is None: energies = self.energies vals = self.interp(energies[np.newaxis, :], self.dtheta[:, np.newaxis], ...
[ "def", "containment_angle", "(", "self", ",", "energies", "=", "None", ",", "fraction", "=", "0.68", ",", "scale_fn", "=", "None", ")", ":", "if", "energies", "is", "None", ":", "energies", "=", "self", ".", "energies", "vals", "=", "self", ".", "inter...
Evaluate the PSF containment angle at a sequence of energies.
[ "Evaluate", "the", "PSF", "containment", "angle", "at", "a", "sequence", "of", "energies", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L450-L459
fermiPy/fermipy
fermipy/irfs.py
PSFModel.containment_angle_bin
def containment_angle_bin(self, egy_bins, fraction=0.68, scale_fn=None): """Evaluate the PSF containment angle averaged over energy bins.""" vals = self.interp_bin(egy_bins, self.dtheta, scale_fn=scale_fn) dtheta = np.radians(self.dtheta[:, np.newaxis] * np.ones(vals.shape)) return self...
python
def containment_angle_bin(self, egy_bins, fraction=0.68, scale_fn=None): """Evaluate the PSF containment angle averaged over energy bins.""" vals = self.interp_bin(egy_bins, self.dtheta, scale_fn=scale_fn) dtheta = np.radians(self.dtheta[:, np.newaxis] * np.ones(vals.shape)) return self...
[ "def", "containment_angle_bin", "(", "self", ",", "egy_bins", ",", "fraction", "=", "0.68", ",", "scale_fn", "=", "None", ")", ":", "vals", "=", "self", ".", "interp_bin", "(", "egy_bins", ",", "self", ".", "dtheta", ",", "scale_fn", "=", "scale_fn", ")"...
Evaluate the PSF containment angle averaged over energy bins.
[ "Evaluate", "the", "PSF", "containment", "angle", "averaged", "over", "energy", "bins", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L461-L466
fermiPy/fermipy
fermipy/irfs.py
PSFModel.create
def create(cls, skydir, ltc, event_class, event_types, energies, cth_bins=None, ndtheta=500, use_edisp=False, fn=None, nbin=64): """Create a PSFModel object. This class can be used to evaluate the exposure-weighted PSF for a source with a given observing profile and energy distri...
python
def create(cls, skydir, ltc, event_class, event_types, energies, cth_bins=None, ndtheta=500, use_edisp=False, fn=None, nbin=64): """Create a PSFModel object. This class can be used to evaluate the exposure-weighted PSF for a source with a given observing profile and energy distri...
[ "def", "create", "(", "cls", ",", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "energies", ",", "cth_bins", "=", "None", ",", "ndtheta", "=", "500", ",", "use_edisp", "=", "False", ",", "fn", "=", "None", ",", "nbin", "=", "64",...
Create a PSFModel object. This class can be used to evaluate the exposure-weighted PSF for a source with a given observing profile and energy distribution. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` ltc : `~fermipy.irfs.LTCube` energies : `...
[ "Create", "a", "PSFModel", "object", ".", "This", "class", "can", "be", "used", "to", "evaluate", "the", "exposure", "-", "weighted", "PSF", "for", "a", "source", "with", "a", "given", "observing", "profile", "and", "energy", "distribution", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L514-L570
fermiPy/fermipy
fermipy/jobs/sys_interface.py
remove_file
def remove_file(filepath, dry_run=False): """Remove the file at filepath Catches exception if the file does not exist. If dry_run is True, print name of file to be removed, but do not remove it. """ if dry_run: sys.stdout.write("rm %s\n" % filepath) else: try: os.re...
python
def remove_file(filepath, dry_run=False): """Remove the file at filepath Catches exception if the file does not exist. If dry_run is True, print name of file to be removed, but do not remove it. """ if dry_run: sys.stdout.write("rm %s\n" % filepath) else: try: os.re...
[ "def", "remove_file", "(", "filepath", ",", "dry_run", "=", "False", ")", ":", "if", "dry_run", ":", "sys", ".", "stdout", ".", "write", "(", "\"rm %s\\n\"", "%", "filepath", ")", "else", ":", "try", ":", "os", ".", "remove", "(", "filepath", ")", "e...
Remove the file at filepath Catches exception if the file does not exist. If dry_run is True, print name of file to be removed, but do not remove it.
[ "Remove", "the", "file", "at", "filepath" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L13-L26
fermiPy/fermipy
fermipy/jobs/sys_interface.py
clean_job
def clean_job(logfile, outfiles, dry_run=False): """Removes log file and files created by failed jobs. If dry_run is True, print name of files to be removed, but do not remove them. """ remove_file(logfile, dry_run) for outfile in outfiles.values(): remove_file(outfile, dry_run)
python
def clean_job(logfile, outfiles, dry_run=False): """Removes log file and files created by failed jobs. If dry_run is True, print name of files to be removed, but do not remove them. """ remove_file(logfile, dry_run) for outfile in outfiles.values(): remove_file(outfile, dry_run)
[ "def", "clean_job", "(", "logfile", ",", "outfiles", ",", "dry_run", "=", "False", ")", ":", "remove_file", "(", "logfile", ",", "dry_run", ")", "for", "outfile", "in", "outfiles", ".", "values", "(", ")", ":", "remove_file", "(", "outfile", ",", "dry_ru...
Removes log file and files created by failed jobs. If dry_run is True, print name of files to be removed, but do not remove them.
[ "Removes", "log", "file", "and", "files", "created", "by", "failed", "jobs", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L29-L36
fermiPy/fermipy
fermipy/jobs/sys_interface.py
check_log
def check_log(logfile, exited='Exited with exit code', successful='Successfully completed'): """Check a log file to determine status of LSF job Often logfile doesn't exist because the job hasn't begun to run. It is unclear what you want to do in that case... Parameters ---------- ...
python
def check_log(logfile, exited='Exited with exit code', successful='Successfully completed'): """Check a log file to determine status of LSF job Often logfile doesn't exist because the job hasn't begun to run. It is unclear what you want to do in that case... Parameters ---------- ...
[ "def", "check_log", "(", "logfile", ",", "exited", "=", "'Exited with exit code'", ",", "successful", "=", "'Successfully completed'", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "logfile", ")", ":", "return", "JobStatus", ".", "ready", "if...
Check a log file to determine status of LSF job Often logfile doesn't exist because the job hasn't begun to run. It is unclear what you want to do in that case... Parameters ---------- logfile : str String with path to logfile exited : str Value to check for in existing logf...
[ "Check", "a", "log", "file", "to", "determine", "status", "of", "LSF", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L39-L66
fermiPy/fermipy
fermipy/jobs/sys_interface.py
SysInterface.check_job
def check_job(cls, job_details): """ Check the status of a specfic job """ return check_log(job_details.logfile, cls.string_exited, cls.string_successful)
python
def check_job(cls, job_details): """ Check the status of a specfic job """ return check_log(job_details.logfile, cls.string_exited, cls.string_successful)
[ "def", "check_job", "(", "cls", ",", "job_details", ")", ":", "return", "check_log", "(", "job_details", ".", "logfile", ",", "cls", ".", "string_exited", ",", "cls", ".", "string_successful", ")" ]
Check the status of a specfic job
[ "Check", "the", "status", "of", "a", "specfic", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L82-L84
fermiPy/fermipy
fermipy/jobs/sys_interface.py
SysInterface.dispatch_job_hook
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Hook to dispatch a single job""" raise NotImplementedError("SysInterface.dispatch_job_hook")
python
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Hook to dispatch a single job""" raise NotImplementedError("SysInterface.dispatch_job_hook")
[ "def", "dispatch_job_hook", "(", "self", ",", "link", ",", "key", ",", "job_config", ",", "logfile", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "raise", "NotImplementedError", "(", "\"SysInterface.dispatch_job_hook\"", ")" ]
Hook to dispatch a single job
[ "Hook", "to", "dispatch", "a", "single", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L86-L88
fermiPy/fermipy
fermipy/jobs/sys_interface.py
SysInterface.dispatch_job
def dispatch_job(self, link, key, job_archive, stream=sys.stdout): """Function to dispatch a single job Parameters ---------- link : `Link` Link object that sendes the job key : str Key used to identify this particular job job_archive : `JobArc...
python
def dispatch_job(self, link, key, job_archive, stream=sys.stdout): """Function to dispatch a single job Parameters ---------- link : `Link` Link object that sendes the job key : str Key used to identify this particular job job_archive : `JobArc...
[ "def", "dispatch_job", "(", "self", ",", "link", ",", "key", ",", "job_archive", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "try", ":", "job_details", "=", "link", ".", "jobs", "[", "key", "]", "except", "KeyError", ":", "print", "(", "key",...
Function to dispatch a single job Parameters ---------- link : `Link` Link object that sendes the job key : str Key used to identify this particular job job_archive : `JobArchive` Archive used to keep track of jobs Returns `JobDeta...
[ "Function", "to", "dispatch", "a", "single", "job" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L90-L122
fermiPy/fermipy
fermipy/jobs/sys_interface.py
SysInterface.submit_jobs
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout): """Run the `Link` with all of the items job_dict as input. If job_dict is None, the job_dict will be take from link.jobs Returns a `JobStatus` enum """ failed = False if job_dict is None: ...
python
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout): """Run the `Link` with all of the items job_dict as input. If job_dict is None, the job_dict will be take from link.jobs Returns a `JobStatus` enum """ failed = False if job_dict is None: ...
[ "def", "submit_jobs", "(", "self", ",", "link", ",", "job_dict", "=", "None", ",", "job_archive", "=", "None", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "failed", "=", "False", "if", "job_dict", "is", "None", ":", "job_dict", "=", "link", "...
Run the `Link` with all of the items job_dict as input. If job_dict is None, the job_dict will be take from link.jobs Returns a `JobStatus` enum
[ "Run", "the", "Link", "with", "all", "of", "the", "items", "job_dict", "as", "input", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L124-L152
fermiPy/fermipy
fermipy/jobs/sys_interface.py
SysInterface.clean_jobs
def clean_jobs(self, link, job_dict=None, clean_all=False): """ Clean up all the jobs associated with this link. Returns a `JobStatus` enum """ failed = False if job_dict is None: job_dict = link.jobs for job_details in job_dict.values(): # clean...
python
def clean_jobs(self, link, job_dict=None, clean_all=False): """ Clean up all the jobs associated with this link. Returns a `JobStatus` enum """ failed = False if job_dict is None: job_dict = link.jobs for job_details in job_dict.values(): # clean...
[ "def", "clean_jobs", "(", "self", ",", "link", ",", "job_dict", "=", "None", ",", "clean_all", "=", "False", ")", ":", "failed", "=", "False", "if", "job_dict", "is", "None", ":", "job_dict", "=", "link", ".", "jobs", "for", "job_details", "in", "job_d...
Clean up all the jobs associated with this link. Returns a `JobStatus` enum
[ "Clean", "up", "all", "the", "jobs", "associated", "with", "this", "link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/sys_interface.py#L154-L171
fermiPy/fermipy
fermipy/model_utils.py
get_function_spec
def get_function_spec(name): """Return a dictionary with the specification of a function: parameter names and defaults (value, bounds, scale, etc.). Returns ------- par_names : list List of parameter names for this function. norm_par : str Name of normalization parameter. ...
python
def get_function_spec(name): """Return a dictionary with the specification of a function: parameter names and defaults (value, bounds, scale, etc.). Returns ------- par_names : list List of parameter names for this function. norm_par : str Name of normalization parameter. ...
[ "def", "get_function_spec", "(", "name", ")", ":", "if", "not", "hasattr", "(", "get_function_spec", ",", "'fndict'", ")", ":", "modelfile", "=", "os", ".", "path", ".", "join", "(", "'$FERMIPY_ROOT'", ",", "'data'", ",", "'models.yaml'", ")", "modelfile", ...
Return a dictionary with the specification of a function: parameter names and defaults (value, bounds, scale, etc.). Returns ------- par_names : list List of parameter names for this function. norm_par : str Name of normalization parameter. default : dict Parameter def...
[ "Return", "a", "dictionary", "with", "the", "specification", "of", "a", "function", ":", "parameter", "names", "and", "defaults", "(", "value", "bounds", "scale", "etc", ".", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/model_utils.py#L41-L65
fermiPy/fermipy
fermipy/model_utils.py
get_spatial_type
def get_spatial_type(spatial_model): """Translate a spatial model string to a spatial type.""" if spatial_model in ['SkyDirFunction', 'PointSource', 'Gaussian']: return 'SkyDirFunction' elif spatial_model in ['SpatialMap']: return 'SpatialMap' elif spatial_model...
python
def get_spatial_type(spatial_model): """Translate a spatial model string to a spatial type.""" if spatial_model in ['SkyDirFunction', 'PointSource', 'Gaussian']: return 'SkyDirFunction' elif spatial_model in ['SpatialMap']: return 'SpatialMap' elif spatial_model...
[ "def", "get_spatial_type", "(", "spatial_model", ")", ":", "if", "spatial_model", "in", "[", "'SkyDirFunction'", ",", "'PointSource'", ",", "'Gaussian'", "]", ":", "return", "'SkyDirFunction'", "elif", "spatial_model", "in", "[", "'SpatialMap'", "]", ":", "return"...
Translate a spatial model string to a spatial type.
[ "Translate", "a", "spatial", "model", "string", "to", "a", "spatial", "type", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/model_utils.py#L77-L95
fermiPy/fermipy
fermipy/model_utils.py
create_pars_from_dict
def create_pars_from_dict(name, pars_dict, rescale=True, update_bounds=False): """Create a dictionary for the parameters of a function. Parameters ---------- name : str Name of the function. pars_dict : dict Existing parameter dict that will be merged with the default d...
python
def create_pars_from_dict(name, pars_dict, rescale=True, update_bounds=False): """Create a dictionary for the parameters of a function. Parameters ---------- name : str Name of the function. pars_dict : dict Existing parameter dict that will be merged with the default d...
[ "def", "create_pars_from_dict", "(", "name", ",", "pars_dict", ",", "rescale", "=", "True", ",", "update_bounds", "=", "False", ")", ":", "o", "=", "get_function_defaults", "(", "name", ")", "pars_dict", "=", "pars_dict", ".", "copy", "(", ")", "for", "k",...
Create a dictionary for the parameters of a function. Parameters ---------- name : str Name of the function. pars_dict : dict Existing parameter dict that will be merged with the default dictionary created by this method. rescale : bool Rescale parameter values...
[ "Create", "a", "dictionary", "for", "the", "parameters", "of", "a", "function", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/model_utils.py#L120-L162
fermiPy/fermipy
fermipy/model_utils.py
make_parameter_dict
def make_parameter_dict(pdict, fixed_par=False, rescale=True, update_bounds=False): """ Update a parameter dictionary. This function will automatically set the parameter scale and bounds if they are not defined. Bounds are also adjusted to ensure that they encompass the para...
python
def make_parameter_dict(pdict, fixed_par=False, rescale=True, update_bounds=False): """ Update a parameter dictionary. This function will automatically set the parameter scale and bounds if they are not defined. Bounds are also adjusted to ensure that they encompass the para...
[ "def", "make_parameter_dict", "(", "pdict", ",", "fixed_par", "=", "False", ",", "rescale", "=", "True", ",", "update_bounds", "=", "False", ")", ":", "o", "=", "copy", ".", "deepcopy", "(", "pdict", ")", "o", ".", "setdefault", "(", "'scale'", ",", "1...
Update a parameter dictionary. This function will automatically set the parameter scale and bounds if they are not defined. Bounds are also adjusted to ensure that they encompass the parameter value.
[ "Update", "a", "parameter", "dictionary", ".", "This", "function", "will", "automatically", "set", "the", "parameter", "scale", "and", "bounds", "if", "they", "are", "not", "defined", ".", "Bounds", "are", "also", "adjusted", "to", "ensure", "that", "they", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/model_utils.py#L165-L197
fermiPy/fermipy
fermipy/model_utils.py
cast_pars_dict
def cast_pars_dict(pars_dict): """Cast the bool and float elements of a parameters dict to the appropriate python types. """ o = {} for pname, pdict in pars_dict.items(): o[pname] = {} for k, v in pdict.items(): if k == 'free': o[pname][k] = bool(int(...
python
def cast_pars_dict(pars_dict): """Cast the bool and float elements of a parameters dict to the appropriate python types. """ o = {} for pname, pdict in pars_dict.items(): o[pname] = {} for k, v in pdict.items(): if k == 'free': o[pname][k] = bool(int(...
[ "def", "cast_pars_dict", "(", "pars_dict", ")", ":", "o", "=", "{", "}", "for", "pname", ",", "pdict", "in", "pars_dict", ".", "items", "(", ")", ":", "o", "[", "pname", "]", "=", "{", "}", "for", "k", ",", "v", "in", "pdict", ".", "items", "("...
Cast the bool and float elements of a parameters dict to the appropriate python types.
[ "Cast", "the", "bool", "and", "float", "elements", "of", "a", "parameters", "dict", "to", "the", "appropriate", "python", "types", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/model_utils.py#L200-L220
fermiPy/fermipy
fermipy/scripts/gather_srcmaps.py
do_gather
def do_gather(flist): """ Gather all the HDUs from a list of files""" hlist = [] nskip = 3 for fname in flist: fin = fits.open(fname) if len(hlist) == 0: if fin[1].name == 'SKYMAP': nskip = 4 start = 0 else: start = nskip ...
python
def do_gather(flist): """ Gather all the HDUs from a list of files""" hlist = [] nskip = 3 for fname in flist: fin = fits.open(fname) if len(hlist) == 0: if fin[1].name == 'SKYMAP': nskip = 4 start = 0 else: start = nskip ...
[ "def", "do_gather", "(", "flist", ")", ":", "hlist", "=", "[", "]", "nskip", "=", "3", "for", "fname", "in", "flist", ":", "fin", "=", "fits", ".", "open", "(", "fname", ")", "if", "len", "(", "hlist", ")", "==", "0", ":", "if", "fin", "[", "...
Gather all the HDUs from a list of files
[ "Gather", "all", "the", "HDUs", "from", "a", "list", "of", "files" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/gather_srcmaps.py#L10-L25
fermiPy/fermipy
fermipy/scripts/gather_srcmaps.py
main
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Gather source maps from Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
python
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Gather source maps from Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
[ "def", "main", "(", ")", ":", "usage", "=", "\"usage: %(prog)s [options] \"", "description", "=", "\"Gather source maps from Fermi-LAT files.\"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "usage", ",", "description", "=", "description", ")",...
Main function for command line usage
[ "Main", "function", "for", "command", "line", "usage" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/gather_srcmaps.py#L28-L60
fermiPy/fermipy
fermipy/jobs/job_archive.py
main_browse
def main_browse(): """Entry point for command line use for browsing a JobArchive """ parser = argparse.ArgumentParser(usage="job_archive.py [options]", description="Browse a job archive") parser.add_argument('--jobs', action='store', dest='job_archive_table', ...
python
def main_browse(): """Entry point for command line use for browsing a JobArchive """ parser = argparse.ArgumentParser(usage="job_archive.py [options]", description="Browse a job archive") parser.add_argument('--jobs', action='store', dest='job_archive_table', ...
[ "def", "main_browse", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "\"job_archive.py [options]\"", ",", "description", "=", "\"Browse a job archive\"", ")", "parser", ".", "add_argument", "(", "'--jobs'", ",", "action", "=", ...
Entry point for command line use for browsing a JobArchive
[ "Entry", "point", "for", "command", "line", "use", "for", "browsing", "a", "JobArchive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L690-L705
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobStatusVector.n_waiting
def n_waiting(self): """Return the number of jobs in various waiting states""" return self._counters[JobStatus.no_job] +\ self._counters[JobStatus.unknown] +\ self._counters[JobStatus.not_ready] +\ self._counters[JobStatus.ready]
python
def n_waiting(self): """Return the number of jobs in various waiting states""" return self._counters[JobStatus.no_job] +\ self._counters[JobStatus.unknown] +\ self._counters[JobStatus.not_ready] +\ self._counters[JobStatus.ready]
[ "def", "n_waiting", "(", "self", ")", ":", "return", "self", ".", "_counters", "[", "JobStatus", ".", "no_job", "]", "+", "self", ".", "_counters", "[", "JobStatus", ".", "unknown", "]", "+", "self", ".", "_counters", "[", "JobStatus", ".", "not_ready", ...
Return the number of jobs in various waiting states
[ "Return", "the", "number", "of", "jobs", "in", "various", "waiting", "states" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L87-L92
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobStatusVector.n_failed
def n_failed(self): """Return the number of failed jobs""" return self._counters[JobStatus.failed] + self._counters[JobStatus.partial_failed]
python
def n_failed(self): """Return the number of failed jobs""" return self._counters[JobStatus.failed] + self._counters[JobStatus.partial_failed]
[ "def", "n_failed", "(", "self", ")", ":", "return", "self", ".", "_counters", "[", "JobStatus", ".", "failed", "]", "+", "self", ".", "_counters", "[", "JobStatus", ".", "partial_failed", "]" ]
Return the number of failed jobs
[ "Return", "the", "number", "of", "failed", "jobs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L110-L112
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobStatusVector.get_status
def get_status(self): """Return an overall status based on the number of jobs in various states. """ if self.n_total == 0: return JobStatus.no_job elif self.n_done == self.n_total: return JobStatus.done elif self.n_failed > 0: # If more...
python
def get_status(self): """Return an overall status based on the number of jobs in various states. """ if self.n_total == 0: return JobStatus.no_job elif self.n_done == self.n_total: return JobStatus.done elif self.n_failed > 0: # If more...
[ "def", "get_status", "(", "self", ")", ":", "if", "self", ".", "n_total", "==", "0", ":", "return", "JobStatus", ".", "no_job", "elif", "self", ".", "n_done", "==", "self", ".", "n_total", ":", "return", "JobStatus", ".", "done", "elif", "self", ".", ...
Return an overall status based on the number of jobs in various states.
[ "Return", "an", "overall", "status", "based", "on", "the", "number", "of", "jobs", "in", "various", "states", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L123-L140
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.make_tables
def make_tables(job_dict): """Build and return an `astropy.table.Table' to store `JobDetails`""" col_dbkey = Column(name='dbkey', dtype=int) col_jobname = Column(name='jobname', dtype='S64') col_jobkey = Column(name='jobkey', dtype='S64') col_appname = Column(name='appname', dtyp...
python
def make_tables(job_dict): """Build and return an `astropy.table.Table' to store `JobDetails`""" col_dbkey = Column(name='dbkey', dtype=int) col_jobname = Column(name='jobname', dtype='S64') col_jobkey = Column(name='jobkey', dtype='S64') col_appname = Column(name='appname', dtyp...
[ "def", "make_tables", "(", "job_dict", ")", ":", "col_dbkey", "=", "Column", "(", "name", "=", "'dbkey'", ",", "dtype", "=", "int", ")", "col_jobname", "=", "Column", "(", "name", "=", "'jobname'", ",", "dtype", "=", "'S64'", ")", "col_jobkey", "=", "C...
Build and return an `astropy.table.Table' to store `JobDetails`
[ "Build", "and", "return", "an", "astropy", ".", "table", ".", "Table", "to", "store", "JobDetails" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L228-L255
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.get_file_ids
def get_file_ids(self, file_archive, creator=None, status=FileStatus.no_file): """Fill the file id arrays from the file lists Parameters ---------- file_archive : `FileArchive` Used to look up file ids creator : int A unique key for the job that created...
python
def get_file_ids(self, file_archive, creator=None, status=FileStatus.no_file): """Fill the file id arrays from the file lists Parameters ---------- file_archive : `FileArchive` Used to look up file ids creator : int A unique key for the job that created...
[ "def", "get_file_ids", "(", "self", ",", "file_archive", ",", "creator", "=", "None", ",", "status", "=", "FileStatus", ".", "no_file", ")", ":", "file_dict", "=", "copy", ".", "deepcopy", "(", "self", ".", "file_dict", ")", "if", "self", ".", "sub_file_...
Fill the file id arrays from the file lists Parameters ---------- file_archive : `FileArchive` Used to look up file ids creator : int A unique key for the job that created these file status : `FileStatus` Enumeration giving current status...
[ "Fill", "the", "file", "id", "arrays", "from", "the", "file", "lists" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L264-L318
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.get_file_paths
def get_file_paths(self, file_archive, file_id_array): """Get the full paths of the files used by this object from the the id arrays Parameters ---------- file_archive : `FileArchive` Used to look up file ids file_id_array : `numpy.array` Array that rema...
python
def get_file_paths(self, file_archive, file_id_array): """Get the full paths of the files used by this object from the the id arrays Parameters ---------- file_archive : `FileArchive` Used to look up file ids file_id_array : `numpy.array` Array that rema...
[ "def", "get_file_paths", "(", "self", ",", "file_archive", ",", "file_id_array", ")", ":", "full_list", "=", "[", "]", "status_dict", "=", "{", "}", "full_list", "+=", "file_archive", ".", "get_file_paths", "(", "file_id_array", "[", "self", ".", "infile_ids",...
Get the full paths of the files used by this object from the the id arrays Parameters ---------- file_archive : `FileArchive` Used to look up file ids file_id_array : `numpy.array` Array that remaps the file indexes
[ "Get", "the", "full", "paths", "of", "the", "files", "used", "by", "this", "object", "from", "the", "the", "id", "arrays" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L320-L347
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails._fill_array_from_list
def _fill_array_from_list(the_list, the_array): """Fill an `array` from a `list`""" for i, val in enumerate(the_list): the_array[i] = val return the_array
python
def _fill_array_from_list(the_list, the_array): """Fill an `array` from a `list`""" for i, val in enumerate(the_list): the_array[i] = val return the_array
[ "def", "_fill_array_from_list", "(", "the_list", ",", "the_array", ")", ":", "for", "i", ",", "val", "in", "enumerate", "(", "the_list", ")", ":", "the_array", "[", "i", "]", "=", "val", "return", "the_array" ]
Fill an `array` from a `list`
[ "Fill", "an", "array", "from", "a", "list" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L350-L354
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.make_dict
def make_dict(cls, table): """Build a dictionary map int to `JobDetails` from an `astropy.table.Table`""" ret_dict = {} for row in table: job_details = cls.create_from_row(row) ret_dict[job_details.dbkey] = job_details return ret_dict
python
def make_dict(cls, table): """Build a dictionary map int to `JobDetails` from an `astropy.table.Table`""" ret_dict = {} for row in table: job_details = cls.create_from_row(row) ret_dict[job_details.dbkey] = job_details return ret_dict
[ "def", "make_dict", "(", "cls", ",", "table", ")", ":", "ret_dict", "=", "{", "}", "for", "row", "in", "table", ":", "job_details", "=", "cls", ".", "create_from_row", "(", "row", ")", "ret_dict", "[", "job_details", ".", "dbkey", "]", "=", "job_detail...
Build a dictionary map int to `JobDetails` from an `astropy.table.Table`
[ "Build", "a", "dictionary", "map", "int", "to", "JobDetails", "from", "an", "astropy", ".", "table", ".", "Table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L362-L368
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.create_from_row
def create_from_row(cls, table_row): """Create a `JobDetails` from an `astropy.table.row.Row` """ kwargs = {} for key in table_row.colnames: kwargs[key] = table_row[key] infile_refs = kwargs.pop('infile_refs') outfile_refs = kwargs.pop('outfile_refs') rmfile_...
python
def create_from_row(cls, table_row): """Create a `JobDetails` from an `astropy.table.row.Row` """ kwargs = {} for key in table_row.colnames: kwargs[key] = table_row[key] infile_refs = kwargs.pop('infile_refs') outfile_refs = kwargs.pop('outfile_refs') rmfile_...
[ "def", "create_from_row", "(", "cls", ",", "table_row", ")", ":", "kwargs", "=", "{", "}", "for", "key", "in", "table_row", ".", "colnames", ":", "kwargs", "[", "key", "]", "=", "table_row", "[", "key", "]", "infile_refs", "=", "kwargs", ".", "pop", ...
Create a `JobDetails` from an `astropy.table.row.Row`
[ "Create", "a", "JobDetails", "from", "an", "astropy", ".", "table", ".", "row", ".", "Row" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L371-L386
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.append_to_tables
def append_to_tables(self, table, table_ids): """Add this instance as a row on a `astropy.table.Table` """ infile_refs = np.zeros((2), int) outfile_refs = np.zeros((2), int) rmfile_refs = np.zeros((2), int) intfile_refs = np.zeros((2), int) f_ptr = len(table_ids['file_id'...
python
def append_to_tables(self, table, table_ids): """Add this instance as a row on a `astropy.table.Table` """ infile_refs = np.zeros((2), int) outfile_refs = np.zeros((2), int) rmfile_refs = np.zeros((2), int) intfile_refs = np.zeros((2), int) f_ptr = len(table_ids['file_id'...
[ "def", "append_to_tables", "(", "self", ",", "table", ",", "table_ids", ")", ":", "infile_refs", "=", "np", ".", "zeros", "(", "(", "2", ")", ",", "int", ")", "outfile_refs", "=", "np", ".", "zeros", "(", "(", "2", ")", ",", "int", ")", "rmfile_ref...
Add this instance as a row on a `astropy.table.Table`
[ "Add", "this", "instance", "as", "a", "row", "on", "a", "astropy", ".", "table", ".", "Table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L388-L431
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.update_table_row
def update_table_row(self, table, row_idx): """Add this instance as a row on a `astropy.table.Table` """ try: table[row_idx]['timestamp'] = self.timestamp table[row_idx]['status'] = self.status except IndexError: print("Index error", len(table), row_idx)
python
def update_table_row(self, table, row_idx): """Add this instance as a row on a `astropy.table.Table` """ try: table[row_idx]['timestamp'] = self.timestamp table[row_idx]['status'] = self.status except IndexError: print("Index error", len(table), row_idx)
[ "def", "update_table_row", "(", "self", ",", "table", ",", "row_idx", ")", ":", "try", ":", "table", "[", "row_idx", "]", "[", "'timestamp'", "]", "=", "self", ".", "timestamp", "table", "[", "row_idx", "]", "[", "'status'", "]", "=", "self", ".", "s...
Add this instance as a row on a `astropy.table.Table`
[ "Add", "this", "instance", "as", "a", "row", "on", "a", "astropy", ".", "table", ".", "Table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L433-L439
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobDetails.check_status_logfile
def check_status_logfile(self, checker_func): """Check on the status of this particular job using the logfile""" self.status = checker_func(self.logfile) return self.status
python
def check_status_logfile(self, checker_func): """Check on the status of this particular job using the logfile""" self.status = checker_func(self.logfile) return self.status
[ "def", "check_status_logfile", "(", "self", ",", "checker_func", ")", ":", "self", ".", "status", "=", "checker_func", "(", "self", ".", "logfile", ")", "return", "self", ".", "status" ]
Check on the status of this particular job using the logfile
[ "Check", "on", "the", "status", "of", "this", "particular", "job", "using", "the", "logfile" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L441-L444
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive._fill_cache
def _fill_cache(self): """Fill the cache from the `astropy.table.Table`""" for irow in range(len(self._table)): job_details = self.make_job_details(irow) self._cache[job_details.fullkey] = job_details
python
def _fill_cache(self): """Fill the cache from the `astropy.table.Table`""" for irow in range(len(self._table)): job_details = self.make_job_details(irow) self._cache[job_details.fullkey] = job_details
[ "def", "_fill_cache", "(", "self", ")", ":", "for", "irow", "in", "range", "(", "len", "(", "self", ".", "_table", ")", ")", ":", "job_details", "=", "self", ".", "make_job_details", "(", "irow", ")", "self", ".", "_cache", "[", "job_details", ".", "...
Fill the cache from the `astropy.table.Table`
[ "Fill", "the", "cache", "from", "the", "astropy", ".", "table", ".", "Table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L519-L523
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive._read_table_file
def _read_table_file(self, table_file): """Read an `astropy.table.Table` from table_file to set up the `JobArchive`""" self._table_file = table_file if os.path.exists(self._table_file): self._table = Table.read(self._table_file, hdu='JOB_ARCHIVE') self._table_ids = Table....
python
def _read_table_file(self, table_file): """Read an `astropy.table.Table` from table_file to set up the `JobArchive`""" self._table_file = table_file if os.path.exists(self._table_file): self._table = Table.read(self._table_file, hdu='JOB_ARCHIVE') self._table_ids = Table....
[ "def", "_read_table_file", "(", "self", ",", "table_file", ")", ":", "self", ".", "_table_file", "=", "table_file", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_table_file", ")", ":", "self", ".", "_table", "=", "Table", ".", "read", "("...
Read an `astropy.table.Table` from table_file to set up the `JobArchive`
[ "Read", "an", "astropy", ".", "table", ".", "Table", "from", "table_file", "to", "set", "up", "the", "JobArchive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L525-L534
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.make_job_details
def make_job_details(self, row_idx): """Create a `JobDetails` from an `astropy.table.row.Row` """ row = self._table[row_idx] job_details = JobDetails.create_from_row(row) job_details.get_file_paths(self._file_archive, self._table_id_array) self._cache[job_details.fullkey] = job_d...
python
def make_job_details(self, row_idx): """Create a `JobDetails` from an `astropy.table.row.Row` """ row = self._table[row_idx] job_details = JobDetails.create_from_row(row) job_details.get_file_paths(self._file_archive, self._table_id_array) self._cache[job_details.fullkey] = job_d...
[ "def", "make_job_details", "(", "self", ",", "row_idx", ")", ":", "row", "=", "self", ".", "_table", "[", "row_idx", "]", "job_details", "=", "JobDetails", ".", "create_from_row", "(", "row", ")", "job_details", ".", "get_file_paths", "(", "self", ".", "_f...
Create a `JobDetails` from an `astropy.table.row.Row`
[ "Create", "a", "JobDetails", "from", "an", "astropy", ".", "table", ".", "row", ".", "Row" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L536-L542
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.get_details
def get_details(self, jobname, jobkey): """Get the `JobDetails` associated to a particular job instance""" fullkey = JobDetails.make_fullkey(jobname, jobkey) return self._cache[fullkey]
python
def get_details(self, jobname, jobkey): """Get the `JobDetails` associated to a particular job instance""" fullkey = JobDetails.make_fullkey(jobname, jobkey) return self._cache[fullkey]
[ "def", "get_details", "(", "self", ",", "jobname", ",", "jobkey", ")", ":", "fullkey", "=", "JobDetails", ".", "make_fullkey", "(", "jobname", ",", "jobkey", ")", "return", "self", ".", "_cache", "[", "fullkey", "]" ]
Get the `JobDetails` associated to a particular job instance
[ "Get", "the", "JobDetails", "associated", "to", "a", "particular", "job", "instance" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L544-L547
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.register_job
def register_job(self, job_details): """Register a job in this `JobArchive` """ # check to see if the job already exists try: job_details_old = self.get_details(job_details.jobname, job_details.jobkey) if job_details_old.stat...
python
def register_job(self, job_details): """Register a job in this `JobArchive` """ # check to see if the job already exists try: job_details_old = self.get_details(job_details.jobname, job_details.jobkey) if job_details_old.stat...
[ "def", "register_job", "(", "self", ",", "job_details", ")", ":", "# check to see if the job already exists", "try", ":", "job_details_old", "=", "self", ".", "get_details", "(", "job_details", ".", "jobname", ",", "job_details", ".", "jobkey", ")", "if", "job_det...
Register a job in this `JobArchive`
[ "Register", "a", "job", "in", "this", "JobArchive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L549-L567
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.register_jobs
def register_jobs(self, job_dict): """Register a bunch of jobs in this archive""" njobs = len(job_dict) sys.stdout.write("Registering %i total jobs: " % njobs) for i, job_details in enumerate(job_dict.values()): if i % 10 == 0: sys.stdout.write('.') ...
python
def register_jobs(self, job_dict): """Register a bunch of jobs in this archive""" njobs = len(job_dict) sys.stdout.write("Registering %i total jobs: " % njobs) for i, job_details in enumerate(job_dict.values()): if i % 10 == 0: sys.stdout.write('.') ...
[ "def", "register_jobs", "(", "self", ",", "job_dict", ")", ":", "njobs", "=", "len", "(", "job_dict", ")", "sys", ".", "stdout", ".", "write", "(", "\"Registering %i total jobs: \"", "%", "njobs", ")", "for", "i", ",", "job_details", "in", "enumerate", "("...
Register a bunch of jobs in this archive
[ "Register", "a", "bunch", "of", "jobs", "in", "this", "archive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L569-L578
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.register_job_from_link
def register_job_from_link(self, link, key, **kwargs): """Register a job in the `JobArchive` from a `Link` object """ job_config = kwargs.get('job_config', None) if job_config is None: job_config = link.args status = kwargs.get('status', JobStatus.unknown) job_details...
python
def register_job_from_link(self, link, key, **kwargs): """Register a job in the `JobArchive` from a `Link` object """ job_config = kwargs.get('job_config', None) if job_config is None: job_config = link.args status = kwargs.get('status', JobStatus.unknown) job_details...
[ "def", "register_job_from_link", "(", "self", ",", "link", ",", "key", ",", "*", "*", "kwargs", ")", ":", "job_config", "=", "kwargs", ".", "get", "(", "'job_config'", ",", "None", ")", "if", "job_config", "is", "None", ":", "job_config", "=", "link", ...
Register a job in the `JobArchive` from a `Link` object
[ "Register", "a", "job", "in", "the", "JobArchive", "from", "a", "Link", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L580-L596
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.update_job
def update_job(self, job_details): """Update a job in the `JobArchive` """ other = self.get_details(job_details.jobname, job_details.jobkey) other.timestamp = job_details.timestamp other.status = job_details.status other.update_table_row(self._tab...
python
def update_job(self, job_details): """Update a job in the `JobArchive` """ other = self.get_details(job_details.jobname, job_details.jobkey) other.timestamp = job_details.timestamp other.status = job_details.status other.update_table_row(self._tab...
[ "def", "update_job", "(", "self", ",", "job_details", ")", ":", "other", "=", "self", ".", "get_details", "(", "job_details", ".", "jobname", ",", "job_details", ".", "jobkey", ")", "other", ".", "timestamp", "=", "job_details", ".", "timestamp", "other", ...
Update a job in the `JobArchive`
[ "Update", "a", "job", "in", "the", "JobArchive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L598-L605
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.remove_jobs
def remove_jobs(self, mask): """Mark all jobs that match a mask as 'removed' """ jobnames = self.table[mask]['jobname'] jobkey = self.table[mask]['jobkey'] self.table[mask]['status'] = JobStatus.removed for jobname, jobkey in zip(jobnames, jobkey): fullkey = JobDetail...
python
def remove_jobs(self, mask): """Mark all jobs that match a mask as 'removed' """ jobnames = self.table[mask]['jobname'] jobkey = self.table[mask]['jobkey'] self.table[mask]['status'] = JobStatus.removed for jobname, jobkey in zip(jobnames, jobkey): fullkey = JobDetail...
[ "def", "remove_jobs", "(", "self", ",", "mask", ")", ":", "jobnames", "=", "self", ".", "table", "[", "mask", "]", "[", "'jobname'", "]", "jobkey", "=", "self", ".", "table", "[", "mask", "]", "[", "'jobkey'", "]", "self", ".", "table", "[", "mask"...
Mark all jobs that match a mask as 'removed'
[ "Mark", "all", "jobs", "that", "match", "a", "mask", "as", "removed" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L607-L615
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.build_temp_job_archive
def build_temp_job_archive(cls): """Build and return a `JobArchive` using defualt locations of persistent files. """ try: os.unlink('job_archive_temp.fits') os.unlink('file_archive_temp.fits') except OSError: pass cls._archive = cls(job_archiv...
python
def build_temp_job_archive(cls): """Build and return a `JobArchive` using defualt locations of persistent files. """ try: os.unlink('job_archive_temp.fits') os.unlink('file_archive_temp.fits') except OSError: pass cls._archive = cls(job_archiv...
[ "def", "build_temp_job_archive", "(", "cls", ")", ":", "try", ":", "os", ".", "unlink", "(", "'job_archive_temp.fits'", ")", "os", ".", "unlink", "(", "'file_archive_temp.fits'", ")", "except", "OSError", ":", "pass", "cls", ".", "_archive", "=", "cls", "(",...
Build and return a `JobArchive` using defualt locations of persistent files.
[ "Build", "and", "return", "a", "JobArchive", "using", "defualt", "locations", "of", "persistent", "files", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L618-L630
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.write_table_file
def write_table_file(self, job_table_file=None, file_table_file=None): """Write the table to self._table_file""" if self._table is None: raise RuntimeError("No table to write") if self._table_ids is None: raise RuntimeError("No ID table to write") if job_table_fil...
python
def write_table_file(self, job_table_file=None, file_table_file=None): """Write the table to self._table_file""" if self._table is None: raise RuntimeError("No table to write") if self._table_ids is None: raise RuntimeError("No ID table to write") if job_table_fil...
[ "def", "write_table_file", "(", "self", ",", "job_table_file", "=", "None", ",", "file_table_file", "=", "None", ")", ":", "if", "self", ".", "_table", "is", "None", ":", "raise", "RuntimeError", "(", "\"No table to write\"", ")", "if", "self", ".", "_table_...
Write the table to self._table_file
[ "Write", "the", "table", "to", "self", ".", "_table_file" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L632-L644
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.update_job_status
def update_job_status(self, checker_func): """Update the status of all the jobs in the archive""" njobs = len(self.cache.keys()) status_vect = np.zeros((8), int) sys.stdout.write("Updating status of %i jobs: " % njobs) sys.stdout.flush() for i, key in enumerate(self.cache...
python
def update_job_status(self, checker_func): """Update the status of all the jobs in the archive""" njobs = len(self.cache.keys()) status_vect = np.zeros((8), int) sys.stdout.write("Updating status of %i jobs: " % njobs) sys.stdout.flush() for i, key in enumerate(self.cache...
[ "def", "update_job_status", "(", "self", ",", "checker_func", ")", ":", "njobs", "=", "len", "(", "self", ".", "cache", ".", "keys", "(", ")", ")", "status_vect", "=", "np", ".", "zeros", "(", "(", "8", ")", ",", "int", ")", "sys", ".", "stdout", ...
Update the status of all the jobs in the archive
[ "Update", "the", "status", "of", "all", "the", "jobs", "in", "the", "archive" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L646-L675
fermiPy/fermipy
fermipy/jobs/job_archive.py
JobArchive.build_archive
def build_archive(cls, **kwargs): """Return the singleton `JobArchive` instance, building it if needed """ if cls._archive is None: cls._archive = cls(**kwargs) return cls._archive
python
def build_archive(cls, **kwargs): """Return the singleton `JobArchive` instance, building it if needed """ if cls._archive is None: cls._archive = cls(**kwargs) return cls._archive
[ "def", "build_archive", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "if", "cls", ".", "_archive", "is", "None", ":", "cls", ".", "_archive", "=", "cls", "(", "*", "*", "kwargs", ")", "return", "cls", ".", "_archive" ]
Return the singleton `JobArchive` instance, building it if needed
[ "Return", "the", "singleton", "JobArchive", "instance", "building", "it", "if", "needed" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L683-L687
fermiPy/fermipy
fermipy/timing.py
Timer.elapsed_time
def elapsed_time(self): """Get the elapsed time.""" # Timer is running if self._t0 is not None: return self._time + self._get_time() else: return self._time
python
def elapsed_time(self): """Get the elapsed time.""" # Timer is running if self._t0 is not None: return self._time + self._get_time() else: return self._time
[ "def", "elapsed_time", "(", "self", ")", ":", "# Timer is running", "if", "self", ".", "_t0", "is", "not", "None", ":", "return", "self", ".", "_time", "+", "self", ".", "_get_time", "(", ")", "else", ":", "return", "self", ".", "_time" ]
Get the elapsed time.
[ "Get", "the", "elapsed", "time", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/timing.py#L14-L21
fermiPy/fermipy
fermipy/timing.py
Timer.stop
def stop(self): """Stop the timer.""" if self._t0 is None: raise RuntimeError('Timer not started.') self._time += self._get_time() self._t0 = None
python
def stop(self): """Stop the timer.""" if self._t0 is None: raise RuntimeError('Timer not started.') self._time += self._get_time() self._t0 = None
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_t0", "is", "None", ":", "raise", "RuntimeError", "(", "'Timer not started.'", ")", "self", ".", "_time", "+=", "self", ".", "_get_time", "(", ")", "self", ".", "_t0", "=", "None" ]
Stop the timer.
[ "Stop", "the", "timer", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/timing.py#L42-L49
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_spatialmap_source
def make_spatialmap_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.Source` object """ data = dict(Spatial_Filename=Spatial_Filename, ra=0.0, dec=0.0, SpatialType='SpatialMap', Source_Name=name) if spectrum is not No...
python
def make_spatialmap_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.Source` object """ data = dict(Spatial_Filename=Spatial_Filename, ra=0.0, dec=0.0, SpatialType='SpatialMap', Source_Name=name) if spectrum is not No...
[ "def", "make_spatialmap_source", "(", "name", ",", "Spatial_Filename", ",", "spectrum", ")", ":", "data", "=", "dict", "(", "Spatial_Filename", "=", "Spatial_Filename", ",", "ra", "=", "0.0", ",", "dec", "=", "0.0", ",", "SpatialType", "=", "'SpatialMap'", "...
Construct and return a `fermipy.roi_model.Source` object
[ "Construct", "and", "return", "a", "fermipy", ".", "roi_model", ".", "Source", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L21-L31
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_mapcube_source
def make_mapcube_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.MapCubeSource` object """ data = dict(Spatial_Filename=Spatial_Filename) if spectrum is not None: data.update(spectrum) return roi_model.MapCubeSource(name, data)
python
def make_mapcube_source(name, Spatial_Filename, spectrum): """Construct and return a `fermipy.roi_model.MapCubeSource` object """ data = dict(Spatial_Filename=Spatial_Filename) if spectrum is not None: data.update(spectrum) return roi_model.MapCubeSource(name, data)
[ "def", "make_mapcube_source", "(", "name", ",", "Spatial_Filename", ",", "spectrum", ")", ":", "data", "=", "dict", "(", "Spatial_Filename", "=", "Spatial_Filename", ")", "if", "spectrum", "is", "not", "None", ":", "data", ".", "update", "(", "spectrum", ")"...
Construct and return a `fermipy.roi_model.MapCubeSource` object
[ "Construct", "and", "return", "a", "fermipy", ".", "roi_model", ".", "MapCubeSource", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L34-L41
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_isotropic_source
def make_isotropic_source(name, Spectrum_Filename, spectrum): """Construct and return a `fermipy.roi_model.IsoSource` object """ data = dict(Spectrum_Filename=Spectrum_Filename) if spectrum is not None: data.update(spectrum) return roi_model.IsoSource(name, data)
python
def make_isotropic_source(name, Spectrum_Filename, spectrum): """Construct and return a `fermipy.roi_model.IsoSource` object """ data = dict(Spectrum_Filename=Spectrum_Filename) if spectrum is not None: data.update(spectrum) return roi_model.IsoSource(name, data)
[ "def", "make_isotropic_source", "(", "name", ",", "Spectrum_Filename", ",", "spectrum", ")", ":", "data", "=", "dict", "(", "Spectrum_Filename", "=", "Spectrum_Filename", ")", "if", "spectrum", "is", "not", "None", ":", "data", ".", "update", "(", "spectrum", ...
Construct and return a `fermipy.roi_model.IsoSource` object
[ "Construct", "and", "return", "a", "fermipy", ".", "roi_model", ".", "IsoSource", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L44-L51
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_composite_source
def make_composite_source(name, spectrum): """Construct and return a `fermipy.roi_model.CompositeSource` object """ data = dict(SpatialType='CompositeSource', SpatialModel='CompositeSource', SourceType='CompositeSource') if spectrum is not None: data.update(spectr...
python
def make_composite_source(name, spectrum): """Construct and return a `fermipy.roi_model.CompositeSource` object """ data = dict(SpatialType='CompositeSource', SpatialModel='CompositeSource', SourceType='CompositeSource') if spectrum is not None: data.update(spectr...
[ "def", "make_composite_source", "(", "name", ",", "spectrum", ")", ":", "data", "=", "dict", "(", "SpatialType", "=", "'CompositeSource'", ",", "SpatialModel", "=", "'CompositeSource'", ",", "SourceType", "=", "'CompositeSource'", ")", "if", "spectrum", "is", "n...
Construct and return a `fermipy.roi_model.CompositeSource` object
[ "Construct", "and", "return", "a", "fermipy", ".", "roi_model", ".", "CompositeSource", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L54-L62
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_catalog_sources
def make_catalog_sources(catalog_roi_model, source_names): """Construct and return dictionary of sources that are a subset of sources in catalog_roi_model. Parameters ---------- catalog_roi_model : dict or `fermipy.roi_model.ROIModel` Input set of sources source_names : list N...
python
def make_catalog_sources(catalog_roi_model, source_names): """Construct and return dictionary of sources that are a subset of sources in catalog_roi_model. Parameters ---------- catalog_roi_model : dict or `fermipy.roi_model.ROIModel` Input set of sources source_names : list N...
[ "def", "make_catalog_sources", "(", "catalog_roi_model", ",", "source_names", ")", ":", "sources", "=", "{", "}", "for", "source_name", "in", "source_names", ":", "sources", "[", "source_name", "]", "=", "catalog_roi_model", "[", "source_name", "]", "return", "s...
Construct and return dictionary of sources that are a subset of sources in catalog_roi_model. Parameters ---------- catalog_roi_model : dict or `fermipy.roi_model.ROIModel` Input set of sources source_names : list Names of sourcs to extract Returns dict mapping source_name to...
[ "Construct", "and", "return", "dictionary", "of", "sources", "that", "are", "a", "subset", "of", "sources", "in", "catalog_roi_model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L65-L83
fermiPy/fermipy
fermipy/diffuse/source_factory.py
make_sources
def make_sources(comp_key, comp_dict): """Make dictionary mapping component keys to a source or set of sources Parameters ---------- comp_key : str Key used to access sources comp_dict : dict Information used to build sources return `OrderedDict` maping comp_key to `fermi...
python
def make_sources(comp_key, comp_dict): """Make dictionary mapping component keys to a source or set of sources Parameters ---------- comp_key : str Key used to access sources comp_dict : dict Information used to build sources return `OrderedDict` maping comp_key to `fermi...
[ "def", "make_sources", "(", "comp_key", ",", "comp_dict", ")", ":", "srcdict", "=", "OrderedDict", "(", ")", "try", ":", "comp_info", "=", "comp_dict", ".", "info", "except", "AttributeError", ":", "comp_info", "=", "comp_dict", "try", ":", "spectrum", "=", ...
Make dictionary mapping component keys to a source or set of sources Parameters ---------- comp_key : str Key used to access sources comp_dict : dict Information used to build sources return `OrderedDict` maping comp_key to `fermipy.roi_model.Source`
[ "Make", "dictionary", "mapping", "component", "keys", "to", "a", "source", "or", "set", "of", "sources" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L86-L135
fermiPy/fermipy
fermipy/diffuse/source_factory.py
SourceFactory.add_sources
def add_sources(self, source_info_dict): """Add all of the sources in source_info_dict to this factory """ self._source_info_dict.update(source_info_dict) for key, value in source_info_dict.items(): self._sources.update(make_sources(key, value))
python
def add_sources(self, source_info_dict): """Add all of the sources in source_info_dict to this factory """ self._source_info_dict.update(source_info_dict) for key, value in source_info_dict.items(): self._sources.update(make_sources(key, value))
[ "def", "add_sources", "(", "self", ",", "source_info_dict", ")", ":", "self", ".", "_source_info_dict", ".", "update", "(", "source_info_dict", ")", "for", "key", ",", "value", "in", "source_info_dict", ".", "items", "(", ")", ":", "self", ".", "_sources", ...
Add all of the sources in source_info_dict to this factory
[ "Add", "all", "of", "the", "sources", "in", "source_info_dict", "to", "this", "factory" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L158-L163
fermiPy/fermipy
fermipy/diffuse/source_factory.py
SourceFactory.build_catalog
def build_catalog(**kwargs): """Build a `fermipy.catalog.Catalog` object Parameters ---------- catalog_type : str Specifies catalog type, options include 2FHL | 3FGL | 4FGLP catalog_file : str FITS file with catalog tables catalog_extdir : str ...
python
def build_catalog(**kwargs): """Build a `fermipy.catalog.Catalog` object Parameters ---------- catalog_type : str Specifies catalog type, options include 2FHL | 3FGL | 4FGLP catalog_file : str FITS file with catalog tables catalog_extdir : str ...
[ "def", "build_catalog", "(", "*", "*", "kwargs", ")", ":", "catalog_type", "=", "kwargs", ".", "get", "(", "'catalog_type'", ")", "catalog_file", "=", "kwargs", ".", "get", "(", "'catalog_file'", ")", "catalog_extdir", "=", "kwargs", ".", "get", "(", "'cat...
Build a `fermipy.catalog.Catalog` object Parameters ---------- catalog_type : str Specifies catalog type, options include 2FHL | 3FGL | 4FGLP catalog_file : str FITS file with catalog tables catalog_extdir : str Path to directory with extende...
[ "Build", "a", "fermipy", ".", "catalog", ".", "Catalog", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L166-L192
fermiPy/fermipy
fermipy/diffuse/source_factory.py
SourceFactory.make_fermipy_roi_model_from_catalogs
def make_fermipy_roi_model_from_catalogs(cataloglist): """Build and return a `fermipy.roi_model.ROIModel object from a list of fermipy.catalog.Catalog` objects """ data = dict(catalogs=cataloglist, src_roiwidth=360.) return roi_model.ROIModel(data, skydir=SkyC...
python
def make_fermipy_roi_model_from_catalogs(cataloglist): """Build and return a `fermipy.roi_model.ROIModel object from a list of fermipy.catalog.Catalog` objects """ data = dict(catalogs=cataloglist, src_roiwidth=360.) return roi_model.ROIModel(data, skydir=SkyC...
[ "def", "make_fermipy_roi_model_from_catalogs", "(", "cataloglist", ")", ":", "data", "=", "dict", "(", "catalogs", "=", "cataloglist", ",", "src_roiwidth", "=", "360.", ")", "return", "roi_model", ".", "ROIModel", "(", "data", ",", "skydir", "=", "SkyCoord", "...
Build and return a `fermipy.roi_model.ROIModel object from a list of fermipy.catalog.Catalog` objects
[ "Build", "and", "return", "a", "fermipy", ".", "roi_model", ".", "ROIModel", "object", "from", "a", "list", "of", "fermipy", ".", "catalog", ".", "Catalog", "objects" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L195-L201
fermiPy/fermipy
fermipy/diffuse/source_factory.py
SourceFactory.make_roi
def make_roi(cls, sources=None): """Build and return a `fermipy.roi_model.ROIModel` object from a dict with information about the sources """ if sources is None: sources = {} src_fact = cls() src_fact.add_sources(sources) ret_model = roi_model.ROIModel...
python
def make_roi(cls, sources=None): """Build and return a `fermipy.roi_model.ROIModel` object from a dict with information about the sources """ if sources is None: sources = {} src_fact = cls() src_fact.add_sources(sources) ret_model = roi_model.ROIModel...
[ "def", "make_roi", "(", "cls", ",", "sources", "=", "None", ")", ":", "if", "sources", "is", "None", ":", "sources", "=", "{", "}", "src_fact", "=", "cls", "(", ")", "src_fact", ".", "add_sources", "(", "sources", ")", "ret_model", "=", "roi_model", ...
Build and return a `fermipy.roi_model.ROIModel` object from a dict with information about the sources
[ "Build", "and", "return", "a", "fermipy", ".", "roi_model", ".", "ROIModel", "object", "from", "a", "dict", "with", "information", "about", "the", "sources" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L204-L217
fermiPy/fermipy
fermipy/diffuse/source_factory.py
SourceFactory.copy_selected_sources
def copy_selected_sources(cls, roi, source_names): """Build and return a `fermipy.roi_model.ROIModel` object by copying selected sources from another such object """ roi_new = cls.make_roi() for source_name in source_names: try: src_cp = roi.copy_sourc...
python
def copy_selected_sources(cls, roi, source_names): """Build and return a `fermipy.roi_model.ROIModel` object by copying selected sources from another such object """ roi_new = cls.make_roi() for source_name in source_names: try: src_cp = roi.copy_sourc...
[ "def", "copy_selected_sources", "(", "cls", ",", "roi", ",", "source_names", ")", ":", "roi_new", "=", "cls", ".", "make_roi", "(", ")", "for", "source_name", "in", "source_names", ":", "try", ":", "src_cp", "=", "roi", ".", "copy_source", "(", "source_nam...
Build and return a `fermipy.roi_model.ROIModel` object by copying selected sources from another such object
[ "Build", "and", "return", "a", "fermipy", ".", "roi_model", ".", "ROIModel", "object", "by", "copying", "selected", "sources", "from", "another", "such", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/source_factory.py#L220-L231
fermiPy/fermipy
fermipy/diffuse/timefilter.py
MktimeFilterDict.build_from_yamlfile
def build_from_yamlfile(yamlfile): """ Build a list of components from a yaml file """ d = yaml.load(open(yamlfile)) return MktimeFilterDict(d['aliases'], d['selections'])
python
def build_from_yamlfile(yamlfile): """ Build a list of components from a yaml file """ d = yaml.load(open(yamlfile)) return MktimeFilterDict(d['aliases'], d['selections'])
[ "def", "build_from_yamlfile", "(", "yamlfile", ")", ":", "d", "=", "yaml", ".", "load", "(", "open", "(", "yamlfile", ")", ")", "return", "MktimeFilterDict", "(", "d", "[", "'aliases'", "]", ",", "d", "[", "'selections'", "]", ")" ]
Build a list of components from a yaml file
[ "Build", "a", "list", "of", "components", "from", "a", "yaml", "file" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/timefilter.py#L39-L43
fermiPy/fermipy
fermipy/jobs/target_extension.py
AnalyzeExtension.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if is_not_null(args.roi_baseline): gta = GTAnalysis.create(args.ro...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if is_not_null(args.roi_baseline): gta = GTAnalysis.create(args.ro...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "if", "not", "HAVE_ST", ":", "raise", "RuntimeError", "(", "\"Trying to run fermipy analysis, but don't have ST\"", ")", "if", ...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_extension.py#L53-L72
fermiPy/fermipy
fermipy/scripts/dispatch.py
collect_jobs
def collect_jobs(dirs, runscript, overwrite=False, max_job_age=90): """Construct a list of job dictionaries.""" jobs = [] for dirname in sorted(dirs): o = dict(cfgfile=os.path.join(dirname, 'config.yaml'), logfile=os.path.join( dirname, os.path.splitext(runsc...
python
def collect_jobs(dirs, runscript, overwrite=False, max_job_age=90): """Construct a list of job dictionaries.""" jobs = [] for dirname in sorted(dirs): o = dict(cfgfile=os.path.join(dirname, 'config.yaml'), logfile=os.path.join( dirname, os.path.splitext(runsc...
[ "def", "collect_jobs", "(", "dirs", ",", "runscript", ",", "overwrite", "=", "False", ",", "max_job_age", "=", "90", ")", ":", "jobs", "=", "[", "]", "for", "dirname", "in", "sorted", "(", "dirs", ")", ":", "o", "=", "dict", "(", "cfgfile", "=", "o...
Construct a list of job dictionaries.
[ "Construct", "a", "list", "of", "job", "dictionaries", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/dispatch.py#L18-L58
fermiPy/fermipy
fermipy/srcmap_utils.py
make_srcmap_old
def make_srcmap_old(psf, spatial_model, sigma, npix=500, xpix=0.0, ypix=0.0, cdelt=0.01, rebin=1, psf_scale_fn=None): """Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` spatial_model : str Spatial model. sigma : ...
python
def make_srcmap_old(psf, spatial_model, sigma, npix=500, xpix=0.0, ypix=0.0, cdelt=0.01, rebin=1, psf_scale_fn=None): """Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` spatial_model : str Spatial model. sigma : ...
[ "def", "make_srcmap_old", "(", "psf", ",", "spatial_model", ",", "sigma", ",", "npix", "=", "500", ",", "xpix", "=", "0.0", ",", "ypix", "=", "0.0", ",", "cdelt", "=", "0.01", ",", "rebin", "=", "1", ",", "psf_scale_fn", "=", "None", ")", ":", "if"...
Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` spatial_model : str Spatial model. sigma : float Spatial size parameter for extended models. xpix : float Source position in pixel coordinates in X dimension. ypix ...
[ "Compute", "the", "source", "map", "for", "a", "given", "spatial", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L177-L222
fermiPy/fermipy
fermipy/srcmap_utils.py
make_srcmap
def make_srcmap(psf, exp, spatial_model, sigma, npix=500, xpix=0.0, ypix=0.0, cdelt=0.01, psf_scale_fn=None, klims=None, sparse=False): """Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` exp : `~numpy.ndarray` Array of ...
python
def make_srcmap(psf, exp, spatial_model, sigma, npix=500, xpix=0.0, ypix=0.0, cdelt=0.01, psf_scale_fn=None, klims=None, sparse=False): """Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` exp : `~numpy.ndarray` Array of ...
[ "def", "make_srcmap", "(", "psf", ",", "exp", ",", "spatial_model", ",", "sigma", ",", "npix", "=", "500", ",", "xpix", "=", "0.0", ",", "ypix", "=", "0.0", ",", "cdelt", "=", "0.01", ",", "psf_scale_fn", "=", "None", ",", "klims", "=", "None", ","...
Compute the source map for a given spatial model. Parameters ---------- psf : `~fermipy.irfs.PSFModel` exp : `~numpy.ndarray` Array of exposures. spatial_model : str Spatial model. sigma : float Spatial size parameter for extended models. xpix : float Sou...
[ "Compute", "the", "source", "map", "for", "a", "given", "spatial", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L225-L280
fermiPy/fermipy
fermipy/srcmap_utils.py
delete_source_map
def delete_source_map(srcmap_file, names, logger=None): """Delete a map from a binned analysis source map file if it exists. Parameters ---------- srcmap_file : str Path to the source map file. names : list List of HDU keys of source maps to be deleted. """ with fits.open(sr...
python
def delete_source_map(srcmap_file, names, logger=None): """Delete a map from a binned analysis source map file if it exists. Parameters ---------- srcmap_file : str Path to the source map file. names : list List of HDU keys of source maps to be deleted. """ with fits.open(sr...
[ "def", "delete_source_map", "(", "srcmap_file", ",", "names", ",", "logger", "=", "None", ")", ":", "with", "fits", ".", "open", "(", "srcmap_file", ")", "as", "hdulist", ":", "hdunames", "=", "[", "hdu", ".", "name", ".", "upper", "(", ")", "for", "...
Delete a map from a binned analysis source map file if it exists. Parameters ---------- srcmap_file : str Path to the source map file. names : list List of HDU keys of source maps to be deleted.
[ "Delete", "a", "map", "from", "a", "binned", "analysis", "source", "map", "file", "if", "it", "exists", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L380-L403
fermiPy/fermipy
fermipy/srcmap_utils.py
MapInterpolator.get_offsets
def get_offsets(self, pix): """Get offset of the first pixel in each dimension in the global coordinate system. Parameters ---------- pix : `~numpy.ndarray` Pixel coordinates in global coordinate system. """ idx = [] for i in range(self.ndim)...
python
def get_offsets(self, pix): """Get offset of the first pixel in each dimension in the global coordinate system. Parameters ---------- pix : `~numpy.ndarray` Pixel coordinates in global coordinate system. """ idx = [] for i in range(self.ndim)...
[ "def", "get_offsets", "(", "self", ",", "pix", ")", ":", "idx", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "ndim", ")", ":", "if", "i", "==", "0", ":", "idx", "+=", "[", "0", "]", "else", ":", "npix1", "=", "int", "(", "sel...
Get offset of the first pixel in each dimension in the global coordinate system. Parameters ---------- pix : `~numpy.ndarray` Pixel coordinates in global coordinate system.
[ "Get", "offset", "of", "the", "first", "pixel", "in", "each", "dimension", "in", "the", "global", "coordinate", "system", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L62-L82
fermiPy/fermipy
fermipy/srcmap_utils.py
MapInterpolator.shift_to_coords
def shift_to_coords(self, pix, fill_value=np.nan): """Create a new map that is shifted to the pixel coordinates ``pix``.""" pix_offset = self.get_offsets(pix) dpix = np.zeros(len(self.shape) - 1) for i in range(len(self.shape) - 1): x = self.rebin * (pix[i] - pix_off...
python
def shift_to_coords(self, pix, fill_value=np.nan): """Create a new map that is shifted to the pixel coordinates ``pix``.""" pix_offset = self.get_offsets(pix) dpix = np.zeros(len(self.shape) - 1) for i in range(len(self.shape) - 1): x = self.rebin * (pix[i] - pix_off...
[ "def", "shift_to_coords", "(", "self", ",", "pix", ",", "fill_value", "=", "np", ".", "nan", ")", ":", "pix_offset", "=", "self", ".", "get_offsets", "(", "pix", ")", "dpix", "=", "np", ".", "zeros", "(", "len", "(", "self", ".", "shape", ")", "-",...
Create a new map that is shifted to the pixel coordinates ``pix``.
[ "Create", "a", "new", "map", "that", "is", "shifted", "to", "the", "pixel", "coordinates", "pix", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L84-L112
fermiPy/fermipy
fermipy/srcmap_utils.py
SourceMapCache.create_map
def create_map(self, pix): """Create a new map with reference pixel coordinates shifted to the pixel coordinates ``pix``. Parameters ---------- pix : `~numpy.ndarray` Reference pixel of new map. Returns ------- out_map : `~numpy.ndarray` ...
python
def create_map(self, pix): """Create a new map with reference pixel coordinates shifted to the pixel coordinates ``pix``. Parameters ---------- pix : `~numpy.ndarray` Reference pixel of new map. Returns ------- out_map : `~numpy.ndarray` ...
[ "def", "create_map", "(", "self", ",", "pix", ")", ":", "k0", "=", "self", ".", "_m0", ".", "shift_to_coords", "(", "pix", ")", "k1", "=", "self", ".", "_m1", ".", "shift_to_coords", "(", "pix", ")", "k0", "[", "np", ".", "isfinite", "(", "k1", "...
Create a new map with reference pixel coordinates shifted to the pixel coordinates ``pix``. Parameters ---------- pix : `~numpy.ndarray` Reference pixel of new map. Returns ------- out_map : `~numpy.ndarray` The shifted map.
[ "Create", "a", "new", "map", "with", "reference", "pixel", "coordinates", "shifted", "to", "the", "pixel", "coordinates", "pix", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/srcmap_utils.py#L123-L142
fermiPy/fermipy
fermipy/version.py
render_pep440
def render_pep440(vcs): """Convert git release tag into a form that is PEP440 compliant.""" if vcs is None: return None tags = vcs.split('-') # Bare version number if len(tags) == 1: return tags[0] else: return tags[0] + '+' + '.'.join(tags[1:])
python
def render_pep440(vcs): """Convert git release tag into a form that is PEP440 compliant.""" if vcs is None: return None tags = vcs.split('-') # Bare version number if len(tags) == 1: return tags[0] else: return tags[0] + '+' + '.'.join(tags[1:])
[ "def", "render_pep440", "(", "vcs", ")", ":", "if", "vcs", "is", "None", ":", "return", "None", "tags", "=", "vcs", ".", "split", "(", "'-'", ")", "# Bare version number", "if", "len", "(", "tags", ")", "==", "1", ":", "return", "tags", "[", "0", "...
Convert git release tag into a form that is PEP440 compliant.
[ "Convert", "git", "release", "tag", "into", "a", "form", "that", "is", "PEP440", "compliant", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/version.py#L62-L74
fermiPy/fermipy
fermipy/version.py
read_release_version
def read_release_version(): """Read the release version from ``_version.py``.""" import re dirname = os.path.abspath(os.path.dirname(__file__)) try: f = open(os.path.join(dirname, "_version.py"), "rt") for line in f.readlines(): m = re.match("__version__ = '([^']+)'", line)...
python
def read_release_version(): """Read the release version from ``_version.py``.""" import re dirname = os.path.abspath(os.path.dirname(__file__)) try: f = open(os.path.join(dirname, "_version.py"), "rt") for line in f.readlines(): m = re.match("__version__ = '([^']+)'", line)...
[ "def", "read_release_version", "(", ")", ":", "import", "re", "dirname", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "try", ":", "f", "=", "open", "(", "os", ".", "path", ".", "join", ...
Read the release version from ``_version.py``.
[ "Read", "the", "release", "version", "from", "_version", ".", "py", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/version.py#L114-L131
fermiPy/fermipy
fermipy/version.py
write_release_version
def write_release_version(version): """Write the release version to ``_version.py``.""" dirname = os.path.abspath(os.path.dirname(__file__)) f = open(os.path.join(dirname, "_version.py"), "wt") f.write("__version__ = '%s'\n" % version) f.close()
python
def write_release_version(version): """Write the release version to ``_version.py``.""" dirname = os.path.abspath(os.path.dirname(__file__)) f = open(os.path.join(dirname, "_version.py"), "wt") f.write("__version__ = '%s'\n" % version) f.close()
[ "def", "write_release_version", "(", "version", ")", ":", "dirname", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "f", "=", "open", "(", "os", ".", "path", ".", "join", "(", "dirname", "...
Write the release version to ``_version.py``.
[ "Write", "the", "release", "version", "to", "_version", ".", "py", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/version.py#L134-L139
fermiPy/fermipy
fermipy/diffuse/gt_split_and_mktime.py
make_full_path
def make_full_path(basedir, outkey, origname): """Make a full file path by combining tokens Parameters ----------- basedir : str The top level output area outkey : str The key for the particular instance of the analysis origname : str Template for the output file name...
python
def make_full_path(basedir, outkey, origname): """Make a full file path by combining tokens Parameters ----------- basedir : str The top level output area outkey : str The key for the particular instance of the analysis origname : str Template for the output file name...
[ "def", "make_full_path", "(", "basedir", ",", "outkey", ",", "origname", ")", ":", "return", "os", ".", "path", ".", "join", "(", "basedir", ",", "outkey", ",", "os", ".", "path", ".", "basename", "(", "origname", ")", ".", "replace", "(", "'.fits'", ...
Make a full file path by combining tokens Parameters ----------- basedir : str The top level output area outkey : str The key for the particular instance of the analysis origname : str Template for the output file name Returns ------- outpath : str T...
[ "Make", "a", "full", "file", "path", "by", "combining", "tokens" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_split_and_mktime.py#L38-L63
fermiPy/fermipy
fermipy/diffuse/gt_split_and_mktime.py
SplitAndMktime._map_arguments
def _map_arguments(self, args): """Map from the top-level arguments to the arguments provided to the indiviudal links """ comp_file = args.get('comp', None) datafile = args.get('data', None) if is_null(comp_file): return if is_null(datafile): retur...
python
def _map_arguments(self, args): """Map from the top-level arguments to the arguments provided to the indiviudal links """ comp_file = args.get('comp', None) datafile = args.get('data', None) if is_null(comp_file): return if is_null(datafile): retur...
[ "def", "_map_arguments", "(", "self", ",", "args", ")", ":", "comp_file", "=", "args", ".", "get", "(", "'comp'", ",", "None", ")", "datafile", "=", "args", ".", "get", "(", "'data'", ",", "None", ")", "if", "is_null", "(", "comp_file", ")", ":", "...
Map from the top-level arguments to the arguments provided to the indiviudal links
[ "Map", "from", "the", "top", "-", "level", "arguments", "to", "the", "arguments", "provided", "to", "the", "indiviudal", "links" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_split_and_mktime.py#L113-L237
fermiPy/fermipy
fermipy/diffuse/gt_split_and_mktime.py
SplitAndMktime_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} comp_file = args.get('comp', None) if comp_file is not None: comp_dict = yaml.safe_load(open(comp_file)) coordsys = comp_dict.pop('coordsys') for v in ...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} comp_file = args.get('comp', None) if comp_file is not None: comp_dict = yaml.safe_load(open(comp_file)) coordsys = comp_dict.pop('coordsys') for v in ...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "comp_file", "=", "args", ".", "get", "(", "'comp'", ",", "None", ")", "if", "comp_file", "is", "not", "None", ":", "comp_dict", "=", "yaml", ".", "safe_load"...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_split_and_mktime.py#L261-L306
fermiPy/fermipy
fermipy/diffuse/gt_split_and_mktime.py
SplitAndMktimeChain._map_arguments
def _map_arguments(self, args): """Map from the top-level arguments to the arguments provided to the indiviudal links """ data = args.get('data') comp = args.get('comp') ft1file = args.get('ft1file') ft2file = args.get('ft2file') scratch = args.get('scratch', None...
python
def _map_arguments(self, args): """Map from the top-level arguments to the arguments provided to the indiviudal links """ data = args.get('data') comp = args.get('comp') ft1file = args.get('ft1file') ft2file = args.get('ft2file') scratch = args.get('scratch', None...
[ "def", "_map_arguments", "(", "self", ",", "args", ")", ":", "data", "=", "args", ".", "get", "(", "'data'", ")", "comp", "=", "args", ".", "get", "(", "'comp'", ")", "ft1file", "=", "args", ".", "get", "(", "'ft1file'", ")", "ft2file", "=", "args"...
Map from the top-level arguments to the arguments provided to the indiviudal links
[ "Map", "from", "the", "top", "-", "level", "arguments", "to", "the", "arguments", "provided", "to", "the", "indiviudal", "links" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_split_and_mktime.py#L350-L381
fermiPy/fermipy
fermipy/utils.py
init_matplotlib_backend
def init_matplotlib_backend(backend=None): """This function initializes the matplotlib backend. When no DISPLAY is available the backend is automatically set to 'Agg'. Parameters ---------- backend : str matplotlib backend name. """ import matplotlib try: os.environ['D...
python
def init_matplotlib_backend(backend=None): """This function initializes the matplotlib backend. When no DISPLAY is available the backend is automatically set to 'Agg'. Parameters ---------- backend : str matplotlib backend name. """ import matplotlib try: os.environ['D...
[ "def", "init_matplotlib_backend", "(", "backend", "=", "None", ")", ":", "import", "matplotlib", "try", ":", "os", ".", "environ", "[", "'DISPLAY'", "]", "except", "KeyError", ":", "matplotlib", ".", "use", "(", "'Agg'", ")", "else", ":", "if", "backend", ...
This function initializes the matplotlib backend. When no DISPLAY is available the backend is automatically set to 'Agg'. Parameters ---------- backend : str matplotlib backend name.
[ "This", "function", "initializes", "the", "matplotlib", "backend", ".", "When", "no", "DISPLAY", "is", "available", "the", "backend", "is", "automatically", "set", "to", "Agg", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L22-L40
fermiPy/fermipy
fermipy/utils.py
load_data
def load_data(infile, workdir=None): """Load python data structure from either a YAML or numpy file. """ infile = resolve_path(infile, workdir=workdir) infile, ext = os.path.splitext(infile) if os.path.isfile(infile + '.npy'): infile += '.npy' elif os.path.isfile(infile + '.yaml'): ...
python
def load_data(infile, workdir=None): """Load python data structure from either a YAML or numpy file. """ infile = resolve_path(infile, workdir=workdir) infile, ext = os.path.splitext(infile) if os.path.isfile(infile + '.npy'): infile += '.npy' elif os.path.isfile(infile + '.yaml'): ...
[ "def", "load_data", "(", "infile", ",", "workdir", "=", "None", ")", ":", "infile", "=", "resolve_path", "(", "infile", ",", "workdir", "=", "workdir", ")", "infile", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "infile", ")", "if", "os"...
Load python data structure from either a YAML or numpy file.
[ "Load", "python", "data", "structure", "from", "either", "a", "YAML", "or", "numpy", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L63-L82
fermiPy/fermipy
fermipy/utils.py
resolve_file_path_list
def resolve_file_path_list(pathlist, workdir, prefix='', randomize=False): """Resolve the path of each file name in the file ``pathlist`` and write the updated paths to a new file. """ files = [] with open(pathlist, 'r') as f: files = [line.strip() for line in f] ...
python
def resolve_file_path_list(pathlist, workdir, prefix='', randomize=False): """Resolve the path of each file name in the file ``pathlist`` and write the updated paths to a new file. """ files = [] with open(pathlist, 'r') as f: files = [line.strip() for line in f] ...
[ "def", "resolve_file_path_list", "(", "pathlist", ",", "workdir", ",", "prefix", "=", "''", ",", "randomize", "=", "False", ")", ":", "files", "=", "[", "]", "with", "open", "(", "pathlist", ",", "'r'", ")", "as", "f", ":", "files", "=", "[", "line",...
Resolve the path of each file name in the file ``pathlist`` and write the updated paths to a new file.
[ "Resolve", "the", "path", "of", "each", "file", "name", "in", "the", "file", "pathlist", "and", "write", "the", "updated", "paths", "to", "a", "new", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L123-L149
fermiPy/fermipy
fermipy/utils.py
collect_dirs
def collect_dirs(path, max_depth=1, followlinks=True): """Recursively find directories under the given path.""" if not os.path.isdir(path): return [] o = [path] if max_depth == 0: return o for subdir in os.listdir(path): subdir = os.path.join(path, subdir) if no...
python
def collect_dirs(path, max_depth=1, followlinks=True): """Recursively find directories under the given path.""" if not os.path.isdir(path): return [] o = [path] if max_depth == 0: return o for subdir in os.listdir(path): subdir = os.path.join(path, subdir) if no...
[ "def", "collect_dirs", "(", "path", ",", "max_depth", "=", "1", ",", "followlinks", "=", "True", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "[", "]", "o", "=", "[", "path", "]", "if", "max_depth", "==...
Recursively find directories under the given path.
[ "Recursively", "find", "directories", "under", "the", "given", "path", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L161-L187
fermiPy/fermipy
fermipy/utils.py
match_regex_list
def match_regex_list(patterns, string): """Perform a regex match of a string against a list of patterns. Returns true if the string matches at least one pattern in the list.""" for p in patterns: if re.findall(p, string): return True return False
python
def match_regex_list(patterns, string): """Perform a regex match of a string against a list of patterns. Returns true if the string matches at least one pattern in the list.""" for p in patterns: if re.findall(p, string): return True return False
[ "def", "match_regex_list", "(", "patterns", ",", "string", ")", ":", "for", "p", "in", "patterns", ":", "if", "re", ".", "findall", "(", "p", ",", "string", ")", ":", "return", "True", "return", "False" ]
Perform a regex match of a string against a list of patterns. Returns true if the string matches at least one pattern in the list.
[ "Perform", "a", "regex", "match", "of", "a", "string", "against", "a", "list", "of", "patterns", ".", "Returns", "true", "if", "the", "string", "matches", "at", "least", "one", "pattern", "in", "the", "list", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L190-L200
fermiPy/fermipy
fermipy/utils.py
find_rows_by_string
def find_rows_by_string(tab, names, colnames=['assoc']): """Find the rows in a table ``tab`` that match at least one of the strings in ``names``. This method ignores whitespace and case when matching strings. Parameters ---------- tab : `astropy.table.Table` Table that will be searched....
python
def find_rows_by_string(tab, names, colnames=['assoc']): """Find the rows in a table ``tab`` that match at least one of the strings in ``names``. This method ignores whitespace and case when matching strings. Parameters ---------- tab : `astropy.table.Table` Table that will be searched....
[ "def", "find_rows_by_string", "(", "tab", ",", "names", ",", "colnames", "=", "[", "'assoc'", "]", ")", ":", "mask", "=", "np", ".", "empty", "(", "len", "(", "tab", ")", ",", "dtype", "=", "bool", ")", "mask", ".", "fill", "(", "False", ")", "na...
Find the rows in a table ``tab`` that match at least one of the strings in ``names``. This method ignores whitespace and case when matching strings. Parameters ---------- tab : `astropy.table.Table` Table that will be searched. names : list List of strings. colname : str ...
[ "Find", "the", "rows", "in", "a", "table", "tab", "that", "match", "at", "least", "one", "of", "the", "strings", "in", "names", ".", "This", "method", "ignores", "whitespace", "and", "case", "when", "matching", "strings", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L203-L239