repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
fermiPy/fermipy | fermipy/skymap.py | Map.xypix_to_ipix | def xypix_to_ipix(self, xypix, colwise=False):
"""Return the flattened pixel indices from an array multi-dimensional
pixel indices.
Parameters
----------
xypix : list
List of pixel indices in the order (LON,LAT,ENERGY).
colwise : bool
Use column-... | python | def xypix_to_ipix(self, xypix, colwise=False):
"""Return the flattened pixel indices from an array multi-dimensional
pixel indices.
Parameters
----------
xypix : list
List of pixel indices in the order (LON,LAT,ENERGY).
colwise : bool
Use column-... | [
"def",
"xypix_to_ipix",
"(",
"self",
",",
"xypix",
",",
"colwise",
"=",
"False",
")",
":",
"return",
"np",
".",
"ravel_multi_index",
"(",
"xypix",
",",
"self",
".",
"npix",
",",
"order",
"=",
"'F'",
"if",
"colwise",
"else",
"'C'",
",",
"mode",
"=",
"... | Return the flattened pixel indices from an array multi-dimensional
pixel indices.
Parameters
----------
xypix : list
List of pixel indices in the order (LON,LAT,ENERGY).
colwise : bool
Use column-wise pixel indexing. | [
"Return",
"the",
"flattened",
"pixel",
"indices",
"from",
"an",
"array",
"multi",
"-",
"dimensional",
"pixel",
"indices",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L259-L273 | train |
fermiPy/fermipy | fermipy/skymap.py | Map.ipix_to_xypix | def ipix_to_xypix(self, ipix, colwise=False):
"""Return array multi-dimensional pixel indices from flattened index.
Parameters
----------
colwise : bool
Use column-wise pixel indexing.
"""
return np.unravel_index(ipix, self.npix,
... | python | def ipix_to_xypix(self, ipix, colwise=False):
"""Return array multi-dimensional pixel indices from flattened index.
Parameters
----------
colwise : bool
Use column-wise pixel indexing.
"""
return np.unravel_index(ipix, self.npix,
... | [
"def",
"ipix_to_xypix",
"(",
"self",
",",
"ipix",
",",
"colwise",
"=",
"False",
")",
":",
"return",
"np",
".",
"unravel_index",
"(",
"ipix",
",",
"self",
".",
"npix",
",",
"order",
"=",
"'F'",
"if",
"colwise",
"else",
"'C'",
")"
] | Return array multi-dimensional pixel indices from flattened index.
Parameters
----------
colwise : bool
Use column-wise pixel indexing. | [
"Return",
"array",
"multi",
"-",
"dimensional",
"pixel",
"indices",
"from",
"flattened",
"index",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L275-L284 | train |
fermiPy/fermipy | fermipy/skymap.py | Map.ipix_swap_axes | def ipix_swap_axes(self, ipix, colwise=False):
""" Return the transposed pixel index from the pixel xy coordinates
if colwise is True (False) this assumes the original index was
in column wise scheme
"""
xy = self.ipix_to_xypix(ipix, colwise)
return self.xypix_to_ipix(xy... | python | def ipix_swap_axes(self, ipix, colwise=False):
""" Return the transposed pixel index from the pixel xy coordinates
if colwise is True (False) this assumes the original index was
in column wise scheme
"""
xy = self.ipix_to_xypix(ipix, colwise)
return self.xypix_to_ipix(xy... | [
"def",
"ipix_swap_axes",
"(",
"self",
",",
"ipix",
",",
"colwise",
"=",
"False",
")",
":",
"xy",
"=",
"self",
".",
"ipix_to_xypix",
"(",
"ipix",
",",
"colwise",
")",
"return",
"self",
".",
"xypix_to_ipix",
"(",
"xy",
",",
"not",
"colwise",
")"
] | Return the transposed pixel index from the pixel xy coordinates
if colwise is True (False) this assumes the original index was
in column wise scheme | [
"Return",
"the",
"transposed",
"pixel",
"index",
"from",
"the",
"pixel",
"xy",
"coordinates"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L286-L293 | train |
fermiPy/fermipy | fermipy/skymap.py | Map.get_map_values | def get_map_values(self, lons, lats, ibin=None):
"""Return the map values corresponding to a set of coordinates.
Parameters
----------
lons : array-like
'Longitudes' (RA or GLON)
lats : array-like
'Latitidues' (DEC or GLAT)
ibin : int or array-l... | python | def get_map_values(self, lons, lats, ibin=None):
"""Return the map values corresponding to a set of coordinates.
Parameters
----------
lons : array-like
'Longitudes' (RA or GLON)
lats : array-like
'Latitidues' (DEC or GLAT)
ibin : int or array-l... | [
"def",
"get_map_values",
"(",
"self",
",",
"lons",
",",
"lats",
",",
"ibin",
"=",
"None",
")",
":",
"pix_idxs",
"=",
"self",
".",
"get_pixel_indices",
"(",
"lons",
",",
"lats",
",",
"ibin",
")",
"idxs",
"=",
"copy",
".",
"copy",
"(",
"pix_idxs",
")",... | Return the map values corresponding to a set of coordinates.
Parameters
----------
lons : array-like
'Longitudes' (RA or GLON)
lats : array-like
'Latitidues' (DEC or GLAT)
ibin : int or array-like
Extract data only for a given energy bin. No... | [
"Return",
"the",
"map",
"values",
"corresponding",
"to",
"a",
"set",
"of",
"coordinates",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L351-L382 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.create_from_hdu | def create_from_hdu(cls, hdu, ebins):
""" Creates and returns an HpxMap object from a FITS HDU.
hdu : The FITS
ebins : Energy bin edges [optional]
"""
hpx = HPX.create_from_hdu(hdu, ebins)
colnames = hdu.columns.names
cnames = []
if hpx.conv.convname ... | python | def create_from_hdu(cls, hdu, ebins):
""" Creates and returns an HpxMap object from a FITS HDU.
hdu : The FITS
ebins : Energy bin edges [optional]
"""
hpx = HPX.create_from_hdu(hdu, ebins)
colnames = hdu.columns.names
cnames = []
if hpx.conv.convname ... | [
"def",
"create_from_hdu",
"(",
"cls",
",",
"hdu",
",",
"ebins",
")",
":",
"hpx",
"=",
"HPX",
".",
"create_from_hdu",
"(",
"hdu",
",",
"ebins",
")",
"colnames",
"=",
"hdu",
".",
"columns",
".",
"names",
"cnames",
"=",
"[",
"]",
"if",
"hpx",
".",
"co... | Creates and returns an HpxMap object from a FITS HDU.
hdu : The FITS
ebins : Energy bin edges [optional] | [
"Creates",
"and",
"returns",
"an",
"HpxMap",
"object",
"from",
"a",
"FITS",
"HDU",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L430-L456 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.create_from_hdulist | def create_from_hdulist(cls, hdulist, **kwargs):
""" Creates and returns an HpxMap object from a FITS HDUList
extname : The name of the HDU with the map data
ebounds : The name of the HDU with the energy bin data
"""
extname = kwargs.get('hdu', hdulist[1].name)
ebins = f... | python | def create_from_hdulist(cls, hdulist, **kwargs):
""" Creates and returns an HpxMap object from a FITS HDUList
extname : The name of the HDU with the map data
ebounds : The name of the HDU with the energy bin data
"""
extname = kwargs.get('hdu', hdulist[1].name)
ebins = f... | [
"def",
"create_from_hdulist",
"(",
"cls",
",",
"hdulist",
",",
"**",
"kwargs",
")",
":",
"extname",
"=",
"kwargs",
".",
"get",
"(",
"'hdu'",
",",
"hdulist",
"[",
"1",
"]",
".",
"name",
")",
"ebins",
"=",
"fits_utils",
".",
"find_and_read_ebins",
"(",
"... | Creates and returns an HpxMap object from a FITS HDUList
extname : The name of the HDU with the map data
ebounds : The name of the HDU with the energy bin data | [
"Creates",
"and",
"returns",
"an",
"HpxMap",
"object",
"from",
"a",
"FITS",
"HDUList"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L459-L467 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.sum_over_energy | def sum_over_energy(self):
""" Reduce a counts cube to a counts map """
# We sum over axis 0 in the array, and drop the energy binning in the
# hpx object
return HpxMap(np.sum(self.counts, axis=0), self.hpx.copy_and_drop_energy()) | python | def sum_over_energy(self):
""" Reduce a counts cube to a counts map """
# We sum over axis 0 in the array, and drop the energy binning in the
# hpx object
return HpxMap(np.sum(self.counts, axis=0), self.hpx.copy_and_drop_energy()) | [
"def",
"sum_over_energy",
"(",
"self",
")",
":",
"return",
"HpxMap",
"(",
"np",
".",
"sum",
"(",
"self",
".",
"counts",
",",
"axis",
"=",
"0",
")",
",",
"self",
".",
"hpx",
".",
"copy_and_drop_energy",
"(",
")",
")"
] | Reduce a counts cube to a counts map | [
"Reduce",
"a",
"counts",
"cube",
"to",
"a",
"counts",
"map"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L579-L583 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.interpolate | def interpolate(self, lon, lat, egy=None, interp_log=True):
"""Interpolate map values.
Parameters
----------
interp_log : bool
Interpolate the z-coordinate in logspace.
"""
if self.data.ndim == 1:
theta = np.pi / 2. - np.radians(lat)
... | python | def interpolate(self, lon, lat, egy=None, interp_log=True):
"""Interpolate map values.
Parameters
----------
interp_log : bool
Interpolate the z-coordinate in logspace.
"""
if self.data.ndim == 1:
theta = np.pi / 2. - np.radians(lat)
... | [
"def",
"interpolate",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"egy",
"=",
"None",
",",
"interp_log",
"=",
"True",
")",
":",
"if",
"self",
".",
"data",
".",
"ndim",
"==",
"1",
":",
"theta",
"=",
"np",
".",
"pi",
"/",
"2.",
"-",
"np",
".",
"r... | Interpolate map values.
Parameters
----------
interp_log : bool
Interpolate the z-coordinate in logspace. | [
"Interpolate",
"map",
"values",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L615-L631 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap._interpolate_cube | def _interpolate_cube(self, lon, lat, egy=None, interp_log=True):
"""Perform interpolation on a healpix cube. If egy is None
then interpolation will be performed on the existing energy
planes.
"""
shape = np.broadcast(lon, lat, egy).shape
lon = lon * np.ones(shape)
... | python | def _interpolate_cube(self, lon, lat, egy=None, interp_log=True):
"""Perform interpolation on a healpix cube. If egy is None
then interpolation will be performed on the existing energy
planes.
"""
shape = np.broadcast(lon, lat, egy).shape
lon = lon * np.ones(shape)
... | [
"def",
"_interpolate_cube",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"egy",
"=",
"None",
",",
"interp_log",
"=",
"True",
")",
":",
"shape",
"=",
"np",
".",
"broadcast",
"(",
"lon",
",",
"lat",
",",
"egy",
")",
".",
"shape",
"lon",
"=",
"lon",
"*... | Perform interpolation on a healpix cube. If egy is None
then interpolation will be performed on the existing energy
planes. | [
"Perform",
"interpolation",
"on",
"a",
"healpix",
"cube",
".",
"If",
"egy",
"is",
"None",
"then",
"interpolation",
"will",
"be",
"performed",
"on",
"the",
"existing",
"energy",
"planes",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L633-L667 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.expanded_counts_map | def expanded_counts_map(self):
""" return the full counts map """
if self.hpx._ipix is None:
return self.counts
output = np.zeros(
(self.counts.shape[0], self.hpx._maxpix), self.counts.dtype)
for i in range(self.counts.shape[0]):
output[i][self.hpx._i... | python | def expanded_counts_map(self):
""" return the full counts map """
if self.hpx._ipix is None:
return self.counts
output = np.zeros(
(self.counts.shape[0], self.hpx._maxpix), self.counts.dtype)
for i in range(self.counts.shape[0]):
output[i][self.hpx._i... | [
"def",
"expanded_counts_map",
"(",
"self",
")",
":",
"if",
"self",
".",
"hpx",
".",
"_ipix",
"is",
"None",
":",
"return",
"self",
".",
"counts",
"output",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"counts",
".",
"shape",
"[",
"0",
"]",
",",
... | return the full counts map | [
"return",
"the",
"full",
"counts",
"map"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L687-L696 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.explicit_counts_map | def explicit_counts_map(self, pixels=None):
""" return a counts map with explicit index scheme
Parameters
----------
pixels : `np.ndarray` or None
If set, grab only those pixels.
If none, grab only non-zero pixels
"""
# No pixel index, so build ... | python | def explicit_counts_map(self, pixels=None):
""" return a counts map with explicit index scheme
Parameters
----------
pixels : `np.ndarray` or None
If set, grab only those pixels.
If none, grab only non-zero pixels
"""
# No pixel index, so build ... | [
"def",
"explicit_counts_map",
"(",
"self",
",",
"pixels",
"=",
"None",
")",
":",
"if",
"self",
".",
"hpx",
".",
"_ipix",
"is",
"None",
":",
"if",
"self",
".",
"data",
".",
"ndim",
"==",
"2",
":",
"summed",
"=",
"self",
".",
"counts",
".",
"sum",
... | return a counts map with explicit index scheme
Parameters
----------
pixels : `np.ndarray` or None
If set, grab only those pixels.
If none, grab only non-zero pixels | [
"return",
"a",
"counts",
"map",
"with",
"explicit",
"index",
"scheme"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L698-L729 | train |
fermiPy/fermipy | fermipy/skymap.py | HpxMap.sparse_counts_map | def sparse_counts_map(self):
""" return a counts map with sparse index scheme
"""
if self.hpx._ipix is None:
flatarray = self.data.flattern()
else:
flatarray = self.expanded_counts_map()
nz = flatarray.nonzero()[0]
data_out = flatarray[nz]
... | python | def sparse_counts_map(self):
""" return a counts map with sparse index scheme
"""
if self.hpx._ipix is None:
flatarray = self.data.flattern()
else:
flatarray = self.expanded_counts_map()
nz = flatarray.nonzero()[0]
data_out = flatarray[nz]
... | [
"def",
"sparse_counts_map",
"(",
"self",
")",
":",
"if",
"self",
".",
"hpx",
".",
"_ipix",
"is",
"None",
":",
"flatarray",
"=",
"self",
".",
"data",
".",
"flattern",
"(",
")",
"else",
":",
"flatarray",
"=",
"self",
".",
"expanded_counts_map",
"(",
")",... | return a counts map with sparse index scheme | [
"return",
"a",
"counts",
"map",
"with",
"sparse",
"index",
"scheme"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L731-L740 | train |
fermiPy/fermipy | fermipy/sensitivity.py | SensitivityCalc.diff_flux_threshold | def diff_flux_threshold(self, skydir, fn, ts_thresh, min_counts):
"""Compute the differential flux threshold for a point source at
position ``skydir`` with spectral parameterization ``fn``.
Parameters
----------
skydir : `~astropy.coordinates.SkyCoord`
Sky coordinate... | python | def diff_flux_threshold(self, skydir, fn, ts_thresh, min_counts):
"""Compute the differential flux threshold for a point source at
position ``skydir`` with spectral parameterization ``fn``.
Parameters
----------
skydir : `~astropy.coordinates.SkyCoord`
Sky coordinate... | [
"def",
"diff_flux_threshold",
"(",
"self",
",",
"skydir",
",",
"fn",
",",
"ts_thresh",
",",
"min_counts",
")",
":",
"sig",
",",
"bkg",
",",
"bkg_fit",
"=",
"self",
".",
"compute_counts",
"(",
"skydir",
",",
"fn",
")",
"norms",
"=",
"irfs",
".",
"comput... | Compute the differential flux threshold for a point source at
position ``skydir`` with spectral parameterization ``fn``.
Parameters
----------
skydir : `~astropy.coordinates.SkyCoord`
Sky coordinates at which the sensitivity will be evaluated.
fn : `~fermipy.spectru... | [
"Compute",
"the",
"differential",
"flux",
"threshold",
"for",
"a",
"point",
"source",
"at",
"position",
"skydir",
"with",
"spectral",
"parameterization",
"fn",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/sensitivity.py#L194-L230 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | coords_to_vec | def coords_to_vec(lon, lat):
""" Converts longitute and latitude coordinates to a unit 3-vector
return array(3,n) with v_x[i],v_y[i],v_z[i] = directional cosines
"""
phi = np.radians(lon)
theta = (np.pi / 2) - np.radians(lat)
sin_t = np.sin(theta)
cos_t = np.cos(theta)
xVals = sin_t * ... | python | def coords_to_vec(lon, lat):
""" Converts longitute and latitude coordinates to a unit 3-vector
return array(3,n) with v_x[i],v_y[i],v_z[i] = directional cosines
"""
phi = np.radians(lon)
theta = (np.pi / 2) - np.radians(lat)
sin_t = np.sin(theta)
cos_t = np.cos(theta)
xVals = sin_t * ... | [
"def",
"coords_to_vec",
"(",
"lon",
",",
"lat",
")",
":",
"phi",
"=",
"np",
".",
"radians",
"(",
"lon",
")",
"theta",
"=",
"(",
"np",
".",
"pi",
"/",
"2",
")",
"-",
"np",
".",
"radians",
"(",
"lat",
")",
"sin_t",
"=",
"np",
".",
"sin",
"(",
... | Converts longitute and latitude coordinates to a unit 3-vector
return array(3,n) with v_x[i],v_y[i],v_z[i] = directional cosines | [
"Converts",
"longitute",
"and",
"latitude",
"coordinates",
"to",
"a",
"unit",
"3",
"-",
"vector"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L57-L73 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | get_pixel_size_from_nside | def get_pixel_size_from_nside(nside):
""" Returns an estimate of the pixel size from the HEALPix nside coordinate
This just uses a lookup table to provide a nice round number for each
HEALPix order.
"""
order = int(np.log2(nside))
if order < 0 or order > 13:
raise ValueError('HEALPix o... | python | def get_pixel_size_from_nside(nside):
""" Returns an estimate of the pixel size from the HEALPix nside coordinate
This just uses a lookup table to provide a nice round number for each
HEALPix order.
"""
order = int(np.log2(nside))
if order < 0 or order > 13:
raise ValueError('HEALPix o... | [
"def",
"get_pixel_size_from_nside",
"(",
"nside",
")",
":",
"order",
"=",
"int",
"(",
"np",
".",
"log2",
"(",
"nside",
")",
")",
"if",
"order",
"<",
"0",
"or",
"order",
">",
"13",
":",
"raise",
"ValueError",
"(",
"'HEALPix order must be between 0 to 13 %i'",... | Returns an estimate of the pixel size from the HEALPix nside coordinate
This just uses a lookup table to provide a nice round number for each
HEALPix order. | [
"Returns",
"an",
"estimate",
"of",
"the",
"pixel",
"size",
"from",
"the",
"HEALPix",
"nside",
"coordinate"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L76-L86 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | hpx_to_axes | def hpx_to_axes(h, npix):
""" Generate a sequence of bin edge vectors corresponding to the
axes of a HPX object."""
x = h.ebins
z = np.arange(npix[-1] + 1)
return x, z | python | def hpx_to_axes(h, npix):
""" Generate a sequence of bin edge vectors corresponding to the
axes of a HPX object."""
x = h.ebins
z = np.arange(npix[-1] + 1)
return x, z | [
"def",
"hpx_to_axes",
"(",
"h",
",",
"npix",
")",
":",
"x",
"=",
"h",
".",
"ebins",
"z",
"=",
"np",
".",
"arange",
"(",
"npix",
"[",
"-",
"1",
"]",
"+",
"1",
")",
"return",
"x",
",",
"z"
] | Generate a sequence of bin edge vectors corresponding to the
axes of a HPX object. | [
"Generate",
"a",
"sequence",
"of",
"bin",
"edge",
"vectors",
"corresponding",
"to",
"the",
"axes",
"of",
"a",
"HPX",
"object",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L89-L95 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | parse_hpxregion | def parse_hpxregion(region):
"""Parse the HPX_REG header keyword into a list of tokens."""
m = re.match(r'([A-Za-z\_]*?)\((.*?)\)', region)
if m is None:
raise Exception('Failed to parse hpx region string.')
if not m.group(1):
return re.split(',', m.group(2))
else:
return [... | python | def parse_hpxregion(region):
"""Parse the HPX_REG header keyword into a list of tokens."""
m = re.match(r'([A-Za-z\_]*?)\((.*?)\)', region)
if m is None:
raise Exception('Failed to parse hpx region string.')
if not m.group(1):
return re.split(',', m.group(2))
else:
return [... | [
"def",
"parse_hpxregion",
"(",
"region",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'([A-Za-z\\_]*?)\\((.*?)\\)'",
",",
"region",
")",
"if",
"m",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'Failed to parse hpx region string.'",
")",
"if",
"not",
"m",
... | Parse the HPX_REG header keyword into a list of tokens. | [
"Parse",
"the",
"HPX_REG",
"header",
"keyword",
"into",
"a",
"list",
"of",
"tokens",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L226-L236 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | upix_to_pix | def upix_to_pix(upix):
"""Get the nside from a unique pixel number."""
nside = np.power(2, np.floor(np.log2(upix / 4)) / 2).astype(int)
pix = upix - 4 * np.power(nside, 2)
return pix, nside | python | def upix_to_pix(upix):
"""Get the nside from a unique pixel number."""
nside = np.power(2, np.floor(np.log2(upix / 4)) / 2).astype(int)
pix = upix - 4 * np.power(nside, 2)
return pix, nside | [
"def",
"upix_to_pix",
"(",
"upix",
")",
":",
"nside",
"=",
"np",
".",
"power",
"(",
"2",
",",
"np",
".",
"floor",
"(",
"np",
".",
"log2",
"(",
"upix",
"/",
"4",
")",
")",
"/",
"2",
")",
".",
"astype",
"(",
"int",
")",
"pix",
"=",
"upix",
"-... | Get the nside from a unique pixel number. | [
"Get",
"the",
"nside",
"from",
"a",
"unique",
"pixel",
"number",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L244-L248 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.create_hpx | def create_hpx(cls, nside, nest, coordsys='CEL', order=-1, ebins=None,
region=None, conv=HPX_Conv('FGST_CCUBE'), pixels=None):
"""Create a HPX object.
Parameters
----------
nside : int
HEALPix nside paramter
nest : bool
True for H... | python | def create_hpx(cls, nside, nest, coordsys='CEL', order=-1, ebins=None,
region=None, conv=HPX_Conv('FGST_CCUBE'), pixels=None):
"""Create a HPX object.
Parameters
----------
nside : int
HEALPix nside paramter
nest : bool
True for H... | [
"def",
"create_hpx",
"(",
"cls",
",",
"nside",
",",
"nest",
",",
"coordsys",
"=",
"'CEL'",
",",
"order",
"=",
"-",
"1",
",",
"ebins",
"=",
"None",
",",
"region",
"=",
"None",
",",
"conv",
"=",
"HPX_Conv",
"(",
"'FGST_CCUBE'",
")",
",",
"pixels",
"=... | Create a HPX object.
Parameters
----------
nside : int
HEALPix nside paramter
nest : bool
True for HEALPix "NESTED" indexing scheme, False for "RING" scheme.
coordsys : str
"CEL" or "GAL"
order : int
nside = 2**ord... | [
"Create",
"a",
"HPX",
"object",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L423-L454 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.identify_HPX_convention | def identify_HPX_convention(header):
""" Identify the convention used to write this file """
# Hopefully the file contains the HPX_CONV keyword specifying
# the convention used
try:
return header['HPX_CONV']
except KeyError:
pass
indxschm = header... | python | def identify_HPX_convention(header):
""" Identify the convention used to write this file """
# Hopefully the file contains the HPX_CONV keyword specifying
# the convention used
try:
return header['HPX_CONV']
except KeyError:
pass
indxschm = header... | [
"def",
"identify_HPX_convention",
"(",
"header",
")",
":",
"try",
":",
"return",
"header",
"[",
"'HPX_CONV'",
"]",
"except",
"KeyError",
":",
"pass",
"indxschm",
"=",
"header",
".",
"get",
"(",
"'INDXSCHM'",
",",
"None",
")",
"extname",
"=",
"header",
".",... | Identify the convention used to write this file | [
"Identify",
"the",
"convention",
"used",
"to",
"write",
"this",
"file"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L457-L501 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.make_header | def make_header(self):
""" Builds and returns FITS header for this HEALPix map """
cards = [fits.Card("TELESCOP", "GLAST"),
fits.Card("INSTRUME", "LAT"),
fits.Card(self._conv.coordsys, self._coordsys),
fits.Card("PIXTYPE", "HEALPIX"),
f... | python | def make_header(self):
""" Builds and returns FITS header for this HEALPix map """
cards = [fits.Card("TELESCOP", "GLAST"),
fits.Card("INSTRUME", "LAT"),
fits.Card(self._conv.coordsys, self._coordsys),
fits.Card("PIXTYPE", "HEALPIX"),
f... | [
"def",
"make_header",
"(",
"self",
")",
":",
"cards",
"=",
"[",
"fits",
".",
"Card",
"(",
"\"TELESCOP\"",
",",
"\"GLAST\"",
")",
",",
"fits",
".",
"Card",
"(",
"\"INSTRUME\"",
",",
"\"LAT\"",
")",
",",
"fits",
".",
"Card",
"(",
"self",
".",
"_conv",
... | Builds and returns FITS header for this HEALPix map | [
"Builds",
"and",
"returns",
"FITS",
"header",
"for",
"this",
"HEALPix",
"map"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L574-L603 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.make_hdu | def make_hdu(self, data, **kwargs):
""" Builds and returns a FITs HDU with input data
data : The data begin stored
Keyword arguments
-------------------
extname : The HDU extension name
colbase : The prefix for column names
"""
shape = d... | python | def make_hdu(self, data, **kwargs):
""" Builds and returns a FITs HDU with input data
data : The data begin stored
Keyword arguments
-------------------
extname : The HDU extension name
colbase : The prefix for column names
"""
shape = d... | [
"def",
"make_hdu",
"(",
"self",
",",
"data",
",",
"**",
"kwargs",
")",
":",
"shape",
"=",
"data",
".",
"shape",
"extname",
"=",
"kwargs",
".",
"get",
"(",
"'extname'",
",",
"self",
".",
"conv",
".",
"extname",
")",
"if",
"shape",
"[",
"-",
"1",
"... | Builds and returns a FITs HDU with input data
data : The data begin stored
Keyword arguments
-------------------
extname : The HDU extension name
colbase : The prefix for column names | [
"Builds",
"and",
"returns",
"a",
"FITs",
"HDU",
"with",
"input",
"data"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L606-L656 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.write_fits | def write_fits(self, data, outfile, extname="SKYMAP", clobber=True):
""" Write input data to a FITS file
data : The data begin stored
outfile : The name of the output file
extname : The HDU extension name
clobber : True -> overwrite existing files
"""
... | python | def write_fits(self, data, outfile, extname="SKYMAP", clobber=True):
""" Write input data to a FITS file
data : The data begin stored
outfile : The name of the output file
extname : The HDU extension name
clobber : True -> overwrite existing files
"""
... | [
"def",
"write_fits",
"(",
"self",
",",
"data",
",",
"outfile",
",",
"extname",
"=",
"\"SKYMAP\"",
",",
"clobber",
"=",
"True",
")",
":",
"hdu_prim",
"=",
"fits",
".",
"PrimaryHDU",
"(",
")",
"hdu_hpx",
"=",
"self",
".",
"make_hdu",
"(",
"data",
",",
... | Write input data to a FITS file
data : The data begin stored
outfile : The name of the output file
extname : The HDU extension name
clobber : True -> overwrite existing files | [
"Write",
"input",
"data",
"to",
"a",
"FITS",
"file"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L686-L704 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.get_index_list | def get_index_list(nside, nest, region):
""" Returns the list of pixels indices for all the pixels in a region
nside : HEALPix nside parameter
nest : True for 'NESTED', False = 'RING'
region : HEALPix region string
"""
tokens = parse_hpxregion(region)
i... | python | def get_index_list(nside, nest, region):
""" Returns the list of pixels indices for all the pixels in a region
nside : HEALPix nside parameter
nest : True for 'NESTED', False = 'RING'
region : HEALPix region string
"""
tokens = parse_hpxregion(region)
i... | [
"def",
"get_index_list",
"(",
"nside",
",",
"nest",
",",
"region",
")",
":",
"tokens",
"=",
"parse_hpxregion",
"(",
"region",
")",
"if",
"tokens",
"[",
"0",
"]",
"==",
"'DISK'",
":",
"vec",
"=",
"coords_to_vec",
"(",
"float",
"(",
"tokens",
"[",
"1",
... | Returns the list of pixels indices for all the pixels in a region
nside : HEALPix nside parameter
nest : True for 'NESTED', False = 'RING'
region : HEALPix region string | [
"Returns",
"the",
"list",
"of",
"pixels",
"indices",
"for",
"all",
"the",
"pixels",
"in",
"a",
"region"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L707-L738 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.get_ref_dir | def get_ref_dir(region, coordsys):
""" Finds and returns the reference direction for a given
HEALPix region string.
region : a string describing a HEALPix region
coordsys : coordinate system, GAL | CEL
"""
if region is None:
if coordsys == "GAL":
... | python | def get_ref_dir(region, coordsys):
""" Finds and returns the reference direction for a given
HEALPix region string.
region : a string describing a HEALPix region
coordsys : coordinate system, GAL | CEL
"""
if region is None:
if coordsys == "GAL":
... | [
"def",
"get_ref_dir",
"(",
"region",
",",
"coordsys",
")",
":",
"if",
"region",
"is",
"None",
":",
"if",
"coordsys",
"==",
"\"GAL\"",
":",
"c",
"=",
"SkyCoord",
"(",
"0.",
",",
"0.",
",",
"frame",
"=",
"Galactic",
",",
"unit",
"=",
"\"deg\"",
")",
... | Finds and returns the reference direction for a given
HEALPix region string.
region : a string describing a HEALPix region
coordsys : coordinate system, GAL | CEL | [
"Finds",
"and",
"returns",
"the",
"reference",
"direction",
"for",
"a",
"given",
"HEALPix",
"region",
"string",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L741-L785 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.make_wcs | def make_wcs(self, naxis=2, proj='CAR', energies=None, oversample=2):
""" Make a WCS projection appropirate for this HPX pixelization
"""
w = WCS(naxis=naxis)
skydir = self.get_ref_dir(self._region, self.coordsys)
if self.coordsys == 'CEL':
w.wcs.ctype[0] = 'RA---%s'... | python | def make_wcs(self, naxis=2, proj='CAR', energies=None, oversample=2):
""" Make a WCS projection appropirate for this HPX pixelization
"""
w = WCS(naxis=naxis)
skydir = self.get_ref_dir(self._region, self.coordsys)
if self.coordsys == 'CEL':
w.wcs.ctype[0] = 'RA---%s'... | [
"def",
"make_wcs",
"(",
"self",
",",
"naxis",
"=",
"2",
",",
"proj",
"=",
"'CAR'",
",",
"energies",
"=",
"None",
",",
"oversample",
"=",
"2",
")",
":",
"w",
"=",
"WCS",
"(",
"naxis",
"=",
"naxis",
")",
"skydir",
"=",
"self",
".",
"get_ref_dir",
"... | Make a WCS projection appropirate for this HPX pixelization | [
"Make",
"a",
"WCS",
"projection",
"appropirate",
"for",
"this",
"HPX",
"pixelization"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L805-L854 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.get_sky_coords | def get_sky_coords(self):
""" Get the sky coordinates of all the pixels in this pixelization """
if self._ipix is None:
theta, phi = hp.pix2ang(
self._nside, list(range(self._npix)), self._nest)
else:
theta, phi = hp.pix2ang(self._nside, self._ipix, self._... | python | def get_sky_coords(self):
""" Get the sky coordinates of all the pixels in this pixelization """
if self._ipix is None:
theta, phi = hp.pix2ang(
self._nside, list(range(self._npix)), self._nest)
else:
theta, phi = hp.pix2ang(self._nside, self._ipix, self._... | [
"def",
"get_sky_coords",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ipix",
"is",
"None",
":",
"theta",
",",
"phi",
"=",
"hp",
".",
"pix2ang",
"(",
"self",
".",
"_nside",
",",
"list",
"(",
"range",
"(",
"self",
".",
"_npix",
")",
")",
",",
"self"... | Get the sky coordinates of all the pixels in this pixelization | [
"Get",
"the",
"sky",
"coordinates",
"of",
"all",
"the",
"pixels",
"in",
"this",
"pixelization"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L856-L866 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HPX.skydir_to_pixel | def skydir_to_pixel(self, skydir):
"""Return the pixel index of a SkyCoord object."""
if self.coordsys in ['CEL', 'EQU']:
skydir = skydir.transform_to('icrs')
lon = skydir.ra.deg
lat = skydir.dec.deg
else:
skydir = skydir.transform_to('galactic')
... | python | def skydir_to_pixel(self, skydir):
"""Return the pixel index of a SkyCoord object."""
if self.coordsys in ['CEL', 'EQU']:
skydir = skydir.transform_to('icrs')
lon = skydir.ra.deg
lat = skydir.dec.deg
else:
skydir = skydir.transform_to('galactic')
... | [
"def",
"skydir_to_pixel",
"(",
"self",
",",
"skydir",
")",
":",
"if",
"self",
".",
"coordsys",
"in",
"[",
"'CEL'",
",",
"'EQU'",
"]",
":",
"skydir",
"=",
"skydir",
".",
"transform_to",
"(",
"'icrs'",
")",
"lon",
"=",
"skydir",
".",
"ra",
".",
"deg",
... | Return the pixel index of a SkyCoord object. | [
"Return",
"the",
"pixel",
"index",
"of",
"a",
"SkyCoord",
"object",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L882-L893 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HpxToWcsMapping.write_to_fitsfile | def write_to_fitsfile(self, fitsfile, clobber=True):
"""Write this mapping to a FITS file, to avoid having to recompute it
"""
from fermipy.skymap import Map
hpx_header = self._hpx.make_header()
index_map = Map(self.ipixs, self.wcs)
mult_map = Map(self.mult_val, self.wcs)... | python | def write_to_fitsfile(self, fitsfile, clobber=True):
"""Write this mapping to a FITS file, to avoid having to recompute it
"""
from fermipy.skymap import Map
hpx_header = self._hpx.make_header()
index_map = Map(self.ipixs, self.wcs)
mult_map = Map(self.mult_val, self.wcs)... | [
"def",
"write_to_fitsfile",
"(",
"self",
",",
"fitsfile",
",",
"clobber",
"=",
"True",
")",
":",
"from",
"fermipy",
".",
"skymap",
"import",
"Map",
"hpx_header",
"=",
"self",
".",
"_hpx",
".",
"make_header",
"(",
")",
"index_map",
"=",
"Map",
"(",
"self"... | Write this mapping to a FITS file, to avoid having to recompute it | [
"Write",
"this",
"mapping",
"to",
"a",
"FITS",
"file",
"to",
"avoid",
"having",
"to",
"recompute",
"it"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L953-L969 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HpxToWcsMapping.create_from_fitsfile | def create_from_fitsfile(cls, fitsfile):
""" Read a fits file and use it to make a mapping
"""
from fermipy.skymap import Map
index_map = Map.create_from_fits(fitsfile)
mult_map = Map.create_from_fits(fitsfile, hdu=1)
ff = fits.open(fitsfile)
hpx = HPX.create_from... | python | def create_from_fitsfile(cls, fitsfile):
""" Read a fits file and use it to make a mapping
"""
from fermipy.skymap import Map
index_map = Map.create_from_fits(fitsfile)
mult_map = Map.create_from_fits(fitsfile, hdu=1)
ff = fits.open(fitsfile)
hpx = HPX.create_from... | [
"def",
"create_from_fitsfile",
"(",
"cls",
",",
"fitsfile",
")",
":",
"from",
"fermipy",
".",
"skymap",
"import",
"Map",
"index_map",
"=",
"Map",
".",
"create_from_fits",
"(",
"fitsfile",
")",
"mult_map",
"=",
"Map",
".",
"create_from_fits",
"(",
"fitsfile",
... | Read a fits file and use it to make a mapping | [
"Read",
"a",
"fits",
"file",
"and",
"use",
"it",
"to",
"make",
"a",
"mapping"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L972-L983 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HpxToWcsMapping.fill_wcs_map_from_hpx_data | def fill_wcs_map_from_hpx_data(self, hpx_data, wcs_data, normalize=True):
"""Fills the wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs_data : the data array being filled
normalize : True -> perserve integral by splitting HEALPi... | python | def fill_wcs_map_from_hpx_data(self, hpx_data, wcs_data, normalize=True):
"""Fills the wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs_data : the data array being filled
normalize : True -> perserve integral by splitting HEALPi... | [
"def",
"fill_wcs_map_from_hpx_data",
"(",
"self",
",",
"hpx_data",
",",
"wcs_data",
",",
"normalize",
"=",
"True",
")",
":",
"hpx_naxis",
"=",
"len",
"(",
"hpx_data",
".",
"shape",
")",
"wcs_naxis",
"=",
"len",
"(",
"wcs_data",
".",
"shape",
")",
"if",
"... | Fills the wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs_data : the data array being filled
normalize : True -> perserve integral by splitting HEALPix values between bins | [
"Fills",
"the",
"wcs",
"map",
"from",
"the",
"hpx",
"data",
"using",
"the",
"pre",
"-",
"calculated",
"mappings"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L985-L1020 | train |
fermiPy/fermipy | fermipy/hpx_utils.py | HpxToWcsMapping.make_wcs_data_from_hpx_data | def make_wcs_data_from_hpx_data(self, hpx_data, wcs, normalize=True):
""" Creates and fills a wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs : the WCS object
normalize : True -> perserve integral by splitting HEALPix valu... | python | def make_wcs_data_from_hpx_data(self, hpx_data, wcs, normalize=True):
""" Creates and fills a wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs : the WCS object
normalize : True -> perserve integral by splitting HEALPix valu... | [
"def",
"make_wcs_data_from_hpx_data",
"(",
"self",
",",
"hpx_data",
",",
"wcs",
",",
"normalize",
"=",
"True",
")",
":",
"wcs_data",
"=",
"np",
".",
"zeros",
"(",
"wcs",
".",
"npix",
")",
"self",
".",
"fill_wcs_map_from_hpx_data",
"(",
"hpx_data",
",",
"wc... | Creates and fills a wcs map from the hpx data using the pre-calculated
mappings
hpx_data : the input HEALPix data
wcs : the WCS object
normalize : True -> perserve integral by splitting HEALPix values between bins | [
"Creates",
"and",
"fills",
"a",
"wcs",
"map",
"from",
"the",
"hpx",
"data",
"using",
"the",
"pre",
"-",
"calculated",
"mappings"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/hpx_utils.py#L1022-L1032 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | _get_enum_bins | def _get_enum_bins(configfile):
"""Get the number of energy bin in the SED
Parameters
----------
configfile : str
Fermipy configuration file.
Returns
-------
nbins : int
The number of energy bins
"""
config = yaml.safe_load(open(configfile))
emin = config['s... | python | def _get_enum_bins(configfile):
"""Get the number of energy bin in the SED
Parameters
----------
configfile : str
Fermipy configuration file.
Returns
-------
nbins : int
The number of energy bins
"""
config = yaml.safe_load(open(configfile))
emin = config['s... | [
"def",
"_get_enum_bins",
"(",
"configfile",
")",
":",
"config",
"=",
"yaml",
".",
"safe_load",
"(",
"open",
"(",
"configfile",
")",
")",
"emin",
"=",
"config",
"[",
"'selection'",
"]",
"[",
"'emin'",
"]",
"emax",
"=",
"config",
"[",
"'selection'",
"]",
... | Get the number of energy bin in the SED
Parameters
----------
configfile : str
Fermipy configuration file.
Returns
-------
nbins : int
The number of energy bins | [
"Get",
"the",
"number",
"of",
"energy",
"bin",
"in",
"the",
"SED"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L33-L59 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | fill_output_table | def fill_output_table(filelist, hdu, collist, nbins):
"""Fill the arrays from the files in filelist
Parameters
----------
filelist : list
List of the files to get data from.
hdu : str
Name of the HDU containing the table with the input data.
colllist : list
List of th... | python | def fill_output_table(filelist, hdu, collist, nbins):
"""Fill the arrays from the files in filelist
Parameters
----------
filelist : list
List of the files to get data from.
hdu : str
Name of the HDU containing the table with the input data.
colllist : list
List of th... | [
"def",
"fill_output_table",
"(",
"filelist",
",",
"hdu",
",",
"collist",
",",
"nbins",
")",
":",
"nfiles",
"=",
"len",
"(",
"filelist",
")",
"shape",
"=",
"(",
"nbins",
",",
"nfiles",
")",
"outdict",
"=",
"{",
"}",
"for",
"c",
"in",
"collist",
":",
... | Fill the arrays from the files in filelist
Parameters
----------
filelist : list
List of the files to get data from.
hdu : str
Name of the HDU containing the table with the input data.
colllist : list
List of the column names
nbins : int
Number of bins in the... | [
"Fill",
"the",
"arrays",
"from",
"the",
"files",
"in",
"filelist"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L63-L115 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | vstack_tables | def vstack_tables(filelist, hdus):
"""vstack a set of HDUs from a set of files
Parameters
----------
filelist : list
List of the files to get data from.
hdus : list
Names of the HDU containing the table with the input data.
Returns
-------
out_tables : list
A... | python | def vstack_tables(filelist, hdus):
"""vstack a set of HDUs from a set of files
Parameters
----------
filelist : list
List of the files to get data from.
hdus : list
Names of the HDU containing the table with the input data.
Returns
-------
out_tables : list
A... | [
"def",
"vstack_tables",
"(",
"filelist",
",",
"hdus",
")",
":",
"nfiles",
"=",
"len",
"(",
"filelist",
")",
"out_tables",
"=",
"[",
"]",
"out_names",
"=",
"[",
"]",
"for",
"hdu",
"in",
"hdus",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"'Working o... | vstack a set of HDUs from a set of files
Parameters
----------
filelist : list
List of the files to get data from.
hdus : list
Names of the HDU containing the table with the input data.
Returns
-------
out_tables : list
A list with the table with all the requeste... | [
"vstack",
"a",
"set",
"of",
"HDUs",
"from",
"a",
"set",
"of",
"files"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L118-L160 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | collect_summary_stats | def collect_summary_stats(data):
"""Collect summary statisitics from an array
This creates a dictionry of output arrays of summary
statistics, with the input array dimension reducted by one.
Parameters
----------
data : `numpy.ndarray`
Array with the collected input data
Returns... | python | def collect_summary_stats(data):
"""Collect summary statisitics from an array
This creates a dictionry of output arrays of summary
statistics, with the input array dimension reducted by one.
Parameters
----------
data : `numpy.ndarray`
Array with the collected input data
Returns... | [
"def",
"collect_summary_stats",
"(",
"data",
")",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"data",
",",
"axis",
"=",
"0",
")",
"std",
"=",
"np",
".",
"std",
"(",
"data",
",",
"axis",
"=",
"0",
")",
"median",
"=",
"np",
".",
"median",
"(",
"dat... | Collect summary statisitics from an array
This creates a dictionry of output arrays of summary
statistics, with the input array dimension reducted by one.
Parameters
----------
data : `numpy.ndarray`
Array with the collected input data
Returns
-------
output : dict
... | [
"Collect",
"summary",
"statisitics",
"from",
"an",
"array"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L163-L197 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | add_summary_stats_to_table | def add_summary_stats_to_table(table_in, table_out, colnames):
"""Collect summary statisitics from an input table and add them to an output table
Parameters
----------
table_in : `astropy.table.Table`
Table with the input data.
table_out : `astropy.table.Table`
Table with the out... | python | def add_summary_stats_to_table(table_in, table_out, colnames):
"""Collect summary statisitics from an input table and add them to an output table
Parameters
----------
table_in : `astropy.table.Table`
Table with the input data.
table_out : `astropy.table.Table`
Table with the out... | [
"def",
"add_summary_stats_to_table",
"(",
"table_in",
",",
"table_out",
",",
"colnames",
")",
":",
"for",
"col",
"in",
"colnames",
":",
"col_in",
"=",
"table_in",
"[",
"col",
"]",
"stats",
"=",
"collect_summary_stats",
"(",
"col_in",
".",
"data",
")",
"for",... | Collect summary statisitics from an input table and add them to an output table
Parameters
----------
table_in : `astropy.table.Table`
Table with the input data.
table_out : `astropy.table.Table`
Table with the output data.
colnames : list
List of the column names to get... | [
"Collect",
"summary",
"statisitics",
"from",
"an",
"input",
"table",
"and",
"add",
"them",
"to",
"an",
"output",
"table"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L200-L223 | train |
fermiPy/fermipy | fermipy/jobs/target_collect.py | summarize_sed_results | def summarize_sed_results(sed_table):
"""Build a stats summary table for a table that has all the SED results """
del_cols = ['dnde', 'dnde_err', 'dnde_errp', 'dnde_errn', 'dnde_ul',
'e2dnde', 'e2dnde_err', 'e2dnde_errp', 'e2dnde_errn', 'e2dnde_ul',
'norm', 'norm_err', 'norm_errp... | python | def summarize_sed_results(sed_table):
"""Build a stats summary table for a table that has all the SED results """
del_cols = ['dnde', 'dnde_err', 'dnde_errp', 'dnde_errn', 'dnde_ul',
'e2dnde', 'e2dnde_err', 'e2dnde_errp', 'e2dnde_errn', 'e2dnde_ul',
'norm', 'norm_err', 'norm_errp... | [
"def",
"summarize_sed_results",
"(",
"sed_table",
")",
":",
"del_cols",
"=",
"[",
"'dnde'",
",",
"'dnde_err'",
",",
"'dnde_errp'",
",",
"'dnde_errn'",
",",
"'dnde_ul'",
",",
"'e2dnde'",
",",
"'e2dnde_err'",
",",
"'e2dnde_errp'",
",",
"'e2dnde_errn'",
",",
"'e2dn... | Build a stats summary table for a table that has all the SED results | [
"Build",
"a",
"stats",
"summary",
"table",
"for",
"a",
"table",
"that",
"has",
"all",
"the",
"SED",
"results"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_collect.py#L226-L239 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory.update_base_dict | def update_base_dict(self, yamlfile):
"""Update the values in baseline dictionary used to resolve names
"""
self.base_dict.update(**yaml.safe_load(open(yamlfile))) | python | def update_base_dict(self, yamlfile):
"""Update the values in baseline dictionary used to resolve names
"""
self.base_dict.update(**yaml.safe_load(open(yamlfile))) | [
"def",
"update_base_dict",
"(",
"self",
",",
"yamlfile",
")",
":",
"self",
".",
"base_dict",
".",
"update",
"(",
"**",
"yaml",
".",
"safe_load",
"(",
"open",
"(",
"yamlfile",
")",
")",
")"
] | Update the values in baseline dictionary used to resolve names | [
"Update",
"the",
"values",
"in",
"baseline",
"dictionary",
"used",
"to",
"resolve",
"names"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L59-L62 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory._format_from_dict | def _format_from_dict(self, format_string, **kwargs):
"""Return a formatted file name dictionary components """
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
localpath = format_string.format(**kwargs_copy)
if kwargs.get('fullpath', False):
return se... | python | def _format_from_dict(self, format_string, **kwargs):
"""Return a formatted file name dictionary components """
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
localpath = format_string.format(**kwargs_copy)
if kwargs.get('fullpath', False):
return se... | [
"def",
"_format_from_dict",
"(",
"self",
",",
"format_string",
",",
"**",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"**",
"kwargs",
")",
"localpath",
"=",
"format_string",
".... | Return a formatted file name dictionary components | [
"Return",
"a",
"formatted",
"file",
"name",
"dictionary",
"components"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L64-L71 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory.sim_sedfile | def sim_sedfile(self, **kwargs):
"""Return the name for the simulated SED file for a particular target
"""
if 'seed' not in kwargs:
kwargs['seed'] = 'SEED'
return self._format_from_dict(NameFactory.sim_sedfile_format, **kwargs) | python | def sim_sedfile(self, **kwargs):
"""Return the name for the simulated SED file for a particular target
"""
if 'seed' not in kwargs:
kwargs['seed'] = 'SEED'
return self._format_from_dict(NameFactory.sim_sedfile_format, **kwargs) | [
"def",
"sim_sedfile",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"'seed'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'seed'",
"]",
"=",
"'SEED'",
"return",
"self",
".",
"_format_from_dict",
"(",
"NameFactory",
".",
"sim_sedfile_format",
",",
"**",... | Return the name for the simulated SED file for a particular target | [
"Return",
"the",
"name",
"for",
"the",
"simulated",
"SED",
"file",
"for",
"a",
"particular",
"target"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L118-L123 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory.stamp | def stamp(self, **kwargs):
"""Return the path for a stamp file for a scatter gather job"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
return NameFactory.stamp_format.format(**kwargs_copy) | python | def stamp(self, **kwargs):
"""Return the path for a stamp file for a scatter gather job"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
return NameFactory.stamp_format.format(**kwargs_copy) | [
"def",
"stamp",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"**",
"kwargs",
")",
"return",
"NameFactory",
".",
"stamp_format",
".",
"format",
"(",
"... | Return the path for a stamp file for a scatter gather job | [
"Return",
"the",
"path",
"for",
"a",
"stamp",
"file",
"for",
"a",
"scatter",
"gather",
"job"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L125-L129 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory.resolve_targetfile | def resolve_targetfile(self, args, require_sim_name=False): # x
"""Get the name of the targetfile based on the job arguments"""
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return (None, None)
sim = args.get('sim... | python | def resolve_targetfile(self, args, require_sim_name=False): # x
"""Get the name of the targetfile based on the job arguments"""
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return (None, None)
sim = args.get('sim... | [
"def",
"resolve_targetfile",
"(",
"self",
",",
"args",
",",
"require_sim_name",
"=",
"False",
")",
":",
"ttype",
"=",
"args",
".",
"get",
"(",
"'ttype'",
")",
"if",
"is_null",
"(",
"ttype",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'Target ty... | Get the name of the targetfile based on the job arguments | [
"Get",
"the",
"name",
"of",
"the",
"targetfile",
"based",
"on",
"the",
"job",
"arguments"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L138-L166 | train |
fermiPy/fermipy | fermipy/jobs/name_policy.py | NameFactory.resolve_randconfig | def resolve_randconfig(self, args):
"""Get the name of the specturm file based on the job arguments"""
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return None
name_keys = dict(target_type=ttype,
... | python | def resolve_randconfig(self, args):
"""Get the name of the specturm file based on the job arguments"""
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return None
name_keys = dict(target_type=ttype,
... | [
"def",
"resolve_randconfig",
"(",
"self",
",",
"args",
")",
":",
"ttype",
"=",
"args",
".",
"get",
"(",
"'ttype'",
")",
"if",
"is_null",
"(",
"ttype",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'Target type must be specified'",
")",
"return",
"N... | Get the name of the specturm file based on the job arguments | [
"Get",
"the",
"name",
"of",
"the",
"specturm",
"file",
"based",
"on",
"the",
"job",
"arguments"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/name_policy.py#L168-L180 | train |
fermiPy/fermipy | fermipy/castro.py | convert_sed_cols | def convert_sed_cols(tab):
"""Cast SED column names to lowercase."""
# Update Column names
for colname in list(tab.columns.keys()):
newname = colname.lower()
newname = newname.replace('dfde', 'dnde')
if tab.columns[colname].name == newname:
continue
tab.columns... | python | def convert_sed_cols(tab):
"""Cast SED column names to lowercase."""
# Update Column names
for colname in list(tab.columns.keys()):
newname = colname.lower()
newname = newname.replace('dfde', 'dnde')
if tab.columns[colname].name == newname:
continue
tab.columns... | [
"def",
"convert_sed_cols",
"(",
"tab",
")",
":",
"for",
"colname",
"in",
"list",
"(",
"tab",
".",
"columns",
".",
"keys",
"(",
")",
")",
":",
"newname",
"=",
"colname",
".",
"lower",
"(",
")",
"newname",
"=",
"newname",
".",
"replace",
"(",
"'dfde'",... | Cast SED column names to lowercase. | [
"Cast",
"SED",
"column",
"names",
"to",
"lowercase",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L38-L51 | train |
fermiPy/fermipy | fermipy/castro.py | Interpolator.derivative | def derivative(self, x, der=1):
""" return the derivative a an array of input values
x : the inputs
der : the order of derivative
"""
from scipy.interpolate import splev
return splev(x, self._sp, der=der) | python | def derivative(self, x, der=1):
""" return the derivative a an array of input values
x : the inputs
der : the order of derivative
"""
from scipy.interpolate import splev
return splev(x, self._sp, der=der) | [
"def",
"derivative",
"(",
"self",
",",
"x",
",",
"der",
"=",
"1",
")",
":",
"from",
"scipy",
".",
"interpolate",
"import",
"splev",
"return",
"splev",
"(",
"x",
",",
"self",
".",
"_sp",
",",
"der",
"=",
"der",
")"
] | return the derivative a an array of input values
x : the inputs
der : the order of derivative | [
"return",
"the",
"derivative",
"a",
"an",
"array",
"of",
"input",
"values"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L112-L119 | train |
fermiPy/fermipy | fermipy/castro.py | LnLFn._compute_mle | def _compute_mle(self):
"""Compute the maximum likelihood estimate.
Calls `scipy.optimize.brentq` to find the roots of the derivative.
"""
min_y = np.min(self._interp.y)
if self._interp.y[0] == min_y:
self._mle = self._interp.x[0]
elif self._interp.y[-1] == m... | python | def _compute_mle(self):
"""Compute the maximum likelihood estimate.
Calls `scipy.optimize.brentq` to find the roots of the derivative.
"""
min_y = np.min(self._interp.y)
if self._interp.y[0] == min_y:
self._mle = self._interp.x[0]
elif self._interp.y[-1] == m... | [
"def",
"_compute_mle",
"(",
"self",
")",
":",
"min_y",
"=",
"np",
".",
"min",
"(",
"self",
".",
"_interp",
".",
"y",
")",
"if",
"self",
".",
"_interp",
".",
"y",
"[",
"0",
"]",
"==",
"min_y",
":",
"self",
".",
"_mle",
"=",
"self",
".",
"_interp... | Compute the maximum likelihood estimate.
Calls `scipy.optimize.brentq` to find the roots of the derivative. | [
"Compute",
"the",
"maximum",
"likelihood",
"estimate",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L193-L216 | train |
fermiPy/fermipy | fermipy/castro.py | LnLFn.getDeltaLogLike | def getDeltaLogLike(self, dlnl, upper=True):
"""Find the point at which the log-likelihood changes by a
given value with respect to its value at the MLE."""
mle_val = self.mle()
# A little bit of paranoia to avoid zeros
if mle_val <= 0.:
mle_val = self._interp.xmin
... | python | def getDeltaLogLike(self, dlnl, upper=True):
"""Find the point at which the log-likelihood changes by a
given value with respect to its value at the MLE."""
mle_val = self.mle()
# A little bit of paranoia to avoid zeros
if mle_val <= 0.:
mle_val = self._interp.xmin
... | [
"def",
"getDeltaLogLike",
"(",
"self",
",",
"dlnl",
",",
"upper",
"=",
"True",
")",
":",
"mle_val",
"=",
"self",
".",
"mle",
"(",
")",
"if",
"mle_val",
"<=",
"0.",
":",
"mle_val",
"=",
"self",
".",
"_interp",
".",
"xmin",
"if",
"mle_val",
"<=",
"0.... | Find the point at which the log-likelihood changes by a
given value with respect to its value at the MLE. | [
"Find",
"the",
"point",
"at",
"which",
"the",
"log",
"-",
"likelihood",
"changes",
"by",
"a",
"given",
"value",
"with",
"respect",
"to",
"its",
"value",
"at",
"the",
"MLE",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L235-L270 | train |
fermiPy/fermipy | fermipy/castro.py | ReferenceSpec.build_ebound_table | def build_ebound_table(self):
""" Build and return an EBOUNDS table with the encapsulated data.
"""
cols = [
Column(name="E_MIN", dtype=float, data=self._emin, unit='MeV'),
Column(name="E_MAX", dtype=float, data=self._emax, unit='MeV'),
Column(name="E_REF", dt... | python | def build_ebound_table(self):
""" Build and return an EBOUNDS table with the encapsulated data.
"""
cols = [
Column(name="E_MIN", dtype=float, data=self._emin, unit='MeV'),
Column(name="E_MAX", dtype=float, data=self._emax, unit='MeV'),
Column(name="E_REF", dt... | [
"def",
"build_ebound_table",
"(",
"self",
")",
":",
"cols",
"=",
"[",
"Column",
"(",
"name",
"=",
"\"E_MIN\"",
",",
"dtype",
"=",
"float",
",",
"data",
"=",
"self",
".",
"_emin",
",",
"unit",
"=",
"'MeV'",
")",
",",
"Column",
"(",
"name",
"=",
"\"E... | Build and return an EBOUNDS table with the encapsulated data. | [
"Build",
"and",
"return",
"an",
"EBOUNDS",
"table",
"with",
"the",
"encapsulated",
"data",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L443-L460 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.derivative | def derivative(self, x, der=1):
"""Return the derivate of the log-like summed over the energy
bins
Parameters
----------
x : `~numpy.ndarray`
Array of N x M values
der : int
Order of the derivate
Returns
-------
der_val :... | python | def derivative(self, x, der=1):
"""Return the derivate of the log-like summed over the energy
bins
Parameters
----------
x : `~numpy.ndarray`
Array of N x M values
der : int
Order of the derivate
Returns
-------
der_val :... | [
"def",
"derivative",
"(",
"self",
",",
"x",
",",
"der",
"=",
"1",
")",
":",
"if",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"1",
":",
"der_val",
"=",
"np",
".",
"zeros",
"(",
"(",
"1",
")",
")",
"else",
":",
"der_val",
"=",
"np",
".",
"zero... | Return the derivate of the log-like summed over the energy
bins
Parameters
----------
x : `~numpy.ndarray`
Array of N x M values
der : int
Order of the derivate
Returns
-------
der_val : `~numpy.ndarray`
Array of negat... | [
"Return",
"the",
"derivate",
"of",
"the",
"log",
"-",
"like",
"summed",
"over",
"the",
"energy",
"bins"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L721-L745 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.mles | def mles(self):
""" return the maximum likelihood estimates for each of the energy bins
"""
mle_vals = np.ndarray((self._nx))
for i in range(self._nx):
mle_vals[i] = self._loglikes[i].mle()
return mle_vals | python | def mles(self):
""" return the maximum likelihood estimates for each of the energy bins
"""
mle_vals = np.ndarray((self._nx))
for i in range(self._nx):
mle_vals[i] = self._loglikes[i].mle()
return mle_vals | [
"def",
"mles",
"(",
"self",
")",
":",
"mle_vals",
"=",
"np",
".",
"ndarray",
"(",
"(",
"self",
".",
"_nx",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_nx",
")",
":",
"mle_vals",
"[",
"i",
"]",
"=",
"self",
".",
"_loglikes",
"[",
... | return the maximum likelihood estimates for each of the energy bins | [
"return",
"the",
"maximum",
"likelihood",
"estimates",
"for",
"each",
"of",
"the",
"energy",
"bins"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L747-L753 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.ts_vals | def ts_vals(self):
""" returns test statistic values for each energy bin
"""
ts_vals = np.ndarray((self._nx))
for i in range(self._nx):
ts_vals[i] = self._loglikes[i].TS()
return ts_vals | python | def ts_vals(self):
""" returns test statistic values for each energy bin
"""
ts_vals = np.ndarray((self._nx))
for i in range(self._nx):
ts_vals[i] = self._loglikes[i].TS()
return ts_vals | [
"def",
"ts_vals",
"(",
"self",
")",
":",
"ts_vals",
"=",
"np",
".",
"ndarray",
"(",
"(",
"self",
".",
"_nx",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_nx",
")",
":",
"ts_vals",
"[",
"i",
"]",
"=",
"self",
".",
"_loglikes",
"[",
... | returns test statistic values for each energy bin | [
"returns",
"test",
"statistic",
"values",
"for",
"each",
"energy",
"bin"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L764-L771 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.chi2_vals | def chi2_vals(self, x):
"""Compute the difference in the log-likelihood between the
MLE in each energy bin and the normalization predicted by a
global best-fit model. This array can be summed to get a
goodness-of-fit chi2 for the model.
Parameters
----------
x :... | python | def chi2_vals(self, x):
"""Compute the difference in the log-likelihood between the
MLE in each energy bin and the normalization predicted by a
global best-fit model. This array can be summed to get a
goodness-of-fit chi2 for the model.
Parameters
----------
x :... | [
"def",
"chi2_vals",
"(",
"self",
",",
"x",
")",
":",
"chi2_vals",
"=",
"np",
".",
"ndarray",
"(",
"(",
"self",
".",
"_nx",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_nx",
")",
":",
"mle",
"=",
"self",
".",
"_loglikes",
"[",
"i",
... | Compute the difference in the log-likelihood between the
MLE in each energy bin and the normalization predicted by a
global best-fit model. This array can be summed to get a
goodness-of-fit chi2 for the model.
Parameters
----------
x : `~numpy.ndarray`
... | [
"Compute",
"the",
"difference",
"in",
"the",
"log",
"-",
"likelihood",
"between",
"the",
"MLE",
"in",
"each",
"energy",
"bin",
"and",
"the",
"normalization",
"predicted",
"by",
"a",
"global",
"best",
"-",
"fit",
"model",
".",
"This",
"array",
"can",
"be",
... | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L773-L799 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.fitNormalization | def fitNormalization(self, specVals, xlims):
"""Fit the normalization given a set of spectral values that
define a spectral shape
This version is faster, and solves for the root of the derivatvie
Parameters
----------
specVals : an array of (nebin values that define a ... | python | def fitNormalization(self, specVals, xlims):
"""Fit the normalization given a set of spectral values that
define a spectral shape
This version is faster, and solves for the root of the derivatvie
Parameters
----------
specVals : an array of (nebin values that define a ... | [
"def",
"fitNormalization",
"(",
"self",
",",
"specVals",
",",
"xlims",
")",
":",
"from",
"scipy",
".",
"optimize",
"import",
"brentq",
"def",
"fDeriv",
"(",
"x",
")",
":",
"return",
"self",
".",
"norm_derivative",
"(",
"specVals",
",",
"x",
")",
"try",
... | Fit the normalization given a set of spectral values that
define a spectral shape
This version is faster, and solves for the root of the derivatvie
Parameters
----------
specVals : an array of (nebin values that define a spectral shape
xlims : fit limits
... | [
"Fit",
"the",
"normalization",
"given",
"a",
"set",
"of",
"spectral",
"values",
"that",
"define",
"a",
"spectral",
"shape"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L847-L872 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.fitNorm_v2 | def fitNorm_v2(self, specVals):
"""Fit the normalization given a set of spectral values
that define a spectral shape.
This version uses `scipy.optimize.fmin`.
Parameters
----------
specVals : an array of (nebin values that define a spectral shape
xlims : f... | python | def fitNorm_v2(self, specVals):
"""Fit the normalization given a set of spectral values
that define a spectral shape.
This version uses `scipy.optimize.fmin`.
Parameters
----------
specVals : an array of (nebin values that define a spectral shape
xlims : f... | [
"def",
"fitNorm_v2",
"(",
"self",
",",
"specVals",
")",
":",
"from",
"scipy",
".",
"optimize",
"import",
"fmin",
"def",
"fToMin",
"(",
"x",
")",
":",
"return",
"self",
".",
"__call__",
"(",
"specVals",
"*",
"x",
")",
"result",
"=",
"fmin",
"(",
"fToM... | Fit the normalization given a set of spectral values
that define a spectral shape.
This version uses `scipy.optimize.fmin`.
Parameters
----------
specVals : an array of (nebin values that define a spectral shape
xlims : fit limits
Returns
---... | [
"Fit",
"the",
"normalization",
"given",
"a",
"set",
"of",
"spectral",
"values",
"that",
"define",
"a",
"spectral",
"shape",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L874-L894 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.fit_spectrum | def fit_spectrum(self, specFunc, initPars, freePars=None):
""" Fit for the free parameters of a spectral function
Parameters
----------
specFunc : `~fermipy.spectrum.SpectralFunction`
The Spectral Function
initPars : `~numpy.ndarray`
The initial values o... | python | def fit_spectrum(self, specFunc, initPars, freePars=None):
""" Fit for the free parameters of a spectral function
Parameters
----------
specFunc : `~fermipy.spectrum.SpectralFunction`
The Spectral Function
initPars : `~numpy.ndarray`
The initial values o... | [
"def",
"fit_spectrum",
"(",
"self",
",",
"specFunc",
",",
"initPars",
",",
"freePars",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"specFunc",
",",
"SEDFunctor",
")",
":",
"specFunc",
"=",
"self",
".",
"create_functor",
"(",
"specFunc",
",",
"... | Fit for the free parameters of a spectral function
Parameters
----------
specFunc : `~fermipy.spectrum.SpectralFunction`
The Spectral Function
initPars : `~numpy.ndarray`
The initial values of the parameters
freePars : `~numpy.ndarray`
... | [
"Fit",
"for",
"the",
"free",
"parameters",
"of",
"a",
"spectral",
"function"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L896-L968 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData_Base.build_scandata_table | def build_scandata_table(self):
"""Build an `astropy.table.Table` object from these data.
"""
shape = self._norm_vals.shape
col_norm = Column(name="norm", dtype=float)
col_normv = Column(name="norm_scan", dtype=float,
shape=shape)
col_dll = Colu... | python | def build_scandata_table(self):
"""Build an `astropy.table.Table` object from these data.
"""
shape = self._norm_vals.shape
col_norm = Column(name="norm", dtype=float)
col_normv = Column(name="norm_scan", dtype=float,
shape=shape)
col_dll = Colu... | [
"def",
"build_scandata_table",
"(",
"self",
")",
":",
"shape",
"=",
"self",
".",
"_norm_vals",
".",
"shape",
"col_norm",
"=",
"Column",
"(",
"name",
"=",
"\"norm\"",
",",
"dtype",
"=",
"float",
")",
"col_normv",
"=",
"Column",
"(",
"name",
"=",
"\"norm_s... | Build an `astropy.table.Table` object from these data. | [
"Build",
"an",
"astropy",
".",
"table",
".",
"Table",
"object",
"from",
"these",
"data",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L975-L988 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_from_yamlfile | def create_from_yamlfile(cls, yamlfile):
"""Create a Castro data object from a yaml file contains
the likelihood data."""
data = load_yaml(yamlfile)
nebins = len(data)
emin = np.array([data[i]['emin'] for i in range(nebins)])
emax = np.array([data[i]['emax'] for i in rang... | python | def create_from_yamlfile(cls, yamlfile):
"""Create a Castro data object from a yaml file contains
the likelihood data."""
data = load_yaml(yamlfile)
nebins = len(data)
emin = np.array([data[i]['emin'] for i in range(nebins)])
emax = np.array([data[i]['emax'] for i in rang... | [
"def",
"create_from_yamlfile",
"(",
"cls",
",",
"yamlfile",
")",
":",
"data",
"=",
"load_yaml",
"(",
"yamlfile",
")",
"nebins",
"=",
"len",
"(",
"data",
")",
"emin",
"=",
"np",
".",
"array",
"(",
"[",
"data",
"[",
"i",
"]",
"[",
"'emin'",
"]",
"for... | Create a Castro data object from a yaml file contains
the likelihood data. | [
"Create",
"a",
"Castro",
"data",
"object",
"from",
"a",
"yaml",
"file",
"contains",
"the",
"likelihood",
"data",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1095-L1112 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_from_flux_points | def create_from_flux_points(cls, txtfile):
"""Create a Castro data object from a text file containing a
sequence of differential flux points."""
tab = Table.read(txtfile, format='ascii.ecsv')
dnde_unit = u.ph / (u.MeV * u.cm ** 2 * u.s)
loge = np.log10(np.array(tab['e_ref'].to(u... | python | def create_from_flux_points(cls, txtfile):
"""Create a Castro data object from a text file containing a
sequence of differential flux points."""
tab = Table.read(txtfile, format='ascii.ecsv')
dnde_unit = u.ph / (u.MeV * u.cm ** 2 * u.s)
loge = np.log10(np.array(tab['e_ref'].to(u... | [
"def",
"create_from_flux_points",
"(",
"cls",
",",
"txtfile",
")",
":",
"tab",
"=",
"Table",
".",
"read",
"(",
"txtfile",
",",
"format",
"=",
"'ascii.ecsv'",
")",
"dnde_unit",
"=",
"u",
".",
"ph",
"/",
"(",
"u",
".",
"MeV",
"*",
"u",
".",
"cm",
"**... | Create a Castro data object from a text file containing a
sequence of differential flux points. | [
"Create",
"a",
"Castro",
"data",
"object",
"from",
"a",
"text",
"file",
"containing",
"a",
"sequence",
"of",
"differential",
"flux",
"points",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1115-L1159 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_from_tables | def create_from_tables(cls, norm_type='eflux',
tab_s="SCANDATA",
tab_e="EBOUNDS"):
"""Create a CastroData object from two tables
Parameters
----------
norm_type : str
Type of normalization to use. Valid options are:
... | python | def create_from_tables(cls, norm_type='eflux',
tab_s="SCANDATA",
tab_e="EBOUNDS"):
"""Create a CastroData object from two tables
Parameters
----------
norm_type : str
Type of normalization to use. Valid options are:
... | [
"def",
"create_from_tables",
"(",
"cls",
",",
"norm_type",
"=",
"'eflux'",
",",
"tab_s",
"=",
"\"SCANDATA\"",
",",
"tab_e",
"=",
"\"EBOUNDS\"",
")",
":",
"if",
"norm_type",
"in",
"[",
"'flux'",
",",
"'eflux'",
",",
"'dnde'",
"]",
":",
"norm_vals",
"=",
"... | Create a CastroData object from two tables
Parameters
----------
norm_type : str
Type of normalization to use. Valid options are:
* norm : Normalization w.r.t. to test source
* flux : Flux of the test source ( ph cm^-2 s^-1 )
* eflux: Energy Flu... | [
"Create",
"a",
"CastroData",
"object",
"from",
"two",
"tables"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1162-L1200 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_from_fits | def create_from_fits(cls, fitsfile, norm_type='eflux',
hdu_scan="SCANDATA",
hdu_energies="EBOUNDS",
irow=None):
"""Create a CastroData object from a tscube FITS file.
Parameters
----------
fitsfile : str
... | python | def create_from_fits(cls, fitsfile, norm_type='eflux',
hdu_scan="SCANDATA",
hdu_energies="EBOUNDS",
irow=None):
"""Create a CastroData object from a tscube FITS file.
Parameters
----------
fitsfile : str
... | [
"def",
"create_from_fits",
"(",
"cls",
",",
"fitsfile",
",",
"norm_type",
"=",
"'eflux'",
",",
"hdu_scan",
"=",
"\"SCANDATA\"",
",",
"hdu_energies",
"=",
"\"EBOUNDS\"",
",",
"irow",
"=",
"None",
")",
":",
"if",
"irow",
"is",
"not",
"None",
":",
"tab_s",
... | Create a CastroData object from a tscube FITS file.
Parameters
----------
fitsfile : str
Name of the fits file
norm_type : str
Type of normalization to use. Valid options are:
* norm : Normalization w.r.t. to test source
* flux : Flux ... | [
"Create",
"a",
"CastroData",
"object",
"from",
"a",
"tscube",
"FITS",
"file",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1203-L1250 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_from_sedfile | def create_from_sedfile(cls, fitsfile, norm_type='eflux'):
"""Create a CastroData object from an SED fits file
Parameters
----------
fitsfile : str
Name of the fits file
norm_type : str
Type of normalization to use, options are:
* norm : N... | python | def create_from_sedfile(cls, fitsfile, norm_type='eflux'):
"""Create a CastroData object from an SED fits file
Parameters
----------
fitsfile : str
Name of the fits file
norm_type : str
Type of normalization to use, options are:
* norm : N... | [
"def",
"create_from_sedfile",
"(",
"cls",
",",
"fitsfile",
",",
"norm_type",
"=",
"'eflux'",
")",
":",
"tab_s",
"=",
"Table",
".",
"read",
"(",
"fitsfile",
",",
"hdu",
"=",
"1",
")",
"tab_s",
"=",
"convert_sed_cols",
"(",
"tab_s",
")",
"if",
"norm_type",... | Create a CastroData object from an SED fits file
Parameters
----------
fitsfile : str
Name of the fits file
norm_type : str
Type of normalization to use, options are:
* norm : Normalization w.r.t. to test source
* flux : Flux of the te... | [
"Create",
"a",
"CastroData",
"object",
"from",
"an",
"SED",
"fits",
"file"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1253-L1290 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.spectrum_loglike | def spectrum_loglike(self, specType, params, scale=1E3):
""" return the log-likelihood for a particular spectrum
Parameters
----------
specTypes : str
The type of spectrum to try
params : array-like
The spectral parameters
scale : float
... | python | def spectrum_loglike(self, specType, params, scale=1E3):
""" return the log-likelihood for a particular spectrum
Parameters
----------
specTypes : str
The type of spectrum to try
params : array-like
The spectral parameters
scale : float
... | [
"def",
"spectrum_loglike",
"(",
"self",
",",
"specType",
",",
"params",
",",
"scale",
"=",
"1E3",
")",
":",
"sfn",
"=",
"self",
".",
"create_functor",
"(",
"specType",
",",
"scale",
")",
"[",
"0",
"]",
"return",
"self",
".",
"__call__",
"(",
"sfn",
"... | return the log-likelihood for a particular spectrum
Parameters
----------
specTypes : str
The type of spectrum to try
params : array-like
The spectral parameters
scale : float
The energy scale or 'pivot' energy | [
"return",
"the",
"log",
"-",
"likelihood",
"for",
"a",
"particular",
"spectrum"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1320-L1335 | train |
fermiPy/fermipy | fermipy/castro.py | CastroData.create_functor | def create_functor(self, specType, initPars=None, scale=1E3):
"""Create a functor object that computes normalizations in a
sequence of energy bins for a given spectral model.
Parameters
----------
specType : str
The type of spectrum to use. This can be a str... | python | def create_functor(self, specType, initPars=None, scale=1E3):
"""Create a functor object that computes normalizations in a
sequence of energy bins for a given spectral model.
Parameters
----------
specType : str
The type of spectrum to use. This can be a str... | [
"def",
"create_functor",
"(",
"self",
",",
"specType",
",",
"initPars",
"=",
"None",
",",
"scale",
"=",
"1E3",
")",
":",
"emin",
"=",
"self",
".",
"_refSpec",
".",
"emin",
"emax",
"=",
"self",
".",
"_refSpec",
".",
"emax",
"fn",
"=",
"SpectralFunction"... | Create a functor object that computes normalizations in a
sequence of energy bins for a given spectral model.
Parameters
----------
specType : str
The type of spectrum to use. This can be a string
corresponding to the spectral model class name or a
... | [
"Create",
"a",
"functor",
"object",
"that",
"computes",
"normalizations",
"in",
"a",
"sequence",
"of",
"energy",
"bins",
"for",
"a",
"given",
"spectral",
"model",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1377-L1419 | train |
fermiPy/fermipy | fermipy/castro.py | TSCube.find_and_refine_peaks | def find_and_refine_peaks(self, threshold, min_separation=1.0,
use_cumul=False):
"""Run a simple peak-finding algorithm, and fit the peaks to
paraboloids to extract their positions and error ellipses.
Parameters
----------
threshold : float
... | python | def find_and_refine_peaks(self, threshold, min_separation=1.0,
use_cumul=False):
"""Run a simple peak-finding algorithm, and fit the peaks to
paraboloids to extract their positions and error ellipses.
Parameters
----------
threshold : float
... | [
"def",
"find_and_refine_peaks",
"(",
"self",
",",
"threshold",
",",
"min_separation",
"=",
"1.0",
",",
"use_cumul",
"=",
"False",
")",
":",
"if",
"use_cumul",
":",
"theMap",
"=",
"self",
".",
"_ts_cumul",
"else",
":",
"theMap",
"=",
"self",
".",
"_tsmap",
... | Run a simple peak-finding algorithm, and fit the peaks to
paraboloids to extract their positions and error ellipses.
Parameters
----------
threshold : float
Peak threshold in TS.
min_separation : float
Radius of region size in degrees. Sets the minimum ... | [
"Run",
"a",
"simple",
"peak",
"-",
"finding",
"algorithm",
"and",
"fit",
"the",
"peaks",
"to",
"paraboloids",
"to",
"extract",
"their",
"positions",
"and",
"error",
"ellipses",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/castro.py#L1624-L1666 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | make_lat_lons | def make_lat_lons(cvects):
""" Convert from directional cosines to latitidue and longitude
Parameters
----------
cvects : directional cosine (i.e., x,y,z component) values
returns (np.ndarray(2,nsrc)) with the directional cosine (i.e., x,y,z component) values
"""
lats = np.degrees(np.arcsi... | python | def make_lat_lons(cvects):
""" Convert from directional cosines to latitidue and longitude
Parameters
----------
cvects : directional cosine (i.e., x,y,z component) values
returns (np.ndarray(2,nsrc)) with the directional cosine (i.e., x,y,z component) values
"""
lats = np.degrees(np.arcsi... | [
"def",
"make_lat_lons",
"(",
"cvects",
")",
":",
"lats",
"=",
"np",
".",
"degrees",
"(",
"np",
".",
"arcsin",
"(",
"cvects",
"[",
"2",
"]",
")",
")",
"lons",
"=",
"np",
".",
"degrees",
"(",
"np",
".",
"arctan2",
"(",
"cvects",
"[",
"0",
"]",
",... | Convert from directional cosines to latitidue and longitude
Parameters
----------
cvects : directional cosine (i.e., x,y,z component) values
returns (np.ndarray(2,nsrc)) with the directional cosine (i.e., x,y,z component) values | [
"Convert",
"from",
"directional",
"cosines",
"to",
"latitidue",
"and",
"longitude"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L20-L31 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | fill_edge_matrix | def fill_edge_matrix(nsrcs, match_dict):
""" Create and fill a matrix with the graph 'edges' between sources.
Parameters
----------
nsrcs : int
number of sources (used to allocate the size of the matrix)
match_dict : dict((int,int):float)
Each entry gives a pair of source in... | python | def fill_edge_matrix(nsrcs, match_dict):
""" Create and fill a matrix with the graph 'edges' between sources.
Parameters
----------
nsrcs : int
number of sources (used to allocate the size of the matrix)
match_dict : dict((int,int):float)
Each entry gives a pair of source in... | [
"def",
"fill_edge_matrix",
"(",
"nsrcs",
",",
"match_dict",
")",
":",
"e_matrix",
"=",
"np",
".",
"zeros",
"(",
"(",
"nsrcs",
",",
"nsrcs",
")",
")",
"for",
"k",
",",
"v",
"in",
"match_dict",
".",
"items",
"(",
")",
":",
"e_matrix",
"[",
"k",
"[",
... | Create and fill a matrix with the graph 'edges' between sources.
Parameters
----------
nsrcs : int
number of sources (used to allocate the size of the matrix)
match_dict : dict((int,int):float)
Each entry gives a pair of source indices, and the
corresponding measure (eit... | [
"Create",
"and",
"fill",
"a",
"matrix",
"with",
"the",
"graph",
"edges",
"between",
"sources",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L132-L154 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | make_rev_dict_unique | def make_rev_dict_unique(cdict):
""" Make a reverse dictionary
Parameters
----------
in_dict : dict(int:dict(int:True))
A dictionary of clusters. Each cluster is a source index and
the dictionary of other sources in the cluster.
Returns
-------
rev_dict : dict(int:dict(i... | python | def make_rev_dict_unique(cdict):
""" Make a reverse dictionary
Parameters
----------
in_dict : dict(int:dict(int:True))
A dictionary of clusters. Each cluster is a source index and
the dictionary of other sources in the cluster.
Returns
-------
rev_dict : dict(int:dict(i... | [
"def",
"make_rev_dict_unique",
"(",
"cdict",
")",
":",
"rev_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"cdict",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"rev_dict",
":",
"rev_dict",
"[",
"k",
"]",
"[",
"k",
"]",
"=",
"True",
"else",
... | Make a reverse dictionary
Parameters
----------
in_dict : dict(int:dict(int:True))
A dictionary of clusters. Each cluster is a source index and
the dictionary of other sources in the cluster.
Returns
-------
rev_dict : dict(int:dict(int:True))
A dictionary pointin... | [
"Make",
"a",
"reverse",
"dictionary"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L157-L184 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | make_clusters | def make_clusters(span_tree, cut_value):
""" Find clusters from the spanning tree
Parameters
----------
span_tree : a sparse nsrcs x nsrcs array
Filled with zeros except for the active edges, which are filled with the
edge measures (either distances or sigmas
cut_value : float
... | python | def make_clusters(span_tree, cut_value):
""" Find clusters from the spanning tree
Parameters
----------
span_tree : a sparse nsrcs x nsrcs array
Filled with zeros except for the active edges, which are filled with the
edge measures (either distances or sigmas
cut_value : float
... | [
"def",
"make_clusters",
"(",
"span_tree",
",",
"cut_value",
")",
":",
"iv0",
",",
"iv1",
"=",
"span_tree",
".",
"nonzero",
"(",
")",
"match_dict",
"=",
"{",
"}",
"for",
"i0",
",",
"i1",
"in",
"zip",
"(",
"iv0",
",",
"iv1",
")",
":",
"d",
"=",
"sp... | Find clusters from the spanning tree
Parameters
----------
span_tree : a sparse nsrcs x nsrcs array
Filled with zeros except for the active edges, which are filled with the
edge measures (either distances or sigmas
cut_value : float
Value used to cluster group. All links with mea... | [
"Find",
"clusters",
"from",
"the",
"spanning",
"tree"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L187-L258 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | select_from_cluster | def select_from_cluster(idx_key, idx_list, measure_vect):
""" Select a single source from a cluster and make it the new cluster key
Parameters
----------
idx_key : int
index of the current key for a cluster
idx_list : [int,...]
list of the other source indices in the cluster
measu... | python | def select_from_cluster(idx_key, idx_list, measure_vect):
""" Select a single source from a cluster and make it the new cluster key
Parameters
----------
idx_key : int
index of the current key for a cluster
idx_list : [int,...]
list of the other source indices in the cluster
measu... | [
"def",
"select_from_cluster",
"(",
"idx_key",
",",
"idx_list",
",",
"measure_vect",
")",
":",
"best_idx",
"=",
"idx_key",
"best_measure",
"=",
"measure_vect",
"[",
"idx_key",
"]",
"out_list",
"=",
"[",
"idx_key",
"]",
"+",
"idx_list",
"for",
"idx",
",",
"mea... | Select a single source from a cluster and make it the new cluster key
Parameters
----------
idx_key : int
index of the current key for a cluster
idx_list : [int,...]
list of the other source indices in the cluster
measure_vect : np.narray((nsrc),float)
vector of the measure used... | [
"Select",
"a",
"single",
"source",
"from",
"a",
"cluster",
"and",
"make",
"it",
"the",
"new",
"cluster",
"key"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L261-L287 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | count_sources_in_cluster | def count_sources_in_cluster(n_src, cdict, rev_dict):
""" Make a vector of sources in each cluster
Parameters
----------
n_src : number of sources
cdict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
... | python | def count_sources_in_cluster(n_src, cdict, rev_dict):
""" Make a vector of sources in each cluster
Parameters
----------
n_src : number of sources
cdict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
... | [
"def",
"count_sources_in_cluster",
"(",
"n_src",
",",
"cdict",
",",
"rev_dict",
")",
":",
"ret_val",
"=",
"np",
".",
"zeros",
"(",
"(",
"n_src",
")",
",",
"int",
")",
"for",
"i",
"in",
"range",
"(",
"n_src",
")",
":",
"try",
":",
"key",
"=",
"rev_d... | Make a vector of sources in each cluster
Parameters
----------
n_src : number of sources
cdict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
rev_dict : dict(int:int)
A single valued dictio... | [
"Make",
"a",
"vector",
"of",
"sources",
"in",
"each",
"cluster"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L317-L350 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | find_dist_to_centroids | def find_dist_to_centroids(cluster_dict, cvects, weights=None):
""" Find the centroids and the distances to the centroid for all sources in a set of clusters
Parameters
----------
cluster_dict : dict(int:[int,...])
Each cluster is a source index and the list of other sources in the cluster. ... | python | def find_dist_to_centroids(cluster_dict, cvects, weights=None):
""" Find the centroids and the distances to the centroid for all sources in a set of clusters
Parameters
----------
cluster_dict : dict(int:[int,...])
Each cluster is a source index and the list of other sources in the cluster. ... | [
"def",
"find_dist_to_centroids",
"(",
"cluster_dict",
",",
"cvects",
",",
"weights",
"=",
"None",
")",
":",
"distances",
"=",
"np",
".",
"zeros",
"(",
"(",
"cvects",
".",
"shape",
"[",
"1",
"]",
")",
")",
"cent_dict",
"=",
"{",
"}",
"for",
"k",
",",
... | Find the centroids and the distances to the centroid for all sources in a set of clusters
Parameters
----------
cluster_dict : dict(int:[int,...])
Each cluster is a source index and the list of other sources in the cluster.
cvects : np.ndarray(3,nsrc)
Directional cosines (i.e., x... | [
"Find",
"the",
"centroids",
"and",
"the",
"distances",
"to",
"the",
"centroid",
"for",
"all",
"sources",
"in",
"a",
"set",
"of",
"clusters"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L372-L397 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | select_from_clusters | def select_from_clusters(cluster_dict, measure_vect):
""" Select a single source from each cluster and make it the new cluster key
cluster_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and the list of other source in the cluster.
measure_vect : np.na... | python | def select_from_clusters(cluster_dict, measure_vect):
""" Select a single source from each cluster and make it the new cluster key
cluster_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and the list of other source in the cluster.
measure_vect : np.na... | [
"def",
"select_from_clusters",
"(",
"cluster_dict",
",",
"measure_vect",
")",
":",
"out_dict",
"=",
"{",
"}",
"for",
"idx_key",
",",
"idx_list",
"in",
"cluster_dict",
".",
"items",
"(",
")",
":",
"out_idx",
",",
"out_list",
"=",
"select_from_cluster",
"(",
"... | Select a single source from each cluster and make it the new cluster key
cluster_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and the list of other source in the cluster.
measure_vect : np.narray((nsrc),float)
vector of the measure used to select ... | [
"Select",
"a",
"single",
"source",
"from",
"each",
"cluster",
"and",
"make",
"it",
"the",
"new",
"cluster",
"key"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L400-L417 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | make_reverse_dict | def make_reverse_dict(in_dict, warn=True):
""" Build a reverse dictionary from a cluster dictionary
Parameters
----------
in_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
Returns
-------
ou... | python | def make_reverse_dict(in_dict, warn=True):
""" Build a reverse dictionary from a cluster dictionary
Parameters
----------
in_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
Returns
-------
ou... | [
"def",
"make_reverse_dict",
"(",
"in_dict",
",",
"warn",
"=",
"True",
")",
":",
"out_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"in_dict",
".",
"items",
"(",
")",
":",
"for",
"vv",
"in",
"v",
":",
"if",
"vv",
"in",
"out_dict",
":",
"if",
... | Build a reverse dictionary from a cluster dictionary
Parameters
----------
in_dict : dict(int:[int,])
A dictionary of clusters. Each cluster is a source index and
the list of other source in the cluster.
Returns
-------
out_dict : dict(int:int)
A single valued d... | [
"Build",
"a",
"reverse",
"dictionary",
"from",
"a",
"cluster",
"dictionary"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L420-L443 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | make_dict_from_vector | def make_dict_from_vector(in_array):
""" Converts the cluster membership array stored in a fits file back to a dictionary
Parameters
----------
in_array : `np.ndarray'
An array filled with the index of the seed of a cluster if a source belongs to a cluster,
and with -1 if it does not.
... | python | def make_dict_from_vector(in_array):
""" Converts the cluster membership array stored in a fits file back to a dictionary
Parameters
----------
in_array : `np.ndarray'
An array filled with the index of the seed of a cluster if a source belongs to a cluster,
and with -1 if it does not.
... | [
"def",
"make_dict_from_vector",
"(",
"in_array",
")",
":",
"out_dict",
"=",
"{",
"}",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"in_array",
")",
":",
"if",
"k",
"<",
"0",
":",
"continue",
"try",
":",
"out_dict",
"[",
"k",
"]",
".",
"append",
"(... | Converts the cluster membership array stored in a fits file back to a dictionary
Parameters
----------
in_array : `np.ndarray'
An array filled with the index of the seed of a cluster if a source belongs to a cluster,
and with -1 if it does not.
Returns
-------
returns dict(int:... | [
"Converts",
"the",
"cluster",
"membership",
"array",
"stored",
"in",
"a",
"fits",
"file",
"back",
"to",
"a",
"dictionary"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L494-L516 | train |
fermiPy/fermipy | fermipy/scripts/cluster_sources.py | filter_and_copy_table | def filter_and_copy_table(tab, to_remove):
""" Filter and copy a FITS table.
Parameters
----------
tab : FITS Table object
to_remove : [int ...}
list of indices to remove from the table
returns FITS Table object
"""
nsrcs = len(tab)
mask = np.zeros((nsrcs), '?')
mas... | python | def filter_and_copy_table(tab, to_remove):
""" Filter and copy a FITS table.
Parameters
----------
tab : FITS Table object
to_remove : [int ...}
list of indices to remove from the table
returns FITS Table object
"""
nsrcs = len(tab)
mask = np.zeros((nsrcs), '?')
mas... | [
"def",
"filter_and_copy_table",
"(",
"tab",
",",
"to_remove",
")",
":",
"nsrcs",
"=",
"len",
"(",
"tab",
")",
"mask",
"=",
"np",
".",
"zeros",
"(",
"(",
"nsrcs",
")",
",",
"'?'",
")",
"mask",
"[",
"to_remove",
"]",
"=",
"True",
"inv_mask",
"=",
"np... | Filter and copy a FITS table.
Parameters
----------
tab : FITS Table object
to_remove : [int ...}
list of indices to remove from the table
returns FITS Table object | [
"Filter",
"and",
"copy",
"a",
"FITS",
"table",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/cluster_sources.py#L519-L536 | train |
fermiPy/fermipy | fermipy/jobs/analysis_utils.py | baseline_roi_fit | def baseline_roi_fit(gta, make_plots=False, minmax_npred=[1e3, np.inf]):
"""Do baseline fitting for a target Region of Interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
make_plots : bool
Flag to make standard analysis plots
minmax_npred... | python | def baseline_roi_fit(gta, make_plots=False, minmax_npred=[1e3, np.inf]):
"""Do baseline fitting for a target Region of Interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
make_plots : bool
Flag to make standard analysis plots
minmax_npred... | [
"def",
"baseline_roi_fit",
"(",
"gta",
",",
"make_plots",
"=",
"False",
",",
"minmax_npred",
"=",
"[",
"1e3",
",",
"np",
".",
"inf",
"]",
")",
":",
"gta",
".",
"free_sources",
"(",
"False",
")",
"gta",
".",
"write_roi",
"(",
"'base_roi'",
",",
"make_pl... | Do baseline fitting for a target Region of Interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
make_plots : bool
Flag to make standard analysis plots
minmax_npred : tuple or list
Range of number of predicted coutns for which to free s... | [
"Do",
"baseline",
"fitting",
"for",
"a",
"target",
"Region",
"of",
"Interest"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/analysis_utils.py#L14-L36 | train |
fermiPy/fermipy | fermipy/jobs/analysis_utils.py | localize_sources | def localize_sources(gta, **kwargs):
"""Relocalize sources in the region of interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
kwargs :
These are passed to the gta.localize function
"""
# Localize all point sources
for src i... | python | def localize_sources(gta, **kwargs):
"""Relocalize sources in the region of interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
kwargs :
These are passed to the gta.localize function
"""
# Localize all point sources
for src i... | [
"def",
"localize_sources",
"(",
"gta",
",",
"**",
"kwargs",
")",
":",
"for",
"src",
"in",
"sorted",
"(",
"gta",
".",
"roi",
".",
"sources",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"'ts'",
"]",
",",
"reverse",
"=",
"True",
")",
":",
"if",
... | Relocalize sources in the region of interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
kwargs :
These are passed to the gta.localize function | [
"Relocalize",
"sources",
"in",
"the",
"region",
"of",
"interest"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/analysis_utils.py#L39-L64 | train |
fermiPy/fermipy | fermipy/jobs/analysis_utils.py | add_source_get_correlated | def add_source_get_correlated(gta, name, src_dict, correl_thresh=0.25, non_null_src=False):
"""Add a source and get the set of correlated sources
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
name : str
Name of the source we are adding
src_d... | python | def add_source_get_correlated(gta, name, src_dict, correl_thresh=0.25, non_null_src=False):
"""Add a source and get the set of correlated sources
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
name : str
Name of the source we are adding
src_d... | [
"def",
"add_source_get_correlated",
"(",
"gta",
",",
"name",
",",
"src_dict",
",",
"correl_thresh",
"=",
"0.25",
",",
"non_null_src",
"=",
"False",
")",
":",
"if",
"gta",
".",
"roi",
".",
"has_source",
"(",
"name",
")",
":",
"gta",
".",
"zero_source",
"(... | Add a source and get the set of correlated sources
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
name : str
Name of the source we are adding
src_dict : dict
Dictionary of the source parameters
correl_thresh : float
Threshold... | [
"Add",
"a",
"source",
"and",
"get",
"the",
"set",
"of",
"correlated",
"sources"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/analysis_utils.py#L67-L127 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | CopyBaseROI.copy_analysis_files | def copy_analysis_files(cls, orig_dir, dest_dir, copyfiles):
""" Copy a list of files from orig_dir to dest_dir"""
for pattern in copyfiles:
glob_path = os.path.join(orig_dir, pattern)
files = glob.glob(glob_path)
for ff in files:
f = os.path.basename(... | python | def copy_analysis_files(cls, orig_dir, dest_dir, copyfiles):
""" Copy a list of files from orig_dir to dest_dir"""
for pattern in copyfiles:
glob_path = os.path.join(orig_dir, pattern)
files = glob.glob(glob_path)
for ff in files:
f = os.path.basename(... | [
"def",
"copy_analysis_files",
"(",
"cls",
",",
"orig_dir",
",",
"dest_dir",
",",
"copyfiles",
")",
":",
"for",
"pattern",
"in",
"copyfiles",
":",
"glob_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"orig_dir",
",",
"pattern",
")",
"files",
"=",
"glob"... | Copy a list of files from orig_dir to dest_dir | [
"Copy",
"a",
"list",
"of",
"files",
"from",
"orig_dir",
"to",
"dest_dir"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L66-L78 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | CopyBaseROI.copy_target_dir | def copy_target_dir(cls, orig_dir, dest_dir, roi_baseline, extracopy):
""" Create and populate directoris for target analysis
"""
try:
os.makedirs(dest_dir)
except OSError:
pass
copyfiles = ['%s.fits' % roi_baseline,
'%s.npy' % roi_ba... | python | def copy_target_dir(cls, orig_dir, dest_dir, roi_baseline, extracopy):
""" Create and populate directoris for target analysis
"""
try:
os.makedirs(dest_dir)
except OSError:
pass
copyfiles = ['%s.fits' % roi_baseline,
'%s.npy' % roi_ba... | [
"def",
"copy_target_dir",
"(",
"cls",
",",
"orig_dir",
",",
"dest_dir",
",",
"roi_baseline",
",",
"extracopy",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"dest_dir",
")",
"except",
"OSError",
":",
"pass",
"copyfiles",
"=",
"[",
"'%s.fits'",
"%",
"... | Create and populate directoris for target analysis | [
"Create",
"and",
"populate",
"directoris",
"for",
"target",
"analysis"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L81-L95 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | RandomDirGen._make_wcsgeom_from_config | def _make_wcsgeom_from_config(config):
"""Build a `WCS.Geom` object from a fermipy coniguration file"""
binning = config['binning']
binsz = binning['binsz']
coordsys = binning.get('coordsys', 'GAL')
roiwidth = binning['roiwidth']
proj = binning.get('proj', 'AIT')
... | python | def _make_wcsgeom_from_config(config):
"""Build a `WCS.Geom` object from a fermipy coniguration file"""
binning = config['binning']
binsz = binning['binsz']
coordsys = binning.get('coordsys', 'GAL')
roiwidth = binning['roiwidth']
proj = binning.get('proj', 'AIT')
... | [
"def",
"_make_wcsgeom_from_config",
"(",
"config",
")",
":",
"binning",
"=",
"config",
"[",
"'binning'",
"]",
"binsz",
"=",
"binning",
"[",
"'binsz'",
"]",
"coordsys",
"=",
"binning",
".",
"get",
"(",
"'coordsys'",
",",
"'GAL'",
")",
"roiwidth",
"=",
"binn... | Build a `WCS.Geom` object from a fermipy coniguration file | [
"Build",
"a",
"WCS",
".",
"Geom",
"object",
"from",
"a",
"fermipy",
"coniguration",
"file"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L176-L192 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | RandomDirGen._build_skydir_dict | def _build_skydir_dict(wcsgeom, rand_config):
"""Build a dictionary of random directions"""
step_x = rand_config['step_x']
step_y = rand_config['step_y']
max_x = rand_config['max_x']
max_y = rand_config['max_y']
seed = rand_config['seed']
nsims = rand_config['nsim... | python | def _build_skydir_dict(wcsgeom, rand_config):
"""Build a dictionary of random directions"""
step_x = rand_config['step_x']
step_y = rand_config['step_y']
max_x = rand_config['max_x']
max_y = rand_config['max_y']
seed = rand_config['seed']
nsims = rand_config['nsim... | [
"def",
"_build_skydir_dict",
"(",
"wcsgeom",
",",
"rand_config",
")",
":",
"step_x",
"=",
"rand_config",
"[",
"'step_x'",
"]",
"step_y",
"=",
"rand_config",
"[",
"'step_y'",
"]",
"max_x",
"=",
"rand_config",
"[",
"'max_x'",
"]",
"max_y",
"=",
"rand_config",
... | Build a dictionary of random directions | [
"Build",
"a",
"dictionary",
"of",
"random",
"directions"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L195-L233 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | SimulateROI._clone_config_and_srcmaps | def _clone_config_and_srcmaps(config_path, seed):
"""Clone the configuration"""
workdir = os.path.dirname(config_path)
new_config_path = config_path.replace('.yaml', '_%06i.yaml' % seed)
config = load_yaml(config_path)
comps = config.get('components', [config])
for i, com... | python | def _clone_config_and_srcmaps(config_path, seed):
"""Clone the configuration"""
workdir = os.path.dirname(config_path)
new_config_path = config_path.replace('.yaml', '_%06i.yaml' % seed)
config = load_yaml(config_path)
comps = config.get('components', [config])
for i, com... | [
"def",
"_clone_config_and_srcmaps",
"(",
"config_path",
",",
"seed",
")",
":",
"workdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"new_config_path",
"=",
"config_path",
".",
"replace",
"(",
"'.yaml'",
",",
"'_%06i.yaml'",
"%",
"seed",
... | Clone the configuration | [
"Clone",
"the",
"configuration"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L276-L293 | train |
fermiPy/fermipy | fermipy/jobs/target_sim.py | SimulateROI._run_simulation | def _run_simulation(gta, roi_baseline,
injected_name, test_sources, current_seed, seed, non_null_src):
"""Simulate a realization of this analysis"""
gta.load_roi('sim_baseline_%06i.npy' % current_seed)
gta.set_random_seed(seed)
gta.simulate_roi()
if inject... | python | def _run_simulation(gta, roi_baseline,
injected_name, test_sources, current_seed, seed, non_null_src):
"""Simulate a realization of this analysis"""
gta.load_roi('sim_baseline_%06i.npy' % current_seed)
gta.set_random_seed(seed)
gta.simulate_roi()
if inject... | [
"def",
"_run_simulation",
"(",
"gta",
",",
"roi_baseline",
",",
"injected_name",
",",
"test_sources",
",",
"current_seed",
",",
"seed",
",",
"non_null_src",
")",
":",
"gta",
".",
"load_roi",
"(",
"'sim_baseline_%06i.npy'",
"%",
"current_seed",
")",
"gta",
".",
... | Simulate a realization of this analysis | [
"Simulate",
"a",
"realization",
"of",
"this",
"analysis"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_sim.py#L297-L334 | train |
fermiPy/fermipy | fermipy/scripts/merit_skimmer.py | get_branches | def get_branches(aliases):
"""Get unique branch names from an alias dictionary."""
ignore = ['pow', 'log10', 'sqrt', 'max']
branches = []
for k, v in aliases.items():
tokens = re.sub('[\(\)\+\*\/\,\=\<\>\&\!\-\|]', ' ', v).split()
for t in tokens:
if bool(re.search(r'^\d'... | python | def get_branches(aliases):
"""Get unique branch names from an alias dictionary."""
ignore = ['pow', 'log10', 'sqrt', 'max']
branches = []
for k, v in aliases.items():
tokens = re.sub('[\(\)\+\*\/\,\=\<\>\&\!\-\|]', ' ', v).split()
for t in tokens:
if bool(re.search(r'^\d'... | [
"def",
"get_branches",
"(",
"aliases",
")",
":",
"ignore",
"=",
"[",
"'pow'",
",",
"'log10'",
",",
"'sqrt'",
",",
"'max'",
"]",
"branches",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"aliases",
".",
"items",
"(",
")",
":",
"tokens",
"=",
"re",
".... | Get unique branch names from an alias dictionary. | [
"Get",
"unique",
"branch",
"names",
"from",
"an",
"alias",
"dictionary",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/merit_skimmer.py#L24-L41 | train |
fermiPy/fermipy | fermipy/scripts/merit_skimmer.py | load_friend_chains | def load_friend_chains(chain, friend_chains, txt, nfiles=None):
"""Load a list of trees from a file and add them as friends to the
chain."""
if re.search('.root?', txt) is not None:
c = ROOT.TChain(chain.GetName())
c.SetDirectory(0)
c.Add(txt)
friend_chains.append(c)
... | python | def load_friend_chains(chain, friend_chains, txt, nfiles=None):
"""Load a list of trees from a file and add them as friends to the
chain."""
if re.search('.root?', txt) is not None:
c = ROOT.TChain(chain.GetName())
c.SetDirectory(0)
c.Add(txt)
friend_chains.append(c)
... | [
"def",
"load_friend_chains",
"(",
"chain",
",",
"friend_chains",
",",
"txt",
",",
"nfiles",
"=",
"None",
")",
":",
"if",
"re",
".",
"search",
"(",
"'.root?'",
",",
"txt",
")",
"is",
"not",
"None",
":",
"c",
"=",
"ROOT",
".",
"TChain",
"(",
"chain",
... | Load a list of trees from a file and add them as friends to the
chain. | [
"Load",
"a",
"list",
"of",
"trees",
"from",
"a",
"file",
"and",
"add",
"them",
"as",
"friends",
"to",
"the",
"chain",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/merit_skimmer.py#L103-L129 | train |
fermiPy/fermipy | fermipy/fits_utils.py | find_and_read_ebins | def find_and_read_ebins(hdulist):
""" Reads and returns the energy bin edges.
This works for both the CASE where the energies are in the ENERGIES HDU
and the case where they are in the EBOUND HDU
"""
from fermipy import utils
ebins = None
if 'ENERGIES' in hdulist:
hdu = hdulist['EN... | python | def find_and_read_ebins(hdulist):
""" Reads and returns the energy bin edges.
This works for both the CASE where the energies are in the ENERGIES HDU
and the case where they are in the EBOUND HDU
"""
from fermipy import utils
ebins = None
if 'ENERGIES' in hdulist:
hdu = hdulist['EN... | [
"def",
"find_and_read_ebins",
"(",
"hdulist",
")",
":",
"from",
"fermipy",
"import",
"utils",
"ebins",
"=",
"None",
"if",
"'ENERGIES'",
"in",
"hdulist",
":",
"hdu",
"=",
"hdulist",
"[",
"'ENERGIES'",
"]",
"ectr",
"=",
"hdu",
".",
"data",
".",
"field",
"(... | Reads and returns the energy bin edges.
This works for both the CASE where the energies are in the ENERGIES HDU
and the case where they are in the EBOUND HDU | [
"Reads",
"and",
"returns",
"the",
"energy",
"bin",
"edges",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L23-L40 | train |
fermiPy/fermipy | fermipy/fits_utils.py | read_energy_bounds | def read_energy_bounds(hdu):
""" Reads and returns the energy bin edges from a FITs HDU
"""
nebins = len(hdu.data)
ebin_edges = np.ndarray((nebins + 1))
try:
ebin_edges[0:-1] = np.log10(hdu.data.field("E_MIN")) - 3.
ebin_edges[-1] = np.log10(hdu.data.field("E_MAX")[-1]) - 3.
exce... | python | def read_energy_bounds(hdu):
""" Reads and returns the energy bin edges from a FITs HDU
"""
nebins = len(hdu.data)
ebin_edges = np.ndarray((nebins + 1))
try:
ebin_edges[0:-1] = np.log10(hdu.data.field("E_MIN")) - 3.
ebin_edges[-1] = np.log10(hdu.data.field("E_MAX")[-1]) - 3.
exce... | [
"def",
"read_energy_bounds",
"(",
"hdu",
")",
":",
"nebins",
"=",
"len",
"(",
"hdu",
".",
"data",
")",
"ebin_edges",
"=",
"np",
".",
"ndarray",
"(",
"(",
"nebins",
"+",
"1",
")",
")",
"try",
":",
"ebin_edges",
"[",
"0",
":",
"-",
"1",
"]",
"=",
... | Reads and returns the energy bin edges from a FITs HDU | [
"Reads",
"and",
"returns",
"the",
"energy",
"bin",
"edges",
"from",
"a",
"FITs",
"HDU"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L43-L54 | train |
fermiPy/fermipy | fermipy/fits_utils.py | read_spectral_data | def read_spectral_data(hdu):
""" Reads and returns the energy bin edges, fluxes and npreds from
a FITs HDU
"""
ebins = read_energy_bounds(hdu)
fluxes = np.ndarray((len(ebins)))
try:
fluxes[0:-1] = hdu.data.field("E_MIN_FL")
fluxes[-1] = hdu.data.field("E_MAX_FL")[-1]
npre... | python | def read_spectral_data(hdu):
""" Reads and returns the energy bin edges, fluxes and npreds from
a FITs HDU
"""
ebins = read_energy_bounds(hdu)
fluxes = np.ndarray((len(ebins)))
try:
fluxes[0:-1] = hdu.data.field("E_MIN_FL")
fluxes[-1] = hdu.data.field("E_MAX_FL")[-1]
npre... | [
"def",
"read_spectral_data",
"(",
"hdu",
")",
":",
"ebins",
"=",
"read_energy_bounds",
"(",
"hdu",
")",
"fluxes",
"=",
"np",
".",
"ndarray",
"(",
"(",
"len",
"(",
"ebins",
")",
")",
")",
"try",
":",
"fluxes",
"[",
"0",
":",
"-",
"1",
"]",
"=",
"h... | Reads and returns the energy bin edges, fluxes and npreds from
a FITs HDU | [
"Reads",
"and",
"returns",
"the",
"energy",
"bin",
"edges",
"fluxes",
"and",
"npreds",
"from",
"a",
"FITs",
"HDU"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L57-L70 | train |
fermiPy/fermipy | fermipy/fits_utils.py | make_energies_hdu | def make_energies_hdu(energy_vals, extname="ENERGIES"):
""" Builds and returns a FITs HDU with the energy values
extname : The HDU extension name
"""
cols = [fits.Column("Energy", "D", unit='MeV', array=energy_vals)]
hdu = fits.BinTableHDU.from_columns(cols, name=extname)
return hd... | python | def make_energies_hdu(energy_vals, extname="ENERGIES"):
""" Builds and returns a FITs HDU with the energy values
extname : The HDU extension name
"""
cols = [fits.Column("Energy", "D", unit='MeV', array=energy_vals)]
hdu = fits.BinTableHDU.from_columns(cols, name=extname)
return hd... | [
"def",
"make_energies_hdu",
"(",
"energy_vals",
",",
"extname",
"=",
"\"ENERGIES\"",
")",
":",
"cols",
"=",
"[",
"fits",
".",
"Column",
"(",
"\"Energy\"",
",",
"\"D\"",
",",
"unit",
"=",
"'MeV'",
",",
"array",
"=",
"energy_vals",
")",
"]",
"hdu",
"=",
... | Builds and returns a FITs HDU with the energy values
extname : The HDU extension name | [
"Builds",
"and",
"returns",
"a",
"FITs",
"HDU",
"with",
"the",
"energy",
"values"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L73-L80 | train |
fermiPy/fermipy | fermipy/fits_utils.py | read_projection_from_fits | def read_projection_from_fits(fitsfile, extname=None):
"""
Load a WCS or HPX projection.
"""
f = fits.open(fitsfile)
nhdu = len(f)
# Try and get the energy bounds
try:
ebins = find_and_read_ebins(f)
except:
ebins = None
if extname is None:
# If there is an im... | python | def read_projection_from_fits(fitsfile, extname=None):
"""
Load a WCS or HPX projection.
"""
f = fits.open(fitsfile)
nhdu = len(f)
# Try and get the energy bounds
try:
ebins = find_and_read_ebins(f)
except:
ebins = None
if extname is None:
# If there is an im... | [
"def",
"read_projection_from_fits",
"(",
"fitsfile",
",",
"extname",
"=",
"None",
")",
":",
"f",
"=",
"fits",
".",
"open",
"(",
"fitsfile",
")",
"nhdu",
"=",
"len",
"(",
"f",
")",
"try",
":",
"ebins",
"=",
"find_and_read_ebins",
"(",
"f",
")",
"except"... | Load a WCS or HPX projection. | [
"Load",
"a",
"WCS",
"or",
"HPX",
"projection",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L125-L176 | train |
fermiPy/fermipy | fermipy/fits_utils.py | write_tables_to_fits | def write_tables_to_fits(filepath, tablelist, clobber=False,
namelist=None, cardslist=None, hdu_list=None):
"""
Write some astropy.table.Table objects to a single fits file
"""
outhdulist = [fits.PrimaryHDU()]
rmlist = []
for i, table in enumerate(tablelist):
ft_... | python | def write_tables_to_fits(filepath, tablelist, clobber=False,
namelist=None, cardslist=None, hdu_list=None):
"""
Write some astropy.table.Table objects to a single fits file
"""
outhdulist = [fits.PrimaryHDU()]
rmlist = []
for i, table in enumerate(tablelist):
ft_... | [
"def",
"write_tables_to_fits",
"(",
"filepath",
",",
"tablelist",
",",
"clobber",
"=",
"False",
",",
"namelist",
"=",
"None",
",",
"cardslist",
"=",
"None",
",",
"hdu_list",
"=",
"None",
")",
":",
"outhdulist",
"=",
"[",
"fits",
".",
"PrimaryHDU",
"(",
"... | Write some astropy.table.Table objects to a single fits file | [
"Write",
"some",
"astropy",
".",
"table",
".",
"Table",
"objects",
"to",
"a",
"single",
"fits",
"file"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/fits_utils.py#L179-L209 | train |
fermiPy/fermipy | fermipy/residmap.py | get_source_kernel | def get_source_kernel(gta, name, kernel=None):
"""Get the PDF for the given source."""
sm = []
zs = 0
for c in gta.components:
z = c.model_counts_map(name).data.astype('float')
if kernel is not None:
shape = (z.shape[0],) + kernel.shape
z = np.apply_over_axes(np.... | python | def get_source_kernel(gta, name, kernel=None):
"""Get the PDF for the given source."""
sm = []
zs = 0
for c in gta.components:
z = c.model_counts_map(name).data.astype('float')
if kernel is not None:
shape = (z.shape[0],) + kernel.shape
z = np.apply_over_axes(np.... | [
"def",
"get_source_kernel",
"(",
"gta",
",",
"name",
",",
"kernel",
"=",
"None",
")",
":",
"sm",
"=",
"[",
"]",
"zs",
"=",
"0",
"for",
"c",
"in",
"gta",
".",
"components",
":",
"z",
"=",
"c",
".",
"model_counts_map",
"(",
"name",
")",
".",
"data"... | Get the PDF for the given source. | [
"Get",
"the",
"PDF",
"for",
"the",
"given",
"source",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/residmap.py#L190-L215 | train |
fermiPy/fermipy | fermipy/residmap.py | ResidMapGenerator.residmap | def residmap(self, prefix='', **kwargs):
"""Generate 2-D spatial residual maps using the current ROI
model and the convolution kernel defined with the `model`
argument.
Parameters
----------
prefix : str
String that will be prefixed to the output residual map... | python | def residmap(self, prefix='', **kwargs):
"""Generate 2-D spatial residual maps using the current ROI
model and the convolution kernel defined with the `model`
argument.
Parameters
----------
prefix : str
String that will be prefixed to the output residual map... | [
"def",
"residmap",
"(",
"self",
",",
"prefix",
"=",
"''",
",",
"**",
"kwargs",
")",
":",
"timer",
"=",
"Timer",
".",
"create",
"(",
"start",
"=",
"True",
")",
"self",
".",
"logger",
".",
"info",
"(",
"'Generating residual maps'",
")",
"schema",
"=",
... | Generate 2-D spatial residual maps using the current ROI
model and the convolution kernel defined with the `model`
argument.
Parameters
----------
prefix : str
String that will be prefixed to the output residual map files.
{options}
Returns
... | [
"Generate",
"2",
"-",
"D",
"spatial",
"residual",
"maps",
"using",
"the",
"current",
"ROI",
"model",
"and",
"the",
"convolution",
"kernel",
"defined",
"with",
"the",
"model",
"argument",
"."
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/residmap.py#L225-L279 | train |
fermiPy/fermipy | fermipy/jobs/factory.py | LinkFactory.create | def create(appname, **kwargs):
"""Create a `Link` of a particular class, using the kwargs as options"""
if appname in LinkFactory._class_dict:
return LinkFactory._class_dict[appname].create(**kwargs)
else:
raise KeyError(
"Could not create object associat... | python | def create(appname, **kwargs):
"""Create a `Link` of a particular class, using the kwargs as options"""
if appname in LinkFactory._class_dict:
return LinkFactory._class_dict[appname].create(**kwargs)
else:
raise KeyError(
"Could not create object associat... | [
"def",
"create",
"(",
"appname",
",",
"**",
"kwargs",
")",
":",
"if",
"appname",
"in",
"LinkFactory",
".",
"_class_dict",
":",
"return",
"LinkFactory",
".",
"_class_dict",
"[",
"appname",
"]",
".",
"create",
"(",
"**",
"kwargs",
")",
"else",
":",
"raise"... | Create a `Link` of a particular class, using the kwargs as options | [
"Create",
"a",
"Link",
"of",
"a",
"particular",
"class",
"using",
"the",
"kwargs",
"as",
"options"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/factory.py#L25-L32 | train |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | NameFactory._replace_none | def _replace_none(self, aDict):
""" Replace all None values in a dict with 'none' """
for k, v in aDict.items():
if v is None:
aDict[k] = 'none' | python | def _replace_none(self, aDict):
""" Replace all None values in a dict with 'none' """
for k, v in aDict.items():
if v is None:
aDict[k] = 'none' | [
"def",
"_replace_none",
"(",
"self",
",",
"aDict",
")",
":",
"for",
"k",
",",
"v",
"in",
"aDict",
".",
"items",
"(",
")",
":",
"if",
"v",
"is",
"None",
":",
"aDict",
"[",
"k",
"]",
"=",
"'none'"
] | Replace all None values in a dict with 'none' | [
"Replace",
"all",
"None",
"values",
"in",
"a",
"dict",
"with",
"none"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L136-L140 | train |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | NameFactory.irfs | def irfs(self, **kwargs):
""" Get the name of IFRs associted with a particular dataset
"""
dsval = kwargs.get('dataset', self.dataset(**kwargs))
tokens = dsval.split('_')
irf_name = "%s_%s_%s" % (DATASET_DICTIONARY['%s_%s' % (tokens[0], tokens[1])],
... | python | def irfs(self, **kwargs):
""" Get the name of IFRs associted with a particular dataset
"""
dsval = kwargs.get('dataset', self.dataset(**kwargs))
tokens = dsval.split('_')
irf_name = "%s_%s_%s" % (DATASET_DICTIONARY['%s_%s' % (tokens[0], tokens[1])],
... | [
"def",
"irfs",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"dsval",
"=",
"kwargs",
".",
"get",
"(",
"'dataset'",
",",
"self",
".",
"dataset",
"(",
"**",
"kwargs",
")",
")",
"tokens",
"=",
"dsval",
".",
"split",
"(",
"'_'",
")",
"irf_name",
"=",
"... | Get the name of IFRs associted with a particular dataset | [
"Get",
"the",
"name",
"of",
"IFRs",
"associted",
"with",
"a",
"particular",
"dataset"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L152-L160 | train |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | NameFactory.dataset | def dataset(self, **kwargs):
""" Return a key that specifies the data selection
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.dataset_format.format(**kwargs_copy)
except Key... | python | def dataset(self, **kwargs):
""" Return a key that specifies the data selection
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.dataset_format.format(**kwargs_copy)
except Key... | [
"def",
"dataset",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"**",
"kwargs",
")",
"self",
".",
"_replace_none",
"(",
"kwargs_copy",
")",
"try",
":"... | Return a key that specifies the data selection | [
"Return",
"a",
"key",
"that",
"specifies",
"the",
"data",
"selection"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L167-L176 | train |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | NameFactory.component | def component(self, **kwargs):
""" Return a key that specifies data the sub-selection
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.component_format.format(**kwargs_copy)
... | python | def component(self, **kwargs):
""" Return a key that specifies data the sub-selection
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.component_format.format(**kwargs_copy)
... | [
"def",
"component",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"**",
"kwargs",
")",
"self",
".",
"_replace_none",
"(",
"kwargs_copy",
")",
"try",
"... | Return a key that specifies data the sub-selection | [
"Return",
"a",
"key",
"that",
"specifies",
"data",
"the",
"sub",
"-",
"selection"
] | 9df5e7e3728307fd58c5bba36fd86783c39fbad4 | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L178-L187 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.