code: def readAltWCS(fobj, ext, wcskey=' ', verbose=False):
      
      if isinstance(fobj, str):
          fobj = fits.open(fobj, memmap=False)
  
      hdr = altwcs._getheader(fobj, ext)
      try:
          original_logging_level = log.level
          log.setLevel(logutil.logging.WARNING)
          nwcs = pywcs.WCS(hdr, fobj=fobj, key=wcskey)
  
      except KeyError:
          if verbose:
              print('readAltWCS: Could not read WCS with key %s' % wcskey)
              print('            Skipping %s[%s]' % (fobj.filename(), str(ext)))
          return None
  
      finally:
          log.setLevel(original_logging_level) # restore original logging level
  
      hwcs = nwcs.to_header()
  
      if nwcs.wcs.has_cd():
          hwcs = altwcs.pc2cd(hwcs, key=wcskey)
      return hwcs
docs: Reads in alternate primary WCS from specified extension.
  
      Parameters
      ----------
      fobj : str, `astropy.io.fits.HDUList`
          fits filename or fits file object
          containing alternate/primary WCS(s) to be converted
      wcskey : str
          [" ",A-Z]
          alternate/primary WCS key that will be replaced by the new key
      ext : int
          fits extension number
      Returns
      -------
      hdr: fits.Header
          header object with ONLY the keywords for specified alternate WCS