コード例 #1
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialise_with_correct_keywords(self):
     cmd = UserCommands(packages=["test_package"],
                        yamls=["test_instrument.yaml"],
                        properties={"!ATMO.life": 42})
     assert isinstance(cmd, UserCommands)
     assert cmd["!ATMO.life"] == 42
     assert cmd["!INST.pixel_scale"] == 0.5
コード例 #2
0
    def yaml_file_can_be_loaded_into_optical_train(self):
        # .. todo: get this working on Travis
        filename = os.path.join(TEST_PATH, "MICADO_SCAO_WIDE_2.yaml")

        cmds = UserCommands(yamls=[filename])
        assert isinstance(cmds, UserCommands)
        assert isinstance(cmds.yaml_dicts, list)

        psf_file = cmds.yaml_dicts[1]["effects"][0]["kwargs"]["filename"]
        if find_file(psf_file) is None:
            new_file = "test_FVPSF.fits"
            cmds.yaml_dicts[1]["effects"][0]["kwargs"]["filename"] = new_file

        opt = OpticalTrain(cmds=cmds)
        assert isinstance(opt, OpticalTrain)
        assert isinstance(opt.optics_manager, OpticsManager)
        assert isinstance(
            opt.optics_manager.get_all(efs.FieldVaryingPSF)[0],
            efs.FieldVaryingPSF)
        assert isinstance(opt.image_plane, ImagePlane)
        assert opt.image_plane.hdu.header["NAXIS1"] >= 4096
        assert isinstance(opt.fov_manager, FOVManager)
        assert len(opt.fov_manager.fovs) == 64

        if PLOTS:
            for fov in opt.fov_manager.fovs:
                sky_cnrs, det_cnrs = fov.corners
                plt.plot(sky_cnrs[0], sky_cnrs[1])
            plt.show()

        r = np.arange(-25, 25)
        x, y = np.meshgrid(r, r)
        x = x.flatten() * u.arcsec
        y = y.flatten() * u.arcsec
        ref = [0] * len(x)
        weight = [1] * len(x)
        spec = sp.SourceSpectrum(sp.Empirical1D,
                                 points=[0.5, 3.0] * u.um,
                                 lookup_table=[1e3, 1e3] *
                                 u.Unit("ph s-1 m-2 um-1"))
        src = Source(x=x, y=y, ref=ref, weight=weight, spectra=[spec])
        opt.observe(src)

        if PLOTS:
            plt.imshow(opt.image_plane.image.T, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()
コード例 #3
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_when_passed_a_instrument_yaml_dict(self):
     cmd = UserCommands(yamls=[{
         "alias": "ATMO",
         "properties": {
             "pwv": 9001
         }
     }])
     assert cmd["!ATMO.pwv"] > 9000
コード例 #4
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
    def test_mode_yamls(self):
        yamls = [{
            "alias": "OBS",
            "properties": {
                "modes": ["mode1"],
                "life": 9001
            }
        }]
        mode_yamls = [{
            "name": "mode1",
            "yamls": [{
                "alias": "OBS",
                "properties": {
                    "life": 42
                }
            }]
        }]
        cmd = UserCommands(yamls=yamls, mode_yamls=mode_yamls)
        assert cmd["!OBS.life"] == 42

        print(cmd.list_modes())
コード例 #5
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_when_combining_yaml_dict_filename_properties(self):
     cmd = UserCommands(packages=["test_package"],
                        yamls=[
                            "test_telescope.yaml", {
                                "alias": "ATMO",
                                "properties": {
                                    "pwv": 9001
                                }
                            }
                        ],
                        properties={"!ATMO.pwv": 8999})
     assert cmd["!TEL.temperature"] > 9000
     assert cmd["!ATMO.pwv"] < 9000
コード例 #6
0
 def test_throws_error_for_wrong_mode_name(self):
     with pytest.raises(ValueError):
         UserCommands(use_instrument="test_package", set_modes=["bogus"])
コード例 #7
0
ファイル: test_OpticalTrain.py プロジェクト: yosata/ScopeSim
def _basic_cmds():
    return UserCommands(yamls=[find_file("CMD_mvs_cmds.yaml")])
コード例 #8
0
ファイル: test_OpticalTrain.py プロジェクト: yosata/ScopeSim
def _unity_cmds():
    return UserCommands(yamls=[find_file("CMD_unity_cmds.yaml")])
コード例 #9
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_update_works_via_setitem(self):
     cmd = UserCommands(use_instrument="test_package")
     cmd["!TEL.gigawatts"] = 1.21
     assert cmd["!TEL.gigawatts"] == 1.21
コード例 #10
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_mode_yamls_read_from_file(self):
     cmd = UserCommands(use_instrument="test_package")
     assert cmd["!TEL.temperature"] < 9000
     assert cmd["!OBS.airmass"] == 2
     assert cmd.yaml_dicts[-1]["effects"][0]["kwargs"][
         "meaning_of_life"] == 42
コード例 #11
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_with_filename_for_default_file(self):
     cmd = UserCommands(packages=["test_package"], yamls=["default.yaml"])
     assert cmd["!TEL.temperature"] < 9000
     assert len(cmd.yaml_dicts) == 7  # 3 yamls filenames + default
コード例 #12
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_with_use_instrument(self):
     cmd = UserCommands(use_instrument="test_package")
     assert cmd["!TEL.temperature"] < 9000
     assert len(cmd.yaml_dicts) == 7  # 3 yamls filenames + default
コード例 #13
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_see_if_theres_an_entry_on_the_server_log_file(self):
     cmds = UserCommands(use_instrument="test_package")
コード例 #14
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_updates_with_yaml_dict(self):
     yaml_input = {"alias": "TEL", "properties": {"temperature": 8999}}
     cmd = UserCommands(use_instrument="test_package")
     cmd.update(yamls=[yaml_input])
     assert cmd["!TEL.temperature"] < 9000
コード例 #15
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_when_passed_a_list_of_yaml_names(self):
     cmd = UserCommands(packages=["test_package"],
                        yamls=["test_telescope.yaml"])
     assert cmd["!TEL.temperature"] > 9000
コード例 #16
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialise_with_nothing(self):
     assert isinstance(UserCommands(), UserCommands)
コード例 #17
0
ファイル: test_UserCommands.py プロジェクト: yosata/ScopeSim
 def test_initialised_when_passed_a_dict_of_properties(self):
     cmd = UserCommands(properties={"!OBS.dit": 60, "!ATMO.pwv": 9001})
     assert cmd["!ATMO.pwv"] > 9000