ifu_centers – IFU center file parser

Parse and manipulation of the IFU center files with the following structure:

# HETDEX IFU description file
# $Id: IFUcen_HETDEX.txt 789 2012-08-17 19:52:17Z mxhf $
#
# IFU 00001
#
# Test date: YYYYMMDD
# Total number of dead fibers (T < X %):
#
#
# history
# date     author   change
# -------------------------
# 20110702 mF       created
#
#
# FIBERD   FIBERSEP
1.55      2.20
# NFIBX NFIBY
20 23
#
# col 1: fiber ID, starts with 1, IDs 1-246 belong to left unit, 247-492 belong to right unit
# col 2: fiber x position ["]
# col 3: fiber y position ["]
# col 4: target unit spectrograph L=left, R=right
# col 5: target fiber within the spectrograph, fiber numbers start with 1 within each spectrograph
# col 6: relative throughput at fiducial wavelength
#
0001  -19.8000  -19.6876 L 0001    1.000
0002  -17.6000  -19.6876 L 0002    1.000
[...]
0447   17.6000   19.6876 R 0223    1.000
0448   19.8000   19.6876 R 0224    1.000

From the header the FIBERD, FIBERSEP, NFIBX and NFIBY are extracted. The rest of the file is parsed as follow:

  • the number of L or R are counted;
  • the columns number 2, 3, 5 and 6 are stored in dictionaries with the
    channels as keys;
  • a row is ignored if:
    1. it starts with #;
    2. the target fiber number is negative or cannot be converted to an
      integer (e.g. nan, --);
  • if the throughput if a valid fiber is less than 0.00 a
    IFUCenterError is raised as such a fiber should be ignored.
exception pyhetdex.het.ifu_centers.IFUCenterError[source]

Exception raised when the IFU center file parsing fails

class pyhetdex.het.ifu_centers.IFUCenter(ifu_center_file)[source]

Parse the IFU center file

Parameters:
ifu_center_file : string

file containing the fiber positions in the IFU.

Raises:
IFUCenterError

if it cannot decide whether a fibers must be used or not

Attributes:
filename : string

name of the IFU center file

fiber_d : float

fiber diameter

fiber_sep : float

fiber separation

nfibx, nfiby : int

number of fibers in the x and y directions

xifu, yifu : dictionary of lists

fibers x and y positions per channel

n_fibers : dictionary of int

number of fibers per channel

fib_number : dictionary of lists

fiber number corresponding to positions xifu, yifu per channel

throughput : dictionary of lists

throughput corresponding to positions xifu, yifu per channel

_read_header(f)[source]
Parameters:
f : file object

file object to parse

Returns:
f : file object

file object after consuming the header

_read_ifu(ifu_center_file)[source]

Read the ifu center file

Parameters:
ifu_center_file : string

file containing the fiber number to fiber position mapping

_read_ifu_map(f)[source]
Parameters:
f : file object

file to parse

Returns:
f : file object

moved to the next non comment line

channels

list of channels