Open itroitskaya opened 11 months ago
Hi there!
I believe the error you've run into may be stemming from NaN values somewhere in the flux array.
As a quick test, in the gollum source code, try going to phoenix.py
line 302, and try changing np.percentile
to np.nanpercentile
, and see if that fixes the issue.
Thanks.
I've checked the data, and it turned out that I've mixed up the wavelength units and PHOENIXSpectrum
returned empty flux and wavelength arrays with these wrong limits. It may be beneficial in phoenix.py:192
to check not only grid_points
, but wavelengths
and fluxes
as well.
However, I've encountered additional problems.
First, there was an "Data should overlap the models, double check your wavelength limits."
assert fail.
The limits were wl_lo = 3850.128, wl_hi = 3925.986
and new_lo: 3850.122160382083, new_hi: 3925.9863831754383
As these were taken directly from the data and Spectrum1D
object, they look like a rounding error. What's the best way to deal with it?
Next, I've commented out the assertion, and got the following error
File "/Users/uqitroit/Dev/gollum/src/gollum/phoenix.py", line 343, in create_interact_ui
legend_label=data.meta["header"]["OBJECT"],
KeyError: 'header'
Looks like it is trying to access the header of the Spectrum1D
object, which does not have one.
What can I do next?
With regard to the first assertion fail, the PHOENIX dashboard requires the following ordering of wavelength limits: wl_lo < new_lo < new_hi < wl_hi
, meaning that your current limits just barely throw the error. The assert message may not have communicated this requirement clearly enough.
For the header error, currently the dashboard assumes that the data spectrum has an object name stored in its metadata. In hindsight, this is a little brittle.
I've pushed a patch that makes the error message clearer, and no longer breaks when there is no object name in metadata. You will have to either shrink your object's wavelength range or expand the grid's wavelength range, to satisfy the above inequality, and things should work then.
(Edit) Sorry I forgot to address this one initially! We are aware of the inconsistencies with inputting units other than Angstroms into the PHOENIXSpectrum/PHOENIXGrid constructors, and are working on those changes. Until the update for this has been implemented, we ask that you input all values as Angstroms.
If you run into anything else, please let us know!
Thanks for the update. Regarding the assert, I am a bit confused as to how the limits are being set and how should I fix my code for it to work. So currently I have the following code. Spectrum is generated from data, and grid is generated from spectrum. I don't manually set the limits anywhere.
bdss_spectrum = Spectrum1D(spectral_axis=data['wavelen'][0]*u.angstrom, flux=data['flux'][0]*u.ct)
wl_lo, wl_hi = (bdss_spectrum.wavelength.value.min(), bdss_spectrum.wavelength.value.max())
grid = PHOENIXGrid(wl_lo=wl_lo, wl_hi=wl_hi, path=data_path)
print(f'data: {data["wavelen"].min()} - {data["wavelen"].max()}')
print(f'spectrum: {bdss_spectrum.wavelength.value.min()} - {bdss_spectrum.wavelength.value.max()}')
print(f'grid: {grid.wavelength.value.min()} - {grid.wavelength.value.max()}')
data: 3850.122160382083 - 3925.9863831754383
spectrum: 3850.122160382083 - 3925.9863831754383
grid: 3850.128 - 3925.986
if I do grid = PHOENIXGrid(wl_lo=wl_lo-1, wl_hi=wl_hi+1, path=phoenix_path)
, then the dashboard is displayed, but I feel that's maybe not the best solution.
For those limits, the intuition was that since we have rotational broadening functionality, if we had the PHOENIXGrid have the exact same wavelength axis as the data spectrum, you would see edge effects creeping in from the sides as the convolution did its thing, which would not be desirable to users.
To prevent this, we enforce the inequalities such the wavelength axis of the data must lie within that of the grid. Providing an ample buffer on either side will hide edge effects such that they do not visually propagate into the region in which the data spectrum lies.
In light of that, the last solution you presented is actually probably the way to go, although we recommend a buffer more like 50 Angstroms on either side if I remember correctly.
Something like
buffer = 50
grid = PHOENIXGrid(wl_lo=wl_lo-buffer, wl_hi=wl_hi+buffer, path=phoenix_path)
should work, and is the intended use when dealing with data.
Welcome @itroitskaya ! 👋 Thank you for your interest in using gollum
!
We promise the dashboard is really great and intuitive once you getting working so thank you for your patience in working around some of the friction points and hardcode. @SujayShankarUT's guidance is correct and should get you up-and-running.
We value your feedback, and so if you're okay if it we'd love to have your feedback on how we can improve the dashboard. We will use this bug report to make some more usability improvements, so please do report your experiences, either positive or negative, with the code.
Thanks again!
Hi Gully, I am a PhD student working with @benjaminpope the The University of Queensland. I am trying to use interactive fitting with PHOENIX dashboard and get this error during
grid.show_dashboard
. Could you please have a look?