sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def stack_nll(shape, components, ylims, weights=None):
"""Combine the log-likelihoods from a number of components.
Parameters
----------
shape : tuple
The shape of the return array
components : `~fermipy.castro.CastroData_Base`
The components to be sta... | Combine the log-likelihoods from a number of components.
Parameters
----------
shape : tuple
The shape of the return array
components : `~fermipy.castro.CastroData_Base`
The components to be stacked
weights : array-like
Returns
------... | entailment |
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... | Create a Castro data object from a yaml file contains
the likelihood data. | entailment |
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... | Create a Castro data object from a text file containing a
sequence of differential flux points. | entailment |
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:
... | 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... | entailment |
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
... | 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 ... | entailment |
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... | 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... | entailment |
def create_from_stack(cls, shape, components, ylims, weights=None):
""" Combine the log-likelihoods from a number of components.
Parameters
----------
shape : tuple
The shape of the return array
components : [~fermipy.castro.CastroData_Base]
The compo... | Combine the log-likelihoods from a number of components.
Parameters
----------
shape : tuple
The shape of the return array
components : [~fermipy.castro.CastroData_Base]
The components to be stacked
weights : array-like
Returns
------... | entailment |
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
... | 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 | entailment |
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... | 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
... | entailment |
def create_from_fits(cls, fitsfile, norm_type='flux'):
"""Build a TSCube object from a fits file created by gttscube
Parameters
----------
fitsfile : str
Path to the tscube FITS file.
norm_type : str
String specifying the quantity used for the normalization... | Build a TSCube object from a fits file created by gttscube
Parameters
----------
fitsfile : str
Path to the tscube FITS file.
norm_type : str
String specifying the quantity used for the normalization | entailment |
def castroData_from_ipix(self, ipix, colwise=False):
""" Build a CastroData object for a particular pixel """
# pix = utils.skydir_to_pix
if colwise:
ipix = self._tsmap.ipix_swap_axes(ipix, colwise)
norm_d = self._norm_vals[ipix]
nll_d = self._nll_vals[ipix]
r... | Build a CastroData object for a particular pixel | entailment |
def castroData_from_pix_xy(self, xy, colwise=False):
""" Build a CastroData object for a particular pixel """
ipix = self._tsmap.xy_pix_to_ipix(xy, colwise)
return self.castroData_from_ipix(ipix) | Build a CastroData object for a particular pixel | entailment |
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
... | 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 ... | entailment |
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... | 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 | entailment |
def make_cos_vects(lon_vect, lat_vect):
""" Convert from longitude (RA or GLON) and latitude (DEC or GLAT) values to directional cosines
Parameters
----------
lon_vect,lat_vect : np.ndarray(nsrc)
Input values
returns (np.ndarray(3,nsrc)) with the directional cosine (i.e., x,y,z component)... | Convert from longitude (RA or GLON) and latitude (DEC or GLAT) values to directional cosines
Parameters
----------
lon_vect,lat_vect : np.ndarray(nsrc)
Input values
returns (np.ndarray(3,nsrc)) with the directional cosine (i.e., x,y,z component) values | entailment |
def find_matches_by_distance(cos_vects, cut_dist):
"""Find all the pairs of sources within a given distance of each
other.
Parameters
----------
cos_vects : np.ndarray(e,nsrc)
Directional cosines (i.e., x,y,z component) values of all the
sources
cut_dist : float
... | Find all the pairs of sources within a given distance of each
other.
Parameters
----------
cos_vects : np.ndarray(e,nsrc)
Directional cosines (i.e., x,y,z component) values of all the
sources
cut_dist : float
Angular cut in degrees that will be used to select pairs ... | entailment |
def find_matches_by_sigma(cos_vects, unc_vect, cut_sigma):
"""Find all the pairs of sources within a given distance of each
other.
Parameters
----------
cos_vects : np.ndarray(3,nsrc)
Directional cosines (i.e., x,y,z component) values of all the sources
unc_vect : np.ndarray(nsrc)
... | Find all the pairs of sources within a given distance of each
other.
Parameters
----------
cos_vects : np.ndarray(3,nsrc)
Directional cosines (i.e., x,y,z component) values of all the sources
unc_vect : np.ndarray(nsrc)
Uncertainties on the source positions
cut_sigma : flo... | entailment |
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... | 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... | entailment |
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... | 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... | entailment |
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
... | 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... | entailment |
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... | 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... | entailment |
def find_centroid(cvects, idx_list, weights=None):
""" Find the centroid for a set of vectors
Parameters
----------
cvects : ~numpy.ndarray(3,nsrc) with directional cosine (i.e., x,y,z component) values
idx_list : [int,...]
list of the source indices in the cluster
weights : ~numpy.ndar... | Find the centroid for a set of vectors
Parameters
----------
cvects : ~numpy.ndarray(3,nsrc) with directional cosine (i.e., x,y,z component) values
idx_list : [int,...]
list of the source indices in the cluster
weights : ~numpy.ndarray(nsrc) with the weights to use. None for equal weightin... | entailment |
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.
... | 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... | entailment |
def find_dist_to_centroid(cvects, idx_list, weights=None):
""" Find the centroid for a set of vectors
Parameters
----------
cvects : ~numpy.ndarray(3,nsrc) with directional cosine (i.e., x,y,z component) values
idx_list : [int,...]
list of the source indices in the cluster
weights : ~nu... | Find the centroid for a set of vectors
Parameters
----------
cvects : ~numpy.ndarray(3,nsrc) with directional cosine (i.e., x,y,z component) values
idx_list : [int,...]
list of the source indices in the cluster
weights : ~numpy.ndarray(nsrc) with the weights to use. None for equal weightin... | entailment |
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. ... | 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... | entailment |
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... | 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 ... | entailment |
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... | 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... | entailment |
def make_cluster_vector(rev_dict, n_src):
""" Converts the cluster membership dictionary to an array
Parameters
----------
rev_dict : dict(int:int)
A single valued dictionary pointing from source index to
cluster key for each source in a cluster.
n_src : int
Number of ... | Converts the cluster membership dictionary to an array
Parameters
----------
rev_dict : dict(int:int)
A single valued dictionary pointing from source index to
cluster key for each source in a cluster.
n_src : int
Number of source in the array
Returns
-------
o... | entailment |
def make_cluster_name_vector(cluster_vect, src_names):
""" Converts the cluster membership dictionary to an array
Parameters
----------
cluster_vect : `numpy.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.
... | Converts the cluster membership dictionary to an array
Parameters
----------
cluster_vect : `numpy.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.
src_names :
An array with the source names
Ret... | entailment |
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.
... | 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:... | entailment |
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... | 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 | entailment |
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... | 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... | entailment |
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... | Relocalize sources in the region of interest
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
kwargs :
These are passed to the gta.localize function | entailment |
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... | 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... | entailment |
def build_profile_dict(basedir, profile_name):
"""Get the name and source dictionary for the test source.
Parameters
----------
basedir : str
Path to the analysis directory
profile_name : str
Key for the spatial from of the target
Returns
-------
... | Get the name and source dictionary for the test source.
Parameters
----------
basedir : str
Path to the analysis directory
profile_name : str
Key for the spatial from of the target
Returns
-------
profile_name : str
Name of for this particular... | entailment |
def get_batch_job_args(job_time=1500):
""" Get the correct set of batch jobs arguments.
Parameters
----------
job_time : int
Expected max length of the job, in seconds.
This is used to select the batch queue and set the
job_check_sleep parameter that sets how often
we c... | Get the correct set of batch jobs arguments.
Parameters
----------
job_time : int
Expected max length of the job, in seconds.
This is used to select the batch queue and set the
job_check_sleep parameter that sets how often
we check for job completion.
Returns
-----... | entailment |
def get_batch_job_interface(job_time=1500):
""" Create a batch job interface object.
Parameters
----------
job_time : int
Expected max length of the job, in seconds.
This is used to select the batch queue and set the
job_check_sleep parameter that sets how often
we chec... | Create a batch job interface object.
Parameters
----------
job_time : int
Expected max length of the job, in seconds.
This is used to select the batch queue and set the
job_check_sleep parameter that sets how often
we check for job completion.
Returns
-------
j... | entailment |
def main():
import sys
import argparse
# Argument defintion
usage = "usage: %(prog)s [options]"
description = "Collect all the new source"
parser = argparse.ArgumentParser(usage, description=__abstract__)
parser.add_argument("-i", "--input", type=argparse.FileType('r'), required=True,
... | if args.ebin == "ALL":
wcsproj = hpxmap.geom.make_wcs(
naxis=2, proj='MOL', energies=None, oversample=2)
mapping = HpxToWcsMapping(hpxmap.hpx, wcsproj)
for i, data in enumerate(hpxmap.counts):
ip = ImagePlotter(data=data, proj=hpxmap.hpx, mapping=mapping)
fig... | entailment |
def register_classes():
"""Register these classes with the `LinkFactory` """
CopyBaseROI.register_class()
CopyBaseROI_SG.register_class()
SimulateROI.register_class()
SimulateROI_SG.register_class()
RandomDirGen.register_class()
RandomDirGen_SG.register_class() | Register these classes with the `LinkFactory` | entailment |
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(... | Copy a list of files from orig_dir to dest_dir | entailment |
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... | Create and populate directoris for target analysis | entailment |
def run_analysis(self, argv):
"""Run this analysis"""
args = self._parser.parse_args(argv)
name_keys = dict(target_type=args.ttype,
target_name=args.target,
sim_name=args.sim,
fullpath=True)
orig_dir = NAME_FACT... | Run this analysis | entailment |
def build_job_configs(self, args):
"""Hook to build job configurations
"""
job_configs = {}
ttype = args['ttype']
(sim_targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args)
targets = load_yaml(sim_targets_yaml)
base_config = dict(ttype=ttype,
... | Hook to build job configurations | entailment |
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')
... | Build a `WCS.Geom` object from a fermipy coniguration file | entailment |
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... | Build a dictionary of random directions | entailment |
def run_analysis(self, argv):
"""Run this analysis"""
args = self._parser.parse_args(argv)
if is_null(args.config):
raise ValueError("Config yaml file must be specified")
if is_null(args.rand_config):
raise ValueError(
"Random direction config yam... | Run this analysis | entailment |
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... | Clone the configuration | entailment |
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... | Simulate a realization of this analysis | entailment |
def run_analysis(self, argv):
"""Run this analysis"""
args = self._parser.parse_args(argv)
if not HAVE_ST:
raise RuntimeError(
"Trying to run fermipy analysis, but don't have ST")
workdir = os.path.dirname(args.config)
_config_file = self._clone_conf... | Run this analysis | entailment |
def build_job_configs(self, args):
"""Hook to build job configurations
"""
job_configs = {}
ttype = args['ttype']
(targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args)
if targets_yaml is None:
return job_configs
config_yaml = 'config.yaml'
... | Hook to build job configurations | entailment |
def build_job_configs(self, args):
"""Hook to build job configurations
"""
job_configs = {}
ttype = args['ttype']
(targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args)
if targets_yaml is None:
return job_configs
config_yaml = 'config.yaml'
... | Hook to build job configurations | entailment |
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'... | Get unique branch names from an alias dictionary. | entailment |
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)
... | Load a list of trees from a file and add them as friends to the
chain. | entailment |
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... | 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 | entailment |
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... | Reads and returns the energy bin edges from a FITs HDU | entailment |
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... | Reads and returns the energy bin edges, fluxes and npreds from
a FITs HDU | entailment |
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... | Builds and returns a FITs HDU with the energy values
extname : The HDU extension name | entailment |
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... | Load a WCS or HPX projection. | entailment |
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_... | Write some astropy.table.Table objects to a single fits file | entailment |
def update_docstring(docstring, options_dict):
"""Update a method docstring by inserting option docstrings defined in
the options dictionary. The input docstring should define `{options}`
at the location where the options docstring block should be inserted.
Parameters
----------
docstring : st... | Update a method docstring by inserting option docstrings defined in
the options dictionary. The input docstring should define `{options}`
at the location where the options docstring block should be inserted.
Parameters
----------
docstring : str
Existing method docstring.
options_dict... | entailment |
def convolve_map(m, k, cpix, threshold=0.001, imin=0, imax=None, wmap=None):
"""
Perform an energy-dependent convolution on a sequence of 2-D spatial maps.
Parameters
----------
m : `~numpy.ndarray`
3-D map containing a sequence of 2-D spatial maps. First
dimension should be energy.... | Perform an energy-dependent convolution on a sequence of 2-D spatial maps.
Parameters
----------
m : `~numpy.ndarray`
3-D map containing a sequence of 2-D spatial maps. First
dimension should be energy.
k : `~numpy.ndarray`
3-D map containing a sequence of convolution kernels (P... | entailment |
def convolve_map_hpx_gauss(m, sigmas, imin=0, imax=None, wmap=None):
"""
Perform an energy-dependent convolution on a sequence of 2-D spatial maps.
Parameters
----------
m : `HpxMap`
2-D map containing a sequence of 1-D HEALPix maps. First
dimension should be energy.
sigmas : `... | Perform an energy-dependent convolution on a sequence of 2-D spatial maps.
Parameters
----------
m : `HpxMap`
2-D map containing a sequence of 1-D HEALPix maps. First
dimension should be energy.
sigmas : `~numpy.ndarray`
1-D map containing a sequence gaussian widths for smoothin... | entailment |
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.... | Get the PDF for the given source. | entailment |
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... | 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
... | entailment |
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... | Create a `Link` of a particular class, using the kwargs as options | entailment |
def _map_arguments(self, args):
"""Map from the top-level arguments to the arguments provided to
the indiviudal links """
comp_file = args.get('comp', None)
datafile = args.get('data', None)
if is_null(comp_file):
return
if is_null(datafile):
retur... | Map from the top-level arguments to the arguments provided to
the indiviudal links | entailment |
def _map_arguments(self, args):
"""Map from the top-level arguments to the arguments provided to
the indiviudal links """
data = args.get('data')
comp = args.get('comp')
ft1file = args.get('ft1file')
scratch = args.get('scratch', None)
dry_run = args.get('dry_run'... | Map from the top-level arguments to the arguments provided to
the indiviudal links | entailment |
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' | Replace all None values in a dict with 'none' | entailment |
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])],
... | Get the name of IFRs associted with a particular dataset | entailment |
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... | Return a key that specifies the data selection | entailment |
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)
... | Return a key that specifies data the sub-selection | entailment |
def sourcekey(self, **kwargs):
""" Return a key that specifies the name and version of a source or component
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.sourcekey_format.f... | Return a key that specifies the name and version of a source or component | entailment |
def galprop_ringkey(self, **kwargs):
""" return the sourcekey for galprop input maps : specifies the component and ring
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
return NameFactory.galprop... | return the sourcekey for galprop input maps : specifies the component and ring | entailment |
def galprop_sourcekey(self, **kwargs):
""" return the sourcekey for merged galprop maps :
specifies the merged component and merging scheme
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
... | return the sourcekey for merged galprop maps :
specifies the merged component and merging scheme | entailment |
def merged_sourcekey(self, **kwargs):
""" return the sourcekey for merged sets of point sources :
specifies the catalog and merging rule
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
try:
r... | return the sourcekey for merged sets of point sources :
specifies the catalog and merging rule | entailment |
def galprop_gasmap(self, **kwargs):
""" return the file name for Galprop input gasmaps
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.galprop_gasmap_format.format(**kwargs_copy)
... | return the file name for Galprop input gasmaps | entailment |
def merged_gasmap(self, **kwargs):
""" return the file name for Galprop merged gasmaps
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.merged_gasmap_format.format(**kwargs_copy)
i... | return the file name for Galprop merged gasmaps | entailment |
def diffuse_template(self, **kwargs):
""" return the file name for other diffuse map templates
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.diffuse_template_format.format(**kwargs_copy... | return the file name for other diffuse map templates | entailment |
def spectral_template(self, **kwargs):
""" return the file name for spectral templates
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
localpath = NameFactory.spectral_template_format.format(**kwargs_copy)
if kwargs.get('fullpath', False):
... | return the file name for spectral templates | entailment |
def srcmdl_xml(self, **kwargs):
""" return the file name for source model xml files
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
localpath = NameFactory.srcmdl_xml_format.format(**kwargs_copy)
if kwargs.get('fullpath', False):
return se... | return the file name for source model xml files | entailment |
def nested_srcmdl_xml(self, **kwargs):
""" return the file name for source model xml files of nested sources
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.nested_srcmdl_xml_format.forma... | return the file name for source model xml files of nested sources | entailment |
def ft1file(self, **kwargs):
""" return the name of the input ft1 file list
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
self._replace_none(kwargs_copy)
localpat... | return the name of the input ft1 file list | entailment |
def ft2file(self, **kwargs):
""" return the name of the input ft2 file list
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['data_time'] = kwargs.get(
'data_time', self.dataset(**kwargs))
self._replace_none(kwargs_copy) ... | return the name of the input ft2 file list | entailment |
def ltcube(self, **kwargs):
""" return the name of a livetime cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
localpath = NameFactory.ltcube_format.format(**kwargs_copy)
... | return the name of a livetime cube file | entailment |
def select(self, **kwargs):
""" return the name of a selected events ft1file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
'com... | return the name of a selected events ft1file | entailment |
def mktime(self, **kwargs):
""" return the name of a selected events ft1file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
'com... | return the name of a selected events ft1file | entailment |
def ccube(self, **kwargs):
""" return the name of a counts cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
'component',... | return the name of a counts cube file | entailment |
def bexpcube(self, **kwargs):
""" return the name of a binned exposure cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
... | return the name of a binned exposure cube file | entailment |
def srcmaps(self, **kwargs):
""" return the name of a source map file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
'component'... | return the name of a source map file | entailment |
def mcube(self, **kwargs):
""" return the name of a model cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
'component', ... | return the name of a model cube file | entailment |
def ltcube_sun(self, **kwargs):
""" return the name of a livetime cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
self._replace_none(kwargs_copy)
localpat... | return the name of a livetime cube file | entailment |
def ltcube_moon(self, **kwargs):
""" return the name of a livetime cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
self._replace_none(kwargs_copy)
localpa... | return the name of a livetime cube file | entailment |
def bexpcube_sun(self, **kwargs):
""" return the name of a binned exposure cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
... | return the name of a binned exposure cube file | entailment |
def bexpcube_moon(self, **kwargs):
""" return the name of a binned exposure cube file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
... | return the name of a binned exposure cube file | entailment |
def angprofile(self, **kwargs):
""" return the file name for sun or moon angular profiles
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.angprofile_format.format(**kwargs_copy)
i... | return the file name for sun or moon angular profiles | entailment |
def template_sunmoon(self, **kwargs):
""" return the file name for sun or moon template files
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(... | return the file name for sun or moon template files | entailment |
def residual_cr(self, **kwargs):
"""Return the name of the residual CR analysis output files"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs))
kwargs_copy['component'] = kwargs.get(
... | Return the name of the residual CR analysis output files | entailment |
def galprop_rings_yaml(self, **kwargs):
""" return the name of a galprop rings merging yaml file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.galprop_rings_yaml_format.format(**kwargs_... | return the name of a galprop rings merging yaml file | entailment |
def catalog_split_yaml(self, **kwargs):
""" return the name of a catalog split yaml file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.catalog_split_yaml_format.format(**kwargs_copy)
... | return the name of a catalog split yaml file | entailment |
def model_yaml(self, **kwargs):
""" return the name of a model yaml file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.model_yaml_format.format(**kwargs_copy)
if kwargs.get('ful... | return the name of a model yaml file | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.