fplane
– Focal plane¶
Base class for fplane file parsing and IFU.
This module provides a basic parser for the focal plane file and an object containing the informations about the IFU from the focal plane.
The focal plane is expected to be:
##IFUSLOT X_FP Y_FP SPECID SPECSLOT IFUID IFUROT PLATESC
001 -450.0 150.0 37 42 024 0.0 1.00
Commented lines are ignored.
Use¶
The simplest use is to create a fplane
instance passing the name of the
focal plane file:
>>> fplane = FPlane("fplane.txt")
>>> print(fplane.difus_ifuid)
{'001': <pyhetdex.het.fplane.IFU object at 0x7ff6a493c1d0>,
'002': <pyhetdex.het.fplane.IFU object at 0x7ff6a493d1d0>, ...}
IFU Customisation¶
If you need to customise the IFU
object, without changing the constructor
signature, you can do something like this:
>>> class MyIFU(IFU):
... def __init__(self, ifuslot, x, y, specid, specslot,
... ifuid, ifurot, platescl):
... super(MyIFU, self).__init__(self, ifuslot, x, y, specid,
... specslot, ifuid, ifurot, platescl)
... # do something else
... def new_method(self, a_variable):
... # implement
... pass
>>> fplane = FPlane("fplane.txt", ifu_class=MyIFU)
FPlane customisation¶
For more complex customisations, when you use a different way of storing
the IFU informations, e.g. a list
, a different __init__
signature,
…, you can override the FPlane.add_ifu()
method:
>>> class MyFPlane(FPlane):
... def add_ifu(self, line):
... # reimplement at need
... pass
Implementation¶
-
class
pyhetdex.het.fplane.
IFU
(ifuslot, x, y, specid, specslot, ifuid, ifurot, platescl)[source]¶ Contain the information for the IFU from the focal plane file.
The input type are cast to the corresponding types when initialising the object.
Parameters: - ifuslot : string
id of the ifu
- x, y : float
x and y position of the ifu in the focal plane
- specid : int
id of the spectrograph where the ifu is plugged into
- specslot : int
id of the spectrograph slot where the spectrograph is plugged into
- ifuid : string
id of the virus ifu bundle
- ifurot : float
rotation of the IFU in its seat in the IHMP
- platescl : float
focal plane plate scale at the position in the IHMP
Raises: - TypeError
if the
ifuslot
is not a string
Attributes: - ifuid, x, y, specid, specslot, ifuid, ifurot, platescl : as before
- xid, yid : int
x (column) and y (row) id of the ifu in the ifu head mounting plate (IHMP), generated from the ifuslot
-
class
pyhetdex.het.fplane.
FPlane
(fplane_file, ifu_class=<class 'pyhetdex.het.fplane.IFU'>, empty_specid='00', empty_ifuid='000', exclude_ifuslot=[], skip_empty=False)[source]¶ Focal plane.
Contains the dictionary of
IFU
instance (or derived or others), with the ifu id as key.Parameters: - fplane_file : string
name of the file containing the ids and position of the IFUs
- ifu_class :
IFU
instance (or anything else), optional class definition containing the IFU information.
- empty_specid, empty_ifuid : string, optional
if the entries for the SPECID (fourth column) or IFUID (sixt column) are as specified, they are replaced by a two digit negative number or a two digit number following a ‘N’. The number is increased any time one of the two conditions is met. Use it with caution as the SPECID and IFUID are used as dictionary keywords and should not be duplicated to avoid losing IFUs
- exclude_ifuslot : list of string, optional
list of ifu slot ids to exclude when loading the fplane file. The ids must much exactly the string in the first column of the file
- skip_empty : bool, optional
if
True
skip one ifu if the specid/ifuid is marked as empty
Attributes: ifus
list of
IFU
instancesifuids
list of IFUIDs (strings)
ifuslots
list of IFUSLOTs (strings)
specids
list of SPECIDs (integers)
difus_ifuid
dictionary of ifus; key: IFUID (string); value:
IFU
difus_ifuslot
dictionary of ifus; key: IFUSLOT (string); value:
IFU
difus_specid
dictionary of ifus; key: SPECID (int); value:
IFU
-
_load_fplane
(fname, empty_specid, empty_ifuid, exclude_ifuslot, skip_empty)[source]¶ Load the focal plane file and creates the
IFU
instancesParameters: - fname : string
name of the focal plane file
- empty_specid, empty_ifuid, exclude_ifuslot, skip_empty :
see
FPlane
-
add_ifu
(fpars)[source]¶ Parse a fplane
line
and add the IFU to the internal dictionary.Make sure that the ifuid, specid are a three digit string. Override this method if the
ifu
class constructor is not as the one ofIFU
.Parameters: - line : string
line of the fplane file
-
by_id
(id_, idtype)[source]¶ Returns the ifu with
id_
Parameters: - id_ : string
id of the spectrograph
- idtype : str
type of the id; must be one of ‘ifuid’, ‘ifuslot’, ‘specid’
Returns: - :class:`IFU` instance
Raises: - NoIFUError
if there is no IFU identified by the input ID
- UnknownIDTypeError
if the ID type is not known
-
by_ifuid
(ifuid)[source]¶ Returns the ifu with
ifuid
Parameters: - ifuid : string
id of the ifu
Returns: - :class:`IFU` instance
Raises: - NoIFUError
if there is no IFU identified by the input ID
-
by_ifuslot
(ifuslot)[source]¶ Returns the ifu with
ifuslot
Parameters: - ifuslot : string
id of the ihmp slot
Returns: - :class:`IFU` instance
Raises: - NoIFUError
if there is no IFU identified by the input ID
-
by_slotpos
(x, y)[source]¶ Returns the ifu in ifu slot position x, y
Parameters: - x : int
x position in the IHMP (1 to 10)
- y : int
y position in the IHMP (1 to 9)
Returns: - :class:`IFU` instance
Raises: - NoIFUError
if there is no IFU for the input positions
-
by_specid
(specid)[source]¶ Returns the ifu with
specid
Parameters: - specid : int or string
id of the spectrograph; the value is cast to an integer
Returns: - :class:`IFU` instance
Raises: - NoIFUError
if there is no IFU identified by the input ID
- TypeError
if the input is not an int or a string that can be cast to an int
-
ifuids
¶ list of IFUIDs (strings)
-
ifuslots
¶ list of IFUSLOTs (strings)
-
specids
¶ list of SPECIDs (integers)