# 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 subprocess
import re
import shutil
import unittest
import json
import glob
import numpy as np
import fitsio
import desimodel
import fiberassign
        import matplotlib.pyplot as plt
from datetime import datetime
from fiberassign.utils import option_list, GlobalTimers
from fiberassign.hardware import load_hardware
from fiberassign.tiles import load_tiles, Tiles
from fiberassign.targets import (TARGET_TYPE_SCIENCE, TARGET_TYPE_SKY,
                                 TARGET_TYPE_SUPPSKY,
                                 TARGET_TYPE_STANDARD, TARGET_TYPE_SAFE,
                                 Targets, TargetsAvailable,
                                 LocationsAvailable, load_target_file, targets_in_tiles, create_tagalong)
from fiberassign.assign import (Assignment, write_assignment_fits,
                                write_assignment_ascii, merge_results)
from fiberassign.qa import qa_tiles, qa_targets
from fiberassign.vis import plot_tiles, plot_qa, set_matplotlib_pdf_backend
from fiberassign.scripts.assign import parse_assign, run_assign_full
from fiberassign.scripts.plot import parse_plot, run_plot
from fiberassign.scripts.qa import parse_qa, run_qa
from fiberassign.scripts.qa_plot import parse_plot_qa, run_plot_qa
from .simulate import (test_subdir_create, sim_tiles, sim_targets,
                       sim_focalplane, petal_rotation, test_assign_date)
        cls.binDir = os.path.join(cls.topDir, "bin")
        if not os.path.isdir(cls.binDir):
            # We are running from some other directory from an installed package
            cls.topDir = os.path.dirname( # top-level
                os.path.dirname( # lib/
                    os.path.dirname( # python3.x/
                        os.path.dirname( # site-packages/
                            os.path.dirname( # egg/
                                os.path.dirname( # fiberassign/
                                    os.path.dirname(os.path.abspath(__file__)) # test/
                                )
                            )
                        )
                    )
                )
            )
            cls.binDir = os.path.join(cls.topDir, "bin")

    def setUp(self):
        self.density_science = 5000
        self.density_standards = 5000
        self.density_sky = 10
        self.density_suppsky = 5000
        pass

    def tearDown(self):
        pass

    def test_science(self):
        set_matplotlib_pdf_backend()

# 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_qa.py
import os
import subprocess
import re
import shutil
import unittest
import json
import glob
import numpy as np
import fitsio
import desimodel
import fiberassign
        import matplotlib.pyplot as plt
from datetime import datetime
from fiberassign.utils import option_list, GlobalTimers
from fiberassign.hardware import load_hardware
from fiberassign.tiles import load_tiles, Tiles
from fiberassign.targets import (TARGET_TYPE_SCIENCE, TARGET_TYPE_SKY,
                                 TARGET_TYPE_SUPPSKY,
                                 TARGET_TYPE_STANDARD, TARGET_TYPE_SAFE,
                                 Targets, TargetsAvailable,
                                 LocationsAvailable, load_target_file, targets_in_tiles, create_tagalong)
from fiberassign.assign import (Assignment, write_assignment_fits,
                                write_assignment_ascii, merge_results)
from fiberassign.qa import qa_tiles, qa_targets
from fiberassign.vis import plot_tiles, plot_qa, set_matplotlib_pdf_backend
from fiberassign.scripts.assign import parse_assign, run_assign_full
from fiberassign.scripts.plot import parse_plot, run_plot
from fiberassign.scripts.qa import parse_qa, run_qa
from fiberassign.scripts.qa_plot import parse_plot_qa, run_plot_qa
from .simulate import (test_subdir_create, sim_tiles, sim_targets,
                       sim_focalplane, petal_rotation, test_assign_date)

        cls.binDir = os.path.join(cls.topDir, "bin")
        if not os.path.isdir(cls.binDir):
            # We are running from some other directory from an installed package
            cls.topDir = os.path.dirname( # top-level
                os.path.dirname( # lib/
                    os.path.dirname( # python3.x/
                        os.path.dirname( # site-packages/
                            os.path.dirname( # egg/
                                os.path.dirname( # fiberassign/
                                    os.path.dirname(os.path.abspath(__file__)) # test/
                                )
                            )
                        )
                    )
                )
            )
            cls.binDir = os.path.join(cls.topDir, "bin")

    def setUp(self):
        self.density_science = 5000
        self.density_standards = 5000
        self.density_sky = 10
        self.density_suppsky = 5000
        pass

    def tearDown(self):
        pass

    def test_science(self):
        set_matplotlib_pdf_backend()

        test_dir = test_subdir_create("qa_test_science")