Builds and returns a FITs HDU with the energy bin boundries

        extname   : The HDU extension name
15042
def make_energies_hdu(self, extname="ENERGIES"):
        
        if self._evals is None:
            return None
        cols = [fits.Column("ENERGY", "1E", unit='MeV',
                            array=self._evals)]
        hdu = fits.BinTableHDU.from_columns(
            cols, self.make_header(), name=extname)
        return hdu
494524
def __finalize_hdfs(self, ext):
        
        java_home = jvm.get_java_home()
        jvm_lib_path, _ = jvm.get_jvm_lib_path_and_name(java_home)
        ext.include_dirs = jvm.get_include_dirs() + ext.include_dirs
        ext.libraries = jvm.get_libraries()
        ext.library_dirs = [os.path.join(java_home, "Libraries"), jvm_lib_path]
        ext.define_macros = jvm.get_macros()
        ext.extra_link_args = ['-Wl,-rpath,%s' % jvm_lib_path]
        if self.__have_better_tls():
            ext.define_macros.append(("HAVE_BETTER_TLS", None))
        try:
            # too many warnings in libhdfs
            self.compiler.compiler_so.remove("-Wsign-compare")
        except (AttributeError, ValueError):
            pass
630389
def createWcsHDU(self):
        
        hdu = fits.ImageHDU()
        hdu.header['EXTNAME'] = 'WCS'
        hdu.header['EXTVER'] = 1
        # Now, update original image size information
        hdu.header['WCSAXES'] = (2, "number of World Coordinate System axes")
        hdu.header['NPIX1'] = (self.naxis1, "Length of array axis 1")
        hdu.header['NPIX2'] = (self.naxis2, "Length of array axis 2")
        hdu.header['PIXVALUE'] = (0.0, "values of pixels in array")

        # Write out values to header...
        excluded_keys = ['naxis1','naxis2']
        for key in self.wcskeys:
            _dkey = self.wcstrans[key]
            if _dkey not in excluded_keys:
                hdu.header[key] = self.__dict__[_dkey]


        return hdu
663834
def _hdu_on_disk(self, hdulist_index):
        
        if self._tempfile is None:
            self._tempfile = tempfile.NamedTemporaryFile(
                mode="r+b", suffix=".fits")
            self.hdulist[hdulist_index].writeto(self._tempfile.name)
        return self._tempfile.name
982430
def get_extver_list(img, extname='SCI'):
    
    if isinstance(img, str):
        img = fits.open(img, memmap=False)
        img.close()
    elif not isinstance(img, fits.HDUList):
        raise TypeError("Argument 'img' must be either a file name (string) "  \
                        "or a fits.HDUList object.")

    # when extver is None - return the range of all FITS extensions
    if extname is None:
        extver = list(range(len(img)))
        return extver

    if not isinstance(extname, str):
        raise TypeError("Argument 'extname' must be either a string "          \
            "indicating the value of the 'EXTNAME' keyword of the extensions " \
            "whose versions are to be returned or None to return "             \
            "extension numbers of all HDUs in the 'img' FITS file.")

    extname = extname.upper()

    extver = []
    for e in img:
        #if not isinstance(e, fits.ImageHDU): continue
        hkeys = list(map(str.upper, list(e.header.keys())))
        if 'EXTNAME' in hkeys and e.header['EXTNAME'].upper() == extname:
            extver.append(e.header['EXTVER'] if 'EXTVER' in hkeys else 1)

    return extver
1196558
def find_and_read_ebins(hdulist):
    
    from fermipy import utils
    ebins = None
    if 'ENERGIES' in hdulist:
        hdu = hdulist['ENERGIES']
        ectr = hdu.data.field(hdu.columns[0].name)
        ebins = np.exp(utils.center_to_edge(np.log(ectr)))
    elif 'EBOUNDS' in hdulist:
        hdu = hdulist['EBOUNDS']
        emin = hdu.data.field('E_MIN') / 1E3
        emax = hdu.data.field('E_MAX') / 1E3
        ebins = np.append(emin, emax[-1])
    return ebins
1258990
function expandPackageDescriptor(descriptor) {
  descriptor = cloneDeep(descriptor)
  descriptor.profile = descriptor.profile || config.DEFAULT_DATA_PACKAGE_PROFILE
  for (const [index, resource] of (descriptor.resources || []).entries()) {
    descriptor.resources[index] = expandResourceDescriptor(resource)
  }
  return descriptor
}
936654
def find_DQ_extension(self):
        
        dqfile = None
        # Look for additional file with DQ array, primarily for WFPC2 data

        indx = self._filename.find('.fits')

        if indx > 3:
            suffix = self._filename[indx-4:indx]
            dqfile = self._filename.replace(suffix[:3],'_c1')

        elif indx < 0 and len(self._filename) > 3 and \
             self._filename[-4] == os.extsep and \
             self._filename[-1].lower() == 'h':

            # assume we've got a GEIS file
            dqfile  = self._filename[:-2]+'1'+self._filename[-1]
            hdulist = readgeis.readgeis(dqfile)
            prih    = hdulist[0].header
            if 'FILETYPE' in prih:
                dq_suffix = prih['FILETYPE'].strip().upper()
            else:
                # assume extension name is 'SDQ' for WFPC2 GEIS files
                dq_suffix = 'SDQ'
            hdulist.close()
            return dqfile,dq_suffix

        else:
            raise ValueError("Input file {} does not appear to be neither " \
                        "a FITS file nor a GEIS file.".format(self._filename))

        if os.path.exists(dqfile):
            dq_suffix = fits.getval(dqfile, "EXTNAME", ext=1, memmap=False)
        else:
            dq_suffix = "SCI"

        return dqfile, dq_suffix
1125309
def write_to_fitsfile(self, fitsfile, clobber=True):
        
        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)
        prim_hdu = index_map.create_primary_hdu()
        mult_hdu = index_map.create_image_hdu()
        for key in ['COORDSYS', 'ORDERING', 'PIXTYPE',
                    'ORDERING', 'ORDER', 'NSIDE',
                    'FIRSTPIX', 'LASTPIX']:
            prim_hdu.header[key] = hpx_header[key]
            mult_hdu.header[key] = hpx_header[key]

        hdulist = fits.HDUList([prim_hdu, mult_hdu])
        hdulist.writeto(fitsfile, overwrite=clobber)
1372495
def walker(top, names):
    
    global packages, extensions
    if any(exc in top for exc in excludes):
        return
    package = top[top.rfind('holoviews'):].replace(os.path.sep, '.')
    packages.append(package)
    for name in names:
        ext = '.'.join(name.split('.')[1:])
        ext_str = '*.%s' % ext
        if ext and ext not in excludes and ext_str not in extensions[package]:
            extensions[package].append(ext_str)
952353
def buildFITSName(geisname):
    """"""

    # User wants to make a FITS copy and update it...
    _indx = geisname.rfind('.')
    _fitsname = geisname[:_indx] + '_' + geisname[_indx + 1:-1] + 'h.fits'

    return _fitsname
399201
def update_null_primary(hdu_in, hdu=None):
    
    if hdu is None:
        hdu = fits.PrimaryHDU(header=hdu_in.header)
    else:
        hdu = hdu_in
        hdu.header.remove('FILENAME')
    return hdu
870241
def build_from_energy_dict(cls, ebin_name, input_dict):
        
        psf_types = input_dict.pop('psf_types')
        output_list = []
        for psf_type, val_dict in sorted(psf_types.items()):
            fulldict = input_dict.copy()
            fulldict.update(val_dict)
            fulldict['evtype_name'] = psf_type
            fulldict['ebin_name'] = ebin_name
            component = cls(**fulldict)
            output_list += [component]
        return output_list
523590
def gather_info_hdu(self, hdulist):
        """"""
        values = {}
        values['n_ext'] = len(hdulist)
        extnames = [hdu.header.get('extname', '') for hdu in hdulist[1:]]
        values['name_ext'] = ['PRIMARY'] + extnames

        fits_extractor = self.extractor_map['fits']
        for key in self.meta_dinfo_headers:
            values[key] = fits_extractor.extract(key, hdulist)

        return values
257578
def movnam_hdu(self, extname, hdutype=ANY_HDU, extver=0):
        
        extname = mks(extname)
        hdu = self._FITS.movnam_hdu(hdutype, extname, extver)
        return hdu
1160870
def next(self):
        
        if self._iter_index == len(self.hdu_list):
            raise StopIteration
        hdu = self.hdu_list[self._iter_index]
        self._iter_index += 1
        return hdu
859637
def build_extension_item(name: str, parameters: List[ExtensionParameter]) -> str:
    
    return "; ".join(
        [name]
        + [
            # Quoted strings aren't necessary because values are always tokens.
            name if value is None else f"{name}={value}"
            for name, value in parameters
        ]
    )