# Path: py/fiberassign/test/simulate.py
# def sim_data_dir():
# def test_subdir_create(name):
# def sim_science_fractions():
# def sim_focalplane(rundate=None, fakepos=False):
# def sim_stuck_sky(dirnm, hw, tiles):
#     def radec2xyz(r, d):
# def sim_tiles(path, selectfile=None):
# def sim_targets(path, tgtype, tgoffset, density=5000.0, science_frac=None):
# def petal_rotation(npos, reverse=False):
#         J = np.flatnonzero(r2 < maxr2)


import os
import unittest
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
from fiberassign.hardware import load_hardware
from fiberassign.vis import (
    plot_positioner,
    plot_positioner_simple,
    Shape,
    set_matplotlib_pdf_backend
)
from .simulate import test_subdir_create, sim_focalplane, test_assign_date
            phi = phi_offset[lid] + np.pi
            # print("loc {} theta_0 {} + min {} = {}".format(lid, theta_offset[lid], theta_min[lid], theta))
            patrol_rad = theta_arm[lid] + phi_arm[lid]
            failed = hw.loc_position_thetaphi(
                lid, theta, phi, shptheta, shpphi
            )
            if failed:
                print(
                    "Failed to move positioner {} to theta = {}, phi = {}"
                    .format(lid, theta, phi)
                )
            else:
                if simple:
                    plot_positioner_simple(
                        ax, patrol_rad, lid, center, theta, theta_arm[lid],
                        phi, phi_arm[lid], color=color, linewidth=linewidth
                    )
                else:
                    plot_positioner(
                        ax, patrol_rad, lid, center, shptheta, shpphi,
                        color=color, linewidth=linewidth
                    )

        outfile = os.path.join(dir, "test_plotfp_{}.pdf".format(suffix))
        ax.set_xlabel("Millimeters", fontsize="large")
        ax.set_ylabel("Millimeters", fontsize="large")
        plt.savefig(outfile, dpi=300, format="pdf")
        plt.close()

    def test_plotfp(self):

# Path: py/fiberassign/test/simulate.py
# def sim_data_dir():
# def test_subdir_create(name):
# def sim_science_fractions():
# def sim_focalplane(rundate=None, fakepos=False):
# def sim_stuck_sky(dirnm, hw, tiles):
#     def radec2xyz(r, d):
# def sim_tiles(path, selectfile=None):
# def sim_targets(path, tgtype, tgoffset, density=5000.0, science_frac=None):
# def petal_rotation(npos, reverse=False):
#         J = np.flatnonzero(r2 < maxr2)


# Path: py/fiberassign/test/test_vis.py
import os
import unittest
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
from fiberassign.hardware import load_hardware
from fiberassign.vis import (
    plot_positioner,
    plot_positioner_simple,
    Shape,
    set_matplotlib_pdf_backend
)
from .simulate import test_subdir_create, sim_focalplane, test_assign_date

            phi = phi_offset[lid] + np.pi
            # print("loc {} theta_0 {} + min {} = {}".format(lid, theta_offset[lid], theta_min[lid], theta))
            patrol_rad = theta_arm[lid] + phi_arm[lid]
            failed = hw.loc_position_thetaphi(
                lid, theta, phi, shptheta, shpphi
            )
            if failed:
                print(
                    "Failed to move positioner {} to theta = {}, phi = {}"
                    .format(lid, theta, phi)
                )
            else:
                if simple:
                    plot_positioner_simple(
                        ax, patrol_rad, lid, center, theta, theta_arm[lid],
                        phi, phi_arm[lid], color=color, linewidth=linewidth
                    )
                else:
                    plot_positioner(
                        ax, patrol_rad, lid, center, shptheta, shpphi,
                        color=color, linewidth=linewidth
                    )

        outfile = os.path.join(dir, "test_plotfp_{}.pdf".format(suffix))
        ax.set_xlabel("Millimeters", fontsize="large")
        ax.set_ylabel("Millimeters", fontsize="large")
        plt.savefig(outfile, dpi=300, format="pdf")
        plt.close()

    def test_plotfp(self):

        test_dir = test_subdir_create("vis_test_plotfp")