Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MICADO notebook 3_scopesim_SCAO_4mas_fv-psf.ipynb is broken #161

Closed
hugobuddel opened this issue Mar 1, 2024 · 8 comments · Fixed by AstarVienna/ScopeSim#507
Closed
Labels
bug Something isn't working instrument-specific Limited to a certain IRDB instrument package validation Cross-checking results with references

Comments

@hugobuddel
Copy link
Collaborator

The MICADO notebook 3_scopesim_SCAO_4mas_fv-psf.ipynb is broken.

The notebook has a section called

!!! It appears

But nothing appears! This is the image I get:

itdoesnotappeartrimmed

@hugobuddel
Copy link
Collaborator Author

The direct cause of the weird image are these two lines:

micado.cmds["!DET.x"] = 10       # [arcsec]
micado.cmds["!DET.y"] = 10

The yellow part on the top right of the image does contain the cluster, but it is all washed out due to the limits.

Removing those two lines, or setting them to 0 does show the proper image.

@hugobuddel
Copy link
Collaborator Author

Short code to reproduce:

%matplotlib inline
import datetime
import shutil
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from astropy import units as u

import scopesim as sim
import scopesim_templates as sim_tp

cluster = sim_tp.cluster(mass=10000, core_radius=0.5, distance=8000)

fig, ax = plt.subplots()
ax.plot(cluster.fields[0]["x"], cluster.fields[0]["y"], ".")
ax.set_aspect('equal', 'datalim')

observation_dict = {
        "!OBS.mjdobs": datetime.datetime(2022, 1, 1, 2, 30, 0)
}

cmd = sim.UserCommands(
    use_instrument="MICADO",
    set_modes=["SCAO", "IMG_4mas"],
)
micado = sim.OpticalTrain(cmd)

micado.cmds["!OBS.dit"] = 600    # [s]
micado.cmds["!DET.x"] = 5       # [arcsec]
micado.cmds["!DET.y"] = 5


micado.observe(cluster)
hdus = micado.readout()

fig, ax = plt.subplots()
im = hdus[0][1].data
ax.imshow(im, origin="lower", norm=LogNorm(vmin=0.9*np.median(im), vmax=1.1*np.median(im)))
# plt.savefig("itdoesnotappear.png")

@hugobuddel
Copy link
Collaborator Author

The last time this seemed to have worked was in February 2022, see https://github.com/AstarVienna/irdb/commits/dev_master/MICADO/docs/example_notebooks/3_scopesim_SCAO_4mas_fv-psf.ipynb

@hugobuddel
Copy link
Collaborator Author

I don't have time to investigate this, and since it has been broken for so long, it is probably not urgent...

@teutoburg teutoburg added bug Something isn't working instrument-specific Limited to a certain IRDB instrument package validation Cross-checking results with references labels Mar 7, 2024
@teutoburg teutoburg moved this from 🆕 New to 📋 Backlog in ScopeSim-development Mar 7, 2024
@teutoburg
Copy link
Contributor

!!! It appears

But nothing appears! This is the image I get:

Huh, I looked at the output of this several times a few months back, but always assumed that's how it should look like and I'm just to stupid to understand what I'm looking at, and why. Intriguing.

@hugobuddel
Copy link
Collaborator Author

Maybe this will get fixed 'automatically' when we improve the FoV stuff as part of AstarVienna/ScopeSim#380 ?

For now I guess it would be good to change the notebook from saying that looking at an on-axis PSF is boring that looking off-axis does not actually work.

Maybe we should get @astronomyk 's opinion first, to get an idea what actually happened here.

@hugobuddel
Copy link
Collaborator Author

Discussing this in Waidhofen, apparently the ImagePlane assumes !DET.x is in arcsec, while the DetectorWindow assumes it is in mm, and they adjust the image_plane and detector_plane accordingly, causing a mismatch.

@hugobuddel
Copy link
Collaborator Author

While fixing the units, I noticed that the FieldVaryingPSF is the only PSF class that uses (and sets) fov.image in its apply_to method instead of fov.hdu.data. fov.image is not used elsewhere, so the FieldVaryingPSF does nothing..

It seems all these three attributes of FieldOfView should be ditched:

        self.cube = None        # 3D array for IFU, long-lit, Slicer-MOS
        self.image = None       # 2D array for Imagers
        self.spectrum = None    # SourceSpectrum for Fibre-fed MOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working instrument-specific Limited to a certain IRDB instrument package validation Cross-checking results with references
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants