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

Oc/line widths #213

Merged
merged 9 commits into from
Jun 13, 2023
Merged

Oc/line widths #213

merged 9 commits into from
Jun 13, 2023

Conversation

oczoske
Copy link
Collaborator

@oczoske oczoske commented May 31, 2023

  • XiLamImage now accepts a dispersion function dlam_per_pix instead of average avg_dlam_per_pix (a constant is still accepted)
  • The dispersion function is computed from the gradient of xy2lam in the dispersion direction.
  • The dispersion axis is taken from the trace definition file if available. Pull request Oc/dispersion direction irdb#102 implements that for METIS LSS, MICADO, OSIRIS LSS and MAAT.
  • If dispersion axis is not in the trace definition file it is determined automatically using the gradient method. The method that was intermittently implemented is not good ( Kl/bugfix/thin slit confusing dispersion direction #169 ).

@codecov
Copy link

codecov bot commented Jun 1, 2023

Codecov Report

Patch coverage: 79.16% and project coverage change: +0.10 🎉

Comparison is base (884e158) 75.13% compared to head (ca266fc) 75.23%.

Additional details and impacted files
@@              Coverage Diff               @@
##           dev_master     #213      +/-   ##
==============================================
+ Coverage       75.13%   75.23%   +0.10%     
==============================================
  Files             147      147              
  Lines           15181    15255      +74     
==============================================
+ Hits            11406    11477      +71     
- Misses           3775     3778       +3     
Impacted Files Coverage Δ
scopesim/effects/psfs.py 72.80% <ø> (ø)
scopesim/effects/spectral_trace_list.py 61.83% <50.00%> (ø)
scopesim/effects/spectral_trace_list_utils.py 73.31% <76.31%> (+0.07%) ⬆️
...esim/tests/tests_effects/test_SpectralTraceList.py 63.54% <100.00%> (+0.77%) ⬆️

... and 24 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@oczoske
Copy link
Collaborator Author

oczoske commented Jun 12, 2023

These changes yield correct line widths and should close issue #212. The example is for an unresolved line from a slit-filling source, observed with METIS LSS L-band and three slits. The dashed lines mark the respective slit widths.
METIS_LSS_L_line_cut

@oczoske oczoske marked this pull request as ready for review June 12, 2023 15:55
Copy link
Collaborator

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @oczoske for taking this on! I can mostly follow what is happening, so I only have two minor optional suggestions. Also thanks for cleaning up the file while you're at it.

@@ -134,7 +141,7 @@ def map_spectra_to_focal_plane(self, fov):
The method returns a section of the fov image along with info on
where this image lies in the focal plane.
"""

print("Mapping", fov.meta['trace_id'])
Copy link
Collaborator

@hugobuddel hugobuddel Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Mapping", fov.meta['trace_id'])
logging.info("Mapping %s", fov.meta['trace_id'])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be logging.info("Mapping %s", fov.meta["trace_id"]), logging functions take *args for the formatting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, nice, except that I don't see the message anymore (admittedly, it's purpose is to keep me awake by providing some progress info). I see that cmd['!SIM.logging.console_level'] is set to 'WARNING' (in scopesim's defaults.yaml, so I guess that would have to be changed explicitely. Do we have a policy on logging? I usually feel that scopesim is a bit too quiet when doing lengthy operations.
In any case, I adopt it with an associated reformulation of the warning on l.177.

@@ -457,12 +457,17 @@ def __init__(self, fov, dlam_per_pix):
# Initialise the array to hold the xi-lambda image
self.image = np.zeros((n_xi, n_lam), dtype=np.float32)
self.lam = cube_lam
try:
dlam_per_pix_val = dlam_per_pix(np.asarray(self.lam))
except TypeError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would this exception occur? XiLamImage is only initialized once in ScopeSim, earlier in this file. There dlam_per_pix is always set to the output of interp1d, which is always a function I think. So it seems this except block can be removed, which would clarify better what's going (perhaps with type hints on the parameters).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was meant to preserve the previous behaviour where dlam_per_pix was passed as just one number (the average dispersion). Although in the current implementation this should not occur, I wouldn't exclude that XiLamImage could be used in a different context in the future.

@oczoske oczoske merged commit f18a662 into dev_master Jun 13, 2023
8 checks passed
@oczoske oczoske deleted the oc/line_widths branch June 13, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants