diff --git a/DREAMS.yaml b/DREAMS.yaml index 65d72c8..7cfd523 100644 --- a/DREAMS.yaml +++ b/DREAMS.yaml @@ -18,6 +18,11 @@ effects: description : Schoepfl PSF class : SeeingPSF kwargs : + # Original PSF FWHM: + #fwhm : 1.5. # [arcsec] + # The original PSF about the size of a pixel. + # This does not work well in ScopeSim currently. + # Therefore, the PSF is arbitrarily resized: fwhm : 1.5 # [arcsec] - name : skycalc_average_atmo description : atmospheric properties for a default skycalc run @@ -44,4 +49,10 @@ effects: filename_format: "filters/J.dat" minimum_throughput: !!float 1.01E-4 outer: 0.05088 - outer_unit: "m" \ No newline at end of file + outer_unit: "m" + +# ExtraFitsKeywords class to prevent the default headers to be saved. +- name: fits_headers + description: FITS headers + class: ExtraFitsKeywords + include: True diff --git a/dreams.detector2.fits b/dreams.detector2.fits new file mode 100644 index 0000000..1daf4a8 Binary files /dev/null and b/dreams.detector2.fits differ diff --git a/dreams.png b/dreams.png new file mode 100644 index 0000000..7d3a3ee Binary files /dev/null and b/dreams.png differ diff --git a/J.dat b/filters/J.dat similarity index 100% rename from J.dat rename to filters/J.dat diff --git a/testt.py b/testt.py index 62289df..3c073c1 100644 --- a/testt.py +++ b/testt.py @@ -9,6 +9,7 @@ from scopesim import rc from scopesim.source.source_templates import star_field import scopesim_templates as sim_tp +from scopesim.optics.fov_manager import FOVManager PLOTS = True @@ -37,18 +38,43 @@ def test_scopesim_loads_package(self): class TestObserves: def test_something_comes_out(self): print("Starting observation test...") - src = star_field(10000, 10, 20, width=700) + + # Setting the width to 10000 arcsec makes the field fill the image. + # A with of 700 works as well, but covers only a fraction of the + # middle two detectors. + src = star_field(10000, 10, 20, width=10000) cmds = scopesim.UserCommands(use_instrument="DREAMS") cmds["!OBS.dit"] = 10 cmds["!DET.bin_size"] = 1 cmds["!OBS.sky.bg_mag"] = 14.9 cmds["!OBS.sky.filter_name"] = "J" + cmds["SIM.sub_pixel.flag"] = True dreams = scopesim.OpticalTrain(cmds) dreams["detector_linearity"].include = False - dreams.observe(src) - hdus = dreams.readout() + + # Hackish workaround to get a larger Field of View. + # This problem is fixed in https://github.com/AstarVienna/ScopeSim/pull/433 + # This hack can thus be removed once that is merged and a new + # ScopeSim version is released. + # First recreate the fov_manager without preloading the field of + # views with the wrong values. + dreams.fov_manager = FOVManager(dreams.optics_manager.fov_setup_effects, cmds=dreams.cmds, preload_fovs=False) + # Then make the initial field of view 10 times larges than normal. + dreams.fov_manager.volumes_list[0]["x_min"] = -18000 # arcsec + dreams.fov_manager.volumes_list[0]["x_max"] = 18000 + dreams.fov_manager.volumes_list[0]["y_min"] = -18000 + dreams.fov_manager.volumes_list[0]["y_max"] = 18000 + # Finally, shrink the field of view to the detector size. + dreams.fov_manager._fovs_list = list(dreams.fov_manager.generate_fovs_list()) + + # We now need to put update=False here, because otherwise the hacked + # fov_manager gets reinitialized. dreams can therefor only be used + # once, and needs to be recreated for the next simulation. + dreams.observe(src, update=False) + + hdus = dreams.readout("dreams.fits") print(f"Observation completed. HDUList type: {type(hdus[0])}") @@ -66,6 +92,14 @@ def test_something_comes_out(self): plt.ylabel("Y Pixels") plt.show() + detector_order = [2, 1, 4, 3, 6, 5] + plt.figure(figsize=(20, 20)) + for plot_number, hdu_number in enumerate(detector_order, 1): + plt.subplot(3, 2, plot_number) + plt.imshow(hdus[0][hdu_number].data, origin="lower", norm=LogNorm()) + plt.colorbar() + plt.show() + @pytest.mark.slow def test_observes_from_scopesim_templates(self): print("Starting scopesim templates observation test...")