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/wcs_utils.py
offset_to_sky
def offset_to_sky(skydir, offset_lon, offset_lat, coordsys='CEL', projection='AIT'): """Convert a cartesian offset (X,Y) in the given projection into a pair of spherical coordinates.""" offset_lon = np.array(offset_lon, ndmin=1) offset_lat = np.array(offset_lat, ndmin=1) w = crea...
python
def offset_to_sky(skydir, offset_lon, offset_lat, coordsys='CEL', projection='AIT'): """Convert a cartesian offset (X,Y) in the given projection into a pair of spherical coordinates.""" offset_lon = np.array(offset_lon, ndmin=1) offset_lat = np.array(offset_lat, ndmin=1) w = crea...
[ "def", "offset_to_sky", "(", "skydir", ",", "offset_lon", ",", "offset_lat", ",", "coordsys", "=", "'CEL'", ",", "projection", "=", "'AIT'", ")", ":", "offset_lon", "=", "np", ".", "array", "(", "offset_lon", ",", "ndmin", "=", "1", ")", "offset_lat", "=...
Convert a cartesian offset (X,Y) in the given projection into a pair of spherical coordinates.
[ "Convert", "a", "cartesian", "offset", "(", "X", "Y", ")", "in", "the", "given", "projection", "into", "a", "pair", "of", "spherical", "coordinates", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L215-L226
fermiPy/fermipy
fermipy/wcs_utils.py
sky_to_offset
def sky_to_offset(skydir, lon, lat, coordsys='CEL', projection='AIT'): """Convert sky coordinates to a projected offset. This function is the inverse of offset_to_sky.""" w = create_wcs(skydir, coordsys, projection) skycrd = np.vstack((lon, lat)).T if len(skycrd) == 0: return skycrd ...
python
def sky_to_offset(skydir, lon, lat, coordsys='CEL', projection='AIT'): """Convert sky coordinates to a projected offset. This function is the inverse of offset_to_sky.""" w = create_wcs(skydir, coordsys, projection) skycrd = np.vstack((lon, lat)).T if len(skycrd) == 0: return skycrd ...
[ "def", "sky_to_offset", "(", "skydir", ",", "lon", ",", "lat", ",", "coordsys", "=", "'CEL'", ",", "projection", "=", "'AIT'", ")", ":", "w", "=", "create_wcs", "(", "skydir", ",", "coordsys", ",", "projection", ")", "skycrd", "=", "np", ".", "vstack",...
Convert sky coordinates to a projected offset. This function is the inverse of offset_to_sky.
[ "Convert", "sky", "coordinates", "to", "a", "projected", "offset", ".", "This", "function", "is", "the", "inverse", "of", "offset_to_sky", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L229-L239
fermiPy/fermipy
fermipy/wcs_utils.py
offset_to_skydir
def offset_to_skydir(skydir, offset_lon, offset_lat, coordsys='CEL', projection='AIT'): """Convert a cartesian offset (X,Y) in the given projection into a SkyCoord.""" offset_lon = np.array(offset_lon, ndmin=1) offset_lat = np.array(offset_lat, ndmin=1) w = create_wcs(skydir, ...
python
def offset_to_skydir(skydir, offset_lon, offset_lat, coordsys='CEL', projection='AIT'): """Convert a cartesian offset (X,Y) in the given projection into a SkyCoord.""" offset_lon = np.array(offset_lon, ndmin=1) offset_lat = np.array(offset_lat, ndmin=1) w = create_wcs(skydir, ...
[ "def", "offset_to_skydir", "(", "skydir", ",", "offset_lon", ",", "offset_lat", ",", "coordsys", "=", "'CEL'", ",", "projection", "=", "'AIT'", ")", ":", "offset_lon", "=", "np", ".", "array", "(", "offset_lon", ",", "ndmin", "=", "1", ")", "offset_lat", ...
Convert a cartesian offset (X,Y) in the given projection into a SkyCoord.
[ "Convert", "a", "cartesian", "offset", "(", "X", "Y", ")", "in", "the", "given", "projection", "into", "a", "SkyCoord", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L242-L251
fermiPy/fermipy
fermipy/wcs_utils.py
skydir_to_pix
def skydir_to_pix(skydir, wcs): """Convert skydir object to pixel coordinates. Gracefully handles 0-d coordinate arrays. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` wcs : `~astropy.wcs.WCS` Returns ------- xp, yp : `numpy.ndarray` The pixel coordinates ...
python
def skydir_to_pix(skydir, wcs): """Convert skydir object to pixel coordinates. Gracefully handles 0-d coordinate arrays. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` wcs : `~astropy.wcs.WCS` Returns ------- xp, yp : `numpy.ndarray` The pixel coordinates ...
[ "def", "skydir_to_pix", "(", "skydir", ",", "wcs", ")", ":", "if", "len", "(", "skydir", ".", "shape", ")", ">", "0", "and", "len", "(", "skydir", ")", "==", "0", ":", "return", "[", "np", ".", "empty", "(", "0", ")", ",", "np", ".", "empty", ...
Convert skydir object to pixel coordinates. Gracefully handles 0-d coordinate arrays. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` wcs : `~astropy.wcs.WCS` Returns ------- xp, yp : `numpy.ndarray` The pixel coordinates
[ "Convert", "skydir", "object", "to", "pixel", "coordinates", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L254-L274
fermiPy/fermipy
fermipy/wcs_utils.py
pix_to_skydir
def pix_to_skydir(xpix, ypix, wcs): """Convert pixel coordinates to a skydir object. Gracefully handles 0-d coordinate arrays. Always returns a celestial coordinate. Parameters ---------- xpix : `numpy.ndarray` ypix : `numpy.ndarray` wcs : `~astropy.wcs.WCS` """ xpix = np.ar...
python
def pix_to_skydir(xpix, ypix, wcs): """Convert pixel coordinates to a skydir object. Gracefully handles 0-d coordinate arrays. Always returns a celestial coordinate. Parameters ---------- xpix : `numpy.ndarray` ypix : `numpy.ndarray` wcs : `~astropy.wcs.WCS` """ xpix = np.ar...
[ "def", "pix_to_skydir", "(", "xpix", ",", "ypix", ",", "wcs", ")", ":", "xpix", "=", "np", ".", "array", "(", "xpix", ")", "ypix", "=", "np", ".", "array", "(", "ypix", ")", "if", "xpix", ".", "ndim", ">", "0", "and", "len", "(", "xpix", ")", ...
Convert pixel coordinates to a skydir object. Gracefully handles 0-d coordinate arrays. Always returns a celestial coordinate. Parameters ---------- xpix : `numpy.ndarray` ypix : `numpy.ndarray` wcs : `~astropy.wcs.WCS`
[ "Convert", "pixel", "coordinates", "to", "a", "skydir", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L277-L300
fermiPy/fermipy
fermipy/wcs_utils.py
wcs_to_axes
def wcs_to_axes(w, npix): """Generate a sequence of bin edge vectors corresponding to the axes of a WCS object.""" npix = npix[::-1] x = np.linspace(-(npix[0]) / 2., (npix[0]) / 2., npix[0] + 1) * np.abs(w.wcs.cdelt[0]) y = np.linspace(-(npix[1]) / 2., (npix[1]) / 2., ...
python
def wcs_to_axes(w, npix): """Generate a sequence of bin edge vectors corresponding to the axes of a WCS object.""" npix = npix[::-1] x = np.linspace(-(npix[0]) / 2., (npix[0]) / 2., npix[0] + 1) * np.abs(w.wcs.cdelt[0]) y = np.linspace(-(npix[1]) / 2., (npix[1]) / 2., ...
[ "def", "wcs_to_axes", "(", "w", ",", "npix", ")", ":", "npix", "=", "npix", "[", ":", ":", "-", "1", "]", "x", "=", "np", ".", "linspace", "(", "-", "(", "npix", "[", "0", "]", ")", "/", "2.", ",", "(", "npix", "[", "0", "]", ")", "/", ...
Generate a sequence of bin edge vectors corresponding to the axes of a WCS object.
[ "Generate", "a", "sequence", "of", "bin", "edge", "vectors", "corresponding", "to", "the", "axes", "of", "a", "WCS", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L353-L372
fermiPy/fermipy
fermipy/wcs_utils.py
wcs_to_coords
def wcs_to_coords(w, shape): """Generate an N x D list of pixel center coordinates where N is the number of pixels and D is the dimensionality of the map.""" if w.naxis == 2: y, x = wcs_to_axes(w, shape) elif w.naxis == 3: z, y, x = wcs_to_axes(w, shape) else: raise Exception...
python
def wcs_to_coords(w, shape): """Generate an N x D list of pixel center coordinates where N is the number of pixels and D is the dimensionality of the map.""" if w.naxis == 2: y, x = wcs_to_axes(w, shape) elif w.naxis == 3: z, y, x = wcs_to_axes(w, shape) else: raise Exception...
[ "def", "wcs_to_coords", "(", "w", ",", "shape", ")", ":", "if", "w", ".", "naxis", "==", "2", ":", "y", ",", "x", "=", "wcs_to_axes", "(", "w", ",", "shape", ")", "elif", "w", ".", "naxis", "==", "3", ":", "z", ",", "y", ",", "x", "=", "wcs...
Generate an N x D list of pixel center coordinates where N is the number of pixels and D is the dimensionality of the map.
[ "Generate", "an", "N", "x", "D", "list", "of", "pixel", "center", "coordinates", "where", "N", "is", "the", "number", "of", "pixels", "and", "D", "is", "the", "dimensionality", "of", "the", "map", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L375-L398
fermiPy/fermipy
fermipy/wcs_utils.py
get_cel_to_gal_angle
def get_cel_to_gal_angle(skydir): """Calculate the rotation angle in radians between the longitude axes of a local projection in celestial and galactic coordinates. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Direction of projection center. Returns ------- an...
python
def get_cel_to_gal_angle(skydir): """Calculate the rotation angle in radians between the longitude axes of a local projection in celestial and galactic coordinates. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Direction of projection center. Returns ------- an...
[ "def", "get_cel_to_gal_angle", "(", "skydir", ")", ":", "wcs0", "=", "create_wcs", "(", "skydir", ",", "coordsys", "=", "'CEL'", ")", "wcs1", "=", "create_wcs", "(", "skydir", ",", "coordsys", "=", "'GAL'", ")", "x", ",", "y", "=", "SkyCoord", ".", "to...
Calculate the rotation angle in radians between the longitude axes of a local projection in celestial and galactic coordinates. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Direction of projection center. Returns ------- angle : float Rotation angle in rad...
[ "Calculate", "the", "rotation", "angle", "in", "radians", "between", "the", "longitude", "axes", "of", "a", "local", "projection", "in", "celestial", "and", "galactic", "coordinates", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L407-L424
fermiPy/fermipy
fermipy/wcs_utils.py
extract_mapcube_region
def extract_mapcube_region(infile, skydir, outfile, maphdu=0): """Extract a region out of an all-sky mapcube file. Parameters ---------- infile : str Path to mapcube file. skydir : `~astropy.coordinates.SkyCoord` """ h = fits.open(os.path.expandvars(infile)) npix = 200 ...
python
def extract_mapcube_region(infile, skydir, outfile, maphdu=0): """Extract a region out of an all-sky mapcube file. Parameters ---------- infile : str Path to mapcube file. skydir : `~astropy.coordinates.SkyCoord` """ h = fits.open(os.path.expandvars(infile)) npix = 200 ...
[ "def", "extract_mapcube_region", "(", "infile", ",", "skydir", ",", "outfile", ",", "maphdu", "=", "0", ")", ":", "h", "=", "fits", ".", "open", "(", "os", ".", "path", ".", "expandvars", "(", "infile", ")", ")", "npix", "=", "200", "shape", "=", "...
Extract a region out of an all-sky mapcube file. Parameters ---------- infile : str Path to mapcube file. skydir : `~astropy.coordinates.SkyCoord`
[ "Extract", "a", "region", "out", "of", "an", "all", "-", "sky", "mapcube", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L448-L493
fermiPy/fermipy
fermipy/wcs_utils.py
WCSProj.distance_to_edge
def distance_to_edge(self, skydir): """Return the angular distance from the given direction and the edge of the projection.""" xpix, ypix = skydir.to_pixel(self.wcs, origin=0) deltax = np.array((xpix - self._pix_center[0]) * self._pix_size[0], ndmin=1) ...
python
def distance_to_edge(self, skydir): """Return the angular distance from the given direction and the edge of the projection.""" xpix, ypix = skydir.to_pixel(self.wcs, origin=0) deltax = np.array((xpix - self._pix_center[0]) * self._pix_size[0], ndmin=1) ...
[ "def", "distance_to_edge", "(", "self", ",", "skydir", ")", ":", "xpix", ",", "ypix", "=", "skydir", ".", "to_pixel", "(", "self", ".", "wcs", ",", "origin", "=", "0", ")", "deltax", "=", "np", ".", "array", "(", "(", "xpix", "-", "self", ".", "_...
Return the angular distance from the given direction and the edge of the projection.
[ "Return", "the", "angular", "distance", "from", "the", "given", "direction", "and", "the", "edge", "of", "the", "projection", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L68-L91
fermiPy/fermipy
fermipy/diffuse/utils.py
readlines
def readlines(arg): """Read lines from a file into a list. Removes whitespace and lines that start with '#' """ fin = open(arg) lines_in = fin.readlines() fin.close() lines_out = [] for line in lines_in: line = line.strip() if not line or line[0] == '#': cont...
python
def readlines(arg): """Read lines from a file into a list. Removes whitespace and lines that start with '#' """ fin = open(arg) lines_in = fin.readlines() fin.close() lines_out = [] for line in lines_in: line = line.strip() if not line or line[0] == '#': cont...
[ "def", "readlines", "(", "arg", ")", ":", "fin", "=", "open", "(", "arg", ")", "lines_in", "=", "fin", ".", "readlines", "(", ")", "fin", ".", "close", "(", ")", "lines_out", "=", "[", "]", "for", "line", "in", "lines_in", ":", "line", "=", "line...
Read lines from a file into a list. Removes whitespace and lines that start with '#'
[ "Read", "lines", "from", "a", "file", "into", "a", "list", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/utils.py#L11-L25
fermiPy/fermipy
fermipy/diffuse/utils.py
create_inputlist
def create_inputlist(arglist): """Read lines from a file and makes a list of file names. Removes whitespace and lines that start with '#' Recursively read all files with the extension '.lst' """ lines = [] if isinstance(arglist, list): for arg in arglist: if os.path.splitext...
python
def create_inputlist(arglist): """Read lines from a file and makes a list of file names. Removes whitespace and lines that start with '#' Recursively read all files with the extension '.lst' """ lines = [] if isinstance(arglist, list): for arg in arglist: if os.path.splitext...
[ "def", "create_inputlist", "(", "arglist", ")", ":", "lines", "=", "[", "]", "if", "isinstance", "(", "arglist", ",", "list", ")", ":", "for", "arg", "in", "arglist", ":", "if", "os", ".", "path", ".", "splitext", "(", "arg", ")", "[", "1", "]", ...
Read lines from a file and makes a list of file names. Removes whitespace and lines that start with '#' Recursively read all files with the extension '.lst'
[ "Read", "lines", "from", "a", "file", "and", "makes", "a", "list", "of", "file", "names", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/utils.py#L28-L48
fermiPy/fermipy
fermipy/validate/tools.py
Validator.init
def init(self): """Initialize histograms.""" evclass_shape = [16, 40, 10] evtype_shape = [16, 16, 40, 10] evclass_psf_shape = [16, 40, 10, 100] evtype_psf_shape = [16, 16, 40, 10, 100] self._hists_eff = dict() self._hists = dict(evclass_on=np.zeros(evclass_shape...
python
def init(self): """Initialize histograms.""" evclass_shape = [16, 40, 10] evtype_shape = [16, 16, 40, 10] evclass_psf_shape = [16, 40, 10, 100] evtype_psf_shape = [16, 16, 40, 10, 100] self._hists_eff = dict() self._hists = dict(evclass_on=np.zeros(evclass_shape...
[ "def", "init", "(", "self", ")", ":", "evclass_shape", "=", "[", "16", ",", "40", ",", "10", "]", "evtype_shape", "=", "[", "16", ",", "16", ",", "40", ",", "10", "]", "evclass_psf_shape", "=", "[", "16", ",", "40", ",", "10", ",", "100", "]", ...
Initialize histograms.
[ "Initialize", "histograms", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/tools.py#L145-L164
fermiPy/fermipy
fermipy/validate/tools.py
Validator.create_hist
def create_hist(self, evclass, evtype, xsep, energy, ctheta, fill_sep=False, fill_evtype=False): """Load into a histogram.""" nevt = len(evclass) ebin = utils.val_to_bin(self._energy_bins, energy) scale = self._psf_scale[ebin] vals = [energy, ctheta] ...
python
def create_hist(self, evclass, evtype, xsep, energy, ctheta, fill_sep=False, fill_evtype=False): """Load into a histogram.""" nevt = len(evclass) ebin = utils.val_to_bin(self._energy_bins, energy) scale = self._psf_scale[ebin] vals = [energy, ctheta] ...
[ "def", "create_hist", "(", "self", ",", "evclass", ",", "evtype", ",", "xsep", ",", "energy", ",", "ctheta", ",", "fill_sep", "=", "False", ",", "fill_evtype", "=", "False", ")", ":", "nevt", "=", "len", "(", "evclass", ")", "ebin", "=", "utils", "."...
Load into a histogram.
[ "Load", "into", "a", "histogram", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/tools.py#L319-L358
fermiPy/fermipy
fermipy/validate/tools.py
Validator.calc_eff
def calc_eff(self): """Calculate the efficiency.""" hists = self.hists hists_out = self._hists_eff cth_axis_idx = dict(evclass=2, evtype=3) for k in ['evclass', 'evtype']: if k == 'evclass': ns0 = hists['evclass_on'][4][None, ...] nb...
python
def calc_eff(self): """Calculate the efficiency.""" hists = self.hists hists_out = self._hists_eff cth_axis_idx = dict(evclass=2, evtype=3) for k in ['evclass', 'evtype']: if k == 'evclass': ns0 = hists['evclass_on'][4][None, ...] nb...
[ "def", "calc_eff", "(", "self", ")", ":", "hists", "=", "self", ".", "hists", "hists_out", "=", "self", ".", "_hists_eff", "cth_axis_idx", "=", "dict", "(", "evclass", "=", "2", ",", "evtype", "=", "3", ")", "for", "k", "in", "[", "'evclass'", ",", ...
Calculate the efficiency.
[ "Calculate", "the", "efficiency", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/tools.py#L360-L387
fermiPy/fermipy
fermipy/validate/tools.py
Validator.calc_containment
def calc_containment(self): """Calculate PSF containment.""" hists = self.hists hists_out = self._hists_eff quantiles = [0.34, 0.68, 0.90, 0.95] cth_axis_idx = dict(evclass=2, evtype=3) for k in ['evclass']: # ,'evtype']: print(k) non = hists['...
python
def calc_containment(self): """Calculate PSF containment.""" hists = self.hists hists_out = self._hists_eff quantiles = [0.34, 0.68, 0.90, 0.95] cth_axis_idx = dict(evclass=2, evtype=3) for k in ['evclass']: # ,'evtype']: print(k) non = hists['...
[ "def", "calc_containment", "(", "self", ")", ":", "hists", "=", "self", ".", "hists", "hists_out", "=", "self", ".", "_hists_eff", "quantiles", "=", "[", "0.34", ",", "0.68", ",", "0.90", ",", "0.95", "]", "cth_axis_idx", "=", "dict", "(", "evclass", "...
Calculate PSF containment.
[ "Calculate", "PSF", "containment", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/validate/tools.py#L398-L430
fermiPy/fermipy
fermipy/config.py
create_default_config
def create_default_config(schema): """Create a configuration dictionary from a schema dictionary. The schema defines the valid configuration keys and their default values. Each element of ``schema`` should be a tuple/list containing (default value,docstring,type) or a dict containing a nested schem...
python
def create_default_config(schema): """Create a configuration dictionary from a schema dictionary. The schema defines the valid configuration keys and their default values. Each element of ``schema`` should be a tuple/list containing (default value,docstring,type) or a dict containing a nested schem...
[ "def", "create_default_config", "(", "schema", ")", ":", "o", "=", "{", "}", "for", "key", ",", "item", "in", "schema", ".", "items", "(", ")", ":", "if", "isinstance", "(", "item", ",", "dict", ")", ":", "o", "[", "key", "]", "=", "create_default_...
Create a configuration dictionary from a schema dictionary. The schema defines the valid configuration keys and their default values. Each element of ``schema`` should be a tuple/list containing (default value,docstring,type) or a dict containing a nested schema.
[ "Create", "a", "configuration", "dictionary", "from", "a", "schema", "dictionary", ".", "The", "schema", "defines", "the", "valid", "configuration", "keys", "and", "their", "default", "values", ".", "Each", "element", "of", "schema", "should", "be", "a", "tupl...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/config.py#L9-L39
fermiPy/fermipy
fermipy/config.py
update_from_schema
def update_from_schema(cfg, cfgin, schema): """Update configuration dictionary ``cfg`` with the contents of ``cfgin`` using the ``schema`` dictionary to determine the valid input keys. Parameters ---------- cfg : dict Configuration dictionary to be updated. cfgin : dict New...
python
def update_from_schema(cfg, cfgin, schema): """Update configuration dictionary ``cfg`` with the contents of ``cfgin`` using the ``schema`` dictionary to determine the valid input keys. Parameters ---------- cfg : dict Configuration dictionary to be updated. cfgin : dict New...
[ "def", "update_from_schema", "(", "cfg", ",", "cfgin", ",", "schema", ")", ":", "cfgout", "=", "copy", ".", "deepcopy", "(", "cfg", ")", "for", "k", ",", "v", "in", "schema", ".", "items", "(", ")", ":", "if", "k", "not", "in", "cfgin", ":", "con...
Update configuration dictionary ``cfg`` with the contents of ``cfgin`` using the ``schema`` dictionary to determine the valid input keys. Parameters ---------- cfg : dict Configuration dictionary to be updated. cfgin : dict New configuration dictionary that will be merged with ...
[ "Update", "configuration", "dictionary", "cfg", "with", "the", "contents", "of", "cfgin", "using", "the", "schema", "dictionary", "to", "determine", "the", "valid", "input", "keys", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/config.py#L76-L111
fermiPy/fermipy
fermipy/config.py
Configurable.write_config
def write_config(self, outfile): """Write the configuration dictionary to an output file.""" utils.write_yaml(self.config, outfile, default_flow_style=False)
python
def write_config(self, outfile): """Write the configuration dictionary to an output file.""" utils.write_yaml(self.config, outfile, default_flow_style=False)
[ "def", "write_config", "(", "self", ",", "outfile", ")", ":", "utils", ".", "write_yaml", "(", "self", ".", "config", ",", "outfile", ",", "default_flow_style", "=", "False", ")" ]
Write the configuration dictionary to an output file.
[ "Write", "the", "configuration", "dictionary", "to", "an", "output", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/config.py#L252-L254
fermiPy/fermipy
fermipy/config.py
ConfigManager.create
def create(cls, configfile): """Create a configuration dictionary from a yaml config file. This function will first populate the dictionary with defaults taken from pre-defined configuration files. The configuration dictionary is then updated with the user-defined configuration ...
python
def create(cls, configfile): """Create a configuration dictionary from a yaml config file. This function will first populate the dictionary with defaults taken from pre-defined configuration files. The configuration dictionary is then updated with the user-defined configuration ...
[ "def", "create", "(", "cls", ",", "configfile", ")", ":", "# populate config dictionary with an initial set of values", "# config_logging = ConfigManager.load('logging.yaml')", "config", "=", "{", "}", "if", "config", "[", "'fileio'", "]", "[", "'outdir'", "]", "is", "N...
Create a configuration dictionary from a yaml config file. This function will first populate the dictionary with defaults taken from pre-defined configuration files. The configuration dictionary is then updated with the user-defined configuration file. Any settings defined by the user ...
[ "Create", "a", "configuration", "dictionary", "from", "a", "yaml", "config", "file", ".", "This", "function", "will", "first", "populate", "the", "dictionary", "with", "defaults", "taken", "from", "pre", "-", "defined", "configuration", "files", ".", "The", "c...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/config.py#L269-L291
fermiPy/fermipy
fermipy/merge_utils.py
update_null_primary
def update_null_primary(hdu_in, hdu=None): """ 'Update' a null primary HDU This actually just checks hdu exists and creates it from hdu_in if it does not. """ if hdu is None: hdu = fits.PrimaryHDU(header=hdu_in.header) else: hdu = hdu_in hdu.header.remove('FILENAME') ret...
python
def update_null_primary(hdu_in, hdu=None): """ 'Update' a null primary HDU This actually just checks hdu exists and creates it from hdu_in if it does not. """ if hdu is None: hdu = fits.PrimaryHDU(header=hdu_in.header) else: hdu = hdu_in hdu.header.remove('FILENAME') ret...
[ "def", "update_null_primary", "(", "hdu_in", ",", "hdu", "=", "None", ")", ":", "if", "hdu", "is", "None", ":", "hdu", "=", "fits", ".", "PrimaryHDU", "(", "header", "=", "hdu_in", ".", "header", ")", "else", ":", "hdu", "=", "hdu_in", "hdu", ".", ...
'Update' a null primary HDU This actually just checks hdu exists and creates it from hdu_in if it does not.
[ "Update", "a", "null", "primary", "HDU" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L13-L23
fermiPy/fermipy
fermipy/merge_utils.py
update_primary
def update_primary(hdu_in, hdu=None): """ 'Update' a primary HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu """ if hdu is None: hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header) else: hdu.d...
python
def update_primary(hdu_in, hdu=None): """ 'Update' a primary HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu """ if hdu is None: hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header) else: hdu.d...
[ "def", "update_primary", "(", "hdu_in", ",", "hdu", "=", "None", ")", ":", "if", "hdu", "is", "None", ":", "hdu", "=", "fits", ".", "PrimaryHDU", "(", "data", "=", "hdu_in", ".", "data", ",", "header", "=", "hdu_in", ".", "header", ")", "else", ":"...
'Update' a primary HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu
[ "Update", "a", "primary", "HDU" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L26-L36
fermiPy/fermipy
fermipy/merge_utils.py
update_image
def update_image(hdu_in, hdu=None): """ 'Update' an image HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu """ if hdu is None: hdu = fits.ImageHDU( data=hdu_in.data, header=hdu_in.header, name=hdu_in.nam...
python
def update_image(hdu_in, hdu=None): """ 'Update' an image HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu """ if hdu is None: hdu = fits.ImageHDU( data=hdu_in.data, header=hdu_in.header, name=hdu_in.nam...
[ "def", "update_image", "(", "hdu_in", ",", "hdu", "=", "None", ")", ":", "if", "hdu", "is", "None", ":", "hdu", "=", "fits", ".", "ImageHDU", "(", "data", "=", "hdu_in", ".", "data", ",", "header", "=", "hdu_in", ".", "header", ",", "name", "=", ...
'Update' an image HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu
[ "Update", "an", "image", "HDU" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L39-L50
fermiPy/fermipy
fermipy/merge_utils.py
update_ebounds
def update_ebounds(hdu_in, hdu=None): """ 'Update' the EBOUNDS HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in """ if hdu is None: hdu = fits.BinTableHDU( data=hdu_in.data, header=hdu_...
python
def update_ebounds(hdu_in, hdu=None): """ 'Update' the EBOUNDS HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in """ if hdu is None: hdu = fits.BinTableHDU( data=hdu_in.data, header=hdu_...
[ "def", "update_ebounds", "(", "hdu_in", ",", "hdu", "=", "None", ")", ":", "if", "hdu", "is", "None", ":", "hdu", "=", "fits", ".", "BinTableHDU", "(", "data", "=", "hdu_in", ".", "data", ",", "header", "=", "hdu_in", ".", "header", ",", "name", "=...
'Update' the EBOUNDS HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in
[ "Update", "the", "EBOUNDS", "HDU" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L53-L67
fermiPy/fermipy
fermipy/merge_utils.py
merge_all_gti_data
def merge_all_gti_data(datalist_in, nrows, first): """ Merge together all the GTI data Parameters ------- datalist_in : list of `astropy.io.fits.BinTableHDU` data The GTI data that is being merged nrows : `~numpy.ndarray` of ints Array with the number of nrows for each object in da...
python
def merge_all_gti_data(datalist_in, nrows, first): """ Merge together all the GTI data Parameters ------- datalist_in : list of `astropy.io.fits.BinTableHDU` data The GTI data that is being merged nrows : `~numpy.ndarray` of ints Array with the number of nrows for each object in da...
[ "def", "merge_all_gti_data", "(", "datalist_in", ",", "nrows", ",", "first", ")", ":", "max_row", "=", "nrows", ".", "cumsum", "(", ")", "min_row", "=", "max_row", "-", "nrows", "out_hdu", "=", "fits", ".", "BinTableHDU", ".", "from_columns", "(", "first",...
Merge together all the GTI data Parameters ------- datalist_in : list of `astropy.io.fits.BinTableHDU` data The GTI data that is being merged nrows : `~numpy.ndarray` of ints Array with the number of nrows for each object in datalist_in first : `astropy.io.fits.BinTableHDU` ...
[ "Merge", "together", "all", "the", "GTI", "data" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L87-L116
fermiPy/fermipy
fermipy/merge_utils.py
extract_gti_data
def extract_gti_data(hdu_in): """ Extract some GTI related data Parameters ------- hdu_in : `astropy.io.fits.BinTableHDU` The GTI data Returns ------- data : `astropy.io.fits.BinTableHDU` data exposure : float Exposure value taken from FITS header tstop : float ...
python
def extract_gti_data(hdu_in): """ Extract some GTI related data Parameters ------- hdu_in : `astropy.io.fits.BinTableHDU` The GTI data Returns ------- data : `astropy.io.fits.BinTableHDU` data exposure : float Exposure value taken from FITS header tstop : float ...
[ "def", "extract_gti_data", "(", "hdu_in", ")", ":", "data", "=", "hdu_in", ".", "data", "exposure", "=", "hdu_in", ".", "header", "[", "'EXPOSURE'", "]", "tstop", "=", "hdu_in", ".", "header", "[", "'TSTOP'", "]", "return", "(", "data", ",", "exposure", ...
Extract some GTI related data Parameters ------- hdu_in : `astropy.io.fits.BinTableHDU` The GTI data Returns ------- data : `astropy.io.fits.BinTableHDU` data exposure : float Exposure value taken from FITS header tstop : float TSTOP value taken from FITS head...
[ "Extract", "some", "GTI", "related", "data" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L119-L141
fermiPy/fermipy
fermipy/merge_utils.py
update_hpx_skymap_allsky
def update_hpx_skymap_allsky(map_in, map_out): """ 'Update' a HEALPix skymap This checks map_out exists and creates it from map_in if it does not. If map_out does exist, this adds the data in map_in to map_out """ if map_out is None: in_hpx = map_in.hpx out_hpx = HPX.create_hpx(in_h...
python
def update_hpx_skymap_allsky(map_in, map_out): """ 'Update' a HEALPix skymap This checks map_out exists and creates it from map_in if it does not. If map_out does exist, this adds the data in map_in to map_out """ if map_out is None: in_hpx = map_in.hpx out_hpx = HPX.create_hpx(in_h...
[ "def", "update_hpx_skymap_allsky", "(", "map_in", ",", "map_out", ")", ":", "if", "map_out", "is", "None", ":", "in_hpx", "=", "map_in", ".", "hpx", "out_hpx", "=", "HPX", ".", "create_hpx", "(", "in_hpx", ".", "nside", ",", "in_hpx", ".", "nest", ",", ...
'Update' a HEALPix skymap This checks map_out exists and creates it from map_in if it does not. If map_out does exist, this adds the data in map_in to map_out
[ "Update", "a", "HEALPix", "skymap" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L144-L159
fermiPy/fermipy
fermipy/merge_utils.py
merge_wcs_counts_cubes
def merge_wcs_counts_cubes(filelist): """ Merge all the files in filelist, assuming that they WCS counts cubes """ out_prim = None out_ebounds = None datalist_gti = [] exposure_sum = 0. nfiles = len(filelist) ngti = np.zeros(nfiles, int) for i, filename in enumerate(filelist): ...
python
def merge_wcs_counts_cubes(filelist): """ Merge all the files in filelist, assuming that they WCS counts cubes """ out_prim = None out_ebounds = None datalist_gti = [] exposure_sum = 0. nfiles = len(filelist) ngti = np.zeros(nfiles, int) for i, filename in enumerate(filelist): ...
[ "def", "merge_wcs_counts_cubes", "(", "filelist", ")", ":", "out_prim", "=", "None", "out_ebounds", "=", "None", "datalist_gti", "=", "[", "]", "exposure_sum", "=", "0.", "nfiles", "=", "len", "(", "filelist", ")", "ngti", "=", "np", ".", "zeros", "(", "...
Merge all the files in filelist, assuming that they WCS counts cubes
[ "Merge", "all", "the", "files", "in", "filelist", "assuming", "that", "they", "WCS", "counts", "cubes" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L162-L201
fermiPy/fermipy
fermipy/merge_utils.py
merge_hpx_counts_cubes
def merge_hpx_counts_cubes(filelist): """ Merge all the files in filelist, assuming that they HEALPix counts cubes """ out_prim = None out_skymap = None out_ebounds = None datalist_gti = [] exposure_sum = 0. nfiles = len(filelist) ngti = np.zeros(nfiles, int) out_name = None ...
python
def merge_hpx_counts_cubes(filelist): """ Merge all the files in filelist, assuming that they HEALPix counts cubes """ out_prim = None out_skymap = None out_ebounds = None datalist_gti = [] exposure_sum = 0. nfiles = len(filelist) ngti = np.zeros(nfiles, int) out_name = None ...
[ "def", "merge_hpx_counts_cubes", "(", "filelist", ")", ":", "out_prim", "=", "None", "out_skymap", "=", "None", "out_ebounds", "=", "None", "datalist_gti", "=", "[", "]", "exposure_sum", "=", "0.", "nfiles", "=", "len", "(", "filelist", ")", "ngti", "=", "...
Merge all the files in filelist, assuming that they HEALPix counts cubes
[ "Merge", "all", "the", "files", "in", "filelist", "assuming", "that", "they", "HEALPix", "counts", "cubes" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L204-L268
fermiPy/fermipy
fermipy/diffuse/gt_srcmaps_catalog.py
GtSrcmapsCatalog.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) obs = BinnedAnalysis.BinnedObs(irfs=args.irfs, expCube=args.expcube, srcMaps=args.cmap, ...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) obs = BinnedAnalysis.BinnedObs(irfs=args.irfs, expCube=args.expcube, srcMaps=args.cmap, ...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "obs", "=", "BinnedAnalysis", ".", "BinnedObs", "(", "irfs", "=", "args", ".", "irfs", ",", "expCube", "=", "args", "...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmaps_catalog.py#L60-L100
fermiPy/fermipy
fermipy/diffuse/gt_srcmaps_catalog.py
SrcmapsCatalog_SG._make_xml_files
def _make_xml_files(catalog_info_dict, comp_info_dict): """Make all the xml file for individual components """ for val in catalog_info_dict.values(): val.roi_model.write_xml(val.srcmdl_name) for val in comp_info_dict.values(): for val2 in val.values(): ...
python
def _make_xml_files(catalog_info_dict, comp_info_dict): """Make all the xml file for individual components """ for val in catalog_info_dict.values(): val.roi_model.write_xml(val.srcmdl_name) for val in comp_info_dict.values(): for val2 in val.values(): ...
[ "def", "_make_xml_files", "(", "catalog_info_dict", ",", "comp_info_dict", ")", ":", "for", "val", "in", "catalog_info_dict", ".", "values", "(", ")", ":", "val", ".", "roi_model", ".", "write_xml", "(", "val", ".", "srcmdl_name", ")", "for", "val", "in", ...
Make all the xml file for individual components
[ "Make", "all", "the", "xml", "file", "for", "individual", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmaps_catalog.py#L131-L139
fermiPy/fermipy
fermipy/diffuse/gt_srcmaps_catalog.py
SrcmapsCatalog_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) if self._comp_dict is None or self._comp_dict_file != args['library']: ...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) if self._comp_dict is None or self._comp_dict_file != args['library']: ...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "components", "=", "Component", ".", "build_from_yamlfile", "(", "args", "[", "'comp'", "]", ")", "NAME_FACTORY", ".", "update_base_dict", "(", "args", "[", "'data'...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmaps_catalog.py#L141-L199
fermiPy/fermipy
fermipy/jobs/target_plotting.py
PlotCastro.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) exttype = splitext(args.infile)[-1] if exttype in ['.fits', '.npy']: castro_data = CastroData.create_from_sedfile(args.infile) elif exttype in ['.yaml']: castro_dat...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) exttype = splitext(args.infile)[-1] if exttype in ['.fits', '.npy']: castro_data = CastroData.create_from_sedfile(args.infile) elif exttype in ['.yaml']: castro_dat...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "exttype", "=", "splitext", "(", "args", ".", "infile", ")", "[", "-", "1", "]", "if", "exttype", "in", "[", "'.fit...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_plotting.py#L43-L59
fermiPy/fermipy
fermipy/jobs/target_plotting.py
PlotCastro_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} ttype = args['ttype'] (targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args) if targets_yaml is None: return job_configs targets = load_yaml(targets_yaml...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} ttype = args['ttype'] (targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args) if targets_yaml is None: return job_configs targets = load_yaml(targets_yaml...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "ttype", "=", "args", "[", "'ttype'", "]", "(", "targets_yaml", ",", "sim", ")", "=", "NAME_FACTORY", ".", "resolve_targetfile", "(", "args", ")", "if", "target...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_plotting.py#L80-L107
fermiPy/fermipy
fermipy/sed.py
SEDGenerator.sed
def sed(self, name, **kwargs): """Generate a spectral energy distribution (SED) for a source. This function will fit the normalization of the source in each energy bin. By default the SED will be generated with the analysis energy bins but a custom binning can be defined with t...
python
def sed(self, name, **kwargs): """Generate a spectral energy distribution (SED) for a source. This function will fit the normalization of the source in each energy bin. By default the SED will be generated with the analysis energy bins but a custom binning can be defined with t...
[ "def", "sed", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "timer", "=", "Timer", ".", "create", "(", "start", "=", "True", ")", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "# Create sc...
Generate a spectral energy distribution (SED) for a source. This function will fit the normalization of the source in each energy bin. By default the SED will be generated with the analysis energy bins but a custom binning can be defined with the ``loge_bins`` parameter. Param...
[ "Generate", "a", "spectral", "energy", "distribution", "(", "SED", ")", "for", "a", "source", ".", "This", "function", "will", "fit", "the", "normalization", "of", "the", "source", "in", "each", "energy", "bin", ".", "By", "default", "the", "SED", "will", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sed.py#L37-L111
fermiPy/fermipy
fermipy/diffuse/gt_srcmap_partial.py
GtSrcmapsDiffuse.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) obs = BinnedAnalysis.BinnedObs(irfs=args.irfs, expCube=args.expcube, srcMaps=args.cmap, ...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) obs = BinnedAnalysis.BinnedObs(irfs=args.irfs, expCube=args.expcube, srcMaps=args.cmap, ...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "obs", "=", "BinnedAnalysis", ".", "BinnedObs", "(", "irfs", "=", "args", ".", "irfs", ",", "expCube", "=", "args", "...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmap_partial.py#L66-L106
fermiPy/fermipy
fermipy/diffuse/gt_srcmap_partial.py
SrcmapsDiffuse_SG._write_xml
def _write_xml(xmlfile, srcs): """Save the ROI model as an XML """ root = ElementTree.Element('source_library') root.set('title', 'source_library') for src in srcs: src.write_xml(root) output_file = open(xmlfile, 'w') output_file.write(utils.prettify_xml(roo...
python
def _write_xml(xmlfile, srcs): """Save the ROI model as an XML """ root = ElementTree.Element('source_library') root.set('title', 'source_library') for src in srcs: src.write_xml(root) output_file = open(xmlfile, 'w') output_file.write(utils.prettify_xml(roo...
[ "def", "_write_xml", "(", "xmlfile", ",", "srcs", ")", ":", "root", "=", "ElementTree", ".", "Element", "(", "'source_library'", ")", "root", ".", "set", "(", "'title'", ",", "'source_library'", ")", "for", "src", "in", "srcs", ":", "src", ".", "write_xm...
Save the ROI model as an XML
[ "Save", "the", "ROI", "model", "as", "an", "XML" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmap_partial.py#L129-L138
fermiPy/fermipy
fermipy/diffuse/gt_srcmap_partial.py
SrcmapsDiffuse_SG._handle_component
def _handle_component(sourcekey, comp_dict): """Make the source objects and write the xml for a component """ if comp_dict.comp_key is None: fullkey = sourcekey else: fullkey = "%s_%s" % (sourcekey, comp_dict.comp_key) srcdict = make_sources(fullkey, comp_...
python
def _handle_component(sourcekey, comp_dict): """Make the source objects and write the xml for a component """ if comp_dict.comp_key is None: fullkey = sourcekey else: fullkey = "%s_%s" % (sourcekey, comp_dict.comp_key) srcdict = make_sources(fullkey, comp_...
[ "def", "_handle_component", "(", "sourcekey", ",", "comp_dict", ")", ":", "if", "comp_dict", ".", "comp_key", "is", "None", ":", "fullkey", "=", "sourcekey", "else", ":", "fullkey", "=", "\"%s_%s\"", "%", "(", "sourcekey", ",", "comp_dict", ".", "comp_key", ...
Make the source objects and write the xml for a component
[ "Make", "the", "source", "objects", "and", "write", "the", "xml", "for", "a", "component" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmap_partial.py#L141-L159
fermiPy/fermipy
fermipy/diffuse/gt_srcmap_partial.py
SrcmapsDiffuse_SG._make_xml_files
def _make_xml_files(diffuse_comp_info_dict): """Make all the xml file for individual components """ try: os.makedirs('srcmdls') except OSError: pass for sourcekey in sorted(diffuse_comp_info_dict.keys()): comp_info = diffuse_comp_info_dict[sou...
python
def _make_xml_files(diffuse_comp_info_dict): """Make all the xml file for individual components """ try: os.makedirs('srcmdls') except OSError: pass for sourcekey in sorted(diffuse_comp_info_dict.keys()): comp_info = diffuse_comp_info_dict[sou...
[ "def", "_make_xml_files", "(", "diffuse_comp_info_dict", ")", ":", "try", ":", "os", ".", "makedirs", "(", "'srcmdls'", ")", "except", "OSError", ":", "pass", "for", "sourcekey", "in", "sorted", "(", "diffuse_comp_info_dict", ".", "keys", "(", ")", ")", ":",...
Make all the xml file for individual components
[ "Make", "all", "the", "xml", "file", "for", "individual", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmap_partial.py#L162-L176
fermiPy/fermipy
fermipy/diffuse/gt_srcmap_partial.py
SrcmapsDiffuse_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) ret_dict = make_diffuse_comp_info_dict(components=components, ...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) ret_dict = make_diffuse_comp_info_dict(components=components, ...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "components", "=", "Component", ".", "build_from_yamlfile", "(", "args", "[", "'comp'", "]", ")", "NAME_FACTORY", ".", "update_base_dict", "(", "args", "[", "'data'...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_srcmap_partial.py#L178-L242
fermiPy/fermipy
fermipy/sourcefind_utils.py
fit_error_ellipse
def fit_error_ellipse(tsmap, xy=None, dpix=3, zmin=None): """Fit a positional uncertainty ellipse from a TS map. The fit will be performed over pixels in the vicinity of the peak pixel with D < dpix OR z > zmin where D is the distance from the peak pixel in pixel coordinates and z is the difference in ...
python
def fit_error_ellipse(tsmap, xy=None, dpix=3, zmin=None): """Fit a positional uncertainty ellipse from a TS map. The fit will be performed over pixels in the vicinity of the peak pixel with D < dpix OR z > zmin where D is the distance from the peak pixel in pixel coordinates and z is the difference in ...
[ "def", "fit_error_ellipse", "(", "tsmap", ",", "xy", "=", "None", ",", "dpix", "=", "3", ",", "zmin", "=", "None", ")", ":", "if", "xy", "is", "None", ":", "ix", ",", "iy", "=", "np", ".", "unravel_index", "(", "np", ".", "argmax", "(", "tsmap", ...
Fit a positional uncertainty ellipse from a TS map. The fit will be performed over pixels in the vicinity of the peak pixel with D < dpix OR z > zmin where D is the distance from the peak pixel in pixel coordinates and z is the difference in amplitude from the peak pixel. Parameters ----------...
[ "Fit", "a", "positional", "uncertainty", "ellipse", "from", "a", "TS", "map", ".", "The", "fit", "will", "be", "performed", "over", "pixels", "in", "the", "vicinity", "of", "the", "peak", "pixel", "with", "D", "<", "dpix", "OR", "z", ">", "zmin", "wher...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind_utils.py#L12-L150
fermiPy/fermipy
fermipy/sourcefind_utils.py
find_peaks
def find_peaks(input_map, threshold, min_separation=0.5): """Find peaks in a 2-D map object that have amplitude larger than `threshold` and lie a distance at least `min_separation` from another peak of larger amplitude. The implementation of this method uses `~scipy.ndimage.filters.maximum_filter`. ...
python
def find_peaks(input_map, threshold, min_separation=0.5): """Find peaks in a 2-D map object that have amplitude larger than `threshold` and lie a distance at least `min_separation` from another peak of larger amplitude. The implementation of this method uses `~scipy.ndimage.filters.maximum_filter`. ...
[ "def", "find_peaks", "(", "input_map", ",", "threshold", ",", "min_separation", "=", "0.5", ")", ":", "data", "=", "input_map", ".", "data", "cdelt", "=", "max", "(", "input_map", ".", "geom", ".", "wcs", ".", "wcs", ".", "cdelt", ")", "min_separation", ...
Find peaks in a 2-D map object that have amplitude larger than `threshold` and lie a distance at least `min_separation` from another peak of larger amplitude. The implementation of this method uses `~scipy.ndimage.filters.maximum_filter`. Parameters ---------- input_map : `~gammapy.maps.WcsMap...
[ "Find", "peaks", "in", "a", "2", "-", "D", "map", "object", "that", "have", "amplitude", "larger", "than", "threshold", "and", "lie", "a", "distance", "at", "least", "min_separation", "from", "another", "peak", "of", "larger", "amplitude", ".", "The", "imp...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind_utils.py#L153-L203
fermiPy/fermipy
fermipy/sourcefind_utils.py
estimate_pos_and_err_parabolic
def estimate_pos_and_err_parabolic(tsvals): """Solve for the position and uncertainty of source in one dimension assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsvals : `~numpy.ndarray` The TS values at the maximum TS, and for each pixel on e...
python
def estimate_pos_and_err_parabolic(tsvals): """Solve for the position and uncertainty of source in one dimension assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsvals : `~numpy.ndarray` The TS values at the maximum TS, and for each pixel on e...
[ "def", "estimate_pos_and_err_parabolic", "(", "tsvals", ")", ":", "a", "=", "tsvals", "[", "2", "]", "-", "tsvals", "[", "0", "]", "bc", "=", "2.", "*", "tsvals", "[", "1", "]", "-", "tsvals", "[", "0", "]", "-", "tsvals", "[", "2", "]", "s", "...
Solve for the position and uncertainty of source in one dimension assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsvals : `~numpy.ndarray` The TS values at the maximum TS, and for each pixel on either side Returns ------- The positio...
[ "Solve", "for", "the", "position", "and", "uncertainty", "of", "source", "in", "one", "dimension", "assuming", "that", "you", "are", "near", "the", "maximum", "and", "the", "errors", "are", "parabolic" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind_utils.py#L206-L225
fermiPy/fermipy
fermipy/sourcefind_utils.py
refine_peak
def refine_peak(tsmap, pix): """Solve for the position and uncertainty of source assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsmap : `~numpy.ndarray` Array with the TS data. Returns ------- The position and uncertainty of the source,...
python
def refine_peak(tsmap, pix): """Solve for the position and uncertainty of source assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsmap : `~numpy.ndarray` Array with the TS data. Returns ------- The position and uncertainty of the source,...
[ "def", "refine_peak", "(", "tsmap", ",", "pix", ")", ":", "# Note the annoying WCS convention", "nx", "=", "tsmap", ".", "shape", "[", "1", "]", "ny", "=", "tsmap", ".", "shape", "[", "0", "]", "if", "pix", "[", "0", "]", "==", "0", "or", "pix", "[...
Solve for the position and uncertainty of source assuming that you are near the maximum and the errors are parabolic Parameters ---------- tsmap : `~numpy.ndarray` Array with the TS data. Returns ------- The position and uncertainty of the source, in pixel units w.r.t. the cente...
[ "Solve", "for", "the", "position", "and", "uncertainty", "of", "source", "assuming", "that", "you", "are", "near", "the", "maximum", "and", "the", "errors", "are", "parabolic" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sourcefind_utils.py#L228-L263
fermiPy/fermipy
fermipy/roi_model.py
create_source_table
def create_source_table(scan_shape): """Create an empty source table. Returns ------- tab : `~astropy.table.Table` """ cols_dict = collections.OrderedDict() cols_dict['Source_Name'] = dict(dtype='S48', format='%s') cols_dict['name'] = dict(dtype='S48', format='%s') cols_dict['class...
python
def create_source_table(scan_shape): """Create an empty source table. Returns ------- tab : `~astropy.table.Table` """ cols_dict = collections.OrderedDict() cols_dict['Source_Name'] = dict(dtype='S48', format='%s') cols_dict['name'] = dict(dtype='S48', format='%s') cols_dict['class...
[ "def", "create_source_table", "(", "scan_shape", ")", ":", "cols_dict", "=", "collections", ".", "OrderedDict", "(", ")", "cols_dict", "[", "'Source_Name'", "]", "=", "dict", "(", "dtype", "=", "'S48'", ",", "format", "=", "'%s'", ")", "cols_dict", "[", "'...
Create an empty source table. Returns ------- tab : `~astropy.table.Table`
[ "Create", "an", "empty", "source", "table", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L35-L134
fermiPy/fermipy
fermipy/roi_model.py
get_skydir_distance_mask
def get_skydir_distance_mask(src_skydir, skydir, dist, min_dist=None, square=False, coordsys='CEL'): """Retrieve sources within a certain angular distance of an (ra,dec) coordinate. This function supports two types of geometric selections: circular (square=False) and square ...
python
def get_skydir_distance_mask(src_skydir, skydir, dist, min_dist=None, square=False, coordsys='CEL'): """Retrieve sources within a certain angular distance of an (ra,dec) coordinate. This function supports two types of geometric selections: circular (square=False) and square ...
[ "def", "get_skydir_distance_mask", "(", "src_skydir", ",", "skydir", ",", "dist", ",", "min_dist", "=", "None", ",", "square", "=", "False", ",", "coordsys", "=", "'CEL'", ")", ":", "if", "dist", "is", "None", ":", "dist", "=", "180.", "if", "not", "sq...
Retrieve sources within a certain angular distance of an (ra,dec) coordinate. This function supports two types of geometric selections: circular (square=False) and square (square=True). The circular selection finds all sources with a given angular distance of the target position. The square selection...
[ "Retrieve", "sources", "within", "a", "certain", "angular", "distance", "of", "an", "(", "ra", "dec", ")", "coordinate", ".", "This", "function", "supports", "two", "types", "of", "geometric", "selections", ":", "circular", "(", "square", "=", "False", ")", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L137-L188
fermiPy/fermipy
fermipy/roi_model.py
spectral_pars_from_catalog
def spectral_pars_from_catalog(cat): """Create spectral parameters from 3FGL catalog columns.""" spectrum_type = cat['SpectrumType'] pars = get_function_defaults(cat['SpectrumType']) par_idxs = {k: i for i, k in enumerate(get_function_par_names(cat['SpectrumType']))} for k in pars:...
python
def spectral_pars_from_catalog(cat): """Create spectral parameters from 3FGL catalog columns.""" spectrum_type = cat['SpectrumType'] pars = get_function_defaults(cat['SpectrumType']) par_idxs = {k: i for i, k in enumerate(get_function_par_names(cat['SpectrumType']))} for k in pars:...
[ "def", "spectral_pars_from_catalog", "(", "cat", ")", ":", "spectrum_type", "=", "cat", "[", "'SpectrumType'", "]", "pars", "=", "get_function_defaults", "(", "cat", "[", "'SpectrumType'", "]", ")", "par_idxs", "=", "{", "k", ":", "i", "for", "i", ",", "k"...
Create spectral parameters from 3FGL catalog columns.
[ "Create", "spectral", "parameters", "from", "3FGL", "catalog", "columns", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L239-L292
fermiPy/fermipy
fermipy/roi_model.py
Model.is_free
def is_free(self): """ returns True if any of the spectral model parameters is set to free, else False """ return bool(np.array([int(value.get("free", False)) for key, value in self.spectral_pars.items()]).sum())
python
def is_free(self): """ returns True if any of the spectral model parameters is set to free, else False """ return bool(np.array([int(value.get("free", False)) for key, value in self.spectral_pars.items()]).sum())
[ "def", "is_free", "(", "self", ")", ":", "return", "bool", "(", "np", ".", "array", "(", "[", "int", "(", "value", ".", "get", "(", "\"free\"", ",", "False", ")", ")", "for", "key", ",", "value", "in", "self", ".", "spectral_pars", ".", "items", ...
returns True if any of the spectral model parameters is set to free, else False
[ "returns", "True", "if", "any", "of", "the", "spectral", "model", "parameters", "is", "set", "to", "free", "else", "False" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L398-L401
fermiPy/fermipy
fermipy/roi_model.py
Source.set_position
def set_position(self, skydir): """ Set the position of the source. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` """ if not isinstance(skydir, SkyCoord): skydir = SkyCoord(ra=skydir[0], dec=skydir[1], unit=u.deg) if not s...
python
def set_position(self, skydir): """ Set the position of the source. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` """ if not isinstance(skydir, SkyCoord): skydir = SkyCoord(ra=skydir[0], dec=skydir[1], unit=u.deg) if not s...
[ "def", "set_position", "(", "self", ",", "skydir", ")", ":", "if", "not", "isinstance", "(", "skydir", ",", "SkyCoord", ")", ":", "skydir", "=", "SkyCoord", "(", "ra", "=", "skydir", "[", "0", "]", ",", "dec", "=", "skydir", "[", "1", "]", ",", "...
Set the position of the source. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord`
[ "Set", "the", "position", "of", "the", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L869-L886
fermiPy/fermipy
fermipy/roi_model.py
Source.skydir
def skydir(self): """Return a SkyCoord representation of the source position. Returns ------- skydir : `~astropy.coordinates.SkyCoord` """ return SkyCoord(self.radec[0] * u.deg, self.radec[1] * u.deg)
python
def skydir(self): """Return a SkyCoord representation of the source position. Returns ------- skydir : `~astropy.coordinates.SkyCoord` """ return SkyCoord(self.radec[0] * u.deg, self.radec[1] * u.deg)
[ "def", "skydir", "(", "self", ")", ":", "return", "SkyCoord", "(", "self", ".", "radec", "[", "0", "]", "*", "u", ".", "deg", ",", "self", ".", "radec", "[", "1", "]", "*", "u", ".", "deg", ")" ]
Return a SkyCoord representation of the source position. Returns ------- skydir : `~astropy.coordinates.SkyCoord`
[ "Return", "a", "SkyCoord", "representation", "of", "the", "source", "position", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L951-L958
fermiPy/fermipy
fermipy/roi_model.py
Source.create_from_dict
def create_from_dict(cls, src_dict, roi_skydir=None, rescale=False): """Create a source object from a python dictionary. Parameters ---------- src_dict : dict Dictionary defining the properties of the source. """ src_dict = copy.deepcopy(src_dict) src...
python
def create_from_dict(cls, src_dict, roi_skydir=None, rescale=False): """Create a source object from a python dictionary. Parameters ---------- src_dict : dict Dictionary defining the properties of the source. """ src_dict = copy.deepcopy(src_dict) src...
[ "def", "create_from_dict", "(", "cls", ",", "src_dict", ",", "roi_skydir", "=", "None", ",", "rescale", "=", "False", ")", ":", "src_dict", "=", "copy", ".", "deepcopy", "(", "src_dict", ")", "src_dict", ".", "setdefault", "(", "'SpatialModel'", ",", "'Poi...
Create a source object from a python dictionary. Parameters ---------- src_dict : dict Dictionary defining the properties of the source.
[ "Create", "a", "source", "object", "from", "a", "python", "dictionary", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L965-L1028
fermiPy/fermipy
fermipy/roi_model.py
Source.create_from_xmlfile
def create_from_xmlfile(cls, xmlfile, extdir=None): """Create a Source object from an XML file. Parameters ---------- xmlfile : str Path to XML file. extdir : str Path to the extended source archive. """ root = ElementTree.ElementTree(fil...
python
def create_from_xmlfile(cls, xmlfile, extdir=None): """Create a Source object from an XML file. Parameters ---------- xmlfile : str Path to XML file. extdir : str Path to the extended source archive. """ root = ElementTree.ElementTree(fil...
[ "def", "create_from_xmlfile", "(", "cls", ",", "xmlfile", ",", "extdir", "=", "None", ")", ":", "root", "=", "ElementTree", ".", "ElementTree", "(", "file", "=", "xmlfile", ")", ".", "getroot", "(", ")", "srcs", "=", "root", ".", "findall", "(", "'sour...
Create a Source object from an XML file. Parameters ---------- xmlfile : str Path to XML file. extdir : str Path to the extended source archive.
[ "Create", "a", "Source", "object", "from", "an", "XML", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1031-L1046
fermiPy/fermipy
fermipy/roi_model.py
Source.create_from_xml
def create_from_xml(root, extdir=None): """Create a Source object from an XML node. Parameters ---------- root : `~xml.etree.ElementTree.Element` XML node containing the source. extdir : str Path to the extended source archive. """ src_t...
python
def create_from_xml(root, extdir=None): """Create a Source object from an XML node. Parameters ---------- root : `~xml.etree.ElementTree.Element` XML node containing the source. extdir : str Path to the extended source archive. """ src_t...
[ "def", "create_from_xml", "(", "root", ",", "extdir", "=", "None", ")", ":", "src_type", "=", "root", ".", "attrib", "[", "'type'", "]", "spec", "=", "utils", ".", "load_xml_elements", "(", "root", ",", "'spectrum'", ")", "spectral_pars", "=", "utils", "...
Create a Source object from an XML node. Parameters ---------- root : `~xml.etree.ElementTree.Element` XML node containing the source. extdir : str Path to the extended source archive.
[ "Create", "a", "Source", "object", "from", "an", "XML", "node", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1049-L1154
fermiPy/fermipy
fermipy/roi_model.py
Source.write_xml
def write_xml(self, root): """Write this source to an XML node.""" if not self.extended: try: source_element = utils.create_xml_element(root, 'source', dict(name=self['Source_Name'], ...
python
def write_xml(self, root): """Write this source to an XML node.""" if not self.extended: try: source_element = utils.create_xml_element(root, 'source', dict(name=self['Source_Name'], ...
[ "def", "write_xml", "(", "self", ",", "root", ")", ":", "if", "not", "self", ".", "extended", ":", "try", ":", "source_element", "=", "utils", ".", "create_xml_element", "(", "root", ",", "'source'", ",", "dict", "(", "name", "=", "self", "[", "'Source...
Write this source to an XML node.
[ "Write", "this", "source", "to", "an", "XML", "node", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1156-L1201
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.clear
def clear(self): """Clear the contents of the ROI.""" self._srcs = [] self._diffuse_srcs = [] self._src_dict = collections.defaultdict(list) self._src_radius = []
python
def clear(self): """Clear the contents of the ROI.""" self._srcs = [] self._diffuse_srcs = [] self._src_dict = collections.defaultdict(list) self._src_radius = []
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_srcs", "=", "[", "]", "self", ".", "_diffuse_srcs", "=", "[", "]", "self", ".", "_src_dict", "=", "collections", ".", "defaultdict", "(", "list", ")", "self", ".", "_src_radius", "=", "[", "]" ]
Clear the contents of the ROI.
[ "Clear", "the", "contents", "of", "the", "ROI", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1411-L1416
fermiPy/fermipy
fermipy/roi_model.py
ROIModel._create_diffuse_src_from_xml
def _create_diffuse_src_from_xml(self, config, src_type='FileFunction'): """Load sources from an XML file. """ diffuse_xmls = config.get('diffuse_xml') srcs_out = [] for diffuse_xml in diffuse_xmls: srcs_out += self.load_xml(diffuse_xml, coordsys=config.get('coordsys'...
python
def _create_diffuse_src_from_xml(self, config, src_type='FileFunction'): """Load sources from an XML file. """ diffuse_xmls = config.get('diffuse_xml') srcs_out = [] for diffuse_xml in diffuse_xmls: srcs_out += self.load_xml(diffuse_xml, coordsys=config.get('coordsys'...
[ "def", "_create_diffuse_src_from_xml", "(", "self", ",", "config", ",", "src_type", "=", "'FileFunction'", ")", ":", "diffuse_xmls", "=", "config", ".", "get", "(", "'diffuse_xml'", ")", "srcs_out", "=", "[", "]", "for", "diffuse_xml", "in", "diffuse_xmls", ":...
Load sources from an XML file.
[ "Load", "sources", "from", "an", "XML", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1507-L1514
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create_source
def create_source(self, name, src_dict, build_index=True, merge_sources=True, rescale=True): """Add a new source to the ROI model from a dictionary or an existing source object. Parameters ---------- name : str src_dict : dict or `~fermipy.roi_mod...
python
def create_source(self, name, src_dict, build_index=True, merge_sources=True, rescale=True): """Add a new source to the ROI model from a dictionary or an existing source object. Parameters ---------- name : str src_dict : dict or `~fermipy.roi_mod...
[ "def", "create_source", "(", "self", ",", "name", ",", "src_dict", ",", "build_index", "=", "True", ",", "merge_sources", "=", "True", ",", "rescale", "=", "True", ")", ":", "src_dict", "=", "copy", ".", "deepcopy", "(", "src_dict", ")", "if", "isinstanc...
Add a new source to the ROI model from a dictionary or an existing source object. Parameters ---------- name : str src_dict : dict or `~fermipy.roi_model.Source` Returns ------- src : `~fermipy.roi_model.Source`
[ "Add", "a", "new", "source", "to", "the", "ROI", "model", "from", "a", "dictionary", "or", "an", "existing", "source", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1517-L1552
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load_sources
def load_sources(self, sources): """Delete all sources in the ROI and load the input source list.""" self.clear() for s in sources: if isinstance(s, dict): s = Model.create_from_dict(s) self.load_source(s, build_index=False) self._build_src_inde...
python
def load_sources(self, sources): """Delete all sources in the ROI and load the input source list.""" self.clear() for s in sources: if isinstance(s, dict): s = Model.create_from_dict(s) self.load_source(s, build_index=False) self._build_src_inde...
[ "def", "load_sources", "(", "self", ",", "sources", ")", ":", "self", ".", "clear", "(", ")", "for", "s", "in", "sources", ":", "if", "isinstance", "(", "s", ",", "dict", ")", ":", "s", "=", "Model", ".", "create_from_dict", "(", "s", ")", "self", ...
Delete all sources in the ROI and load the input source list.
[ "Delete", "all", "sources", "in", "the", "ROI", "and", "load", "the", "input", "source", "list", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1558-L1568
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load_source
def load_source(self, src, build_index=True, merge_sources=True, **kwargs): """ Load a single source. Parameters ---------- src : `~fermipy.roi_model.Source` Source object that will be added to the ROI. merge_sources : bool ...
python
def load_source(self, src, build_index=True, merge_sources=True, **kwargs): """ Load a single source. Parameters ---------- src : `~fermipy.roi_model.Source` Source object that will be added to the ROI. merge_sources : bool ...
[ "def", "load_source", "(", "self", ",", "src", ",", "build_index", "=", "True", ",", "merge_sources", "=", "True", ",", "*", "*", "kwargs", ")", ":", "src", "=", "copy", ".", "deepcopy", "(", "src", ")", "name", "=", "src", ".", "name", ".", "repla...
Load a single source. Parameters ---------- src : `~fermipy.roi_model.Source` Source object that will be added to the ROI. merge_sources : bool When a source matches an existing source in the model update that source with the properties of the ...
[ "Load", "a", "single", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1575-L1634
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.match_source
def match_source(self, src): """Look for source or sources in the model that match the given source. Sources are matched by name and any association columns defined in the assoc_xmatch_columns parameter. """ srcs = [] names = [src.name] for col in self.config['...
python
def match_source(self, src): """Look for source or sources in the model that match the given source. Sources are matched by name and any association columns defined in the assoc_xmatch_columns parameter. """ srcs = [] names = [src.name] for col in self.config['...
[ "def", "match_source", "(", "self", ",", "src", ")", ":", "srcs", "=", "[", "]", "names", "=", "[", "src", ".", "name", "]", "for", "col", "in", "self", ".", "config", "[", "'assoc_xmatch_columns'", "]", ":", "if", "col", "in", "src", ".", "assoc",...
Look for source or sources in the model that match the given source. Sources are matched by name and any association columns defined in the assoc_xmatch_columns parameter.
[ "Look", "for", "source", "or", "sources", "in", "the", "model", "that", "match", "the", "given", "source", ".", "Sources", "are", "matched", "by", "name", "and", "any", "association", "columns", "defined", "in", "the", "assoc_xmatch_columns", "parameter", "." ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1636-L1655
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load
def load(self, **kwargs): """Load both point source and diffuse components.""" coordsys = kwargs.get('coordsys', 'CEL') extdir = kwargs.get('extdir', self.extdir) srcname = kwargs.get('srcname', None) self.clear() self.load_diffuse_srcs() for c in self.config['...
python
def load(self, **kwargs): """Load both point source and diffuse components.""" coordsys = kwargs.get('coordsys', 'CEL') extdir = kwargs.get('extdir', self.extdir) srcname = kwargs.get('srcname', None) self.clear() self.load_diffuse_srcs() for c in self.config['...
[ "def", "load", "(", "self", ",", "*", "*", "kwargs", ")", ":", "coordsys", "=", "kwargs", ".", "get", "(", "'coordsys'", ",", "'CEL'", ")", "extdir", "=", "kwargs", ".", "get", "(", "'extdir'", ",", "self", ".", "extdir", ")", "srcname", "=", "kwar...
Load both point source and diffuse components.
[ "Load", "both", "point", "source", "and", "diffuse", "components", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1657-L1690
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create_from_roi_data
def create_from_roi_data(cls, datafile): """Create an ROI model.""" data = np.load(datafile).flat[0] roi = cls() roi.load_sources(data['sources'].values()) return roi
python
def create_from_roi_data(cls, datafile): """Create an ROI model.""" data = np.load(datafile).flat[0] roi = cls() roi.load_sources(data['sources'].values()) return roi
[ "def", "create_from_roi_data", "(", "cls", ",", "datafile", ")", ":", "data", "=", "np", ".", "load", "(", "datafile", ")", ".", "flat", "[", "0", "]", "roi", "=", "cls", "(", ")", "roi", ".", "load_sources", "(", "data", "[", "'sources'", "]", "."...
Create an ROI model.
[ "Create", "an", "ROI", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1706-L1713
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create
def create(cls, selection, config, **kwargs): """Create an ROIModel instance.""" if selection['target'] is not None: return cls.create_from_source(selection['target'], config, **kwargs) else: target_skydir = wcs_utils.get_target_...
python
def create(cls, selection, config, **kwargs): """Create an ROIModel instance.""" if selection['target'] is not None: return cls.create_from_source(selection['target'], config, **kwargs) else: target_skydir = wcs_utils.get_target_...
[ "def", "create", "(", "cls", ",", "selection", ",", "config", ",", "*", "*", "kwargs", ")", ":", "if", "selection", "[", "'target'", "]", "is", "not", "None", ":", "return", "cls", ".", "create_from_source", "(", "selection", "[", "'target'", "]", ",",...
Create an ROIModel instance.
[ "Create", "an", "ROIModel", "instance", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1716-L1724
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create_from_position
def create_from_position(cls, skydir, config, **kwargs): """Create an ROIModel instance centered on a sky direction. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky direction on which the ROI will be centered. config : dict Model con...
python
def create_from_position(cls, skydir, config, **kwargs): """Create an ROIModel instance centered on a sky direction. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky direction on which the ROI will be centered. config : dict Model con...
[ "def", "create_from_position", "(", "cls", ",", "skydir", ",", "config", ",", "*", "*", "kwargs", ")", ":", "coordsys", "=", "kwargs", ".", "pop", "(", "'coordsys'", ",", "'CEL'", ")", "roi", "=", "cls", "(", "config", ",", "skydir", "=", "skydir", "...
Create an ROIModel instance centered on a sky direction. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky direction on which the ROI will be centered. config : dict Model configuration dictionary.
[ "Create", "an", "ROIModel", "instance", "centered", "on", "a", "sky", "direction", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1727-L1742
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create_from_source
def create_from_source(cls, name, config, **kwargs): """Create an ROI centered on the given source.""" coordsys = kwargs.pop('coordsys', 'CEL') roi = cls(config, src_radius=None, src_roiwidth=None, srcname=name, **kwargs) src = roi.get_source_by_name(name) re...
python
def create_from_source(cls, name, config, **kwargs): """Create an ROI centered on the given source.""" coordsys = kwargs.pop('coordsys', 'CEL') roi = cls(config, src_radius=None, src_roiwidth=None, srcname=name, **kwargs) src = roi.get_source_by_name(name) re...
[ "def", "create_from_source", "(", "cls", ",", "name", ",", "config", ",", "*", "*", "kwargs", ")", ":", "coordsys", "=", "kwargs", ".", "pop", "(", "'coordsys'", ",", "'CEL'", ")", "roi", "=", "cls", "(", "config", ",", "src_radius", "=", "None", ","...
Create an ROI centered on the given source.
[ "Create", "an", "ROI", "centered", "on", "the", "given", "source", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1745-L1755
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.get_source_by_name
def get_source_by_name(self, name): """Return a single source in the ROI with the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. If no sources are found or m...
python
def get_source_by_name(self, name): """Return a single source in the ROI with the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. If no sources are found or m...
[ "def", "get_source_by_name", "(", "self", ",", "name", ")", ":", "srcs", "=", "self", ".", "get_sources_by_name", "(", "name", ")", "if", "len", "(", "srcs", ")", "==", "1", ":", "return", "srcs", "[", "0", "]", "elif", "len", "(", "srcs", ")", "==...
Return a single source in the ROI with the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. If no sources are found or multiple sources then an exception is thrown. ...
[ "Return", "a", "single", "source", "in", "the", "ROI", "with", "the", "given", "name", ".", "The", "input", "name", "string", "can", "match", "any", "of", "the", "strings", "in", "the", "names", "property", "of", "the", "source", "object", ".", "Case", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1771-L1796
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.get_sources_by_name
def get_sources_by_name(self, name): """Return a list of sources in the ROI matching the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. Parameters --...
python
def get_sources_by_name(self, name): """Return a list of sources in the ROI matching the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. Parameters --...
[ "def", "get_sources_by_name", "(", "self", ",", "name", ")", ":", "index_name", "=", "name", ".", "replace", "(", "' '", ",", "''", ")", ".", "lower", "(", ")", "if", "index_name", "in", "self", ".", "_src_dict", ":", "return", "list", "(", "self", "...
Return a list of sources in the ROI matching the given name. The input name string can match any of the strings in the names property of the source object. Case and whitespace are ignored when matching name strings. Parameters ---------- name : str Returns ...
[ "Return", "a", "list", "of", "sources", "in", "the", "ROI", "matching", "the", "given", "name", ".", "The", "input", "name", "string", "can", "match", "any", "of", "the", "strings", "in", "the", "names", "property", "of", "the", "source", "object", ".", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1798-L1819
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.get_sources
def get_sources(self, skydir=None, distance=None, cuts=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, coordsys='CEL', names=None): """Retrieve list of source objects satisfying the following selections: * Angular ...
python
def get_sources(self, skydir=None, distance=None, cuts=None, minmax_ts=None, minmax_npred=None, exclude=None, square=False, coordsys='CEL', names=None): """Retrieve list of source objects satisfying the following selections: * Angular ...
[ "def", "get_sources", "(", "self", ",", "skydir", "=", "None", ",", "distance", "=", "None", ",", "cuts", "=", "None", ",", "minmax_ts", "=", "None", ",", "minmax_npred", "=", "None", ",", "exclude", "=", "None", ",", "square", "=", "False", ",", "co...
Retrieve list of source objects satisfying the following selections: * Angular separation from ``skydir`` or ROI center (if ``skydir`` is None) less than ``distance``. * Cuts on source properties defined in ``cuts`` list. * TS and Npred in range specified by ``...
[ "Retrieve", "list", "of", "source", "objects", "satisfying", "the", "following", "selections", ":" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1829-L1883
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.get_sources_by_position
def get_sources_by_position(self, skydir, dist, min_dist=None, square=False, coordsys='CEL'): """Retrieve sources within a certain angular distance of a sky coordinate. This function supports two types of geometric selections: circular (square=False) and square (...
python
def get_sources_by_position(self, skydir, dist, min_dist=None, square=False, coordsys='CEL'): """Retrieve sources within a certain angular distance of a sky coordinate. This function supports two types of geometric selections: circular (square=False) and square (...
[ "def", "get_sources_by_position", "(", "self", ",", "skydir", ",", "dist", ",", "min_dist", "=", "None", ",", "square", "=", "False", ",", "coordsys", "=", "'CEL'", ")", ":", "msk", "=", "get_skydir_distance_mask", "(", "self", ".", "_src_skydir", ",", "sk...
Retrieve sources within a certain angular distance of a sky coordinate. This function supports two types of geometric selections: circular (square=False) and square (square=True). The circular selection finds all sources with a given angular distance of the target position. The square ...
[ "Retrieve", "sources", "within", "a", "certain", "angular", "distance", "of", "a", "sky", "coordinate", ".", "This", "function", "supports", "two", "types", "of", "geometric", "selections", ":", "circular", "(", "square", "=", "False", ")", "and", "square", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1898-L1938
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load_fits_catalog
def load_fits_catalog(self, name, **kwargs): """Load sources from a FITS catalog file. Parameters ---------- name : str Catalog name or path to a catalog FITS file. """ # EAC split this function to make it easier to load an existing catalog cat = cat...
python
def load_fits_catalog(self, name, **kwargs): """Load sources from a FITS catalog file. Parameters ---------- name : str Catalog name or path to a catalog FITS file. """ # EAC split this function to make it easier to load an existing catalog cat = cat...
[ "def", "load_fits_catalog", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "# EAC split this function to make it easier to load an existing catalog", "cat", "=", "catalog", ".", "Catalog", ".", "create", "(", "name", ")", "self", ".", "load_existing_ca...
Load sources from a FITS catalog file. Parameters ---------- name : str Catalog name or path to a catalog FITS file.
[ "Load", "sources", "from", "a", "FITS", "catalog", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1940-L1951
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load_existing_catalog
def load_existing_catalog(self, cat, **kwargs): """Load sources from an existing catalog object. Parameters ---------- cat : `~fermipy.catalog.Catalog` Catalog object. """ coordsys = kwargs.get('coordsys', 'CEL') extdir = kwargs.get('extdir', self.ex...
python
def load_existing_catalog(self, cat, **kwargs): """Load sources from an existing catalog object. Parameters ---------- cat : `~fermipy.catalog.Catalog` Catalog object. """ coordsys = kwargs.get('coordsys', 'CEL') extdir = kwargs.get('extdir', self.ex...
[ "def", "load_existing_catalog", "(", "self", ",", "cat", ",", "*", "*", "kwargs", ")", ":", "coordsys", "=", "kwargs", ".", "get", "(", "'coordsys'", ",", "'CEL'", ")", "extdir", "=", "kwargs", ".", "get", "(", "'extdir'", ",", "self", ".", "extdir", ...
Load sources from an existing catalog object. Parameters ---------- cat : `~fermipy.catalog.Catalog` Catalog object.
[ "Load", "sources", "from", "an", "existing", "catalog", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L1953-L2027
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.load_xml
def load_xml(self, xmlfile, **kwargs): """Load sources from an XML file.""" extdir = kwargs.get('extdir', self.extdir) coordsys = kwargs.get('coordsys', 'CEL') if not os.path.isfile(xmlfile): xmlfile = os.path.join(fermipy.PACKAGE_DATA, 'catalogs', xmlfile) root = E...
python
def load_xml(self, xmlfile, **kwargs): """Load sources from an XML file.""" extdir = kwargs.get('extdir', self.extdir) coordsys = kwargs.get('coordsys', 'CEL') if not os.path.isfile(xmlfile): xmlfile = os.path.join(fermipy.PACKAGE_DATA, 'catalogs', xmlfile) root = E...
[ "def", "load_xml", "(", "self", ",", "xmlfile", ",", "*", "*", "kwargs", ")", ":", "extdir", "=", "kwargs", ".", "get", "(", "'extdir'", ",", "self", ".", "extdir", ")", "coordsys", "=", "kwargs", ".", "get", "(", "'coordsys'", ",", "'CEL'", ")", "...
Load sources from an XML file.
[ "Load", "sources", "from", "an", "XML", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2029-L2085
fermiPy/fermipy
fermipy/roi_model.py
ROIModel._build_src_index
def _build_src_index(self): """Build an indices for fast lookup of a source given its name or coordinates.""" self._srcs = sorted(self._srcs, key=lambda t: t['offset']) nsrc = len(self._srcs) radec = np.zeros((2, nsrc)) for i, src in enumerate(self._srcs): r...
python
def _build_src_index(self): """Build an indices for fast lookup of a source given its name or coordinates.""" self._srcs = sorted(self._srcs, key=lambda t: t['offset']) nsrc = len(self._srcs) radec = np.zeros((2, nsrc)) for i, src in enumerate(self._srcs): r...
[ "def", "_build_src_index", "(", "self", ")", ":", "self", ".", "_srcs", "=", "sorted", "(", "self", ".", "_srcs", ",", "key", "=", "lambda", "t", ":", "t", "[", "'offset'", "]", ")", "nsrc", "=", "len", "(", "self", ".", "_srcs", ")", "radec", "=...
Build an indices for fast lookup of a source given its name or coordinates.
[ "Build", "an", "indices", "for", "fast", "lookup", "of", "a", "source", "given", "its", "name", "or", "coordinates", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2087-L2099
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.write_xml
def write_xml(self, xmlfile, config=None): """Save the ROI model as an XML file.""" root = ElementTree.Element('source_library') root.set('title', 'source_library') for s in self._srcs: s.write_xml(root) if config is not None: srcs = self.create_diffuse...
python
def write_xml(self, xmlfile, config=None): """Save the ROI model as an XML file.""" root = ElementTree.Element('source_library') root.set('title', 'source_library') for s in self._srcs: s.write_xml(root) if config is not None: srcs = self.create_diffuse...
[ "def", "write_xml", "(", "self", ",", "xmlfile", ",", "config", "=", "None", ")", ":", "root", "=", "ElementTree", ".", "Element", "(", "'source_library'", ")", "root", ".", "set", "(", "'title'", ",", "'source_library'", ")", "for", "s", "in", "self", ...
Save the ROI model as an XML file.
[ "Save", "the", "ROI", "model", "as", "an", "XML", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2101-L2122
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.create_table
def create_table(self, names=None): """Create an astropy Table object with the contents of the ROI model. """ scan_shape = (1,) for src in self._srcs: scan_shape = max(scan_shape, src['dloglike_scan'].shape) tab = create_source_table(scan_shape) for s in sel...
python
def create_table(self, names=None): """Create an astropy Table object with the contents of the ROI model. """ scan_shape = (1,) for src in self._srcs: scan_shape = max(scan_shape, src['dloglike_scan'].shape) tab = create_source_table(scan_shape) for s in sel...
[ "def", "create_table", "(", "self", ",", "names", "=", "None", ")", ":", "scan_shape", "=", "(", "1", ",", ")", "for", "src", "in", "self", ".", "_srcs", ":", "scan_shape", "=", "max", "(", "scan_shape", ",", "src", "[", "'dloglike_scan'", "]", ".", ...
Create an astropy Table object with the contents of the ROI model.
[ "Create", "an", "astropy", "Table", "object", "with", "the", "contents", "of", "the", "ROI", "model", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2184-L2198
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.write_fits
def write_fits(self, fitsfile): """Write the ROI model to a FITS file.""" tab = self.create_table() hdu_data = fits.table_to_hdu(tab) hdus = [fits.PrimaryHDU(), hdu_data] fits_utils.write_hdus(hdus, fitsfile)
python
def write_fits(self, fitsfile): """Write the ROI model to a FITS file.""" tab = self.create_table() hdu_data = fits.table_to_hdu(tab) hdus = [fits.PrimaryHDU(), hdu_data] fits_utils.write_hdus(hdus, fitsfile)
[ "def", "write_fits", "(", "self", ",", "fitsfile", ")", ":", "tab", "=", "self", ".", "create_table", "(", ")", "hdu_data", "=", "fits", ".", "table_to_hdu", "(", "tab", ")", "hdus", "=", "[", "fits", ".", "PrimaryHDU", "(", ")", ",", "hdu_data", "]"...
Write the ROI model to a FITS file.
[ "Write", "the", "ROI", "model", "to", "a", "FITS", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2200-L2206
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.to_ds9
def to_ds9(self, free='box',fixed='cross',frame='fk5',color='green',header=True): """Returns a list of ds9 region definitions Parameters ---------- free: bool one of the supported ds9 point symbols, used for free sources, see here: http://ds9.si.edu/doc/ref/region.html ...
python
def to_ds9(self, free='box',fixed='cross',frame='fk5',color='green',header=True): """Returns a list of ds9 region definitions Parameters ---------- free: bool one of the supported ds9 point symbols, used for free sources, see here: http://ds9.si.edu/doc/ref/region.html ...
[ "def", "to_ds9", "(", "self", ",", "free", "=", "'box'", ",", "fixed", "=", "'cross'", ",", "frame", "=", "'fk5'", ",", "color", "=", "'green'", ",", "header", "=", "True", ")", ":", "# todo: add support for extended sources?!", "allowed_symbols", "=", "[", ...
Returns a list of ds9 region definitions Parameters ---------- free: bool one of the supported ds9 point symbols, used for free sources, see here: http://ds9.si.edu/doc/ref/region.html fixed: bool as free but for fixed sources frame: str ...
[ "Returns", "a", "list", "of", "ds9", "region", "definitions", "Parameters", "----------", "free", ":", "bool", "one", "of", "the", "supported", "ds9", "point", "symbols", "used", "for", "free", "sources", "see", "here", ":", "http", ":", "//", "ds9", ".", ...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2208-L2251
fermiPy/fermipy
fermipy/roi_model.py
ROIModel.write_ds9region
def write_ds9region(self, region, *args, **kwargs): """Create a ds9 compatible region file from the ROI. It calls the `to_ds9` method and write the result to the region file. Only the file name is required. All other parameters will be forwarded to the `to_ds9` method, see the documentation of...
python
def write_ds9region(self, region, *args, **kwargs): """Create a ds9 compatible region file from the ROI. It calls the `to_ds9` method and write the result to the region file. Only the file name is required. All other parameters will be forwarded to the `to_ds9` method, see the documentation of...
[ "def", "write_ds9region", "(", "self", ",", "region", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "self", ".", "to_ds9", "(", "*", "args", ",", "*", "*", "kwargs", ")", "with", "open", "(", "region", ",", "'w'", ")", "as", ...
Create a ds9 compatible region file from the ROI. It calls the `to_ds9` method and write the result to the region file. Only the file name is required. All other parameters will be forwarded to the `to_ds9` method, see the documentation of that method for all accepted parameters and options. ...
[ "Create", "a", "ds9", "compatible", "region", "file", "from", "the", "ROI", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2253-L2267
fermiPy/fermipy
fermipy/scripts/select_data.py
main
def main(): gtselect_keys = ['tmin', 'tmax', 'emin', 'emax', 'zmax', 'evtype', 'evclass', 'phasemin', 'phasemax', 'convtype', 'rad', 'ra', 'dec'] gtmktime_keys = ['roicut', 'filter'] usage = "usage: %(prog)s [options] " description = "Run gtselect and gtmktime on one or more FT1 ...
python
def main(): gtselect_keys = ['tmin', 'tmax', 'emin', 'emax', 'zmax', 'evtype', 'evclass', 'phasemin', 'phasemax', 'convtype', 'rad', 'ra', 'dec'] gtmktime_keys = ['roicut', 'filter'] usage = "usage: %(prog)s [options] " description = "Run gtselect and gtmktime on one or more FT1 ...
[ "def", "main", "(", ")", ":", "gtselect_keys", "=", "[", "'tmin'", ",", "'tmax'", ",", "'emin'", ",", "'emax'", ",", "'zmax'", ",", "'evtype'", ",", "'evclass'", ",", "'phasemin'", ",", "'phasemax'", ",", "'convtype'", ",", "'rad'", ",", "'ra'", ",", "...
Note that gtmktime will be skipped if no FT2 file is provided.
[ "Note", "that", "gtmktime", "will", "be", "skipped", "if", "no", "FT2", "file", "is", "provided", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/select_data.py#L27-L208
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
select_extended
def select_extended(cat_table): """Select only rows representing extended sources from a catalog table """ try: l = [len(row.strip()) > 0 for row in cat_table['Extended_Source_Name'].data] return np.array(l, bool) except KeyError: return cat_table['Extended']
python
def select_extended(cat_table): """Select only rows representing extended sources from a catalog table """ try: l = [len(row.strip()) > 0 for row in cat_table['Extended_Source_Name'].data] return np.array(l, bool) except KeyError: return cat_table['Extended']
[ "def", "select_extended", "(", "cat_table", ")", ":", "try", ":", "l", "=", "[", "len", "(", "row", ".", "strip", "(", ")", ")", ">", "0", "for", "row", "in", "cat_table", "[", "'Extended_Source_Name'", "]", ".", "data", "]", "return", "np", ".", "...
Select only rows representing extended sources from a catalog table
[ "Select", "only", "rows", "representing", "extended", "sources", "from", "a", "catalog", "table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L23-L30
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
make_mask
def make_mask(cat_table, cut): """Mask a bit mask selecting the rows that pass a selection """ cut_var = cut['cut_var'] min_val = cut.get('min_val', None) max_val = cut.get('max_val', None) nsrc = len(cat_table) if min_val is None: min_mask = np.ones((nsrc), bool) else: ...
python
def make_mask(cat_table, cut): """Mask a bit mask selecting the rows that pass a selection """ cut_var = cut['cut_var'] min_val = cut.get('min_val', None) max_val = cut.get('max_val', None) nsrc = len(cat_table) if min_val is None: min_mask = np.ones((nsrc), bool) else: ...
[ "def", "make_mask", "(", "cat_table", ",", "cut", ")", ":", "cut_var", "=", "cut", "[", "'cut_var'", "]", "min_val", "=", "cut", ".", "get", "(", "'min_val'", ",", "None", ")", "max_val", "=", "cut", ".", "get", "(", "'max_val'", ",", "None", ")", ...
Mask a bit mask selecting the rows that pass a selection
[ "Mask", "a", "bit", "mask", "selecting", "the", "rows", "that", "pass", "a", "selection" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L33-L50
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
select_sources
def select_sources(cat_table, cuts): """Select only rows passing a set of cuts from catalog table """ nsrc = len(cat_table) full_mask = np.ones((nsrc), bool) for cut in cuts: if cut == 'mask_extended': full_mask *= mask_extended(cat_table) elif cut == 'select_extended': ...
python
def select_sources(cat_table, cuts): """Select only rows passing a set of cuts from catalog table """ nsrc = len(cat_table) full_mask = np.ones((nsrc), bool) for cut in cuts: if cut == 'mask_extended': full_mask *= mask_extended(cat_table) elif cut == 'select_extended': ...
[ "def", "select_sources", "(", "cat_table", ",", "cuts", ")", ":", "nsrc", "=", "len", "(", "cat_table", ")", "full_mask", "=", "np", ".", "ones", "(", "(", "nsrc", ")", ",", "bool", ")", "for", "cut", "in", "cuts", ":", "if", "cut", "==", "'mask_ex...
Select only rows passing a set of cuts from catalog table
[ "Select", "only", "rows", "passing", "a", "set", "of", "cuts", "from", "catalog", "table" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L53-L67
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
make_catalog_comp_dict
def make_catalog_comp_dict(**kwargs): """Build and return the information about the catalog components """ library_yamlfile = kwargs.pop('library', 'models/library.yaml') csm = kwargs.pop('CatalogSourceManager', CatalogSourceManager(**kwargs)) if library_yamlfile is None or library_yamlfile == 'None...
python
def make_catalog_comp_dict(**kwargs): """Build and return the information about the catalog components """ library_yamlfile = kwargs.pop('library', 'models/library.yaml') csm = kwargs.pop('CatalogSourceManager', CatalogSourceManager(**kwargs)) if library_yamlfile is None or library_yamlfile == 'None...
[ "def", "make_catalog_comp_dict", "(", "*", "*", "kwargs", ")", ":", "library_yamlfile", "=", "kwargs", ".", "pop", "(", "'library'", ",", "'models/library.yaml'", ")", "csm", "=", "kwargs", ".", "pop", "(", "'CatalogSourceManager'", ",", "CatalogSourceManager", ...
Build and return the information about the catalog components
[ "Build", "and", "return", "the", "information", "about", "the", "catalog", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L256-L268
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.read_catalog_info_yaml
def read_catalog_info_yaml(self, splitkey): """ Read the yaml file for a particular split key """ catalog_info_yaml = self._name_factory.catalog_split_yaml(sourcekey=splitkey, fullpath=True) yaml_dict = yaml.safe_load(open...
python
def read_catalog_info_yaml(self, splitkey): """ Read the yaml file for a particular split key """ catalog_info_yaml = self._name_factory.catalog_split_yaml(sourcekey=splitkey, fullpath=True) yaml_dict = yaml.safe_load(open...
[ "def", "read_catalog_info_yaml", "(", "self", ",", "splitkey", ")", ":", "catalog_info_yaml", "=", "self", ".", "_name_factory", ".", "catalog_split_yaml", "(", "sourcekey", "=", "splitkey", ",", "fullpath", "=", "True", ")", "yaml_dict", "=", "yaml", ".", "sa...
Read the yaml file for a particular split key
[ "Read", "the", "yaml", "file", "for", "a", "particular", "split", "key" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L101-L110
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.build_catalog_info
def build_catalog_info(self, catalog_info): """ Build a CatalogInfo object """ cat = SourceFactory.build_catalog(**catalog_info) catalog_info['catalog'] = cat # catalog_info['catalog_table'] = # Table.read(catalog_info['catalog_file']) catalog_info['catalog_table'] = c...
python
def build_catalog_info(self, catalog_info): """ Build a CatalogInfo object """ cat = SourceFactory.build_catalog(**catalog_info) catalog_info['catalog'] = cat # catalog_info['catalog_table'] = # Table.read(catalog_info['catalog_file']) catalog_info['catalog_table'] = c...
[ "def", "build_catalog_info", "(", "self", ",", "catalog_info", ")", ":", "cat", "=", "SourceFactory", ".", "build_catalog", "(", "*", "*", "catalog_info", ")", "catalog_info", "[", "'catalog'", "]", "=", "cat", "# catalog_info['catalog_table'] =", "# Table.read(c...
Build a CatalogInfo object
[ "Build", "a", "CatalogInfo", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L112-L123
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.catalog_components
def catalog_components(self, catalog_name, split_ver): """ Return the set of merged components for a particular split key """ return sorted(self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)].keys())
python
def catalog_components(self, catalog_name, split_ver): """ Return the set of merged components for a particular split key """ return sorted(self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)].keys())
[ "def", "catalog_components", "(", "self", ",", "catalog_name", ",", "split_ver", ")", ":", "return", "sorted", "(", "self", ".", "_split_comp_info_dicts", "[", "\"%s_%s\"", "%", "(", "catalog_name", ",", "split_ver", ")", "]", ".", "keys", "(", ")", ")" ]
Return the set of merged components for a particular split key
[ "Return", "the", "set", "of", "merged", "components", "for", "a", "particular", "split", "key" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L141-L143
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.split_comp_info
def split_comp_info(self, catalog_name, split_ver, split_key): """ Return the info for a particular split key """ return self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)][split_key]
python
def split_comp_info(self, catalog_name, split_ver, split_key): """ Return the info for a particular split key """ return self._split_comp_info_dicts["%s_%s" % (catalog_name, split_ver)][split_key]
[ "def", "split_comp_info", "(", "self", ",", "catalog_name", ",", "split_ver", ",", "split_key", ")", ":", "return", "self", ".", "_split_comp_info_dicts", "[", "\"%s_%s\"", "%", "(", "catalog_name", ",", "split_ver", ")", "]", "[", "split_key", "]" ]
Return the info for a particular split key
[ "Return", "the", "info", "for", "a", "particular", "split", "key" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L145-L147
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.make_catalog_comp_info
def make_catalog_comp_info(self, full_cat_info, split_key, rule_key, rule_val, sources): """ Make the information about a single merged component Parameters ---------- full_cat_info : `_model_component.CatalogInfo` Information about the full catalog split_key : str ...
python
def make_catalog_comp_info(self, full_cat_info, split_key, rule_key, rule_val, sources): """ Make the information about a single merged component Parameters ---------- full_cat_info : `_model_component.CatalogInfo` Information about the full catalog split_key : str ...
[ "def", "make_catalog_comp_info", "(", "self", ",", "full_cat_info", ",", "split_key", ",", "rule_key", ",", "rule_val", ",", "sources", ")", ":", "merge", "=", "rule_val", ".", "get", "(", "'merge'", ",", "True", ")", "sourcekey", "=", "\"%s_%s_%s\"", "%", ...
Make the information about a single merged component Parameters ---------- full_cat_info : `_model_component.CatalogInfo` Information about the full catalog split_key : str Key identifying the version of the spliting used rule_key : str Key i...
[ "Make", "the", "information", "about", "a", "single", "merged", "component" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L149-L183
fermiPy/fermipy
fermipy/diffuse/catalog_src_manager.py
CatalogSourceManager.make_catalog_comp_info_dict
def make_catalog_comp_info_dict(self, catalog_sources): """ Make the information about the catalog components Parameters ---------- catalog_sources : dict Dictionary with catalog source defintions Returns ------- catalog_ret_dict : dict ...
python
def make_catalog_comp_info_dict(self, catalog_sources): """ Make the information about the catalog components Parameters ---------- catalog_sources : dict Dictionary with catalog source defintions Returns ------- catalog_ret_dict : dict ...
[ "def", "make_catalog_comp_info_dict", "(", "self", ",", "catalog_sources", ")", ":", "catalog_ret_dict", "=", "{", "}", "split_ret_dict", "=", "{", "}", "for", "key", ",", "value", "in", "catalog_sources", ".", "items", "(", ")", ":", "if", "value", "is", ...
Make the information about the catalog components Parameters ---------- catalog_sources : dict Dictionary with catalog source defintions Returns ------- catalog_ret_dict : dict Dictionary mapping catalog_name to `model_component.CatalogInfo` ...
[ "Make", "the", "information", "about", "the", "catalog", "components" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/catalog_src_manager.py#L185-L253
fermiPy/fermipy
fermipy/tsmap.py
extract_images_from_tscube
def extract_images_from_tscube(infile, outfile): """ Extract data from table HDUs in TSCube file and convert them to FITS images """ inhdulist = fits.open(infile) wcs = pywcs.WCS(inhdulist[0].header) map_shape = inhdulist[0].data.shape t_eng = Table.read(infile, "EBOUNDS") t_scan = Table.re...
python
def extract_images_from_tscube(infile, outfile): """ Extract data from table HDUs in TSCube file and convert them to FITS images """ inhdulist = fits.open(infile) wcs = pywcs.WCS(inhdulist[0].header) map_shape = inhdulist[0].data.shape t_eng = Table.read(infile, "EBOUNDS") t_scan = Table.re...
[ "def", "extract_images_from_tscube", "(", "infile", ",", "outfile", ")", ":", "inhdulist", "=", "fits", ".", "open", "(", "infile", ")", "wcs", "=", "pywcs", ".", "WCS", "(", "inhdulist", "[", "0", "]", ".", "header", ")", "map_shape", "=", "inhdulist", ...
Extract data from table HDUs in TSCube file and convert them to FITS images
[ "Extract", "data", "from", "table", "HDUs", "in", "TSCube", "file", "and", "convert", "them", "to", "FITS", "images" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L35-L74
fermiPy/fermipy
fermipy/tsmap.py
convert_tscube_old
def convert_tscube_old(infile, outfile): """Convert between old and new TSCube formats.""" inhdulist = fits.open(infile) # If already in the new-style format just write and exit if 'DLOGLIKE_SCAN' in inhdulist['SCANDATA'].columns.names: if infile != outfile: inhdulist.writeto(outfil...
python
def convert_tscube_old(infile, outfile): """Convert between old and new TSCube formats.""" inhdulist = fits.open(infile) # If already in the new-style format just write and exit if 'DLOGLIKE_SCAN' in inhdulist['SCANDATA'].columns.names: if infile != outfile: inhdulist.writeto(outfil...
[ "def", "convert_tscube_old", "(", "infile", ",", "outfile", ")", ":", "inhdulist", "=", "fits", ".", "open", "(", "infile", ")", "# If already in the new-style format just write and exit", "if", "'DLOGLIKE_SCAN'", "in", "inhdulist", "[", "'SCANDATA'", "]", ".", "col...
Convert between old and new TSCube formats.
[ "Convert", "between", "old", "and", "new", "TSCube", "formats", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L104-L262
fermiPy/fermipy
fermipy/tsmap.py
truncate_array
def truncate_array(array1, array2, position): """Truncate array1 by finding the overlap with array2 when the array1 center is located at the given position in array2.""" slices = [] for i in range(array1.ndim): xmin = 0 xmax = array1.shape[i] dxlo = array1.shape[i] // 2 ...
python
def truncate_array(array1, array2, position): """Truncate array1 by finding the overlap with array2 when the array1 center is located at the given position in array2.""" slices = [] for i in range(array1.ndim): xmin = 0 xmax = array1.shape[i] dxlo = array1.shape[i] // 2 ...
[ "def", "truncate_array", "(", "array1", ",", "array2", ",", "position", ")", ":", "slices", "=", "[", "]", "for", "i", "in", "range", "(", "array1", ".", "ndim", ")", ":", "xmin", "=", "0", "xmax", "=", "array1", ".", "shape", "[", "i", "]", "dxl...
Truncate array1 by finding the overlap with array2 when the array1 center is located at the given position in array2.
[ "Truncate", "array1", "by", "finding", "the", "overlap", "with", "array2", "when", "the", "array1", "center", "is", "located", "at", "the", "given", "position", "in", "array2", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L265-L283
fermiPy/fermipy
fermipy/tsmap.py
_sum_wrapper
def _sum_wrapper(fn): """ Wrapper to perform row-wise aggregation of list arguments and pass them to a function. The return value of the function is summed over the argument groups. Non-list arguments will be automatically cast to a list. """ def wrapper(*args, **kwargs): v = 0 ...
python
def _sum_wrapper(fn): """ Wrapper to perform row-wise aggregation of list arguments and pass them to a function. The return value of the function is summed over the argument groups. Non-list arguments will be automatically cast to a list. """ def wrapper(*args, **kwargs): v = 0 ...
[ "def", "_sum_wrapper", "(", "fn", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "v", "=", "0", "new_args", "=", "_cast_args_to_list", "(", "args", ")", "for", "arg", "in", "zip", "(", "*", "new_args", ")", ":", ...
Wrapper to perform row-wise aggregation of list arguments and pass them to a function. The return value of the function is summed over the argument groups. Non-list arguments will be automatically cast to a list.
[ "Wrapper", "to", "perform", "row", "-", "wise", "aggregation", "of", "list", "arguments", "and", "pass", "them", "to", "a", "function", ".", "The", "return", "value", "of", "the", "function", "is", "summed", "over", "the", "argument", "groups", ".", "Non",...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L325-L340
fermiPy/fermipy
fermipy/tsmap.py
_amplitude_bounds
def _amplitude_bounds(counts, bkg, model): """ Compute bounds for the root of `_f_cash_root_cython`. Parameters ---------- counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background map. model : `~numpy.ndarray` Source template (multiplied with exposure)....
python
def _amplitude_bounds(counts, bkg, model): """ Compute bounds for the root of `_f_cash_root_cython`. Parameters ---------- counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background map. model : `~numpy.ndarray` Source template (multiplied with exposure)....
[ "def", "_amplitude_bounds", "(", "counts", ",", "bkg", ",", "model", ")", ":", "if", "isinstance", "(", "counts", ",", "list", ")", ":", "counts", "=", "np", ".", "concatenate", "(", "[", "t", ".", "flat", "for", "t", "in", "counts", "]", ")", "bkg...
Compute bounds for the root of `_f_cash_root_cython`. Parameters ---------- counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background map. model : `~numpy.ndarray` Source template (multiplied with exposure).
[ "Compute", "bounds", "for", "the", "root", "of", "_f_cash_root_cython", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L358-L387
fermiPy/fermipy
fermipy/tsmap.py
_f_cash_root
def _f_cash_root(x, counts, bkg, model): """ Function to find root of. Described in Appendix A, Stewart (2009). Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map s...
python
def _f_cash_root(x, counts, bkg, model): """ Function to find root of. Described in Appendix A, Stewart (2009). Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map s...
[ "def", "_f_cash_root", "(", "x", ",", "counts", ",", "bkg", ",", "model", ")", ":", "return", "np", ".", "sum", "(", "model", "*", "(", "counts", "/", "(", "x", "*", "model", "+", "bkg", ")", "-", "1.0", ")", ")" ]
Function to find root of. Described in Appendix A, Stewart (2009). Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map slice, where model is defined. model : `~numpy.nda...
[ "Function", "to", "find", "root", "of", ".", "Described", "in", "Appendix", "A", "Stewart", "(", "2009", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L390-L405
fermiPy/fermipy
fermipy/tsmap.py
_root_amplitude_brentq
def _root_amplitude_brentq(counts, bkg, model, root_fn=_f_cash_root): """Fit amplitude by finding roots using Brent algorithm. See Appendix A Stewart (2009). Parameters ---------- counts : `~numpy.ndarray` Slice of count map. bkg : `~numpy.ndarray` Slice of background map. ...
python
def _root_amplitude_brentq(counts, bkg, model, root_fn=_f_cash_root): """Fit amplitude by finding roots using Brent algorithm. See Appendix A Stewart (2009). Parameters ---------- counts : `~numpy.ndarray` Slice of count map. bkg : `~numpy.ndarray` Slice of background map. ...
[ "def", "_root_amplitude_brentq", "(", "counts", ",", "bkg", ",", "model", ",", "root_fn", "=", "_f_cash_root", ")", ":", "# Compute amplitude bounds and assert counts > 0", "amplitude_min", ",", "amplitude_max", "=", "_amplitude_bounds", "(", "counts", ",", "bkg", ","...
Fit amplitude by finding roots using Brent algorithm. See Appendix A Stewart (2009). Parameters ---------- counts : `~numpy.ndarray` Slice of count map. bkg : `~numpy.ndarray` Slice of background map. model : `~numpy.ndarray` Model template to fit. Returns ----...
[ "Fit", "amplitude", "by", "finding", "roots", "using", "Brent", "algorithm", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L445-L486
fermiPy/fermipy
fermipy/tsmap.py
poisson_log_like
def poisson_log_like(counts, model): """Compute the Poisson log-likelihood function for the given counts and model arrays.""" loglike = np.array(model) m = counts > 0 loglike[m] -= counts[m] * np.log(model[m]) return loglike
python
def poisson_log_like(counts, model): """Compute the Poisson log-likelihood function for the given counts and model arrays.""" loglike = np.array(model) m = counts > 0 loglike[m] -= counts[m] * np.log(model[m]) return loglike
[ "def", "poisson_log_like", "(", "counts", ",", "model", ")", ":", "loglike", "=", "np", ".", "array", "(", "model", ")", "m", "=", "counts", ">", "0", "loglike", "[", "m", "]", "-=", "counts", "[", "m", "]", "*", "np", ".", "log", "(", "model", ...
Compute the Poisson log-likelihood function for the given counts and model arrays.
[ "Compute", "the", "Poisson", "log", "-", "likelihood", "function", "for", "the", "given", "counts", "and", "model", "arrays", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L489-L495
fermiPy/fermipy
fermipy/tsmap.py
f_cash
def f_cash(x, counts, bkg, model): """ Wrapper for cash statistics, that defines the model function. Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map slice, where...
python
def f_cash(x, counts, bkg, model): """ Wrapper for cash statistics, that defines the model function. Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map slice, where...
[ "def", "f_cash", "(", "x", ",", "counts", ",", "bkg", ",", "model", ")", ":", "return", "2.0", "*", "poisson_log_like", "(", "counts", ",", "bkg", "+", "x", "*", "model", ")" ]
Wrapper for cash statistics, that defines the model function. Parameters ---------- x : float Model amplitude. counts : `~numpy.ndarray` Count map slice, where model is defined. bkg : `~numpy.ndarray` Background map slice, where model is defined. model : `~numpy.ndarray`...
[ "Wrapper", "for", "cash", "statistics", "that", "defines", "the", "model", "function", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L507-L523
fermiPy/fermipy
fermipy/tsmap.py
_ts_value
def _ts_value(position, counts, bkg, model, C_0_map): """ Compute TS value at a given pixel position using the approach described in Stewart (2009). Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` ...
python
def _ts_value(position, counts, bkg, model, C_0_map): """ Compute TS value at a given pixel position using the approach described in Stewart (2009). Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` ...
[ "def", "_ts_value", "(", "position", ",", "counts", ",", "bkg", ",", "model", ",", "C_0_map", ")", ":", "extract_fn", "=", "_collect_wrapper", "(", "extract_large_array", ")", "truncate_fn", "=", "_collect_wrapper", "(", "extract_small_array", ")", "# Get data sli...
Compute TS value at a given pixel position using the approach described in Stewart (2009). Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background map. model : `~numpy.ndarray` Source model...
[ "Compute", "TS", "value", "at", "a", "given", "pixel", "position", "using", "the", "approach", "described", "in", "Stewart", "(", "2009", ")", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L526-L575
fermiPy/fermipy
fermipy/tsmap.py
_ts_value_newton
def _ts_value_newton(position, counts, bkg, model, C_0_map): """ Compute TS value at a given pixel position using the newton method. Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background ma...
python
def _ts_value_newton(position, counts, bkg, model, C_0_map): """ Compute TS value at a given pixel position using the newton method. Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background ma...
[ "def", "_ts_value_newton", "(", "position", ",", "counts", ",", "bkg", ",", "model", ",", "C_0_map", ")", ":", "extract_fn", "=", "_collect_wrapper", "(", "extract_large_array", ")", "truncate_fn", "=", "_collect_wrapper", "(", "extract_small_array", ")", "# Get d...
Compute TS value at a given pixel position using the newton method. Parameters ---------- position : tuple Pixel position. counts : `~numpy.ndarray` Count map. bkg : `~numpy.ndarray` Background map. model : `~numpy.ndarray` Source model map. Returns ...
[ "Compute", "TS", "value", "at", "a", "given", "pixel", "position", "using", "the", "newton", "method", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/tsmap.py#L578-L643