Sitelet https://github.com/AstarVienna/ScopeSim/pull/1037
Skip to content

Move spline calculation outside the for loop, reducing runtime by 25%. - #1037

Open
hugobuddel wants to merge 1 commit into
mainfrom
move-splines
Open

hugobuddel wants to merge 1 commit into
mainfrom
move-splines

Conversation

@hugobuddel

@hugobuddel hugobuddel commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

I've timed this with a small script:

import scopesim
cmd = scopesim.UserCommands(use_instrument="METIS", set_modes=["wcu_lms"])
cmd["!SIM.random.seed"] = 1234
metis = scopesim.OpticalTrain(cmd)
metis['wcu_source'].set_lamp('laser')
metis.observe()
metis.readout("test.fits")

and that goes from about 160 seconds to 125 seconds.

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.85%. Comparing base (4ed185b) to head (7b0eb4e).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
scopesim/effects/metis_lms_trace_list.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
- Coverage   74.87%   74.85%   -0.02%     
==========================================
  Files          70       70              
  Lines        9003     9005       +2     
==========================================
  Hits         6741     6741              
- Misses       2262     2264       +2     
Flag Coverage Δ
offline 72.54% <0.00%> (-0.02%) ⬇️
webtests 29.89% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@teutoburg teutoburg added spectroscopy Related to spectroscopic modes performance Execution speed or memory consumtion labels Sep 25, 2026
@teutoburg teutoburg moved this to 👀 Awaiting Review in ScopeSim-development Sep 25, 2026
@hugobuddel

Copy link
Copy Markdown
Collaborator Author

Drafted, because I'm not sure this is the right approach. We could also do #1038, which is even better, and makes this redundant, but is perhaps too complex. What do you think?

@hugobuddel

Copy link
Copy Markdown
Collaborator Author

As discussed in #1038 (comment) it would be better to use an explicit interpolation, which would make this P.R. kinda redundant. But in the meantime, I think we can still merge this, as this change is not too invasive. But I'm also fine with closing this. I'll unwip it.

@hugobuddel
hugobuddel marked this pull request as ready for review September 27, 2026 08:34
@teutoburg

Copy link
Copy Markdown
Contributor

I'm slightly worried about the "0 % patch coverage" here. While coverage itself has limited utility as a measure, if the affected code is not covered by anything, that's a bit concerning...

I also realize it's maybe hard to test the LMS, but the "basic_instrument" should have an IFU mode.

@oczoske oczoske left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is quite harmless and only repairs a stupid loop nesting. The additional memory requirement for keeping the list spatial_interps should be manageable. Explicit interpolation can be implemented once this PR is merged, modifying l.120 (new) instead of l.136 (old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Execution speed or memory consumtion spectroscopy Related to spectroscopic modes

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

3 participants