# 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 shutil
import unittest
import glob
import json
import numpy as np
import fitsio
import desimodel
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, targets_in_tiles,
                                 LocationsAvailable, load_target_file, create_tagalong)
from fiberassign.assign import (Assignment, write_assignment_fits,
                                write_assignment_ascii, merge_results,
                                read_assignment_fits_tile, run)
from fiberassign.stucksky import stuck_on_sky
from fiberassign.qa import qa_tiles
from fiberassign.vis import plot_tiles, plot_qa
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,
                       sim_stuck_sky)












class TestAssign(unittest.TestCase):

    def setUp(self):
        self.saved_skybricks = os.environ.get('STUCKSKY_DIR')
        if self.saved_skybricks is not None:
            del os.environ['SKYBRICKS_DIR']
        self.density_science = 5000
        self.density_standards = 5000
        self.density_sky = 100
        self.density_suppsky = 5000
        pass

    def tearDown(self):
        if self.saved_skybricks is not None:
            os.environ['STUCKSKY_DIR'] = self.saved_skybricks

    def test_io(self):
        np.random.seed(123456789)

# 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_assign.py
import os
import shutil
import unittest
import glob
import json
import numpy as np
import fitsio
import desimodel
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, targets_in_tiles,
                                 LocationsAvailable, load_target_file, create_tagalong)
from fiberassign.assign import (Assignment, write_assignment_fits,
                                write_assignment_ascii, merge_results,
                                read_assignment_fits_tile, run)
from fiberassign.stucksky import stuck_on_sky
from fiberassign.qa import qa_tiles
from fiberassign.vis import plot_tiles, plot_qa
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,
                       sim_stuck_sky)













class TestAssign(unittest.TestCase):

    def setUp(self):
        self.saved_skybricks = os.environ.get('STUCKSKY_DIR')
        if self.saved_skybricks is not None:
            del os.environ['SKYBRICKS_DIR']
        self.density_science = 5000
        self.density_standards = 5000
        self.density_sky = 100
        self.density_suppsky = 5000
        pass

    def tearDown(self):
        if self.saved_skybricks is not None:
            os.environ['STUCKSKY_DIR'] = self.saved_skybricks

    def test_io(self):
        np.random.seed(123456789)

        test_dir = test_subdir_create("assign_test_io")