# 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
from desitarget.targetmask import desi_mask, mws_mask
from fiberassign.hardware import load_hardware
from fiberassign.tiles import load_tiles
from fiberassign.targets import (TARGET_TYPE_SCIENCE, TARGET_TYPE_SKY,
                                 TARGET_TYPE_SUPPSKY,
                                 TARGET_TYPE_STANDARD, load_target_file,
                                 desi_target_type, default_main_sciencemask,
                                 default_main_skymask, default_main_stdmask,
                                 default_main_suppskymask,
                                 default_main_safemask,
                                 default_main_excludemask,
                                 default_main_gaia_stdmask,
                                 Targets, TargetsAvailable,
                                 LocationsAvailable, targets_in_tiles, create_tagalong)
from .simulate import (test_subdir_create, sim_tiles, sim_targets, test_assign_date)
"""










class TestTargets(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_available(self):
        test_dir = test_subdir_create("targets_test_available")
        input_mtl = os.path.join(test_dir, "mtl.fits")
        input_std = os.path.join(test_dir, "standards.fits")
        input_sky = os.path.join(test_dir, "sky.fits")
        input_suppsky = os.path.join(test_dir, "suppsky.fits")
        tgoff = 0
        nscience = sim_targets(input_mtl, TARGET_TYPE_SCIENCE, tgoff)
        tgoff += nscience
        nstd = sim_targets(input_std, TARGET_TYPE_STANDARD, tgoff)
        tgoff += nstd

# 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_targets.py
import os
import unittest
import numpy as np
from desitarget.targetmask import desi_mask, mws_mask
from fiberassign.hardware import load_hardware
from fiberassign.tiles import load_tiles
from fiberassign.targets import (TARGET_TYPE_SCIENCE, TARGET_TYPE_SKY,
                                 TARGET_TYPE_SUPPSKY,
                                 TARGET_TYPE_STANDARD, load_target_file,
                                 desi_target_type, default_main_sciencemask,
                                 default_main_skymask, default_main_stdmask,
                                 default_main_suppskymask,
                                 default_main_safemask,
                                 default_main_excludemask,
                                 default_main_gaia_stdmask,
                                 Targets, TargetsAvailable,
                                 LocationsAvailable, targets_in_tiles, create_tagalong)
from .simulate import (test_subdir_create, sim_tiles, sim_targets, test_assign_date)

"""










class TestTargets(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_available(self):
        test_dir = test_subdir_create("targets_test_available")
        input_mtl = os.path.join(test_dir, "mtl.fits")
        input_std = os.path.join(test_dir, "standards.fits")
        input_sky = os.path.join(test_dir, "sky.fits")
        input_suppsky = os.path.join(test_dir, "suppsky.fits")
        tgoff = 0
        nscience = sim_targets(input_mtl, TARGET_TYPE_SCIENCE, tgoff)
        tgoff += nscience
        nstd = sim_targets(input_std, TARGET_TYPE_STANDARD, tgoff)
        tgoff += nstd

        nsky = sim_targets(input_sky, TARGET_TYPE_SKY, tgoff)