sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def create_from_eflux(cls, params, emin, emax, eflux, scale=1.0): """Create a spectral function instance given its energy flux.""" params = params.copy() params[0] = 1.0 params[0] = eflux / cls.eval_eflux(emin, emax, params, scale=scale) return cls(params, scale)
Create a spectral function instance given its energy flux.
entailment
def _integrate(cls, fn, emin, emax, params, scale=1.0, extra_params=None, npt=20): """Fast numerical integration method using mid-point rule.""" emin = np.expand_dims(emin, -1) emax = np.expand_dims(emax, -1) params = copy.deepcopy(params) for i, p in enumera...
Fast numerical integration method using mid-point rule.
entailment
def dnde(self, x, params=None): """Evaluate differential flux.""" params = self.params if params is None else params return np.squeeze(self.eval_dnde(x, params, self.scale, self.extra_params))
Evaluate differential flux.
entailment
def ednde(self, x, params=None): """Evaluate E times differential flux.""" params = self.params if params is None else params return np.squeeze(self.eval_ednde(x, params, self.scale, self.extra_params))
Evaluate E times differential flux.
entailment
def e2dnde(self, x, params=None): """Evaluate E^2 times differential flux.""" params = self.params if params is None else params return np.squeeze(self.eval_e2dnde(x, params, self.scale, self.extra_params))
Evaluate E^2 times differential flux.
entailment
def dnde_deriv(self, x, params=None): """Evaluate derivative of the differential flux with respect to E.""" params = self.params if params is None else params return np.squeeze(self.eval_dnde_deriv(x, params, self.scale, self.extra_params))
Evaluate derivative of the differential flux with respect to E.
entailment
def ednde_deriv(self, x, params=None): """Evaluate derivative of E times differential flux with respect to E.""" params = self.params if params is None else params return np.squeeze(self.eval_ednde_deriv(x, params, self.scale, self.extra_pa...
Evaluate derivative of E times differential flux with respect to E.
entailment
def e2dnde_deriv(self, x, params=None): """Evaluate derivative of E^2 times differential flux with respect to E.""" params = self.params if params is None else params return np.squeeze(self.eval_e2dnde_deriv(x, params, self.scale, self.ext...
Evaluate derivative of E^2 times differential flux with respect to E.
entailment
def flux(self, emin, emax, params=None): """Evaluate the integral flux.""" params = self.params if params is None else params return np.squeeze(self.eval_flux(emin, emax, params, self.scale, self.extra_params))
Evaluate the integral flux.
entailment
def eflux(self, emin, emax, params=None): """Evaluate the integral energy flux.""" params = self.params if params is None else params return np.squeeze(self.eval_eflux(emin, emax, params, self.scale, self.extra_params))
Evaluate the integral energy flux.
entailment
def extension(self, name, **kwargs): """Test this source for spatial extension with the likelihood ratio method (TS_ext). This method will substitute an extended spatial model for the given source and perform a one-dimensional scan of the spatial extension parameter over the ran...
Test this source for spatial extension with the likelihood ratio method (TS_ext). This method will substitute an extended spatial model for the given source and perform a one-dimensional scan of the spatial extension parameter over the range specified with the width parameters. The 1-D...
entailment
def plotNLL_v_Flux(nll, fluxType, nstep=25, xlims=None): """ Plot the (negative) log-likelihood as a function of normalization nll : a LnLFN object nstep : Number of steps to plot xlims : x-axis limits, if None, take tem from the nll object returns fig,ax, which are matplotlib figure and axes o...
Plot the (negative) log-likelihood as a function of normalization nll : a LnLFN object nstep : Number of steps to plot xlims : x-axis limits, if None, take tem from the nll object returns fig,ax, which are matplotlib figure and axes objects
entailment
def plotCastro_base(castroData, ylims, xlabel, ylabel, nstep=25, zlims=None, global_min=False): """ Make a color plot (castro plot) of the log-likelihood as a function of energy and flux normalization castroData : A CastroData_Base object, with the log-li...
Make a color plot (castro plot) of the log-likelihood as a function of energy and flux normalization castroData : A CastroData_Base object, with the log-likelihood v. normalization for each energy bin ylims : y-axis limits xlabel : x-axis title ylabel : ...
entailment
def plotCastro(castroData, ylims, nstep=25, zlims=None): """ Make a color plot (castro plot) of the delta log-likelihood as a function of energy and flux normalization castroData : A CastroData object, with the log-likelihood v. normalization for each energy bin ylims ...
Make a color plot (castro plot) of the delta log-likelihood as a function of energy and flux normalization castroData : A CastroData object, with the log-likelihood v. normalization for each energy bin ylims : y-axis limits nstep : Number of y-axis steps to plo...
entailment
def plotSED(castroData, ylims, TS_thresh=4.0, errSigma=1.0, specVals=[]): """ Make a color plot (castro plot) of the (negative) log-likelihood as a function of energy and flux normalization castroData : A CastroData object, with the log-likelihood v. normalization for each energy bin...
Make a color plot (castro plot) of the (negative) log-likelihood as a function of energy and flux normalization castroData : A CastroData object, with the log-likelihood v. normalization for each energy bin ylims : y-axis limits TS_thresh : TS value above with to plot a poi...
entailment
def compare_SED(castroData1, castroData2, ylims, TS_thresh=4.0, errSigma=1.0, specVals=[]): """ Compare two SEDs castroData1: A CastroData object, with the log-likelihood v. normalization for each energy bin castroData2: A CastroData object, with the log...
Compare two SEDs castroData1: A CastroData object, with the log-likelihood v. normalization for each energy bin castroData2: A CastroData object, with the log-likelihood v. normalization for each energy bin ylims : y-axis limits TS_thresh : TS value above with...
entailment
def make_ring_dicts(**kwargs): """Build and return the information about the Galprop rings """ library_yamlfile = kwargs.get('library', 'models/library.yaml') gmm = kwargs.get('GalpropMapManager', GalpropMapManager(**kwargs)) if library_yamlfile is None or library_yamlfile == 'None': return ...
Build and return the information about the Galprop rings
entailment
def make_diffuse_comp_info_dict(**kwargs): """Build and return the information about the diffuse components """ library_yamlfile = kwargs.pop('library', 'models/library.yaml') components = kwargs.pop('components', None) if components is None: comp_yamlfile = kwargs.pop('comp', 'config/binnin...
Build and return the information about the diffuse components
entailment
def read_galprop_rings_yaml(self, galkey): """ Read the yaml file for a partiuclar galprop key """ galprop_rings_yaml = self._name_factory.galprop_rings_yaml(galkey=galkey, fullpath=True) galprop_rings = yaml.safe_load(op...
Read the yaml file for a partiuclar galprop key
entailment
def make_ring_filename(self, source_name, ring, galprop_run): """ Make the name of a gasmap file for a single ring Parameters ---------- source_name : str The galprop component, used to define path to gasmap files ring : int The ring index galpro...
Make the name of a gasmap file for a single ring Parameters ---------- source_name : str The galprop component, used to define path to gasmap files ring : int The ring index galprop_run : str String identifying the galprop parameters
entailment
def make_merged_name(self, source_name, galkey, fullpath): """ Make the name of a gasmap file for a set of merged rings Parameters ---------- source_name : str The galprop component, used to define path to gasmap files galkey : str A short key identifyin...
Make the name of a gasmap file for a set of merged rings Parameters ---------- source_name : str The galprop component, used to define path to gasmap files galkey : str A short key identifying the galprop parameters fullpath : bool Return the...
entailment
def make_xml_name(self, source_name, galkey, fullpath): """ Make the name of an xml file for a model definition for a set of merged rings Parameters ---------- source_name : str The galprop component, used to define path to gasmap files galkey : str A sh...
Make the name of an xml file for a model definition for a set of merged rings Parameters ---------- source_name : str The galprop component, used to define path to gasmap files galkey : str A short key identifying the galprop parameters fullpath : bool ...
entailment
def make_ring_filelist(self, sourcekeys, rings, galprop_run): """ Make a list of all the template files for a merged component Parameters ---------- sourcekeys : list-like of str The names of the componenents to merge rings : list-like of int The indices...
Make a list of all the template files for a merged component Parameters ---------- sourcekeys : list-like of str The names of the componenents to merge rings : list-like of int The indices of the rings to merge galprop_run : str String identi...
entailment
def make_ring_dict(self, galkey): """ Make a dictionary mapping the merged component names to list of template files Parameters ---------- galkey : str Unique key for this ring dictionary Returns `model_component.GalpropMergedRingInfo` """ galprop_r...
Make a dictionary mapping the merged component names to list of template files Parameters ---------- galkey : str Unique key for this ring dictionary Returns `model_component.GalpropMergedRingInfo`
entailment
def make_diffuse_comp_info(self, merged_name, galkey): """ Make the information about a single merged component Parameters ---------- merged_name : str The name of the merged component galkey : str A short key identifying the galprop parameters ...
Make the information about a single merged component Parameters ---------- merged_name : str The name of the merged component galkey : str A short key identifying the galprop parameters Returns `Model_component.ModelComponentInfo`
entailment
def make_diffuse_comp_info_dict(self, galkey): """ Make a dictionary maping from merged component to information about that component Parameters ---------- galkey : str A short key identifying the galprop parameters """ galprop_rings = self.read_galprop_ring...
Make a dictionary maping from merged component to information about that component Parameters ---------- galkey : str A short key identifying the galprop parameters
entailment
def make_template_name(self, model_type, sourcekey): """ Make the name of a template file for particular component Parameters ---------- model_type : str Type of model to use for this component sourcekey : str Key to identify this component Retu...
Make the name of a template file for particular component Parameters ---------- model_type : str Type of model to use for this component sourcekey : str Key to identify this component Returns filename or None if component does not require a template fil...
entailment
def make_xml_name(self, sourcekey): """ Make the name of an xml file for a model definition of a single component Parameters ---------- sourcekey : str Key to identify this component """ format_dict = self.__dict__.copy() format_dict['sourcekey'] = s...
Make the name of an xml file for a model definition of a single component Parameters ---------- sourcekey : str Key to identify this component
entailment
def make_diffuse_comp_info(self, source_name, source_ver, diffuse_dict, components=None, comp_key=None): """ Make a dictionary mapping the merged component names to list of template files Parameters ---------- source_name : str Name of the sour...
Make a dictionary mapping the merged component names to list of template files Parameters ---------- source_name : str Name of the source source_ver : str Key identifying the version of the source diffuse_dict : dict Information about this compo...
entailment
def make_diffuse_comp_info_dict(self, diffuse_sources, components): """ Make a dictionary maping from diffuse component to information about that component Parameters ---------- diffuse_sources : dict Dictionary with diffuse source defintions components : dict ...
Make a dictionary maping from diffuse component to information about that component Parameters ---------- diffuse_sources : dict Dictionary with diffuse source defintions components : dict Dictionary with event selection defintions, needed for select...
entailment
def get_unique_match(table, colname, value): """Get the row matching value for a particular column. If exactly one row matchs, return index of that row, Otherwise raise KeyError. """ # FIXME, This is here for python 3.5, where astropy is now returning bytes # instead of str if table[colname]...
Get the row matching value for a particular column. If exactly one row matchs, return index of that row, Otherwise raise KeyError.
entailment
def main_browse(): """Entry point for command line use for browsing a FileArchive """ import argparse parser = argparse.ArgumentParser(usage="file_archive.py [options]", description="Browse a job archive") parser.add_argument('--files', action='store', dest='file_...
Entry point for command line use for browsing a FileArchive
entailment
def latch_file_info(self, args): """Extract the file paths from a set of arguments """ self.file_dict.clear() for key, val in self.file_args.items(): try: file_path = args[key] if file_path is None: continue ...
Extract the file paths from a set of arguments
entailment
def update(self, file_dict): """Update self with values from a dictionary mapping file path [str] to `FileFlags` enum """ for key, val in file_dict.items(): if key in self.file_dict: self.file_dict[key] |= val else: self.file_dict[key] = va...
Update self with values from a dictionary mapping file path [str] to `FileFlags` enum
entailment
def input_files(self): """Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to anot...
Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to another `Link` in the `Chain`
entailment
def output_files(self): """Return a list of the output files produced by this link. For `Link` sub-classes this will return the union of all the output files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to...
Return a list of the output files produced by this link. For `Link` sub-classes this will return the union of all the output files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to another `Link` in the `Chain`
entailment
def chain_input_files(self): """Return a list of the input files needed by this chain. For `Link` sub-classes this will return only those files that were not created by any internal `Link` """ ret_list = [] for key, val in self.file_dict.items(): # For chain ...
Return a list of the input files needed by this chain. For `Link` sub-classes this will return only those files that were not created by any internal `Link`
entailment
def chain_output_files(self): """Return a list of the all the output files produced by this link. For `Link` sub-classes this will return only those files that were not marked as internal files or marked for removal. """ ret_list = [] for key, val in self.file_dict.items...
Return a list of the all the output files produced by this link. For `Link` sub-classes this will return only those files that were not marked as internal files or marked for removal.
entailment
def input_files_to_stage(self): """Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as inpu...
Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to another `Link` in the `Chain`
entailment
def output_files_to_stage(self): """Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as inp...
Return a list of the input files needed by this link. For `Link` sub-classes this will return the union of all the input files of each internal `Link`. That is to say this will include files produced by one `Link` in a `Chain` and used as input to another `Link` in the `Chain`
entailment
def internal_files(self): """Return a list of the intermediate files produced by this link. This returns all files that were explicitly marked as internal files. """ ret_list = [] for key, val in self.file_dict.items(): # For internal files we only want files that we...
Return a list of the intermediate files produced by this link. This returns all files that were explicitly marked as internal files.
entailment
def temp_files(self): """Return a list of the temporary files produced by this link. This returns all files that were explicitly marked for removal. """ ret_list = [] for key, val in self.file_dict.items(): # For temp files we only want files that were marked for rem...
Return a list of the temporary files produced by this link. This returns all files that were explicitly marked for removal.
entailment
def gzip_files(self): """Return a list of the files compressed by this link. This returns all files that were explicitly marked for compression. """ ret_list = [] for key, val in self.file_dict.items(): # For temp files we only want files that were marked for removal...
Return a list of the files compressed by this link. This returns all files that were explicitly marked for compression.
entailment
def print_summary(self, stream=sys.stdout, indent=""): """Print a summary of the files in this file dict. This version explictly counts the union of all input and output files. """ stream.write("%sTotal files : %i\n" % (indent, len(self.file_dict))) str...
Print a summary of the files in this file dict. This version explictly counts the union of all input and output files.
entailment
def print_chain_summary(self, stream=sys.stdout, indent=""): """Print a summary of the files in this file dict. This version uses chain_input_files and chain_output_files to count the input and output files. """ stream.write("%sTotal files : %i\n" % (in...
Print a summary of the files in this file dict. This version uses chain_input_files and chain_output_files to count the input and output files.
entailment
def split_local_path(self, local_file): """Split the local path into a directory name and a file name If local_file is in self.workdir or a subdirectory of it, the directory will consist of the relative path from workdir. If local_file is not in self.workdir, directory will be empty. ...
Split the local path into a directory name and a file name If local_file is in self.workdir or a subdirectory of it, the directory will consist of the relative path from workdir. If local_file is not in self.workdir, directory will be empty. Returns (dirname, basename)
entailment
def construct_scratch_path(self, dirname, basename): """Construct and return a path in the scratch area. This will be <self.scratchdir>/<dirname>/<basename> """ return os.path.join(self.scratchdir, dirname, basename)
Construct and return a path in the scratch area. This will be <self.scratchdir>/<dirname>/<basename>
entailment
def get_scratch_path(self, local_file): """Construct and return a path in the scratch area from a local file. """ (local_dirname, local_basename) = self.split_local_path(local_file) return self.construct_scratch_path(local_dirname, local_basename)
Construct and return a path in the scratch area from a local file.
entailment
def map_files(self, local_files): """Build a dictionary mapping local paths to scratch paths. Parameters ---------- local_files : list List of filenames to be mapped to scratch area Returns dict Mapping local_file : fullpath of scratch file """ ...
Build a dictionary mapping local paths to scratch paths. Parameters ---------- local_files : list List of filenames to be mapped to scratch area Returns dict Mapping local_file : fullpath of scratch file
entailment
def make_scratch_dirs(file_mapping, dry_run=True): """Make any directories need in the scratch area""" scratch_dirs = {} for value in file_mapping.values(): scratch_dirname = os.path.dirname(value) scratch_dirs[scratch_dirname] = True for scratch_dirname in scratc...
Make any directories need in the scratch area
entailment
def copy_to_scratch(file_mapping, dry_run=True): """Copy input files to scratch area """ for key, value in file_mapping.items(): if not os.path.exists(key): continue if dry_run: print ("copy %s %s" % (key, value)) else: ...
Copy input files to scratch area
entailment
def copy_from_scratch(file_mapping, dry_run=True): """Copy output files from scratch area """ for key, value in file_mapping.items(): if dry_run: print ("copy %s %s" % (value, key)) else: try: outdir = os.path.dirname(key) ...
Copy output files from scratch area
entailment
def make_table(file_dict): """Build and return an `astropy.table.Table` to store `FileHandle`""" col_key = Column(name='key', dtype=int) col_path = Column(name='path', dtype='S256') col_creator = Column(name='creator', dtype=int) col_timestamp = Column(name='timestamp', dtype=int...
Build and return an `astropy.table.Table` to store `FileHandle`
entailment
def make_dict(cls, table): """Build and return a dict of `FileHandle` from an `astropy.table.Table` The dictionary is keyed by FileHandle.key, which is a unique integer for each file """ ret_dict = {} for row in table: file_handle = cls.create_from_row(row) r...
Build and return a dict of `FileHandle` from an `astropy.table.Table` The dictionary is keyed by FileHandle.key, which is a unique integer for each file
entailment
def create_from_row(cls, table_row): """Build and return a `FileHandle` from an `astropy.table.row.Row` """ kwargs = {} for key in table_row.colnames: kwargs[key] = table_row[key] try: return cls(**kwargs) except KeyError: print(kwargs)
Build and return a `FileHandle` from an `astropy.table.row.Row`
entailment
def check_status(self, basepath=None): """Check on the status of this particular file""" if basepath is None: fullpath = self.path else: fullpath = os.path.join(basepath, self.path) exists = os.path.exists(fullpath) if not exists: if self.flag...
Check on the status of this particular file
entailment
def append_to_table(self, table): """Add this instance as a row on a `astropy.table.Table` """ table.add_row(dict(path=self.path, key=self.key, creator=self.creator, timestamp=self.timestamp, stat...
Add this instance as a row on a `astropy.table.Table`
entailment
def update_table_row(self, table, row_idx): """Update the values in an `astropy.table.Table` for this instances""" table[row_idx]['path'] = self.path table[row_idx]['key'] = self.key table[row_idx]['creator'] = self.creator table[row_idx]['timestamp'] = self.timestamp tab...
Update the values in an `astropy.table.Table` for this instances
entailment
def _get_fullpath(self, filepath): """Return filepath with the base_path prefixed """ if filepath[0] == '/': return filepath return os.path.join(self._base_path, filepath)
Return filepath with the base_path prefixed
entailment
def _fill_cache(self): """Fill the cache from the `astropy.table.Table`""" for irow in range(len(self._table)): file_handle = self._make_file_handle(irow) self._cache[file_handle.path] = file_handle
Fill the cache from the `astropy.table.Table`
entailment
def _read_table_file(self, table_file): """Read an `astropy.table.Table` to set up the archive""" self._table_file = table_file if os.path.exists(self._table_file): self._table = Table.read(self._table_file) else: self._table = FileHandle.make_table({}) se...
Read an `astropy.table.Table` to set up the archive
entailment
def _make_file_handle(self, row_idx): """Build and return a `FileHandle` object from an `astropy.table.row.Row` """ row = self._table[row_idx] return FileHandle.create_from_row(row)
Build and return a `FileHandle` object from an `astropy.table.row.Row`
entailment
def get_handle(self, filepath): """Get the `FileHandle` object associated to a particular file """ localpath = self._get_localpath(filepath) return self._cache[localpath]
Get the `FileHandle` object associated to a particular file
entailment
def register_file(self, filepath, creator, status=FileStatus.no_file, flags=FileFlags.no_flags): """Register a file in the archive. If the file already exists, this raises a `KeyError` Parameters ---------- filepath : str The path to the file creatror : int...
Register a file in the archive. If the file already exists, this raises a `KeyError` Parameters ---------- filepath : str The path to the file creatror : int A unique key for the job that created this file status : `FileStatus` Enu...
entailment
def update_file(self, filepath, creator, status): """Update a file in the archive If the file does not exists, this raises a `KeyError` Parameters ---------- filepath : str The path to the file creatror : int A unique key for the job that create...
Update a file in the archive If the file does not exists, this raises a `KeyError` Parameters ---------- filepath : str The path to the file creatror : int A unique key for the job that created this file status : `FileStatus` Enume...
entailment
def get_file_ids(self, file_list, creator=None, status=FileStatus.no_file, file_dict=None): """Get or create a list of file ids based on file names Parameters ---------- file_list : list The paths to the file creatror : int A unique ...
Get or create a list of file ids based on file names Parameters ---------- file_list : list The paths to the file creatror : int A unique key for the job that created these files status : `FileStatus` Enumeration giving current status of fi...
entailment
def get_file_paths(self, id_list): """Get a list of file paths based of a set of ids Parameters ---------- id_list : list List of integer file keys Returns list of file paths """ if id_list is None: return [] try: pat...
Get a list of file paths based of a set of ids Parameters ---------- id_list : list List of integer file keys Returns list of file paths
entailment
def write_table_file(self, table_file=None): """Write the table to self._table_file""" if self._table is None: raise RuntimeError("No table to write") if table_file is not None: self._table_file = table_file if self._table_file is None: raise RuntimeEr...
Write the table to self._table_file
entailment
def update_file_status(self): """Update the status of all the files in the archive""" nfiles = len(self.cache.keys()) status_vect = np.zeros((6), int) sys.stdout.write("Updating status of %i files: " % nfiles) sys.stdout.flush() for i, key in enumerate(self.cache.keys()):...
Update the status of all the files in the archive
entailment
def _make_ltcube_file_list(ltsumfile, num_files): """Make the list of input files for a particular energy bin X psf type """ outbasename = os.path.basename(ltsumfile) lt_list_file = ltsumfile.replace('fits', 'lst') outfile = open(lt_list_file, 'w') for i in range(num_files): split_key = "%06...
Make the list of input files for a particular energy bin X psf type
entailment
def register_classes(): """Register these classes with the `LinkFactory` """ Gtlink_select.register_class() Gtlink_bin.register_class() Gtlink_expcube2.register_class() Gtlink_scrmaps.register_class() Gtlink_mktime.register_class() Gtlink_ltcube.register_class() Link_FermipyCoadd.registe...
Register these classes with the `LinkFactory`
entailment
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) datafile = args['data'] if datafile is None or datafile == 'None': return job_configs NAME_FACTORY.upd...
Hook to build job configurations
entailment
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} gmm = make_ring_dicts(library=args['library'], basedir='.') for galkey in gmm.galkeys(): ring_dict = gmm.ring_dict(galkey) for ring_key, ring_info in ring_dict.it...
Hook to build job configurations
entailment
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) ret_dict = make_diffuse_comp_info_dict(components=components, ...
Hook to build job configurations
entailment
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) ret_dict = make_catalog_comp_dict(library=args['library'], ...
Hook to build job configurations
entailment
def norm(x, mu, sigma=1.0): """ Scipy norm function """ return stats.norm(loc=mu, scale=sigma).pdf(x)
Scipy norm function
entailment
def ln_norm(x, mu, sigma=1.0): """ Natural log of scipy norm function truncated at zero """ return np.log(stats.norm(loc=mu, scale=sigma).pdf(x))
Natural log of scipy norm function truncated at zero
entailment
def lognorm(x, mu, sigma=1.0): """ Log-normal function from scipy """ return stats.lognorm(sigma, scale=mu).pdf(x)
Log-normal function from scipy
entailment
def log10norm(x, mu, sigma=1.0): """ Scale scipy lognorm from natural log to base 10 x : input parameter mu : mean of the underlying log10 gaussian sigma : variance of underlying log10 gaussian """ return stats.lognorm(sigma * np.log(10), scale=mu).pdf(x)
Scale scipy lognorm from natural log to base 10 x : input parameter mu : mean of the underlying log10 gaussian sigma : variance of underlying log10 gaussian
entailment
def lgauss(x, mu, sigma=1.0, logpdf=False): """ Log10 normal distribution... x : Parameter of interest for scanning the pdf mu : Peak of the lognormal distribution (mean of the underlying normal distribution is log10(mu) sigma : Standard deviation of the underlying normal distributio...
Log10 normal distribution... x : Parameter of interest for scanning the pdf mu : Peak of the lognormal distribution (mean of the underlying normal distribution is log10(mu) sigma : Standard deviation of the underlying normal distribution
entailment
def create_prior_functor(d): """Build a prior from a dictionary. Parameters ---------- d : A dictionary, it must contain: d['functype'] : a recognized function type and all of the required parameters for the prior_functor of the desired type ...
Build a prior from a dictionary. Parameters ---------- d : A dictionary, it must contain: d['functype'] : a recognized function type and all of the required parameters for the prior_functor of the desired type Returns ---------- A sub-...
entailment
def marginalization_bins(self): """Binning to use to do the marginalization integrals """ log_mean = np.log10(self.mean()) # Default is to marginalize over two decades, # centered on mean, using 1000 bins return np.logspace(-1. + log_mean, 1. + log_mean, 1001)/self._j_ref
Binning to use to do the marginalization integrals
entailment
def profile_bins(self): """ The binning to use to do the profile fitting """ log_mean = np.log10(self.mean()) log_half_width = max(5. * self.sigma(), 3.) # Default is to profile over +-5 sigma, # centered on mean, using 100 bins return np.logspace(log_mean - log_h...
The binning to use to do the profile fitting
entailment
def normalization(self): """ The normalization i.e., the intergral of the function over the normalization_range """ norm_r = self.normalization_range() return quad(self, norm_r[0]*self._j_ref, norm_r[1]*self._j_ref)[0]
The normalization i.e., the intergral of the function over the normalization_range
entailment
def init_return(self, ret_type): """Specify the return type. Note that this will also construct the '~fermipy.castro.Interpolator' object for the requested return type. """ if self._ret_type == ret_type: return if ret_type == "straight": ...
Specify the return type. Note that this will also construct the '~fermipy.castro.Interpolator' object for the requested return type.
entailment
def clear_cached_values(self): """Removes all of the cached values and interpolators """ self._prof_interp = None self._prof_y = None self._prof_z = None self._marg_interp = None self._marg_z = None self._post = None self._post_interp = None ...
Removes all of the cached values and interpolators
entailment
def like(self, x, y): """Evaluate the 2-D likelihood in the x/y parameter space. The dimension of the two input arrays should be the same. Parameters ---------- x : array_like Array of coordinates in the `x` parameter. y : array_like Arra...
Evaluate the 2-D likelihood in the x/y parameter space. The dimension of the two input arrays should be the same. Parameters ---------- x : array_like Array of coordinates in the `x` parameter. y : array_like Array of coordinates in the `y` nuisa...
entailment
def loglike(self, x, y): """Evaluate the 2-D log-likelihood in the x/y parameter space. The dimension of the two input arrays should be the same. Parameters ---------- x : array_like Array of coordinates in the `x` parameter. y : array_like ...
Evaluate the 2-D log-likelihood in the x/y parameter space. The dimension of the two input arrays should be the same. Parameters ---------- x : array_like Array of coordinates in the `x` parameter. y : array_like Array of coordinates in the `y` n...
entailment
def profile_loglike(self, x): """Profile log-likelihood. Returns ``L_prof(x,y=y_min|z')`` : where y_min is the value of y that minimizes L for a given x. This will used the cached '~fermipy.castro.Interp...
Profile log-likelihood. Returns ``L_prof(x,y=y_min|z')`` : where y_min is the value of y that minimizes L for a given x. This will used the cached '~fermipy.castro.Interpolator' object if possible, and ...
entailment
def marginal_loglike(self, x): """Marginal log-likelihood. Returns ``L_marg(x) = \int L(x,y|z') L(y) dy`` This will used the cached '~fermipy.castro.Interpolator' object if possible, and construct it if needed. """ if self._marg_interp is None: # This calcu...
Marginal log-likelihood. Returns ``L_marg(x) = \int L(x,y|z') L(y) dy`` This will used the cached '~fermipy.castro.Interpolator' object if possible, and construct it if needed.
entailment
def posterior(self, x): """Posterior function. Returns ``P(x) = \int L(x,y|z') L(y) dy / \int L(x,y|z') L(y) dx dy`` This will used the cached '~fermipy.castro.Interpolator' object if possible, and construct it if needed. """ if self._post is None: return ...
Posterior function. Returns ``P(x) = \int L(x,y|z') L(y) dy / \int L(x,y|z') L(y) dx dy`` This will used the cached '~fermipy.castro.Interpolator' object if possible, and construct it if needed.
entailment
def _profile_loglike(self, x): """Internal function to calculate and cache the profile likelihood """ x = np.array(x, ndmin=1) z = [] y = [] for xtmp in x: def fn(t): return -self.loglike(xtmp, t) ytmp = opt.fmin(fn, 1.0, disp=False)[0] ...
Internal function to calculate and cache the profile likelihood
entailment
def _profile_loglike_spline(self, x): """Internal function to calculate and cache the profile likelihood """ z = [] y = [] yv = self._nuis_pdf.profile_bins() nuis_vals = self._nuis_pdf.log_value(yv) - self._nuis_log_norm for xtmp in x: zv = -1. * self...
Internal function to calculate and cache the profile likelihood
entailment
def _marginal_loglike(self, x): """Internal function to calculate and cache the marginal likelihood """ yedge = self._nuis_pdf.marginalization_bins() yw = yedge[1:] - yedge[:-1] yc = 0.5 * (yedge[1:] + yedge[:-1]) s = self.like(x[:, np.newaxis], yc[np.newaxis, :]) ...
Internal function to calculate and cache the marginal likelihood
entailment
def _posterior(self, x): """Internal function to calculate and cache the posterior """ yedge = self._nuis_pdf.marginalization_bins() yc = 0.5 * (yedge[1:] + yedge[:-1]) yw = yedge[1:] - yedge[:-1] like_array = self.like(x[:, np.newaxis], yc[np.newaxis, :]) * yw l...
Internal function to calculate and cache the posterior
entailment
def _compute_mle(self): """Maximum likelihood estimator. """ xmax = self._lnlfn.interp.xmax x0 = max(self._lnlfn.mle(), xmax * 1e-5) ret = opt.fmin(lambda x: np.where( xmax > x > 0, -self(x), np.inf), x0, disp=False) mle = float(ret[0]) return mle
Maximum likelihood estimator.
entailment
def build_from_energy_dict(cls, ebin_name, input_dict): """ Build a list of components from a dictionary for a single energy range """ psf_types = input_dict.pop('psf_types') output_list = [] for psf_type, val_dict in sorted(psf_types.items()): fulldict = input_dict.c...
Build a list of components from a dictionary for a single energy range
entailment
def build_from_yamlstr(cls, yamlstr): """ Build a list of components from a yaml string """ top_dict = yaml.safe_load(yamlstr) coordsys = top_dict.pop('coordsys') output_list = [] for e_key, e_dict in sorted(top_dict.items()): if e_key == 'coordsys': ...
Build a list of components from a yaml string
entailment
def _match_cubes(ccube_clean, ccube_dirty, bexpcube_clean, bexpcube_dirty, hpx_order): """ Match the HEALPIX scheme and order of all the input cubes return a dictionary of cubes with the same HEALPIX scheme and order """ if hpx_order == ccube_cl...
Match the HEALPIX scheme and order of all the input cubes return a dictionary of cubes with the same HEALPIX scheme and order
entailment
def _compute_intensity(ccube, bexpcube): """ Compute the intensity map """ bexp_data = np.sqrt(bexpcube.data[0:-1, 0:] * bexpcube.data[1:, 0:]) intensity_data = ccube.data / bexp_data intensity_map = HpxMap(intensity_data, ccube.hpx) return intensity_map
Compute the intensity map
entailment