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

Accept both pre-v0.9 and current ScopeSim versions #91

Merged
merged 1 commit into from
Aug 30, 2024
Merged

Conversation

teutoburg
Copy link
Contributor

Bit of a hack, but ensures (hopefully) that tests pass and things work both before and after AstarVienna/ScopeSim#405.

In the neat future we should update the requirements in ScopeSim_Templates and make a v0.5.3 release that uses ScopeSim v0.8.4 and a v0.6.0 release that requires ScopeSim v0.9.x or something along those lines...

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.51%. Comparing base (c979f48) to head (57d067d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
- Coverage   73.53%   73.51%   -0.02%     
==========================================
  Files          30       30              
  Lines        1485     1484       -1     
==========================================
- Hits         1092     1091       -1     
  Misses        393      393              

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

@teutoburg teutoburg merged commit 56e6c8e into main Aug 30, 2024
18 checks passed
@teutoburg teutoburg deleted the fh/fixv09 branch August 30, 2024 10:20
Comment on lines +279 to +297
srcs = []
for i in range(img_ext, spec_ext):
w, h = hdulist[i].data.shape
hdulist[i].header["CRPIX1"] = (w + 1) / 2,
hdulist[i].header["CRPIX2"] = (h + 1) / 2,
hdulist[i].header["CRVAL1"] = 0
hdulist[i].header["CRVAL2"] = 0
hdulist[i].header["CDELT1"] = extent / w
hdulist[i].header["CDELT2"] = extent / w
hdulist[i].header["CUNIT1"] = "deg"
hdulist[i].header["CUNIT2"] = "deg"
hdulist[i].header["CTYPE1"] = "RA---TAN"
hdulist[i].header["CTYPE2"] = "DEC--TAN"
# hdulist[i].header["SPEC_REF"] = hdulist[i].header["SPEC_EXT"] - spec_ext

i_spec_ext = spec_ext - img_ext + i
srcs.append(Source(image_hdu=hdulist[i],
spectra=[hdu_to_synphot(hdulist[i_spec_ext])]))
src = sum(srcs[1:], start=srcs[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this code is now making better use of the ScopeSim Source interface, it is still rather ugly. Having nice(r) code here is important, because this code also doubles as 'this is a good way to create a Source from an image'-documentation.

In particular, the src = Source() and then src.append(...) is way more clear than the srcs = [], srcs.append(...) and subsequently this ugly sum() line.

The for i in range() is also a bit ugly. Would it be feasible to replace that with an iterator? E.g. for img_hdu, spec_hdu in zip(hdulist[img_ext:spec_ext], hdulist[spec_ext:]):?

Perhaps not worthwhile to make this change now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I made this rather hastily because things were broken (in hacking into the source fields directly). Not sure though how flexible we need this code to be, i.e. the structure of this particular fits file will not change, yet we dynamically create the source parts (HDU and spectrum), which seems a bit overkill here. So either we refactor this into a separate function that truly dynamically deals with such fits files and then the spiral two components is basically a wrapper for that. Or we could just say this fits file will never change anyway and hardcode the number of extensions in there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants