# Path: py/fiberassign/utils.py
# def option_list(opts):
# def assert_isoformat_utc(time_str):
# def get_date_cutoff(datetype, cutoff_case):
# def get_svn_version(svn_dir):
# def get_last_line(fn):
# def read_ecsv_keys(fn):


from datetime import datetime, timezone
from scipy.interpolate import interp1d
from .utils import Logger
from ._internal import (
    Hardware,
    FIBER_STATE_OK,
    FIBER_STATE_UNASSIGNED,
    FIBER_STATE_STUCK,
    FIBER_STATE_BROKEN,
    FIBER_STATE_RESTRICT,
    Circle,
    Segments,
    Shape,
)
    from astropy.time import Time
    from desimeter.fiberassign import fiberassign_radec2xy_cs5, fiberassign_radec2xy_flat
    from desimeter.fiberassign import fiberassign_cs5_xy2radec, fiberassign_flat_xy2radec
    from astropy.time import Time
    from desimeter.transform.pos2ptl import flat2ptl
    from desimeter.transform.pos2ptl import ptl2flat
import numpy as np
import desimodel.io as dmio
                theta =  np.pi - theta
            else:
                theta = -np.pi - theta
        da = np.pi/2. + theta/2.
        # This places the point further from the original keeps the vectors parallel to their originals
        stretch = 1./np.cos(theta/2.)
        dx = -margin * stretch * np.cos(a + da)
        dy = -margin * stretch * np.sin(a + da)

        ex.append(x2 + dx)
        ey.append(y2 + dy)

    return ex, ey


def load_hardware(focalplane=None, rundate=None,
                  add_margins={}):
    """Create a hardware class representing properties of the telescope.

    Args:
        focalplane (tuple):  Override the focalplane model.  If not None, this
            should be a tuple of the same data types returned by
            desimodel.io.load_focalplane()
        rundate (str):  ISO 8601 format time stamp as a string in the
            format YYYY-MM-DDTHH:MM:SS+-zz:zz.  If None, uses current time.

    Returns:
        (Hardware):  The hardware object.

    """

# Path: py/fiberassign/utils.py
# def option_list(opts):
# def assert_isoformat_utc(time_str):
# def get_date_cutoff(datetype, cutoff_case):
# def get_svn_version(svn_dir):
# def get_last_line(fn):
# def read_ecsv_keys(fn):


# Path: py/fiberassign/hardware.py
from datetime import datetime, timezone
from scipy.interpolate import interp1d
from .utils import Logger
from ._internal import (
    Hardware,
    FIBER_STATE_OK,
    FIBER_STATE_UNASSIGNED,
    FIBER_STATE_STUCK,
    FIBER_STATE_BROKEN,
    FIBER_STATE_RESTRICT,
    Circle,
    Segments,
    Shape,
)
    from astropy.time import Time
    from desimeter.fiberassign import fiberassign_radec2xy_cs5, fiberassign_radec2xy_flat
    from desimeter.fiberassign import fiberassign_cs5_xy2radec, fiberassign_flat_xy2radec
    from astropy.time import Time
    from desimeter.transform.pos2ptl import flat2ptl
    from desimeter.transform.pos2ptl import ptl2flat
import numpy as np
import desimodel.io as dmio

                theta =  np.pi - theta
            else:
                theta = -np.pi - theta
        da = np.pi/2. + theta/2.
        # This places the point further from the original keeps the vectors parallel to their originals
        stretch = 1./np.cos(theta/2.)
        dx = -margin * stretch * np.cos(a + da)
        dy = -margin * stretch * np.sin(a + da)

        ex.append(x2 + dx)
        ey.append(y2 + dy)

    return ex, ey


def load_hardware(focalplane=None, rundate=None,
                  add_margins={}):
    """Create a hardware class representing properties of the telescope.

    Args:
        focalplane (tuple):  Override the focalplane model.  If not None, this
            should be a tuple of the same data types returned by
            desimodel.io.load_focalplane()
        rundate (str):  ISO 8601 format time stamp as a string in the
            format YYYY-MM-DDTHH:MM:SS+-zz:zz.  If None, uses current time.

    Returns:
        (Hardware):  The hardware object.

    """

    log = Logger.get()