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/utils.py
project
def project(lon0, lat0, lon1, lat1): """This function performs a stereographic projection on the unit vector (lon1,lat1) with the pole defined at the reference unit vector (lon0,lat0).""" costh = np.cos(np.pi / 2. - lat0) cosphi = np.cos(lon0) sinth = np.sin(np.pi / 2. - lat0) sinphi = np....
python
def project(lon0, lat0, lon1, lat1): """This function performs a stereographic projection on the unit vector (lon1,lat1) with the pole defined at the reference unit vector (lon0,lat0).""" costh = np.cos(np.pi / 2. - lat0) cosphi = np.cos(lon0) sinth = np.sin(np.pi / 2. - lat0) sinphi = np....
[ "def", "project", "(", "lon0", ",", "lat0", ",", "lon1", ",", "lat1", ")", ":", "costh", "=", "np", ".", "cos", "(", "np", ".", "pi", "/", "2.", "-", "lat0", ")", "cosphi", "=", "np", ".", "cos", "(", "lon0", ")", "sinth", "=", "np", ".", "...
This function performs a stereographic projection on the unit vector (lon1,lat1) with the pole defined at the reference unit vector (lon0,lat0).
[ "This", "function", "performs", "a", "stereographic", "projection", "on", "the", "unit", "vector", "(", "lon1", "lat1", ")", "with", "the", "pole", "defined", "at", "the", "reference", "unit", "vector", "(", "lon0", "lat0", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L368-L391
fermiPy/fermipy
fermipy/utils.py
separation_cos_angle
def separation_cos_angle(lon0, lat0, lon1, lat1): """Evaluate the cosine of the angular separation between two direction vectors.""" return (np.sin(lat1) * np.sin(lat0) + np.cos(lat1) * np.cos(lat0) * np.cos(lon1 - lon0))
python
def separation_cos_angle(lon0, lat0, lon1, lat1): """Evaluate the cosine of the angular separation between two direction vectors.""" return (np.sin(lat1) * np.sin(lat0) + np.cos(lat1) * np.cos(lat0) * np.cos(lon1 - lon0))
[ "def", "separation_cos_angle", "(", "lon0", ",", "lat0", ",", "lon1", ",", "lat1", ")", ":", "return", "(", "np", ".", "sin", "(", "lat1", ")", "*", "np", ".", "sin", "(", "lat0", ")", "+", "np", ".", "cos", "(", "lat1", ")", "*", "np", ".", ...
Evaluate the cosine of the angular separation between two direction vectors.
[ "Evaluate", "the", "cosine", "of", "the", "angular", "separation", "between", "two", "direction", "vectors", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L394-L398
fermiPy/fermipy
fermipy/utils.py
angle_to_cartesian
def angle_to_cartesian(lon, lat): """Convert spherical coordinates to cartesian unit vectors.""" theta = np.array(np.pi / 2. - lat) return np.vstack((np.sin(theta) * np.cos(lon), np.sin(theta) * np.sin(lon), np.cos(theta))).T
python
def angle_to_cartesian(lon, lat): """Convert spherical coordinates to cartesian unit vectors.""" theta = np.array(np.pi / 2. - lat) return np.vstack((np.sin(theta) * np.cos(lon), np.sin(theta) * np.sin(lon), np.cos(theta))).T
[ "def", "angle_to_cartesian", "(", "lon", ",", "lat", ")", ":", "theta", "=", "np", ".", "array", "(", "np", ".", "pi", "/", "2.", "-", "lat", ")", "return", "np", ".", "vstack", "(", "(", "np", ".", "sin", "(", "theta", ")", "*", "np", ".", "...
Convert spherical coordinates to cartesian unit vectors.
[ "Convert", "spherical", "coordinates", "to", "cartesian", "unit", "vectors", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L407-L412
fermiPy/fermipy
fermipy/utils.py
create_model_name
def create_model_name(src): """Generate a name for a source object given its spatial/spectral properties. Parameters ---------- src : `~fermipy.roi_model.Source` A source object. Returns ------- name : str A source name. """ o = '' spatial_type = src['S...
python
def create_model_name(src): """Generate a name for a source object given its spatial/spectral properties. Parameters ---------- src : `~fermipy.roi_model.Source` A source object. Returns ------- name : str A source name. """ o = '' spatial_type = src['S...
[ "def", "create_model_name", "(", "src", ")", ":", "o", "=", "''", "spatial_type", "=", "src", "[", "'SpatialModel'", "]", ".", "lower", "(", ")", "o", "+=", "spatial_type", "if", "spatial_type", "==", "'gaussian'", ":", "o", "+=", "'_s%04.2f'", "%", "src...
Generate a name for a source object given its spatial/spectral properties. Parameters ---------- src : `~fermipy.roi_model.Source` A source object. Returns ------- name : str A source name.
[ "Generate", "a", "name", "for", "a", "source", "object", "given", "its", "spatial", "/", "spectral", "properties", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L466-L492
fermiPy/fermipy
fermipy/utils.py
cov_to_correlation
def cov_to_correlation(cov): """Compute the correlation matrix given the covariance matrix. Parameters ---------- cov : `~numpy.ndarray` N x N matrix of covariances among N parameters. Returns ------- corr : `~numpy.ndarray` N x N matrix of correlations among N parameters. ...
python
def cov_to_correlation(cov): """Compute the correlation matrix given the covariance matrix. Parameters ---------- cov : `~numpy.ndarray` N x N matrix of covariances among N parameters. Returns ------- corr : `~numpy.ndarray` N x N matrix of correlations among N parameters. ...
[ "def", "cov_to_correlation", "(", "cov", ")", ":", "err", "=", "np", ".", "sqrt", "(", "np", ".", "diag", "(", "cov", ")", ")", "errinv", "=", "np", ".", "ones_like", "(", "err", ")", "*", "np", ".", "nan", "m", "=", "np", ".", "isfinite", "(",...
Compute the correlation matrix given the covariance matrix. Parameters ---------- cov : `~numpy.ndarray` N x N matrix of covariances among N parameters. Returns ------- corr : `~numpy.ndarray` N x N matrix of correlations among N parameters.
[ "Compute", "the", "correlation", "matrix", "given", "the", "covariance", "matrix", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L495-L513
fermiPy/fermipy
fermipy/utils.py
ellipse_to_cov
def ellipse_to_cov(sigma_maj, sigma_min, theta): """Compute the covariance matrix in two variables x and y given the std. deviation along the semi-major and semi-minor axes and the rotation angle of the error ellipse. Parameters ---------- sigma_maj : float Std. deviation along major ax...
python
def ellipse_to_cov(sigma_maj, sigma_min, theta): """Compute the covariance matrix in two variables x and y given the std. deviation along the semi-major and semi-minor axes and the rotation angle of the error ellipse. Parameters ---------- sigma_maj : float Std. deviation along major ax...
[ "def", "ellipse_to_cov", "(", "sigma_maj", ",", "sigma_min", ",", "theta", ")", ":", "cth", "=", "np", ".", "cos", "(", "theta", ")", "sth", "=", "np", ".", "sin", "(", "theta", ")", "covxx", "=", "cth", "**", "2", "*", "sigma_maj", "**", "2", "+...
Compute the covariance matrix in two variables x and y given the std. deviation along the semi-major and semi-minor axes and the rotation angle of the error ellipse. Parameters ---------- sigma_maj : float Std. deviation along major axis of error ellipse. sigma_min : float Std....
[ "Compute", "the", "covariance", "matrix", "in", "two", "variables", "x", "and", "y", "given", "the", "std", ".", "deviation", "along", "the", "semi", "-", "major", "and", "semi", "-", "minor", "axes", "and", "the", "rotation", "angle", "of", "the", "erro...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L516-L537
fermiPy/fermipy
fermipy/utils.py
onesided_cl_to_dlnl
def onesided_cl_to_dlnl(cl): """Compute the delta-loglikehood values that corresponds to an upper limit of the given confidence level. Parameters ---------- cl : float Confidence level. Returns ------- dlnl : float Delta-loglikelihood value with respect to the maximum o...
python
def onesided_cl_to_dlnl(cl): """Compute the delta-loglikehood values that corresponds to an upper limit of the given confidence level. Parameters ---------- cl : float Confidence level. Returns ------- dlnl : float Delta-loglikelihood value with respect to the maximum o...
[ "def", "onesided_cl_to_dlnl", "(", "cl", ")", ":", "alpha", "=", "1.0", "-", "cl", "return", "0.5", "*", "np", ".", "power", "(", "np", ".", "sqrt", "(", "2.", ")", "*", "special", ".", "erfinv", "(", "1", "-", "2", "*", "alpha", ")", ",", "2."...
Compute the delta-loglikehood values that corresponds to an upper limit of the given confidence level. Parameters ---------- cl : float Confidence level. Returns ------- dlnl : float Delta-loglikelihood value with respect to the maximum of the likelihood function.
[ "Compute", "the", "delta", "-", "loglikehood", "values", "that", "corresponds", "to", "an", "upper", "limit", "of", "the", "given", "confidence", "level", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L576-L592
fermiPy/fermipy
fermipy/utils.py
find_function_root
def find_function_root(fn, x0, xb, delta=0.0, bounds=None): """Find the root of a function: f(x)+delta in the interval encompassed by x0 and xb. Parameters ---------- fn : function Python function. x0 : float Fixed bound for the root search. This will either be used as t...
python
def find_function_root(fn, x0, xb, delta=0.0, bounds=None): """Find the root of a function: f(x)+delta in the interval encompassed by x0 and xb. Parameters ---------- fn : function Python function. x0 : float Fixed bound for the root search. This will either be used as t...
[ "def", "find_function_root", "(", "fn", ",", "x0", ",", "xb", ",", "delta", "=", "0.0", ",", "bounds", "=", "None", ")", ":", "if", "x0", "==", "xb", ":", "return", "np", ".", "nan", "for", "i", "in", "range", "(", "10", ")", ":", "if", "np", ...
Find the root of a function: f(x)+delta in the interval encompassed by x0 and xb. Parameters ---------- fn : function Python function. x0 : float Fixed bound for the root search. This will either be used as the lower or upper bound depending on the relative value of xb. ...
[ "Find", "the", "root", "of", "a", "function", ":", "f", "(", "x", ")", "+", "delta", "in", "the", "interval", "encompassed", "by", "x0", "and", "xb", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L634-L677
fermiPy/fermipy
fermipy/utils.py
get_parameter_limits
def get_parameter_limits(xval, loglike, cl_limit=0.95, cl_err=0.68269, tol=1E-2, bounds=None): """Compute upper/lower limits, peak position, and 1-sigma errors from a 1-D likelihood function. This function uses the delta-loglikelihood method to evaluate parameter limits by sear...
python
def get_parameter_limits(xval, loglike, cl_limit=0.95, cl_err=0.68269, tol=1E-2, bounds=None): """Compute upper/lower limits, peak position, and 1-sigma errors from a 1-D likelihood function. This function uses the delta-loglikelihood method to evaluate parameter limits by sear...
[ "def", "get_parameter_limits", "(", "xval", ",", "loglike", ",", "cl_limit", "=", "0.95", ",", "cl_err", "=", "0.68269", ",", "tol", "=", "1E-2", ",", "bounds", "=", "None", ")", ":", "dlnl_limit", "=", "onesided_cl_to_dlnl", "(", "cl_limit", ")", "dlnl_er...
Compute upper/lower limits, peak position, and 1-sigma errors from a 1-D likelihood function. This function uses the delta-loglikelihood method to evaluate parameter limits by searching for the point at which the change in the log-likelihood value with respect to the maximum equals a specific value. A...
[ "Compute", "upper", "/", "lower", "limits", "peak", "position", "and", "1", "-", "sigma", "errors", "from", "a", "1", "-", "D", "likelihood", "function", ".", "This", "function", "uses", "the", "delta", "-", "loglikelihood", "method", "to", "evaluate", "pa...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L680-L821
fermiPy/fermipy
fermipy/utils.py
parabola
def parabola(xy, amplitude, x0, y0, sx, sy, theta): """Evaluate a 2D parabola given by: f(x,y) = f_0 - (1/2) * \delta^T * R * \Sigma * R^T * \delta where \delta = [(x - x_0), (y - y_0)] and R is the matrix for a 2D rotation by angle \theta and \Sigma is the covariance matrix: \Sigma = [...
python
def parabola(xy, amplitude, x0, y0, sx, sy, theta): """Evaluate a 2D parabola given by: f(x,y) = f_0 - (1/2) * \delta^T * R * \Sigma * R^T * \delta where \delta = [(x - x_0), (y - y_0)] and R is the matrix for a 2D rotation by angle \theta and \Sigma is the covariance matrix: \Sigma = [...
[ "def", "parabola", "(", "xy", ",", "amplitude", ",", "x0", ",", "y0", ",", "sx", ",", "sy", ",", "theta", ")", ":", "x", "=", "xy", "[", "0", "]", "y", "=", "xy", "[", "1", "]", "cth", "=", "np", ".", "cos", "(", "theta", ")", "sth", "=",...
Evaluate a 2D parabola given by: f(x,y) = f_0 - (1/2) * \delta^T * R * \Sigma * R^T * \delta where \delta = [(x - x_0), (y - y_0)] and R is the matrix for a 2D rotation by angle \theta and \Sigma is the covariance matrix: \Sigma = [[1/\sigma_x^2, 0 ], [0 , ...
[ "Evaluate", "a", "2D", "parabola", "given", "by", ":" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L832-L892
fermiPy/fermipy
fermipy/utils.py
get_region_mask
def get_region_mask(z, delta, xy=None): """Get mask of connected region within delta of max(z).""" if xy is None: ix, iy = np.unravel_index(np.argmax(z), z.shape) else: ix, iy = xy mz = (z > z[ix, iy] - delta) labels = label(mz)[0] mz &= labels == labels[ix, iy] return mz
python
def get_region_mask(z, delta, xy=None): """Get mask of connected region within delta of max(z).""" if xy is None: ix, iy = np.unravel_index(np.argmax(z), z.shape) else: ix, iy = xy mz = (z > z[ix, iy] - delta) labels = label(mz)[0] mz &= labels == labels[ix, iy] return mz
[ "def", "get_region_mask", "(", "z", ",", "delta", ",", "xy", "=", "None", ")", ":", "if", "xy", "is", "None", ":", "ix", ",", "iy", "=", "np", ".", "unravel_index", "(", "np", ".", "argmax", "(", "z", ")", ",", "z", ".", "shape", ")", "else", ...
Get mask of connected region within delta of max(z).
[ "Get", "mask", "of", "connected", "region", "within", "delta", "of", "max", "(", "z", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L911-L922
fermiPy/fermipy
fermipy/utils.py
fit_parabola
def fit_parabola(z, ix, iy, dpix=3, zmin=None): """Fit a parabola to a 2D numpy array. This function will fit a parabola with the functional form described in `~fermipy.utils.parabola` to a 2D slice of the input array `z`. The fit region encompasses pixels that are within `dpix` of the pixel coordi...
python
def fit_parabola(z, ix, iy, dpix=3, zmin=None): """Fit a parabola to a 2D numpy array. This function will fit a parabola with the functional form described in `~fermipy.utils.parabola` to a 2D slice of the input array `z`. The fit region encompasses pixels that are within `dpix` of the pixel coordi...
[ "def", "fit_parabola", "(", "z", ",", "ix", ",", "iy", ",", "dpix", "=", "3", ",", "zmin", "=", "None", ")", ":", "offset", "=", "make_pixel_distance", "(", "z", ".", "shape", ",", "iy", ",", "ix", ")", "x", ",", "y", "=", "np", ".", "meshgrid"...
Fit a parabola to a 2D numpy array. This function will fit a parabola with the functional form described in `~fermipy.utils.parabola` to a 2D slice of the input array `z`. The fit region encompasses pixels that are within `dpix` of the pixel coordinate (iz,iy) OR that have a value relative to the peak ...
[ "Fit", "a", "parabola", "to", "a", "2D", "numpy", "array", ".", "This", "function", "will", "fit", "a", "parabola", "with", "the", "functional", "form", "described", "in", "~fermipy", ".", "utils", ".", "parabola", "to", "a", "2D", "slice", "of", "the", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L925-L1007
fermiPy/fermipy
fermipy/utils.py
split_bin_edges
def split_bin_edges(edges, npts=2): """Subdivide an array of bins by splitting each bin into ``npts`` subintervals. Parameters ---------- edges : `~numpy.ndarray` Bin edge array. npts : int Number of intervals into which each bin will be subdivided. Returns ------- ...
python
def split_bin_edges(edges, npts=2): """Subdivide an array of bins by splitting each bin into ``npts`` subintervals. Parameters ---------- edges : `~numpy.ndarray` Bin edge array. npts : int Number of intervals into which each bin will be subdivided. Returns ------- ...
[ "def", "split_bin_edges", "(", "edges", ",", "npts", "=", "2", ")", ":", "if", "npts", "<", "2", ":", "return", "edges", "x", "=", "(", "edges", "[", ":", "-", "1", ",", "None", "]", "+", "(", "edges", "[", "1", ":", ",", "None", "]", "-", ...
Subdivide an array of bins by splitting each bin into ``npts`` subintervals. Parameters ---------- edges : `~numpy.ndarray` Bin edge array. npts : int Number of intervals into which each bin will be subdivided. Returns ------- edges : `~numpy.ndarray` Subdivide...
[ "Subdivide", "an", "array", "of", "bins", "by", "splitting", "each", "bin", "into", "npts", "subintervals", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1010-L1034
fermiPy/fermipy
fermipy/utils.py
val_to_bin
def val_to_bin(edges, x): """Convert axis coordinate to bin index.""" ibin = np.digitize(np.array(x, ndmin=1), edges) - 1 return ibin
python
def val_to_bin(edges, x): """Convert axis coordinate to bin index.""" ibin = np.digitize(np.array(x, ndmin=1), edges) - 1 return ibin
[ "def", "val_to_bin", "(", "edges", ",", "x", ")", ":", "ibin", "=", "np", ".", "digitize", "(", "np", ".", "array", "(", "x", ",", "ndmin", "=", "1", ")", ",", "edges", ")", "-", "1", "return", "ibin" ]
Convert axis coordinate to bin index.
[ "Convert", "axis", "coordinate", "to", "bin", "index", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1058-L1061
fermiPy/fermipy
fermipy/utils.py
val_to_edge
def val_to_edge(edges, x): """Convert axis coordinate to bin index.""" edges = np.array(edges) w = edges[1:] - edges[:-1] w = np.insert(w, 0, w[0]) ibin = np.digitize(np.array(x, ndmin=1), edges - 0.5 * w) - 1 ibin[ibin < 0] = 0 return ibin
python
def val_to_edge(edges, x): """Convert axis coordinate to bin index.""" edges = np.array(edges) w = edges[1:] - edges[:-1] w = np.insert(w, 0, w[0]) ibin = np.digitize(np.array(x, ndmin=1), edges - 0.5 * w) - 1 ibin[ibin < 0] = 0 return ibin
[ "def", "val_to_edge", "(", "edges", ",", "x", ")", ":", "edges", "=", "np", ".", "array", "(", "edges", ")", "w", "=", "edges", "[", "1", ":", "]", "-", "edges", "[", ":", "-", "1", "]", "w", "=", "np", ".", "insert", "(", "w", ",", "0", ...
Convert axis coordinate to bin index.
[ "Convert", "axis", "coordinate", "to", "bin", "index", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1068-L1075
fermiPy/fermipy
fermipy/utils.py
val_to_bin_bounded
def val_to_bin_bounded(edges, x): """Convert axis coordinate to bin index.""" nbins = len(edges) - 1 ibin = val_to_bin(edges, x) ibin[ibin < 0] = 0 ibin[ibin > nbins - 1] = nbins - 1 return ibin
python
def val_to_bin_bounded(edges, x): """Convert axis coordinate to bin index.""" nbins = len(edges) - 1 ibin = val_to_bin(edges, x) ibin[ibin < 0] = 0 ibin[ibin > nbins - 1] = nbins - 1 return ibin
[ "def", "val_to_bin_bounded", "(", "edges", ",", "x", ")", ":", "nbins", "=", "len", "(", "edges", ")", "-", "1", "ibin", "=", "val_to_bin", "(", "edges", ",", "x", ")", "ibin", "[", "ibin", "<", "0", "]", "=", "0", "ibin", "[", "ibin", ">", "nb...
Convert axis coordinate to bin index.
[ "Convert", "axis", "coordinate", "to", "bin", "index", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1078-L1084
fermiPy/fermipy
fermipy/utils.py
extend_array
def extend_array(edges, binsz, lo, hi): """Extend an array to encompass lo and hi values.""" numlo = int(np.ceil((edges[0] - lo) / binsz)) numhi = int(np.ceil((hi - edges[-1]) / binsz)) edges = copy.deepcopy(edges) if numlo > 0: edges_lo = np.linspace(edges[0] - numlo * binsz, edges[0], nu...
python
def extend_array(edges, binsz, lo, hi): """Extend an array to encompass lo and hi values.""" numlo = int(np.ceil((edges[0] - lo) / binsz)) numhi = int(np.ceil((hi - edges[-1]) / binsz)) edges = copy.deepcopy(edges) if numlo > 0: edges_lo = np.linspace(edges[0] - numlo * binsz, edges[0], nu...
[ "def", "extend_array", "(", "edges", ",", "binsz", ",", "lo", ",", "hi", ")", ":", "numlo", "=", "int", "(", "np", ".", "ceil", "(", "(", "edges", "[", "0", "]", "-", "lo", ")", "/", "binsz", ")", ")", "numhi", "=", "int", "(", "np", ".", "...
Extend an array to encompass lo and hi values.
[ "Extend", "an", "array", "to", "encompass", "lo", "and", "hi", "values", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1087-L1102
fermiPy/fermipy
fermipy/utils.py
fits_recarray_to_dict
def fits_recarray_to_dict(table): """Convert a FITS recarray to a python dictionary.""" cols = {} for icol, col in enumerate(table.columns.names): col_data = table.data[col] if type(col_data[0]) == np.float32: cols[col] = np.array(col_data, dtype=float) elif type(col_da...
python
def fits_recarray_to_dict(table): """Convert a FITS recarray to a python dictionary.""" cols = {} for icol, col in enumerate(table.columns.names): col_data = table.data[col] if type(col_data[0]) == np.float32: cols[col] = np.array(col_data, dtype=float) elif type(col_da...
[ "def", "fits_recarray_to_dict", "(", "table", ")", ":", "cols", "=", "{", "}", "for", "icol", ",", "col", "in", "enumerate", "(", "table", ".", "columns", ".", "names", ")", ":", "col_data", "=", "table", ".", "data", "[", "col", "]", "if", "type", ...
Convert a FITS recarray to a python dictionary.
[ "Convert", "a", "FITS", "recarray", "to", "a", "python", "dictionary", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1111-L1134
fermiPy/fermipy
fermipy/utils.py
prettify_xml
def prettify_xml(elem): """Return a pretty-printed XML string for the Element. """ from xml.dom import minidom import xml.etree.cElementTree as et rough_string = et.tostring(elem, 'utf-8') reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ")
python
def prettify_xml(elem): """Return a pretty-printed XML string for the Element. """ from xml.dom import minidom import xml.etree.cElementTree as et rough_string = et.tostring(elem, 'utf-8') reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ")
[ "def", "prettify_xml", "(", "elem", ")", ":", "from", "xml", ".", "dom", "import", "minidom", "import", "xml", ".", "etree", ".", "cElementTree", "as", "et", "rough_string", "=", "et", ".", "tostring", "(", "elem", ",", "'utf-8'", ")", "reparsed", "=", ...
Return a pretty-printed XML string for the Element.
[ "Return", "a", "pretty", "-", "printed", "XML", "string", "for", "the", "Element", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1198-L1206
fermiPy/fermipy
fermipy/utils.py
merge_dict
def merge_dict(d0, d1, add_new_keys=False, append_arrays=False): """Recursively merge the contents of python dictionary d0 with the contents of another python dictionary, d1. Parameters ---------- d0 : dict The input dictionary. d1 : dict Dictionary to be merged with the input di...
python
def merge_dict(d0, d1, add_new_keys=False, append_arrays=False): """Recursively merge the contents of python dictionary d0 with the contents of another python dictionary, d1. Parameters ---------- d0 : dict The input dictionary. d1 : dict Dictionary to be merged with the input di...
[ "def", "merge_dict", "(", "d0", ",", "d1", ",", "add_new_keys", "=", "False", ",", "append_arrays", "=", "False", ")", ":", "if", "d1", "is", "None", ":", "return", "d0", "elif", "d0", "is", "None", ":", "return", "d1", "elif", "d0", "is", "None", ...
Recursively merge the contents of python dictionary d0 with the contents of another python dictionary, d1. Parameters ---------- d0 : dict The input dictionary. d1 : dict Dictionary to be merged with the input dictionary. add_new_keys : str Do not skip keys that only exis...
[ "Recursively", "merge", "the", "contents", "of", "python", "dictionary", "d0", "with", "the", "contents", "of", "another", "python", "dictionary", "d1", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1239-L1302
fermiPy/fermipy
fermipy/utils.py
tolist
def tolist(x): """ convenience function that takes in a nested structure of lists and dictionaries and converts everything to its base objects. This is useful for dupming a file to yaml. (a) numpy arrays into python lists >>> type(tolist(np.asarray(123))) == int ...
python
def tolist(x): """ convenience function that takes in a nested structure of lists and dictionaries and converts everything to its base objects. This is useful for dupming a file to yaml. (a) numpy arrays into python lists >>> type(tolist(np.asarray(123))) == int ...
[ "def", "tolist", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "list", ")", ":", "return", "map", "(", "tolist", ",", "x", ")", "elif", "isinstance", "(", "x", ",", "dict", ")", ":", "return", "dict", "(", "(", "tolist", "(", "k", ")",...
convenience function that takes in a nested structure of lists and dictionaries and converts everything to its base objects. This is useful for dupming a file to yaml. (a) numpy arrays into python lists >>> type(tolist(np.asarray(123))) == int True >...
[ "convenience", "function", "that", "takes", "in", "a", "nested", "structure", "of", "lists", "and", "dictionaries", "and", "converts", "everything", "to", "its", "base", "objects", ".", "This", "is", "useful", "for", "dupming", "a", "file", "to", "yaml", "."...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1316-L1383
fermiPy/fermipy
fermipy/utils.py
convolve2d_disk
def convolve2d_disk(fn, r, sig, nstep=200): """Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a step function given by: g(r) = H(1-r/s) Parameters ---------- fn : function Input function that takes a single radial...
python
def convolve2d_disk(fn, r, sig, nstep=200): """Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a step function given by: g(r) = H(1-r/s) Parameters ---------- fn : function Input function that takes a single radial...
[ "def", "convolve2d_disk", "(", "fn", ",", "r", ",", "sig", ",", "nstep", "=", "200", ")", ":", "r", "=", "np", ".", "array", "(", "r", ",", "ndmin", "=", "1", ")", "sig", "=", "np", ".", "array", "(", "sig", ",", "ndmin", "=", "1", ")", "rm...
Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a step function given by: g(r) = H(1-r/s) Parameters ---------- fn : function Input function that takes a single radial coordinate parameter. r : `~numpy.ndarray` ...
[ "Evaluate", "the", "convolution", "f", "(", "r", ")", "=", "f", "(", "r", ")", "*", "g", "(", "r", ")", "where", "f", "(", "r", ")", "is", "azimuthally", "symmetric", "function", "in", "two", "dimensions", "and", "g", "is", "a", "step", "function",...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1409-L1457
fermiPy/fermipy
fermipy/utils.py
convolve2d_gauss
def convolve2d_gauss(fn, r, sig, nstep=200): """Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a 2D gaussian with standard deviation s given by: g(r) = 1/(2*pi*s^2) Exp[-r^2/(2*s^2)] Parameters ---------- fn : function ...
python
def convolve2d_gauss(fn, r, sig, nstep=200): """Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a 2D gaussian with standard deviation s given by: g(r) = 1/(2*pi*s^2) Exp[-r^2/(2*s^2)] Parameters ---------- fn : function ...
[ "def", "convolve2d_gauss", "(", "fn", ",", "r", ",", "sig", ",", "nstep", "=", "200", ")", ":", "r", "=", "np", ".", "array", "(", "r", ",", "ndmin", "=", "1", ")", "sig", "=", "np", ".", "array", "(", "sig", ",", "ndmin", "=", "1", ")", "r...
Evaluate the convolution f'(r) = f(r) * g(r) where f(r) is azimuthally symmetric function in two dimensions and g is a 2D gaussian with standard deviation s given by: g(r) = 1/(2*pi*s^2) Exp[-r^2/(2*s^2)] Parameters ---------- fn : function Input function that takes a single radial coor...
[ "Evaluate", "the", "convolution", "f", "(", "r", ")", "=", "f", "(", "r", ")", "*", "g", "(", "r", ")", "where", "f", "(", "r", ")", "is", "azimuthally", "symmetric", "function", "in", "two", "dimensions", "and", "g", "is", "a", "2D", "gaussian", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1460-L1515
fermiPy/fermipy
fermipy/utils.py
make_pixel_distance
def make_pixel_distance(shape, xpix=None, ypix=None): """Fill a 2D array with dimensions `shape` with the distance of each pixel from a reference direction (xpix,ypix) in pixel coordinates. Pixel coordinates are defined such that (0,0) is located at the center of the corner pixel. """ if np.iss...
python
def make_pixel_distance(shape, xpix=None, ypix=None): """Fill a 2D array with dimensions `shape` with the distance of each pixel from a reference direction (xpix,ypix) in pixel coordinates. Pixel coordinates are defined such that (0,0) is located at the center of the corner pixel. """ if np.iss...
[ "def", "make_pixel_distance", "(", "shape", ",", "xpix", "=", "None", ",", "ypix", "=", "None", ")", ":", "if", "np", ".", "isscalar", "(", "shape", ")", ":", "shape", "=", "[", "shape", ",", "shape", "]", "if", "xpix", "is", "None", ":", "xpix", ...
Fill a 2D array with dimensions `shape` with the distance of each pixel from a reference direction (xpix,ypix) in pixel coordinates. Pixel coordinates are defined such that (0,0) is located at the center of the corner pixel.
[ "Fill", "a", "2D", "array", "with", "dimensions", "shape", "with", "the", "distance", "of", "each", "pixel", "from", "a", "reference", "direction", "(", "xpix", "ypix", ")", "in", "pixel", "coordinates", ".", "Pixel", "coordinates", "are", "defined", "such",...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1518-L1539
fermiPy/fermipy
fermipy/utils.py
make_gaussian_kernel
def make_gaussian_kernel(sigma, npix=501, cdelt=0.01, xpix=None, ypix=None): """Make kernel for a 2D gaussian. Parameters ---------- sigma : float Standard deviation in degrees. """ sigma /= cdelt def fn(t, s): return 1. / (2 * np.pi * s ** 2) * np.exp( -t ** 2 / (s ** 2 * ...
python
def make_gaussian_kernel(sigma, npix=501, cdelt=0.01, xpix=None, ypix=None): """Make kernel for a 2D gaussian. Parameters ---------- sigma : float Standard deviation in degrees. """ sigma /= cdelt def fn(t, s): return 1. / (2 * np.pi * s ** 2) * np.exp( -t ** 2 / (s ** 2 * ...
[ "def", "make_gaussian_kernel", "(", "sigma", ",", "npix", "=", "501", ",", "cdelt", "=", "0.01", ",", "xpix", "=", "None", ",", "ypix", "=", "None", ")", ":", "sigma", "/=", "cdelt", "def", "fn", "(", "t", ",", "s", ")", ":", "return", "1.", "/",...
Make kernel for a 2D gaussian. Parameters ---------- sigma : float Standard deviation in degrees.
[ "Make", "kernel", "for", "a", "2D", "gaussian", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1542-L1560
fermiPy/fermipy
fermipy/utils.py
make_disk_kernel
def make_disk_kernel(radius, npix=501, cdelt=0.01, xpix=None, ypix=None): """Make kernel for a 2D disk. Parameters ---------- radius : float Disk radius in deg. """ radius /= cdelt def fn(t, s): return 0.5 * (np.sign(s - t) + 1.0) dxy = make_pixel_distance(npix, xpix, ypix) ...
python
def make_disk_kernel(radius, npix=501, cdelt=0.01, xpix=None, ypix=None): """Make kernel for a 2D disk. Parameters ---------- radius : float Disk radius in deg. """ radius /= cdelt def fn(t, s): return 0.5 * (np.sign(s - t) + 1.0) dxy = make_pixel_distance(npix, xpix, ypix) ...
[ "def", "make_disk_kernel", "(", "radius", ",", "npix", "=", "501", ",", "cdelt", "=", "0.01", ",", "xpix", "=", "None", ",", "ypix", "=", "None", ")", ":", "radius", "/=", "cdelt", "def", "fn", "(", "t", ",", "s", ")", ":", "return", "0.5", "*", ...
Make kernel for a 2D disk. Parameters ---------- radius : float Disk radius in deg.
[ "Make", "kernel", "for", "a", "2D", "disk", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1563-L1581
fermiPy/fermipy
fermipy/utils.py
make_cdisk_kernel
def make_cdisk_kernel(psf, sigma, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False): """Make a kernel for a PSF-convolved 2D disk. Parameters ---------- psf : `~fermipy.irfs.PSFModel` sigma : float 68% containment radius in degrees. """ sigma /= 0.8...
python
def make_cdisk_kernel(psf, sigma, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False): """Make a kernel for a PSF-convolved 2D disk. Parameters ---------- psf : `~fermipy.irfs.PSFModel` sigma : float 68% containment radius in degrees. """ sigma /= 0.8...
[ "def", "make_cdisk_kernel", "(", "psf", ",", "sigma", ",", "npix", ",", "cdelt", ",", "xpix", ",", "ypix", ",", "psf_scale_fn", "=", "None", ",", "normalize", "=", "False", ")", ":", "sigma", "/=", "0.8246211251235321", "dtheta", "=", "psf", ".", "dtheta...
Make a kernel for a PSF-convolved 2D disk. Parameters ---------- psf : `~fermipy.irfs.PSFModel` sigma : float 68% containment radius in degrees.
[ "Make", "a", "kernel", "for", "a", "PSF", "-", "convolved", "2D", "disk", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1584-L1614
fermiPy/fermipy
fermipy/utils.py
make_radial_kernel
def make_radial_kernel(psf, fn, sigma, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False, klims=None, sparse=False): """Make a kernel for a general radially symmetric 2D function. Parameters ---------- psf : `~fermipy.irfs.PSFModel` fn : callable Function ...
python
def make_radial_kernel(psf, fn, sigma, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False, klims=None, sparse=False): """Make a kernel for a general radially symmetric 2D function. Parameters ---------- psf : `~fermipy.irfs.PSFModel` fn : callable Function ...
[ "def", "make_radial_kernel", "(", "psf", ",", "fn", ",", "sigma", ",", "npix", ",", "cdelt", ",", "xpix", ",", "ypix", ",", "psf_scale_fn", "=", "None", ",", "normalize", "=", "False", ",", "klims", "=", "None", ",", "sparse", "=", "False", ")", ":",...
Make a kernel for a general radially symmetric 2D function. Parameters ---------- psf : `~fermipy.irfs.PSFModel` fn : callable Function that evaluates the kernel at a radial coordinate r. sigma : float 68% containment radius in degrees.
[ "Make", "a", "kernel", "for", "a", "general", "radially", "symmetric", "2D", "function", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1663-L1738
fermiPy/fermipy
fermipy/utils.py
make_psf_kernel
def make_psf_kernel(psf, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False): """ Generate a kernel for a point-source. Parameters ---------- psf : `~fermipy.irfs.PSFModel` npix : int Number of pixels in X and Y dimensions. cdelt : float Pixel size in degrees. ...
python
def make_psf_kernel(psf, npix, cdelt, xpix, ypix, psf_scale_fn=None, normalize=False): """ Generate a kernel for a point-source. Parameters ---------- psf : `~fermipy.irfs.PSFModel` npix : int Number of pixels in X and Y dimensions. cdelt : float Pixel size in degrees. ...
[ "def", "make_psf_kernel", "(", "psf", ",", "npix", ",", "cdelt", ",", "xpix", ",", "ypix", ",", "psf_scale_fn", "=", "None", ",", "normalize", "=", "False", ")", ":", "egy", "=", "psf", ".", "energies", "x", "=", "make_pixel_distance", "(", "npix", ","...
Generate a kernel for a point-source. Parameters ---------- psf : `~fermipy.irfs.PSFModel` npix : int Number of pixels in X and Y dimensions. cdelt : float Pixel size in degrees.
[ "Generate", "a", "kernel", "for", "a", "point", "-", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1777-L1805
fermiPy/fermipy
fermipy/utils.py
overlap_slices
def overlap_slices(large_array_shape, small_array_shape, position): """ Modified version of `~astropy.nddata.utils.overlap_slices`. Get slices for the overlapping part of a small and a large array. Given a certain position of the center of the small array, with respect to the large array, tuples o...
python
def overlap_slices(large_array_shape, small_array_shape, position): """ Modified version of `~astropy.nddata.utils.overlap_slices`. Get slices for the overlapping part of a small and a large array. Given a certain position of the center of the small array, with respect to the large array, tuples o...
[ "def", "overlap_slices", "(", "large_array_shape", ",", "small_array_shape", ",", "position", ")", ":", "# Get edge coordinates", "edges_min", "=", "[", "int", "(", "pos", "-", "small_shape", "//", "2", ")", "for", "(", "pos", ",", "small_shape", ")", "in", ...
Modified version of `~astropy.nddata.utils.overlap_slices`. Get slices for the overlapping part of a small and a large array. Given a certain position of the center of the small array, with respect to the large array, tuples of slices are returned which can be used to extract, add or subtract the smal...
[ "Modified", "version", "of", "~astropy", ".", "nddata", ".", "utils", ".", "overlap_slices", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/utils.py#L1828-L1878
fermiPy/fermipy
fermipy/diffuse/model_manager.py
make_library
def make_library(**kwargs): """Build and return a ModelManager object and fill the associated model library """ library_yaml = kwargs.pop('library', 'models/library.yaml') comp_yaml = kwargs.pop('comp', 'config/binning.yaml') basedir = kwargs.pop('basedir', os.path.abspath('.')) model_man = kwa...
python
def make_library(**kwargs): """Build and return a ModelManager object and fill the associated model library """ library_yaml = kwargs.pop('library', 'models/library.yaml') comp_yaml = kwargs.pop('comp', 'config/binning.yaml') basedir = kwargs.pop('basedir', os.path.abspath('.')) model_man = kwa...
[ "def", "make_library", "(", "*", "*", "kwargs", ")", ":", "library_yaml", "=", "kwargs", ".", "pop", "(", "'library'", ",", "'models/library.yaml'", ")", "comp_yaml", "=", "kwargs", ".", "pop", "(", "'comp'", ",", "'config/binning.yaml'", ")", "basedir", "="...
Build and return a ModelManager object and fill the associated model library
[ "Build", "and", "return", "a", "ModelManager", "object", "and", "fill", "the", "associated", "model", "library" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L472-L484
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelInfo.edisp_disable_list
def edisp_disable_list(self): """ Return the list of source for which energy dispersion should be turned off """ l = [] for model_comp in self.model_components.values(): if model_comp.edisp_disable: l += [model_comp.info.source_name] return l
python
def edisp_disable_list(self): """ Return the list of source for which energy dispersion should be turned off """ l = [] for model_comp in self.model_components.values(): if model_comp.edisp_disable: l += [model_comp.info.source_name] return l
[ "def", "edisp_disable_list", "(", "self", ")", ":", "l", "=", "[", "]", "for", "model_comp", "in", "self", ".", "model_components", ".", "values", "(", ")", ":", "if", "model_comp", ".", "edisp_disable", ":", "l", "+=", "[", "model_comp", ".", "info", ...
Return the list of source for which energy dispersion should be turned off
[ "Return", "the", "list", "of", "source", "for", "which", "energy", "dispersion", "should", "be", "turned", "off" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L66-L72
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelInfo.make_srcmap_manifest
def make_srcmap_manifest(self, components, name_factory): """ Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- components : list The binning components used in this analysis name_factory : `NameFactory` ...
python
def make_srcmap_manifest(self, components, name_factory): """ Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- components : list The binning components used in this analysis name_factory : `NameFactory` ...
[ "def", "make_srcmap_manifest", "(", "self", ",", "components", ",", "name_factory", ")", ":", "ret_dict", "=", "{", "}", "for", "comp", "in", "components", ":", "compkey", "=", "comp", ".", "make_key", "(", "'{ebin_name}_{evtype_name}'", ")", "zcut", "=", "\...
Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- components : list The binning components used in this analysis name_factory : `NameFactory` Object that handles naming conventions Returns a dictio...
[ "Build", "a", "yaml", "file", "that", "specfies", "how", "to", "make", "the", "srcmap", "files", "for", "a", "particular", "model" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L74-L125
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelInfo.make_model_rois
def make_model_rois(self, components, name_factory): """ Make the fermipy roi_model objects for each of a set of binning components """ ret_dict = {} # Figure out which sources need to be split by components master_roi_source_info = {} sub_comp_sources = {} for comp_name...
python
def make_model_rois(self, components, name_factory): """ Make the fermipy roi_model objects for each of a set of binning components """ ret_dict = {} # Figure out which sources need to be split by components master_roi_source_info = {} sub_comp_sources = {} for comp_name...
[ "def", "make_model_rois", "(", "self", ",", "components", ",", "name_factory", ")", ":", "ret_dict", "=", "{", "}", "# Figure out which sources need to be split by components", "master_roi_source_info", "=", "{", "}", "sub_comp_sources", "=", "{", "}", "for", "comp_na...
Make the fermipy roi_model objects for each of a set of binning components
[ "Make", "the", "fermipy", "roi_model", "objects", "for", "each", "of", "a", "set", "of", "binning", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L127-L177
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.read_model_yaml
def read_model_yaml(self, modelkey): """ Read the yaml file for the diffuse components """ model_yaml = self._name_factory.model_yaml(modelkey=modelkey, fullpath=True) model = yaml.safe_load(open(model_yaml)) return model
python
def read_model_yaml(self, modelkey): """ Read the yaml file for the diffuse components """ model_yaml = self._name_factory.model_yaml(modelkey=modelkey, fullpath=True) model = yaml.safe_load(open(model_yaml)) return model
[ "def", "read_model_yaml", "(", "self", ",", "modelkey", ")", ":", "model_yaml", "=", "self", ".", "_name_factory", ".", "model_yaml", "(", "modelkey", "=", "modelkey", ",", "fullpath", "=", "True", ")", "model", "=", "yaml", ".", "safe_load", "(", "open", ...
Read the yaml file for the diffuse components
[ "Read", "the", "yaml", "file", "for", "the", "diffuse", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L209-L215
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.make_library
def make_library(self, diffuse_yaml, catalog_yaml, binning_yaml): """ Build up the library of all the components Parameters ---------- diffuse_yaml : str Name of the yaml file with the library of diffuse component definitions catalog_yaml : str Name of t...
python
def make_library(self, diffuse_yaml, catalog_yaml, binning_yaml): """ Build up the library of all the components Parameters ---------- diffuse_yaml : str Name of the yaml file with the library of diffuse component definitions catalog_yaml : str Name of t...
[ "def", "make_library", "(", "self", ",", "diffuse_yaml", ",", "catalog_yaml", ",", "binning_yaml", ")", ":", "ret_dict", "=", "{", "}", "#catalog_dict = yaml.safe_load(open(catalog_yaml))", "components_dict", "=", "Component", ".", "build_from_yamlfile", "(", "binning_y...
Build up the library of all the components Parameters ---------- diffuse_yaml : str Name of the yaml file with the library of diffuse component definitions catalog_yaml : str Name of the yaml file width the library of catalog split definitions binning_ya...
[ "Build", "up", "the", "library", "of", "all", "the", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L232-L257
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.make_model_info
def make_model_info(self, modelkey): """ Build a dictionary with the information for a particular model. Parameters ---------- modelkey : str Key used to identify this particular model Return `ModelInfo` """ model = self.read_model_yaml(modelkey) ...
python
def make_model_info(self, modelkey): """ Build a dictionary with the information for a particular model. Parameters ---------- modelkey : str Key used to identify this particular model Return `ModelInfo` """ model = self.read_model_yaml(modelkey) ...
[ "def", "make_model_info", "(", "self", ",", "modelkey", ")", ":", "model", "=", "self", ".", "read_model_yaml", "(", "modelkey", ")", "sources", "=", "model", "[", "'sources'", "]", "components", "=", "OrderedDict", "(", ")", "spec_model_yaml", "=", "self", ...
Build a dictionary with the information for a particular model. Parameters ---------- modelkey : str Key used to identify this particular model Return `ModelInfo`
[ "Build", "a", "dictionary", "with", "the", "information", "for", "a", "particular", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L259-L314
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.make_srcmap_manifest
def make_srcmap_manifest(self, modelkey, components, data): """Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- modelkey : str Key used to identify this particular model components : list The binni...
python
def make_srcmap_manifest(self, modelkey, components, data): """Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- modelkey : str Key used to identify this particular model components : list The binni...
[ "def", "make_srcmap_manifest", "(", "self", ",", "modelkey", ",", "components", ",", "data", ")", ":", "try", ":", "model_info", "=", "self", ".", "_models", "[", "modelkey", "]", "except", "KeyError", ":", "model_info", "=", "self", ".", "make_model_info", ...
Build a yaml file that specfies how to make the srcmap files for a particular model Parameters ---------- modelkey : str Key used to identify this particular model components : list The binning components used in this analysis data : str Path...
[ "Build", "a", "yaml", "file", "that", "specfies", "how", "to", "make", "the", "srcmap", "files", "for", "a", "particular", "model" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L316-L344
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.make_fermipy_config_yaml
def make_fermipy_config_yaml(self, modelkey, components, data, **kwargs): """Build a fermipy top-level yaml configuration file Parameters ---------- modelkey : str Key used to identify this particular model components : list The binning components used i...
python
def make_fermipy_config_yaml(self, modelkey, components, data, **kwargs): """Build a fermipy top-level yaml configuration file Parameters ---------- modelkey : str Key used to identify this particular model components : list The binning components used i...
[ "def", "make_fermipy_config_yaml", "(", "self", ",", "modelkey", ",", "components", ",", "data", ",", "*", "*", "kwargs", ")", ":", "model_dir", "=", "os", ".", "path", ".", "join", "(", "'analysis'", ",", "'model_%s'", "%", "modelkey", ")", "hpx_order", ...
Build a fermipy top-level yaml configuration file Parameters ---------- modelkey : str Key used to identify this particular model components : list The binning components used in this analysis data : str Path to file containing dataset defini...
[ "Build", "a", "fermipy", "top", "-", "level", "yaml", "configuration", "file" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L346-L452
fermiPy/fermipy
fermipy/diffuse/model_manager.py
ModelManager.get_sub_comp_info
def get_sub_comp_info(source_info, comp): """Build and return information about a sub-component for a particular selection """ sub_comps = source_info.get('components', None) if sub_comps is None: return source_info.copy() moving = source_info.get('moving', False) ...
python
def get_sub_comp_info(source_info, comp): """Build and return information about a sub-component for a particular selection """ sub_comps = source_info.get('components', None) if sub_comps is None: return source_info.copy() moving = source_info.get('moving', False) ...
[ "def", "get_sub_comp_info", "(", "source_info", ",", "comp", ")", ":", "sub_comps", "=", "source_info", ".", "get", "(", "'components'", ",", "None", ")", "if", "sub_comps", "is", "None", ":", "return", "source_info", ".", "copy", "(", ")", "moving", "=", ...
Build and return information about a sub-component for a particular selection
[ "Build", "and", "return", "information", "about", "a", "sub", "-", "component", "for", "a", "particular", "selection" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L455-L469
fermiPy/fermipy
fermipy/validate/utils.py
replace_aliases
def replace_aliases(cut_dict, aliases): """Substitute aliases in a cut dictionary.""" for k, v in cut_dict.items(): for k0, v0 in aliases.items(): cut_dict[k] = cut_dict[k].replace(k0, '(%s)' % v0)
python
def replace_aliases(cut_dict, aliases): """Substitute aliases in a cut dictionary.""" for k, v in cut_dict.items(): for k0, v0 in aliases.items(): cut_dict[k] = cut_dict[k].replace(k0, '(%s)' % v0)
[ "def", "replace_aliases", "(", "cut_dict", ",", "aliases", ")", ":", "for", "k", ",", "v", "in", "cut_dict", ".", "items", "(", ")", ":", "for", "k0", ",", "v0", "in", "aliases", ".", "items", "(", ")", ":", "cut_dict", "[", "k", "]", "=", "cut_d...
Substitute aliases in a cut dictionary.
[ "Substitute", "aliases", "in", "a", "cut", "dictionary", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/utils.py#L25-L29
fermiPy/fermipy
fermipy/validate/utils.py
get_files
def get_files(files, extnames=['.root']): """Extract a list of file paths from a list containing both paths and file lists with one path per line.""" files_out = [] for f in files: mime = mimetypes.guess_type(f) if os.path.splitext(f)[1] in extnames: files_out += [f] ...
python
def get_files(files, extnames=['.root']): """Extract a list of file paths from a list containing both paths and file lists with one path per line.""" files_out = [] for f in files: mime = mimetypes.guess_type(f) if os.path.splitext(f)[1] in extnames: files_out += [f] ...
[ "def", "get_files", "(", "files", ",", "extnames", "=", "[", "'.root'", "]", ")", ":", "files_out", "=", "[", "]", "for", "f", "in", "files", ":", "mime", "=", "mimetypes", ".", "guess_type", "(", "f", ")", "if", "os", ".", "path", ".", "splitext",...
Extract a list of file paths from a list containing both paths and file lists with one path per line.
[ "Extract", "a", "list", "of", "file", "paths", "from", "a", "list", "containing", "both", "paths", "and", "file", "lists", "with", "one", "path", "per", "line", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/utils.py#L37-L52
fermiPy/fermipy
fermipy/validate/utils.py
get_cuts_from_xml
def get_cuts_from_xml(xmlfile): """Extract event selection strings from the XML file.""" root = ElementTree.ElementTree(file=xmlfile).getroot() event_maps = root.findall('EventMap') alias_maps = root.findall('AliasDict')[0] event_classes = {} event_types = {} event_aliases = {} for m ...
python
def get_cuts_from_xml(xmlfile): """Extract event selection strings from the XML file.""" root = ElementTree.ElementTree(file=xmlfile).getroot() event_maps = root.findall('EventMap') alias_maps = root.findall('AliasDict')[0] event_classes = {} event_types = {} event_aliases = {} for m ...
[ "def", "get_cuts_from_xml", "(", "xmlfile", ")", ":", "root", "=", "ElementTree", ".", "ElementTree", "(", "file", "=", "xmlfile", ")", ".", "getroot", "(", ")", "event_maps", "=", "root", ".", "findall", "(", "'EventMap'", ")", "alias_maps", "=", "root", ...
Extract event selection strings from the XML file.
[ "Extract", "event", "selection", "strings", "from", "the", "XML", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/utils.py#L84-L117
fermiPy/fermipy
fermipy/validate/utils.py
set_event_list
def set_event_list(tree, selection=None, fraction=None, start_fraction=None): """ Set the event list for a tree or chain. Parameters ---------- tree : `ROOT.TTree` Input tree/chain. selection : str Cut string defining the event list. fraction : float Fraction of ...
python
def set_event_list(tree, selection=None, fraction=None, start_fraction=None): """ Set the event list for a tree or chain. Parameters ---------- tree : `ROOT.TTree` Input tree/chain. selection : str Cut string defining the event list. fraction : float Fraction of ...
[ "def", "set_event_list", "(", "tree", ",", "selection", "=", "None", ",", "fraction", "=", "None", ",", "start_fraction", "=", "None", ")", ":", "import", "ROOT", "elist", "=", "rand_str", "(", ")", "if", "selection", "is", "None", ":", "cuts", "=", "'...
Set the event list for a tree or chain. Parameters ---------- tree : `ROOT.TTree` Input tree/chain. selection : str Cut string defining the event list. fraction : float Fraction of the total file to include in the event list starting from the *end* of the file.
[ "Set", "the", "event", "list", "for", "a", "tree", "or", "chain", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/utils.py#L120-L160
fermiPy/fermipy
fermipy/sourcefind.py
SourceFind.find_sources
def find_sources(self, prefix='', **kwargs): """An iterative source-finding algorithm that uses likelihood ratio (TS) maps of the region of interest to find new sources. After each iteration a new TS map is generated incorporating sources found in the previous iteration. The method stop...
python
def find_sources(self, prefix='', **kwargs): """An iterative source-finding algorithm that uses likelihood ratio (TS) maps of the region of interest to find new sources. After each iteration a new TS map is generated incorporating sources found in the previous iteration. The method stop...
[ "def", "find_sources", "(", "self", ",", "prefix", "=", "''", ",", "*", "*", "kwargs", ")", ":", "timer", "=", "Timer", ".", "create", "(", "start", "=", "True", ")", "self", ".", "logger", ".", "info", "(", "'Starting.'", ")", "schema", "=", "Conf...
An iterative source-finding algorithm that uses likelihood ratio (TS) maps of the region of interest to find new sources. After each iteration a new TS map is generated incorporating sources found in the previous iteration. The method stops when the number of iterations exceeds ``max_it...
[ "An", "iterative", "source", "-", "finding", "algorithm", "that", "uses", "likelihood", "ratio", "(", "TS", ")", "maps", "of", "the", "region", "of", "interest", "to", "find", "new", "sources", ".", "After", "each", "iteration", "a", "new", "TS", "map", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind.py#L33-L98
fermiPy/fermipy
fermipy/sourcefind.py
SourceFind.localize
def localize(self, name, **kwargs): """Find the best-fit position of a source. Localization is performed in two steps. First a TS map is computed centered on the source with half-width set by ``dtheta_max``. A fit is then performed to the maximum TS peak in this map. The source ...
python
def localize(self, name, **kwargs): """Find the best-fit position of a source. Localization is performed in two steps. First a TS map is computed centered on the source with half-width set by ``dtheta_max``. A fit is then performed to the maximum TS peak in this map. The source ...
[ "def", "localize", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "timer", "=", "Timer", ".", "create", "(", "start", "=", "True", ")", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "schema...
Find the best-fit position of a source. Localization is performed in two steps. First a TS map is computed centered on the source with half-width set by ``dtheta_max``. A fit is then performed to the maximum TS peak in this map. The source position is then further refined by scanning...
[ "Find", "the", "best", "-", "fit", "position", "of", "a", "source", ".", "Localization", "is", "performed", "in", "two", "steps", ".", "First", "a", "TS", "map", "is", "computed", "centered", "on", "the", "source", "with", "half", "-", "width", "set", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind.py#L237-L301
fermiPy/fermipy
fermipy/sourcefind.py
SourceFind._fit_position_tsmap
def _fit_position_tsmap(self, name, **kwargs): """Localize a source from its TS map.""" prefix = kwargs.get('prefix', '') dtheta_max = kwargs.get('dtheta_max', 0.5) zmin = kwargs.get('zmin', -3.0) kw = { 'map_size': 2.0 * dtheta_max, 'write_fits': kwarg...
python
def _fit_position_tsmap(self, name, **kwargs): """Localize a source from its TS map.""" prefix = kwargs.get('prefix', '') dtheta_max = kwargs.get('dtheta_max', 0.5) zmin = kwargs.get('zmin', -3.0) kw = { 'map_size': 2.0 * dtheta_max, 'write_fits': kwarg...
[ "def", "_fit_position_tsmap", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "prefix", "=", "kwargs", ".", "get", "(", "'prefix'", ",", "''", ")", "dtheta_max", "=", "kwargs", ".", "get", "(", "'dtheta_max'", ",", "0.5", ")", "zmin", "=...
Localize a source from its TS map.
[ "Localize", "a", "source", "from", "its", "TS", "map", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind.py#L503-L562
fermiPy/fermipy
fermipy/jobs/slac_impl.py
make_nfs_path
def make_nfs_path(path): """Make a nfs version of a file path. This just puts /nfs at the beginning instead of /gpfs""" if os.path.isabs(path): fullpath = path else: fullpath = os.path.abspath(path) if len(fullpath) < 6: return fullpath if fullpath[0:6] == '/gpfs/': ...
python
def make_nfs_path(path): """Make a nfs version of a file path. This just puts /nfs at the beginning instead of /gpfs""" if os.path.isabs(path): fullpath = path else: fullpath = os.path.abspath(path) if len(fullpath) < 6: return fullpath if fullpath[0:6] == '/gpfs/': ...
[ "def", "make_nfs_path", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "fullpath", "=", "path", "else", ":", "fullpath", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "len", "(", "fullpath", ...
Make a nfs version of a file path. This just puts /nfs at the beginning instead of /gpfs
[ "Make", "a", "nfs", "version", "of", "a", "file", "path", ".", "This", "just", "puts", "/", "nfs", "at", "the", "beginning", "instead", "of", "/", "gpfs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L16-L27
fermiPy/fermipy
fermipy/jobs/slac_impl.py
make_gpfs_path
def make_gpfs_path(path): """Make a gpfs version of a file path. This just puts /gpfs at the beginning instead of /nfs""" if os.path.isabs(path): fullpath = os.path.abspath(path) else: fullpath = os.path.abspath(path) if len(fullpath) < 5: return fullpath if fullpath[0:5]...
python
def make_gpfs_path(path): """Make a gpfs version of a file path. This just puts /gpfs at the beginning instead of /nfs""" if os.path.isabs(path): fullpath = os.path.abspath(path) else: fullpath = os.path.abspath(path) if len(fullpath) < 5: return fullpath if fullpath[0:5]...
[ "def", "make_gpfs_path", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "fullpath", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "else", ":", "fullpath", "=", "os", ".", "path", ".", "abspath", "...
Make a gpfs version of a file path. This just puts /gpfs at the beginning instead of /nfs
[ "Make", "a", "gpfs", "version", "of", "a", "file", "path", ".", "This", "just", "puts", "/", "gpfs", "at", "the", "beginning", "instead", "of", "/", "nfs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L30-L41
fermiPy/fermipy
fermipy/jobs/slac_impl.py
get_lsf_status
def get_lsf_status(): """Count and print the number of jobs in various LSF states """ status_count = {'RUN': 0, 'PEND': 0, 'SUSP': 0, 'USUSP': 0, 'NJOB': 0, 'UNKNWN': 0} try: subproc = subprocess...
python
def get_lsf_status(): """Count and print the number of jobs in various LSF states """ status_count = {'RUN': 0, 'PEND': 0, 'SUSP': 0, 'USUSP': 0, 'NJOB': 0, 'UNKNWN': 0} try: subproc = subprocess...
[ "def", "get_lsf_status", "(", ")", ":", "status_count", "=", "{", "'RUN'", ":", "0", ",", "'PEND'", ":", "0", ",", "'SUSP'", ":", "0", ",", "'USUSP'", ":", "0", ",", "'NJOB'", ":", "0", ",", "'UNKNWN'", ":", "0", "}", "try", ":", "subproc", "=", ...
Count and print the number of jobs in various LSF states
[ "Count", "and", "print", "the", "number", "of", "jobs", "in", "various", "LSF", "states" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L44-L75
fermiPy/fermipy
fermipy/jobs/slac_impl.py
build_bsub_command
def build_bsub_command(command_template, lsf_args): """Build and return a lsf batch command template The structure will be 'bsub -s <key> <value> <command_template>' where <key> and <value> refer to items in lsf_args """ if command_template is None: return "" full_command = 'bsub -o...
python
def build_bsub_command(command_template, lsf_args): """Build and return a lsf batch command template The structure will be 'bsub -s <key> <value> <command_template>' where <key> and <value> refer to items in lsf_args """ if command_template is None: return "" full_command = 'bsub -o...
[ "def", "build_bsub_command", "(", "command_template", ",", "lsf_args", ")", ":", "if", "command_template", "is", "None", ":", "return", "\"\"", "full_command", "=", "'bsub -o {logfile}'", "for", "key", ",", "value", "in", "lsf_args", ".", "items", "(", ")", ":...
Build and return a lsf batch command template The structure will be 'bsub -s <key> <value> <command_template>' where <key> and <value> refer to items in lsf_args
[ "Build", "and", "return", "a", "lsf", "batch", "command", "template" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L78-L92
fermiPy/fermipy
fermipy/jobs/slac_impl.py
get_slac_default_args
def get_slac_default_args(job_time=1500): """ Create a batch job interface object. Parameters ---------- job_time : int Expected max length of the job, in seconds. This is used to select the batch queue and set the job_check_sleep parameter that sets how often we check ...
python
def get_slac_default_args(job_time=1500): """ Create a batch job interface object. Parameters ---------- job_time : int Expected max length of the job, in seconds. This is used to select the batch queue and set the job_check_sleep parameter that sets how often we check ...
[ "def", "get_slac_default_args", "(", "job_time", "=", "1500", ")", ":", "slac_default_args", "=", "dict", "(", "lsf_args", "=", "{", "'W'", ":", "job_time", ",", "'R'", ":", "'\\\"select[rhel60&&!fell]\\\"'", "}", ",", "max_jobs", "=", "500", ",", "time_per_cy...
Create a batch job interface object. Parameters ---------- job_time : int Expected max length of the job, in seconds. This is used to select the batch queue and set the job_check_sleep parameter that sets how often we check for job completion.
[ "Create", "a", "batch", "job", "interface", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L242-L262
fermiPy/fermipy
fermipy/jobs/slac_impl.py
SlacInterface.dispatch_job_hook
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Send a single job to the LSF batch Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that ident...
python
def dispatch_job_hook(self, link, key, job_config, logfile, stream=sys.stdout): """Send a single job to the LSF batch Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that ident...
[ "def", "dispatch_job_hook", "(", "self", ",", "link", ",", "key", ",", "job_config", ",", "logfile", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "full_sub_dict", "=", "job_config", ".", "copy", "(", ")", "if", "self", ".", "_no_batch", ":", "fu...
Send a single job to the LSF batch Parameters ---------- link : `fermipy.jobs.chain.Link` The link used to invoke the command we are running key : str A string that identifies this particular instance of the job job_config : dict A dictionr...
[ "Send", "a", "single", "job", "to", "the", "LSF", "batch" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L128-L174
fermiPy/fermipy
fermipy/jobs/slac_impl.py
SlacInterface.submit_jobs
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout): """Submit all the jobs in job_dict """ if link is None: return JobStatus.no_job if job_dict is None: job_keys = link.jobs.keys() else: job_keys = sorted(job_dict.keys()) ...
python
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout): """Submit all the jobs in job_dict """ if link is None: return JobStatus.no_job if job_dict is None: job_keys = link.jobs.keys() else: job_keys = sorted(job_dict.keys()) ...
[ "def", "submit_jobs", "(", "self", ",", "link", ",", "job_dict", "=", "None", ",", "job_archive", "=", "None", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "if", "link", "is", "None", ":", "return", "JobStatus", ".", "no_job", "if", "job_dict", ...
Submit all the jobs in job_dict
[ "Submit", "all", "the", "jobs", "in", "job_dict" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/slac_impl.py#L176-L239
fermiPy/fermipy
fermipy/gtanalysis.py
create_sc_table
def create_sc_table(scfile, colnames=None): """Load an FT2 file from a file or list of files.""" if utils.is_fits_file(scfile) and colnames is None: return create_table_from_fits(scfile, 'SC_DATA') if utils.is_fits_file(scfile): files = [scfile] else: files = [line.strip() for ...
python
def create_sc_table(scfile, colnames=None): """Load an FT2 file from a file or list of files.""" if utils.is_fits_file(scfile) and colnames is None: return create_table_from_fits(scfile, 'SC_DATA') if utils.is_fits_file(scfile): files = [scfile] else: files = [line.strip() for ...
[ "def", "create_sc_table", "(", "scfile", ",", "colnames", "=", "None", ")", ":", "if", "utils", ".", "is_fits_file", "(", "scfile", ")", "and", "colnames", "is", "None", ":", "return", "create_table_from_fits", "(", "scfile", ",", "'SC_DATA'", ")", "if", "...
Load an FT2 file from a file or list of files.
[ "Load", "an", "FT2", "file", "from", "a", "file", "or", "list", "of", "files", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L134-L148
fermiPy/fermipy
fermipy/gtanalysis.py
create_table_from_fits
def create_table_from_fits(fitsfile, hduname, colnames=None): """Memory efficient function for loading a table from a FITS file.""" if colnames is None: return Table.read(fitsfile, hduname) cols = [] with fits.open(fitsfile, memmap=True) as h: for k in colnames: data = ...
python
def create_table_from_fits(fitsfile, hduname, colnames=None): """Memory efficient function for loading a table from a FITS file.""" if colnames is None: return Table.read(fitsfile, hduname) cols = [] with fits.open(fitsfile, memmap=True) as h: for k in colnames: data = ...
[ "def", "create_table_from_fits", "(", "fitsfile", ",", "hduname", ",", "colnames", "=", "None", ")", ":", "if", "colnames", "is", "None", ":", "return", "Table", ".", "read", "(", "fitsfile", ",", "hduname", ")", "cols", "=", "[", "]", "with", "fits", ...
Memory efficient function for loading a table from a FITS file.
[ "Memory", "efficient", "function", "for", "loading", "a", "table", "from", "a", "FITS", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L151-L163
fermiPy/fermipy
fermipy/gtanalysis.py
get_spectral_index
def get_spectral_index(src, egy): """Compute the local spectral index of a source.""" delta = 1E-5 f0 = src.spectrum()(pyLike.dArg(egy * (1 - delta))) f1 = src.spectrum()(pyLike.dArg(egy * (1 + delta))) if f0 > 0 and f1 > 0: gamma = np.log10(f0 / f1) / np.log10((1 - delta) / (1 + delta)) ...
python
def get_spectral_index(src, egy): """Compute the local spectral index of a source.""" delta = 1E-5 f0 = src.spectrum()(pyLike.dArg(egy * (1 - delta))) f1 = src.spectrum()(pyLike.dArg(egy * (1 + delta))) if f0 > 0 and f1 > 0: gamma = np.log10(f0 / f1) / np.log10((1 - delta) / (1 + delta)) ...
[ "def", "get_spectral_index", "(", "src", ",", "egy", ")", ":", "delta", "=", "1E-5", "f0", "=", "src", ".", "spectrum", "(", ")", "(", "pyLike", ".", "dArg", "(", "egy", "*", "(", "1", "-", "delta", ")", ")", ")", "f1", "=", "src", ".", "spectr...
Compute the local spectral index of a source.
[ "Compute", "the", "local", "spectral", "index", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L166-L177
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.create
def create(cls, infile, config=None, params=None, mask=None): """Create a new instance of GTAnalysis from an analysis output file generated with `~fermipy.GTAnalysis.write_roi`. By default the new instance will inherit the configuration of the saved analysis instance. The configuration...
python
def create(cls, infile, config=None, params=None, mask=None): """Create a new instance of GTAnalysis from an analysis output file generated with `~fermipy.GTAnalysis.write_roi`. By default the new instance will inherit the configuration of the saved analysis instance. The configuration...
[ "def", "create", "(", "cls", ",", "infile", ",", "config", "=", "None", ",", "params", "=", "None", ",", "mask", "=", "None", ")", ":", "infile", "=", "os", ".", "path", ".", "abspath", "(", "infile", ")", "roi_file", ",", "roi_data", "=", "utils",...
Create a new instance of GTAnalysis from an analysis output file generated with `~fermipy.GTAnalysis.write_roi`. By default the new instance will inherit the configuration of the saved analysis instance. The configuration may be overriden by passing a configuration file path with the `...
[ "Create", "a", "new", "instance", "of", "GTAnalysis", "from", "an", "analysis", "output", "file", "generated", "with", "~fermipy", ".", "GTAnalysis", ".", "write_roi", ".", "By", "default", "the", "new", "instance", "will", "inherit", "the", "configuration", "...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L511-L549
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.clone
def clone(self, config, **kwargs): """Make a clone of this analysis instance.""" gta = GTAnalysis(config, **kwargs) gta._roi = copy.deepcopy(self.roi) return gta
python
def clone(self, config, **kwargs): """Make a clone of this analysis instance.""" gta = GTAnalysis(config, **kwargs) gta._roi = copy.deepcopy(self.roi) return gta
[ "def", "clone", "(", "self", ",", "config", ",", "*", "*", "kwargs", ")", ":", "gta", "=", "GTAnalysis", "(", "config", ",", "*", "*", "kwargs", ")", "gta", ".", "_roi", "=", "copy", ".", "deepcopy", "(", "self", ".", "roi", ")", "return", "gta" ...
Make a clone of this analysis instance.
[ "Make", "a", "clone", "of", "this", "analysis", "instance", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L551-L555
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_random_seed
def set_random_seed(self, seed): """Set the seed for the random number generator""" self.config['mc']['seed'] = seed np.random.seed(seed)
python
def set_random_seed(self, seed): """Set the seed for the random number generator""" self.config['mc']['seed'] = seed np.random.seed(seed)
[ "def", "set_random_seed", "(", "self", ",", "seed", ")", ":", "self", ".", "config", "[", "'mc'", "]", "[", "'seed'", "]", "=", "seed", "np", ".", "random", ".", "seed", "(", "seed", ")" ]
Set the seed for the random number generator
[ "Set", "the", "seed", "for", "the", "random", "number", "generator" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L557-L560
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.reload_source
def reload_source(self, name, init_source=True): """Delete and reload a source in the model. This will update the spatial model of this source to the one defined in the XML model.""" for c in self.components: c.reload_source(name) if init_source: self._...
python
def reload_source(self, name, init_source=True): """Delete and reload a source in the model. This will update the spatial model of this source to the one defined in the XML model.""" for c in self.components: c.reload_source(name) if init_source: self._...
[ "def", "reload_source", "(", "self", ",", "name", ",", "init_source", "=", "True", ")", ":", "for", "c", "in", "self", ".", "components", ":", "c", ".", "reload_source", "(", "name", ")", "if", "init_source", ":", "self", ".", "_init_source", "(", "nam...
Delete and reload a source in the model. This will update the spatial model of this source to the one defined in the XML model.
[ "Delete", "and", "reload", "a", "source", "in", "the", "model", ".", "This", "will", "update", "the", "spatial", "model", "of", "this", "source", "to", "the", "one", "defined", "in", "the", "XML", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L630-L641
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_source_morphology
def set_source_morphology(self, name, **kwargs): """Set the spatial model of a source. Parameters ---------- name : str Source name. spatial_model : str Spatial model name (PointSource, RadialGaussian, etc.). spatial_pars : dict Diction...
python
def set_source_morphology(self, name, **kwargs): """Set the spatial model of a source. Parameters ---------- name : str Source name. spatial_model : str Spatial model name (PointSource, RadialGaussian, etc.). spatial_pars : dict Diction...
[ "def", "set_source_morphology", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "src", "=", "self", ".", "roi", "[", "name", "]", "spatial_model", ...
Set the spatial model of a source. Parameters ---------- name : str Source name. spatial_model : str Spatial model name (PointSource, RadialGaussian, etc.). spatial_pars : dict Dictionary of spatial parameters (optional). use_cache : b...
[ "Set", "the", "spatial", "model", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L654-L696
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_source_spectrum
def set_source_spectrum(self, name, spectrum_type='PowerLaw', spectrum_pars=None, update_source=True): """Set the spectral model of a source. This function can be used to change the spectral type of a source or modify its spectral parameters. If called with ...
python
def set_source_spectrum(self, name, spectrum_type='PowerLaw', spectrum_pars=None, update_source=True): """Set the spectral model of a source. This function can be used to change the spectral type of a source or modify its spectral parameters. If called with ...
[ "def", "set_source_spectrum", "(", "self", ",", "name", ",", "spectrum_type", "=", "'PowerLaw'", ",", "spectrum_pars", "=", "None", ",", "update_source", "=", "True", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", "...
Set the spectral model of a source. This function can be used to change the spectral type of a source or modify its spectral parameters. If called with spectrum_type='FileFunction' and spectrum_pars=None, the source spectrum will be replaced with a FileFunction with the same di...
[ "Set", "the", "spectral", "model", "of", "a", "source", ".", "This", "function", "can", "be", "used", "to", "change", "the", "spectral", "type", "of", "a", "source", "or", "modify", "its", "spectral", "parameters", ".", "If", "called", "with", "spectrum_ty...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L698-L759
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_source_dnde
def set_source_dnde(self, name, dnde, update_source=True): """Set the differential flux distribution of a source with the FileFunction spectral type. Parameters ---------- name : str Source name. dnde : `~numpy.ndarray` Array of differential flux v...
python
def set_source_dnde(self, name, dnde, update_source=True): """Set the differential flux distribution of a source with the FileFunction spectral type. Parameters ---------- name : str Source name. dnde : `~numpy.ndarray` Array of differential flux v...
[ "def", "set_source_dnde", "(", "self", ",", "name", ",", "dnde", ",", "update_source", "=", "True", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "if", "self", ".", "roi", "[", "name", "]", "[", ...
Set the differential flux distribution of a source with the FileFunction spectral type. Parameters ---------- name : str Source name. dnde : `~numpy.ndarray` Array of differential flux values (cm^{-2} s^{-1} MeV^{-1}).
[ "Set", "the", "differential", "flux", "distribution", "of", "a", "source", "with", "the", "FileFunction", "spectral", "type", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L761-L794
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.get_source_dnde
def get_source_dnde(self, name): """Return differential flux distribution of a source. For sources with FileFunction spectral type this returns the internal differential flux array. Returns ------- loge : `~numpy.ndarray` Array of energies at which the differ...
python
def get_source_dnde(self, name): """Return differential flux distribution of a source. For sources with FileFunction spectral type this returns the internal differential flux array. Returns ------- loge : `~numpy.ndarray` Array of energies at which the differ...
[ "def", "get_source_dnde", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "if", "self", ".", "roi", "[", "name", "]", "[", "'SpectrumType'", "]", "!=", "'FileFunction'", ":"...
Return differential flux distribution of a source. For sources with FileFunction spectral type this returns the internal differential flux array. Returns ------- loge : `~numpy.ndarray` Array of energies at which the differential flux is evaluated (log10(E...
[ "Return", "differential", "flux", "distribution", "of", "a", "source", ".", "For", "sources", "with", "FileFunction", "spectral", "type", "this", "returns", "the", "internal", "differential", "flux", "array", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L796-L835
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis._create_filefunction
def _create_filefunction(self, name, spectrum_pars): """Replace the spectrum of an existing source with a FileFunction.""" spectrum_pars = {} if spectrum_pars is None else spectrum_pars if 'loge' in spectrum_pars: loge = spectrum_pars.get('loge') else: e...
python
def _create_filefunction(self, name, spectrum_pars): """Replace the spectrum of an existing source with a FileFunction.""" spectrum_pars = {} if spectrum_pars is None else spectrum_pars if 'loge' in spectrum_pars: loge = spectrum_pars.get('loge') else: e...
[ "def", "_create_filefunction", "(", "self", ",", "name", ",", "spectrum_pars", ")", ":", "spectrum_pars", "=", "{", "}", "if", "spectrum_pars", "is", "None", "else", "spectrum_pars", "if", "'loge'", "in", "spectrum_pars", ":", "loge", "=", "spectrum_pars", "."...
Replace the spectrum of an existing source with a FileFunction.
[ "Replace", "the", "spectrum", "of", "an", "existing", "source", "with", "a", "FileFunction", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L837-L876
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.stage_output
def stage_output(self): """Copy data products to final output directory.""" if self.workdir == self.outdir: return elif not os.path.isdir(self.workdir): self.logger.error('Working directory does not exist.') return regex = self.config['fileio']['outd...
python
def stage_output(self): """Copy data products to final output directory.""" if self.workdir == self.outdir: return elif not os.path.isdir(self.workdir): self.logger.error('Working directory does not exist.') return regex = self.config['fileio']['outd...
[ "def", "stage_output", "(", "self", ")", ":", "if", "self", ".", "workdir", "==", "self", ".", "outdir", ":", "return", "elif", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "workdir", ")", ":", "self", ".", "logger", ".", "error", "(",...
Copy data products to final output directory.
[ "Copy", "data", "products", "to", "final", "output", "directory", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L926-L966
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.stage_input
def stage_input(self): """Copy input files to working directory.""" if self.workdir == self.outdir: return elif not os.path.isdir(self.workdir): self.logger.error('Working directory does not exist.') return self.logger.info('Staging files to %s', sel...
python
def stage_input(self): """Copy input files to working directory.""" if self.workdir == self.outdir: return elif not os.path.isdir(self.workdir): self.logger.error('Working directory does not exist.') return self.logger.info('Staging files to %s', sel...
[ "def", "stage_input", "(", "self", ")", ":", "if", "self", ".", "workdir", "==", "self", ".", "outdir", ":", "return", "elif", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "workdir", ")", ":", "self", ".", "logger", ".", "error", "(", ...
Copy input files to working directory.
[ "Copy", "input", "files", "to", "working", "directory", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L968-L1009
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.setup
def setup(self, init_sources=True, overwrite=False, **kwargs): """Run pre-processing for each analysis component and construct a joint likelihood object. This function performs the following tasks: data selection (gtselect, gtmktime), data binning (gtbin), and model generation (gtexpcub...
python
def setup(self, init_sources=True, overwrite=False, **kwargs): """Run pre-processing for each analysis component and construct a joint likelihood object. This function performs the following tasks: data selection (gtselect, gtmktime), data binning (gtbin), and model generation (gtexpcub...
[ "def", "setup", "(", "self", ",", "init_sources", "=", "True", ",", "overwrite", "=", "False", ",", "*", "*", "kwargs", ")", ":", "loglevel", "=", "kwargs", ".", "get", "(", "'loglevel'", ",", "self", ".", "loglevel", ")", "self", ".", "logger", ".",...
Run pre-processing for each analysis component and construct a joint likelihood object. This function performs the following tasks: data selection (gtselect, gtmktime), data binning (gtbin), and model generation (gtexpcube2,gtsrcmaps). Parameters ---------- init_source...
[ "Run", "pre", "-", "processing", "for", "each", "analysis", "component", "and", "construct", "a", "joint", "likelihood", "object", ".", "This", "function", "performs", "the", "following", "tasks", ":", "data", "selection", "(", "gtselect", "gtmktime", ")", "da...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1011-L1068
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis._create_likelihood
def _create_likelihood(self, srcmdl=None): """Instantiate the likelihood object for each component and create a SummedLikelihood.""" self._like = SummedLikelihood() for c in self.components: c._create_binned_analysis(srcmdl) self._like.addComponent(c.like) ...
python
def _create_likelihood(self, srcmdl=None): """Instantiate the likelihood object for each component and create a SummedLikelihood.""" self._like = SummedLikelihood() for c in self.components: c._create_binned_analysis(srcmdl) self._like.addComponent(c.like) ...
[ "def", "_create_likelihood", "(", "self", ",", "srcmdl", "=", "None", ")", ":", "self", ".", "_like", "=", "SummedLikelihood", "(", ")", "for", "c", "in", "self", ".", "components", ":", "c", ".", "_create_binned_analysis", "(", "srcmdl", ")", "self", "....
Instantiate the likelihood object for each component and create a SummedLikelihood.
[ "Instantiate", "the", "likelihood", "object", "for", "each", "component", "and", "create", "a", "SummedLikelihood", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1070-L1081
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.generate_model
def generate_model(self, model_name=None): """Generate model maps for all components. model_name should be a unique identifier for the model. If model_name is None then the model maps will be generated using the current parameters of the ROI.""" for i, c in enumerate(self._com...
python
def generate_model(self, model_name=None): """Generate model maps for all components. model_name should be a unique identifier for the model. If model_name is None then the model maps will be generated using the current parameters of the ROI.""" for i, c in enumerate(self._com...
[ "def", "generate_model", "(", "self", ",", "model_name", "=", "None", ")", ":", "for", "i", ",", "c", "in", "enumerate", "(", "self", ".", "_components", ")", ":", "c", ".", "generate_model", "(", "model_name", "=", "model_name", ")" ]
Generate model maps for all components. model_name should be a unique identifier for the model. If model_name is None then the model maps will be generated using the current parameters of the ROI.
[ "Generate", "model", "maps", "for", "all", "components", ".", "model_name", "should", "be", "a", "unique", "identifier", "for", "the", "model", ".", "If", "model_name", "is", "None", "then", "the", "model", "maps", "will", "be", "generated", "using", "the", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1142-L1149
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_energy_range
def set_energy_range(self, logemin, logemax): """Set the energy bounds of the analysis. This restricts the evaluation of the likelihood to the data that falls in this range. Input values will be rounded to the closest bin edge value. If either argument is None then the lower or upper ...
python
def set_energy_range(self, logemin, logemax): """Set the energy bounds of the analysis. This restricts the evaluation of the likelihood to the data that falls in this range. Input values will be rounded to the closest bin edge value. If either argument is None then the lower or upper ...
[ "def", "set_energy_range", "(", "self", ",", "logemin", ",", "logemax", ")", ":", "if", "logemin", "is", "None", ":", "logemin", "=", "self", ".", "log_energies", "[", "0", "]", "else", ":", "imin", "=", "int", "(", "utils", ".", "val_to_edge", "(", ...
Set the energy bounds of the analysis. This restricts the evaluation of the likelihood to the data that falls in this range. Input values will be rounded to the closest bin edge value. If either argument is None then the lower or upper bound of the analysis instance will be used. ...
[ "Set", "the", "energy", "bounds", "of", "the", "analysis", ".", "This", "restricts", "the", "evaluation", "of", "the", "likelihood", "to", "the", "data", "that", "falls", "in", "this", "range", ".", "Input", "values", "will", "be", "rounded", "to", "the", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1154-L1195
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.model_counts_map
def model_counts_map(self, name=None, exclude=None, use_mask=False): """Return the model counts map for a single source, a list of sources, or for the sum of all sources in the ROI. The exclude parameter can be used to exclude one or more components when generating the model map. ...
python
def model_counts_map(self, name=None, exclude=None, use_mask=False): """Return the model counts map for a single source, a list of sources, or for the sum of all sources in the ROI. The exclude parameter can be used to exclude one or more components when generating the model map. ...
[ "def", "model_counts_map", "(", "self", ",", "name", "=", "None", ",", "exclude", "=", "None", ",", "use_mask", "=", "False", ")", ":", "maps", "=", "[", "c", ".", "model_counts_map", "(", "name", ",", "exclude", ",", "use_mask", "=", "use_mask", ")", ...
Return the model counts map for a single source, a list of sources, or for the sum of all sources in the ROI. The exclude parameter can be used to exclude one or more components when generating the model map. Parameters ---------- name : str or list of str P...
[ "Return", "the", "model", "counts", "map", "for", "a", "single", "source", "a", "list", "of", "sources", "or", "for", "the", "sum", "of", "all", "sources", "in", "the", "ROI", ".", "The", "exclude", "parameter", "can", "be", "used", "to", "exclude", "o...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1219-L1249
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.model_counts_spectrum
def model_counts_spectrum(self, name, logemin=None, logemax=None, summed=False, weighted=False): """Return the predicted number of model counts versus energy for a given source and energy range. If summed=True return the counts spectrum summed over all components o...
python
def model_counts_spectrum(self, name, logemin=None, logemax=None, summed=False, weighted=False): """Return the predicted number of model counts versus energy for a given source and energy range. If summed=True return the counts spectrum summed over all components o...
[ "def", "model_counts_spectrum", "(", "self", ",", "name", ",", "logemin", "=", "None", ",", "logemax", "=", "None", ",", "summed", "=", "False", ",", "weighted", "=", "False", ")", ":", "if", "logemin", "is", "None", ":", "logemin", "=", "self", ".", ...
Return the predicted number of model counts versus energy for a given source and energy range. If summed=True return the counts spectrum summed over all components otherwise return a list of model spectra. If weighted=True return the weighted version of the counts spectrum
[ "Return", "the", "predicted", "number", "of", "model", "counts", "versus", "energy", "for", "a", "given", "source", "and", "energy", "range", ".", "If", "summed", "=", "True", "return", "the", "counts", "spectrum", "summed", "over", "all", "components", "oth...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1251-L1286
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.get_sources
def get_sources(self, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False): """Retrieve list of sources in the ROI satisfying the given selections. Returns ------- srcs : list A ...
python
def get_sources(self, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False): """Retrieve list of sources in the ROI satisfying the given selections. Returns ------- srcs : list A ...
[ "def", "get_sources", "(", "self", ",", "cuts", "=", "None", ",", "distance", "=", "None", ",", "skydir", "=", "None", ",", "minmax_ts", "=", "None", ",", "minmax_npred", "=", "None", ",", "exclude", "=", "None", ",", "square", "=", "False", ")", ":"...
Retrieve list of sources in the ROI satisfying the given selections. Returns ------- srcs : list A list of `~fermipy.roi_model.Model` objects.
[ "Retrieve", "list", "of", "sources", "in", "the", "ROI", "satisfying", "the", "given", "selections", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1288-L1305
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.add_source
def add_source(self, name, src_dict, free=None, init_source=True, save_source_maps=True, use_pylike=True, use_single_psf=False, **kwargs): """Add a source to the ROI model. This function may be called either before or after `~fermipy.gtanalysis.GTAnalysis.setup`. ...
python
def add_source(self, name, src_dict, free=None, init_source=True, save_source_maps=True, use_pylike=True, use_single_psf=False, **kwargs): """Add a source to the ROI model. This function may be called either before or after `~fermipy.gtanalysis.GTAnalysis.setup`. ...
[ "def", "add_source", "(", "self", ",", "name", ",", "src_dict", ",", "free", "=", "None", ",", "init_source", "=", "True", ",", "save_source_maps", "=", "True", ",", "use_pylike", "=", "True", ",", "use_single_psf", "=", "False", ",", "*", "*", "kwargs",...
Add a source to the ROI model. This function may be called either before or after `~fermipy.gtanalysis.GTAnalysis.setup`. Parameters ---------- name : str Source name. src_dict : dict or `~fermipy.roi_model.Source` object Dictionary or source object def...
[ "Add", "a", "source", "to", "the", "ROI", "model", ".", "This", "function", "may", "be", "called", "either", "before", "or", "after", "~fermipy", ".", "gtanalysis", ".", "GTAnalysis", ".", "setup", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1307-L1370
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.add_sources_from_roi
def add_sources_from_roi(self, names, roi, free=False, **kwargs): """Add multiple sources to the current ROI model copied from another ROI model. Parameters ---------- names : list List of str source names to add. roi : `~fermipy.roi_model.ROIModel` object ...
python
def add_sources_from_roi(self, names, roi, free=False, **kwargs): """Add multiple sources to the current ROI model copied from another ROI model. Parameters ---------- names : list List of str source names to add. roi : `~fermipy.roi_model.ROIModel` object ...
[ "def", "add_sources_from_roi", "(", "self", ",", "names", ",", "roi", ",", "free", "=", "False", ",", "*", "*", "kwargs", ")", ":", "for", "name", "in", "names", ":", "self", ".", "add_source", "(", "name", ",", "roi", "[", "name", "]", ".", "data"...
Add multiple sources to the current ROI model copied from another ROI model. Parameters ---------- names : list List of str source names to add. roi : `~fermipy.roi_model.ROIModel` object The roi model from which to add sources. free : bool ...
[ "Add", "multiple", "sources", "to", "the", "current", "ROI", "model", "copied", "from", "another", "ROI", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1372-L1390
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.delete_source
def delete_source(self, name, save_template=True, delete_source_map=False, build_fixed_wts=True, **kwargs): """Delete a source from the ROI model. Parameters ---------- name : str Source name. save_template : bool Keep the SpatialMa...
python
def delete_source(self, name, save_template=True, delete_source_map=False, build_fixed_wts=True, **kwargs): """Delete a source from the ROI model. Parameters ---------- name : str Source name. save_template : bool Keep the SpatialMa...
[ "def", "delete_source", "(", "self", ",", "name", ",", "save_template", "=", "True", ",", "delete_source_map", "=", "False", ",", "build_fixed_wts", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "roi", ".", "has_source", "(", ...
Delete a source from the ROI model. Parameters ---------- name : str Source name. save_template : bool Keep the SpatialMap FITS template associated with this source. delete_source_map : bool Delete the source map associated with ...
[ "Delete", "a", "source", "from", "the", "ROI", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1392-L1438
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.delete_sources
def delete_sources(self, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, names=None): """Delete sources in the ROI model satisfying the given selection criteria. Parameters ---------- ...
python
def delete_sources(self, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, names=None): """Delete sources in the ROI model satisfying the given selection criteria. Parameters ---------- ...
[ "def", "delete_sources", "(", "self", ",", "cuts", "=", "None", ",", "distance", "=", "None", ",", "skydir", "=", "None", ",", "minmax_ts", "=", "None", ",", "minmax_npred", "=", "None", ",", "exclude", "=", "None", ",", "square", "=", "False", ",", ...
Delete sources in the ROI model satisfying the given selection criteria. Parameters ---------- cuts : dict Dictionary of [min,max] selections on source properties. distance : float Cut on angular distance from ``skydir``. If None then no sel...
[ "Delete", "sources", "in", "the", "ROI", "model", "satisfying", "the", "given", "selection", "criteria", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1440-L1504
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_sources_by_name
def free_sources_by_name(self, names, free=True, pars=None, **kwargs): """Free all sources with names matching ``names``. Parameters ---------- names : list List of source names. free : bool Choose whether to free (free=True)...
python
def free_sources_by_name(self, names, free=True, pars=None, **kwargs): """Free all sources with names matching ``names``. Parameters ---------- names : list List of source names. free : bool Choose whether to free (free=True)...
[ "def", "free_sources_by_name", "(", "self", ",", "names", ",", "free", "=", "True", ",", "pars", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "names", "is", "None", ":", "return", "names", "=", "[", "names", "]", "if", "not", "isinstance", ...
Free all sources with names matching ``names``. Parameters ---------- names : list List of source names. free : bool Choose whether to free (free=True) or fix (free=False) source parameters. pars : list Set a list of parameters t...
[ "Free", "all", "sources", "with", "names", "matching", "names", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1573-L1607
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_sources
def free_sources(self, free=True, pars=None, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, **kwargs): """Free or fix sources in the ROI model satisfying the given selection. When multiple selections are de...
python
def free_sources(self, free=True, pars=None, cuts=None, distance=None, skydir=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, **kwargs): """Free or fix sources in the ROI model satisfying the given selection. When multiple selections are de...
[ "def", "free_sources", "(", "self", ",", "free", "=", "True", ",", "pars", "=", "None", ",", "cuts", "=", "None", ",", "distance", "=", "None", ",", "skydir", "=", "None", ",", "minmax_ts", "=", "None", ",", "minmax_npred", "=", "None", ",", "exclude...
Free or fix sources in the ROI model satisfying the given selection. When multiple selections are defined, the selected sources will be those satisfying the logical AND of all selections (e.g. distance < X && minmax_ts[0] < ts < minmax_ts[1] && ...). Parameters --------...
[ "Free", "or", "fix", "sources", "in", "the", "ROI", "model", "satisfying", "the", "given", "selection", ".", "When", "multiple", "selections", "are", "defined", "the", "selected", "sources", "will", "be", "those", "satisfying", "the", "logical", "AND", "of", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1609-L1679
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_parameter
def set_parameter(self, name, par, value, true_value=True, scale=None, bounds=None, error=None, update_source=True): """ Update the value of a parameter. Parameter bounds will automatically be adjusted to encompass the new parameter value. Parameters ...
python
def set_parameter(self, name, par, value, true_value=True, scale=None, bounds=None, error=None, update_source=True): """ Update the value of a parameter. Parameter bounds will automatically be adjusted to encompass the new parameter value. Parameters ...
[ "def", "set_parameter", "(", "self", ",", "name", ",", "par", ",", "value", ",", "true_value", "=", "True", ",", "scale", "=", "None", ",", "bounds", "=", "None", ",", "error", "=", "None", ",", "update_source", "=", "True", ")", ":", "name", "=", ...
Update the value of a parameter. Parameter bounds will automatically be adjusted to encompass the new parameter value. Parameters ---------- name : str Source name. par : str Parameter name. value : float Parameter value. ...
[ "Update", "the", "value", "of", "a", "parameter", ".", "Parameter", "bounds", "will", "automatically", "be", "adjusted", "to", "encompass", "the", "new", "parameter", "value", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1702-L1784
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_parameter_scale
def set_parameter_scale(self, name, par, scale): """Update the scale of a parameter while keeping its value constant.""" name = self.roi.get_source_by_name(name).name idx = self.like.par_index(name, par) current_bounds = list(self.like.model[idx].getBounds()) current_scale = self...
python
def set_parameter_scale(self, name, par, scale): """Update the scale of a parameter while keeping its value constant.""" name = self.roi.get_source_by_name(name).name idx = self.like.par_index(name, par) current_bounds = list(self.like.model[idx].getBounds()) current_scale = self...
[ "def", "set_parameter_scale", "(", "self", ",", "name", ",", "par", ",", "scale", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "idx", "=", "self", ".", "like", ".", "par_index", "(", "name", ","...
Update the scale of a parameter while keeping its value constant.
[ "Update", "the", "scale", "of", "a", "parameter", "while", "keeping", "its", "value", "constant", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1786-L1798
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_parameter_bounds
def set_parameter_bounds(self, name, par, bounds): """Set the bounds on the scaled value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. bounds : list Upper and lower bound. """ ...
python
def set_parameter_bounds(self, name, par, bounds): """Set the bounds on the scaled value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. bounds : list Upper and lower bound. """ ...
[ "def", "set_parameter_bounds", "(", "self", ",", "name", ",", "par", ",", "bounds", ")", ":", "idx", "=", "self", ".", "like", ".", "par_index", "(", "name", ",", "par", ")", "self", ".", "like", "[", "idx", "]", ".", "setBounds", "(", "*", "bounds...
Set the bounds on the scaled value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. bounds : list Upper and lower bound.
[ "Set", "the", "bounds", "on", "the", "scaled", "value", "of", "a", "parameter", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1800-L1818
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.set_parameter_error
def set_parameter_error(self, name, par, error): """Set the error on the value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. error : float The value for the parameter error """ ...
python
def set_parameter_error(self, name, par, error): """Set the error on the value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. error : float The value for the parameter error """ ...
[ "def", "set_parameter_error", "(", "self", ",", "name", ",", "par", ",", "error", ")", ":", "idx", "=", "self", ".", "like", ".", "par_index", "(", "name", ",", "par", ")", "self", ".", "like", "[", "idx", "]", ".", "setError", "(", "error", ")", ...
Set the error on the value of a parameter. Parameters ---------- name : str Source name. par : str Parameter name. error : float The value for the parameter error
[ "Set", "the", "error", "on", "the", "value", "of", "a", "parameter", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1820-L1837
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.lock_parameter
def lock_parameter(self, name, par, lock=True): """Set parameter to locked/unlocked state. A locked parameter will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. par : str ...
python
def lock_parameter(self, name, par, lock=True): """Set parameter to locked/unlocked state. A locked parameter will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. par : str ...
[ "def", "lock_parameter", "(", "self", ",", "name", ",", "par", ",", "lock", "=", "True", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "lck_params", "=", "self", ".", "_lck_params", ".", "setdefaul...
Set parameter to locked/unlocked state. A locked parameter will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. par : str Parameter name. lock : bool ...
[ "Set", "parameter", "to", "locked", "/", "unlocked", "state", ".", "A", "locked", "parameter", "will", "be", "ignored", "when", "running", "methods", "that", "free", "/", "fix", "sources", "or", "parameters", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1839-L1864
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_parameter
def free_parameter(self, name, par, free=True): """Free/Fix a parameter of a source by name. Parameters ---------- name : str Source name. par : str Parameter name. """ name = self.get_source_name(name) if par in self._lck_params....
python
def free_parameter(self, name, par, free=True): """Free/Fix a parameter of a source by name. Parameters ---------- name : str Source name. par : str Parameter name. """ name = self.get_source_name(name) if par in self._lck_params....
[ "def", "free_parameter", "(", "self", ",", "name", ",", "par", ",", "free", "=", "True", ")", ":", "name", "=", "self", ".", "get_source_name", "(", "name", ")", "if", "par", "in", "self", ".", "_lck_params", ".", "get", "(", "name", ",", "[", "]",...
Free/Fix a parameter of a source by name. Parameters ---------- name : str Source name. par : str Parameter name.
[ "Free", "/", "Fix", "a", "parameter", "of", "a", "source", "by", "name", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1866-L1882
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.lock_source
def lock_source(self, name, lock=True): """Set all parameters of a source to a locked/unlocked state. Locked parameters will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. lock : boo...
python
def lock_source(self, name, lock=True): """Set all parameters of a source to a locked/unlocked state. Locked parameters will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. lock : boo...
[ "def", "lock_source", "(", "self", ",", "name", ",", "lock", "=", "True", ")", ":", "name", "=", "self", ".", "get_source_name", "(", "name", ")", "if", "lock", ":", "par_names", "=", "self", ".", "get_source_params", "(", "name", ")", "self", ".", "...
Set all parameters of a source to a locked/unlocked state. Locked parameters will be ignored when running methods that free/fix sources or parameters. Parameters ---------- name : str Source name. lock : bool Set source parameters to lock...
[ "Set", "all", "parameters", "of", "a", "source", "to", "a", "locked", "/", "unlocked", "state", ".", "Locked", "parameters", "will", "be", "ignored", "when", "running", "methods", "that", "free", "/", "fix", "sources", "or", "parameters", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1884-L1904
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_source
def free_source(self, name, free=True, pars=None, **kwargs): """Free/Fix parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False) source parameters. par...
python
def free_source(self, name, free=True, pars=None, **kwargs): """Free/Fix parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False) source parameters. par...
[ "def", "free_source", "(", "self", ",", "name", ",", "free", "=", "True", ",", "pars", "=", "None", ",", "*", "*", "kwargs", ")", ":", "free_pars", "=", "self", ".", "get_free_param_vector", "(", ")", "loglevel", "=", "kwargs", ".", "pop", "(", "'log...
Free/Fix parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False) source parameters. pars : list Set a list of parameters to be freed/fixed for this...
[ "Free", "/", "Fix", "parameters", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L1906-L1982
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_norm
def free_norm(self, name, free=True, **kwargs): """Free/Fix normalization of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ name = self.get_source_name(nam...
python
def free_norm(self, name, free=True, **kwargs): """Free/Fix normalization of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ name = self.get_source_name(nam...
[ "def", "free_norm", "(", "self", ",", "name", ",", "free", "=", "True", ",", "*", "*", "kwargs", ")", ":", "name", "=", "self", ".", "get_source_name", "(", "name", ")", "normPar", "=", "self", ".", "like", ".", "normPar", "(", "name", ")", ".", ...
Free/Fix normalization of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False).
[ "Free", "/", "Fix", "normalization", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2001-L2016
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_index
def free_index(self, name, free=True, **kwargs): """Free/Fix index of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ src = self.roi.get_source_by_name(name...
python
def free_index(self, name, free=True, **kwargs): """Free/Fix index of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ src = self.roi.get_source_by_name(name...
[ "def", "free_index", "(", "self", ",", "name", ",", "free", "=", "True", ",", "*", "*", "kwargs", ")", ":", "src", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", "self", ".", "free_source", "(", "name", ",", "free", "=", "fre...
Free/Fix index of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False).
[ "Free", "/", "Fix", "index", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2018-L2034
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.free_shape
def free_shape(self, name, free=True, **kwargs): """Free/Fix shape parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ src = self.roi.get_source_by...
python
def free_shape(self, name, free=True, **kwargs): """Free/Fix shape parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False). """ src = self.roi.get_source_by...
[ "def", "free_shape", "(", "self", ",", "name", ",", "free", "=", "True", ",", "*", "*", "kwargs", ")", ":", "src", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", "self", ".", "free_source", "(", "name", ",", "free", "=", "fre...
Free/Fix shape parameters of a source. Parameters ---------- name : str Source name. free : bool Choose whether to free (free=True) or fix (free=False).
[ "Free", "/", "Fix", "shape", "parameters", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2036-L2051
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.get_source_name
def get_source_name(self, name): """Return the name of a source as it is defined in the pyLikelihood model object.""" if name not in self.like.sourceNames(): name = self.roi.get_source_by_name(name).name return name
python
def get_source_name(self, name): """Return the name of a source as it is defined in the pyLikelihood model object.""" if name not in self.like.sourceNames(): name = self.roi.get_source_by_name(name).name return name
[ "def", "get_source_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "like", ".", "sourceNames", "(", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "return", "nam...
Return the name of a source as it is defined in the pyLikelihood model object.
[ "Return", "the", "name", "of", "a", "source", "as", "it", "is", "defined", "in", "the", "pyLikelihood", "model", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2160-L2165
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.optimize
def optimize(self, **kwargs): """Iteratively optimize the ROI model. The optimization is performed in three sequential steps: * Free the normalization of the N largest components (as determined from NPred) that contain a fraction ``npred_frac`` of the total predicted counts...
python
def optimize(self, **kwargs): """Iteratively optimize the ROI model. The optimization is performed in three sequential steps: * Free the normalization of the N largest components (as determined from NPred) that contain a fraction ``npred_frac`` of the total predicted counts...
[ "def", "optimize", "(", "self", ",", "*", "*", "kwargs", ")", ":", "loglevel", "=", "kwargs", ".", "pop", "(", "'loglevel'", ",", "self", ".", "loglevel", ")", "timer", "=", "Timer", ".", "create", "(", "start", "=", "True", ")", "self", ".", "logg...
Iteratively optimize the ROI model. The optimization is performed in three sequential steps: * Free the normalization of the N largest components (as determined from NPred) that contain a fraction ``npred_frac`` of the total predicted counts in the model and perform a sim...
[ "Iteratively", "optimize", "the", "ROI", "model", ".", "The", "optimization", "is", "performed", "in", "three", "sequential", "steps", ":" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2176-L2347
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.profile_norm
def profile_norm(self, name, logemin=None, logemax=None, reoptimize=False, xvals=None, npts=None, fix_shape=True, savestate=True, **kwargs): """Profile the normalization of a source. Parameters ---------- name : str Source name. ...
python
def profile_norm(self, name, logemin=None, logemax=None, reoptimize=False, xvals=None, npts=None, fix_shape=True, savestate=True, **kwargs): """Profile the normalization of a source. Parameters ---------- name : str Source name. ...
[ "def", "profile_norm", "(", "self", ",", "name", ",", "logemin", "=", "None", ",", "logemax", "=", "None", ",", "reoptimize", "=", "False", ",", "xvals", "=", "None", ",", "npts", "=", "None", ",", "fix_shape", "=", "True", ",", "savestate", "=", "Tr...
Profile the normalization of a source. Parameters ---------- name : str Source name. reoptimize : bool Re-optimize free parameters in the model at each point in the profile likelihood scan.
[ "Profile", "the", "normalization", "of", "a", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2349-L2436
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.profile
def profile(self, name, parName, logemin=None, logemax=None, reoptimize=False, xvals=None, npts=None, savestate=True, **kwargs): """Profile the likelihood for the given source and parameter. Parameters ---------- name : str Source name. ...
python
def profile(self, name, parName, logemin=None, logemax=None, reoptimize=False, xvals=None, npts=None, savestate=True, **kwargs): """Profile the likelihood for the given source and parameter. Parameters ---------- name : str Source name. ...
[ "def", "profile", "(", "self", ",", "name", ",", "parName", ",", "logemin", "=", "None", ",", "logemax", "=", "None", ",", "reoptimize", "=", "False", ",", "xvals", "=", "None", ",", "npts", "=", "None", ",", "savestate", "=", "True", ",", "*", "*"...
Profile the likelihood for the given source and parameter. Parameters ---------- name : str Source name. parName : str Parameter name. reoptimize : bool Re-fit nuisance parameters at each step in the scan. Note that enabling this o...
[ "Profile", "the", "likelihood", "for", "the", "given", "source", "and", "parameter", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2569-L2717
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.constrain_norms
def constrain_norms(self, srcNames, cov_scale=1.0): """Constrain the normalizations of one or more sources by adding gaussian priors with sigma equal to the parameter error times a scaling factor.""" # Get the covariance matrix for name in srcNames: par = self.like....
python
def constrain_norms(self, srcNames, cov_scale=1.0): """Constrain the normalizations of one or more sources by adding gaussian priors with sigma equal to the parameter error times a scaling factor.""" # Get the covariance matrix for name in srcNames: par = self.like....
[ "def", "constrain_norms", "(", "self", ",", "srcNames", ",", "cov_scale", "=", "1.0", ")", ":", "# Get the covariance matrix", "for", "name", "in", "srcNames", ":", "par", "=", "self", ".", "like", ".", "normPar", "(", "name", ")", "err", "=", "par", "."...
Constrain the normalizations of one or more sources by adding gaussian priors with sigma equal to the parameter error times a scaling factor.
[ "Constrain", "the", "normalizations", "of", "one", "or", "more", "sources", "by", "adding", "gaussian", "priors", "with", "sigma", "equal", "to", "the", "parameter", "error", "times", "a", "scaling", "factor", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2719-L2736
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.remove_priors
def remove_priors(self): """Clear all priors.""" for src in self.roi.sources: for par in self.like[src.name].funcs["Spectrum"].params.values(): par.removePrior()
python
def remove_priors(self): """Clear all priors.""" for src in self.roi.sources: for par in self.like[src.name].funcs["Spectrum"].params.values(): par.removePrior()
[ "def", "remove_priors", "(", "self", ")", ":", "for", "src", "in", "self", ".", "roi", ".", "sources", ":", "for", "par", "in", "self", ".", "like", "[", "src", ".", "name", "]", ".", "funcs", "[", "\"Spectrum\"", "]", ".", "params", ".", "values",...
Clear all priors.
[ "Clear", "all", "priors", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2748-L2754
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis._create_optObject
def _create_optObject(self, **kwargs): """ Make MINUIT or NewMinuit type optimizer object """ optimizer = kwargs.get('optimizer', self.config['optimizer']['optimizer']) if optimizer.upper() == 'MINUIT': optObject = pyLike.Minuit(self.like.logLike) ...
python
def _create_optObject(self, **kwargs): """ Make MINUIT or NewMinuit type optimizer object """ optimizer = kwargs.get('optimizer', self.config['optimizer']['optimizer']) if optimizer.upper() == 'MINUIT': optObject = pyLike.Minuit(self.like.logLike) ...
[ "def", "_create_optObject", "(", "self", ",", "*", "*", "kwargs", ")", ":", "optimizer", "=", "kwargs", ".", "get", "(", "'optimizer'", ",", "self", ".", "config", "[", "'optimizer'", "]", "[", "'optimizer'", "]", ")", "if", "optimizer", ".", "upper", ...
Make MINUIT or NewMinuit type optimizer object
[ "Make", "MINUIT", "or", "NewMinuit", "type", "optimizer", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2756-L2769
fermiPy/fermipy
fermipy/gtanalysis.py
GTAnalysis.fit
def fit(self, update=True, **kwargs): """Run the likelihood optimization. This will execute a fit of all parameters that are currently free in the model and update the charateristics of the corresponding model components (TS, npred, etc.). The fit will be repeated N times (set with the...
python
def fit(self, update=True, **kwargs): """Run the likelihood optimization. This will execute a fit of all parameters that are currently free in the model and update the charateristics of the corresponding model components (TS, npred, etc.). The fit will be repeated N times (set with the...
[ "def", "fit", "(", "self", ",", "update", "=", "True", ",", "*", "*", "kwargs", ")", ":", "loglevel", "=", "kwargs", ".", "pop", "(", "'loglevel'", ",", "self", ".", "loglevel", ")", "self", ".", "logger", ".", "log", "(", "loglevel", ",", "\"Start...
Run the likelihood optimization. This will execute a fit of all parameters that are currently free in the model and update the charateristics of the corresponding model components (TS, npred, etc.). The fit will be repeated N times (set with the `retries` parameter) until a fit quality...
[ "Run", "the", "likelihood", "optimization", ".", "This", "will", "execute", "a", "fit", "of", "all", "parameters", "that", "are", "currently", "free", "in", "the", "model", "and", "update", "the", "charateristics", "of", "the", "corresponding", "model", "compo...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L2903-L3020