def test_ifu_centers_missingid(tmpdir): "Test missing ID string in header" ifucenter = tmpdir.join('IFUcenter.txt') header = tw.dedent("""\ 1.55 2.20 20 23 # """) ifucenter.write(header) ifucen.IFUCenter(ifucenter.strpath)
def test_ifu_centers_load(datadir, fname): '''Make sure that line endings are handled properly when loading the IFU cen files''' ifucenter = datadir.join(fname) ifu_cen = ifucen.IFUCenter(ifucenter.strpath) assert len(ifu_cen.n_fibers) == 2 assert ifu_cen.n_fibers['L'] == 224 assert ifu_cen.n_fibers['R'] == 224
def _load_ifu_center(self, ifu_center): '''Load the IFUcen file Parameters ---------- ifu_center : instance of :class:`~pyhetdex.het.ifu_centers.IFUCenter` fiber number to fiber position mapping ''' if not ifu_center: raise ReconstructValueError('An IFU center file is needed to' ' quickreconstruct an image') self.ifu_center = ifu_centers.IFUCenter(ifu_center)
def from_files(cls, ifu_center_file, dither_file=None, fextract=None, fe_prefix=""): """ Read and parse the file Parameters ---------- ifu_center_file : string file containing the fiber number to fiber position mapping dither_file : string, optional file containing the dither relative position. If not given, a singe dither is assumed fextract : None or list of fits files, optional if None the list of files is inferred from the second column of the ``dither_file``; if not None must have ``ndither`` x ``nchannels`` elements. The channel name and dither number are extracted from the ``CCDPOS`` and the ``DITHER`` header keywords fe_prefix : string, optional when getting the names from the dither file, prepend ``fe_prefix`` to the ``basename`` Raises ------ ReconstructValueError if both ``dither_file`` and ``fextract`` are ``None`` ReconstructValueError, ReconstructIOError as in :class:`~ReconstructedIFU` Notes ----- if ``dither_file`` is None, ``fextract`` must contain a number of files equal to the number of channels (2) """ if dither_file is None and fextract is None: msg = "dither_file and/or fextract must be provided" raise ReconstructValueError(msg) _ifu_center = ifu_centers.IFUCenter(ifu_center_file) if dither_file is None: _dither = dith.EmptyDither() else: _dither = dith.ParseDither(dither_file) return cls(_ifu_center, _dither, fextract=fextract, fe_prefix=fe_prefix)
def test_ifu_centers(tmpdir, lines, channels, n_fibers): '''Create a temporary IFU cen files and try to parse it''' ifucenter = tmpdir.join('IFUcenter.txt') header = tw.dedent("""\ # Extra comment # IFU 00001 # FIBERD FIBERSEP 1.55 2.20 # NFIBX NFIBY 20 23 # """) ifucenter.write(header) for l in lines: ifucenter.write(l + '\n', mode='a') ifu_cen = ifucen.IFUCenter(ifucenter.strpath) assert sorted(ifu_cen.channels) == sorted(channels) for c, n in zip(channels, n_fibers): assert ifu_cen.n_fibers[c] == n assert len(ifu_cen.fib_number[c]) == n