Comments (3)
So originally I thought XSpec was failing due to the spectra generated by SAS, turns out it was actually failing due to the issue fixed in #942 (which was why I switched from the release version to the current github version) and me not properly removing my xga_output
files and xga just reusing the old XSpec scripts.
This caused the model fits to fail and the Spectrum.view()
method to fall-back to show_model_fits=False
behaviour. Just nuking every xga_ouput
file I could find on my system was enough to fix the code I was using to produce the expected output.
However, I still think there may be a problem with the Spectrum.view()
method as manually disabling the model fits with
sp.view(show_model_fits=False)
Still causes a negative xerr value for the errorbar plot.
I still wonder if this may be due to my SAS version but need someone else to test this...
from xga.
Thanks for writing this out so nicely Toby, and I'm sorry for the slow response, I've been very busy recently. I'm also coming across what sounds like the same problem in one of my spectral plots:
ValueError Traceback (most recent call last)
Cell In[4], line 5
3 for sp in src.get_spectra(src.r500):
4 print(sp.obs_id, sp.instrument)
----> 5 sp.view()
6 print('\n\n\n')
File /mnt/ufs18/home-218/turne540/code/XGA/xga/products/spec.py:1662, in Spectrum.view(self, figsize, lo_lim, hi_lim, back_sub, energy, src_colour, bck_colour, grouped, xscale, yscale, fontsize, show_model_fits, save_path)
1658 if not show_model_fits:
1659 # Plotting the data, accounting for the different combinations of x-axis and y-axis
1660 if back_sub:
1661 # If we're going for background subtracted data, then that is all we plot
-> 1662 plt.errorbar(x_dat, src_sub_bck_rate.value[:, 0] / per_x, xerr=x_wid,
1663 yerr=src_sub_bck_rate.value[:, 1] / per_x, fmt="+", color=src_colour,
1664 label="Background subtracted source data", zorder=1)
1665 else:
1666 # But if we're not wanting background subtracted, we need to plot the source and background spectra
1667 plt.errorbar(x_dat, src_rate.value[:, 0] / per_x, xerr=x_wid, yerr=src_rate.value[:, 1] / per_x, fmt="+",
1668 color=src_colour, label="Source data", zorder=1)
File ~/software/anaconda3/envs/xga_dev/lib/python3.9/site-packages/matplotlib/pyplot.py:2564, in errorbar(x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, data, **kwargs)
2558 @_copy_docstring_and_deprecators(Axes.errorbar)
2559 def errorbar(
2560 x, y, yerr=None, xerr=None, fmt='', ecolor=None,
2561 elinewidth=None, capsize=None, barsabove=False, lolims=False,
2562 uplims=False, xlolims=False, xuplims=False, errorevery=1,
2563 capthick=None, *, data=None, **kwargs):
-> 2564 return gca().errorbar(
2565 x, y, yerr=yerr, xerr=xerr, fmt=fmt, ecolor=ecolor,
2566 elinewidth=elinewidth, capsize=capsize, barsabove=barsabove,
2567 lolims=lolims, uplims=uplims, xlolims=xlolims,
2568 xuplims=xuplims, errorevery=errorevery, capthick=capthick,
2569 **({"data": data} if data is not None else {}), **kwargs)
File ~/software/anaconda3/envs/xga_dev/lib/python3.9/site-packages/matplotlib/init.py:1442, in _preprocess_data..inner(ax, data, *args, **kwargs)
1439 @functools.wraps(func)
1440 def inner(ax, *args, data=None, **kwargs):
1441 if data is None:
-> 1442 return func(ax, *map(sanitize_sequence, args), **kwargs)
1444 bound = new_sig.bind(ax, *args, **kwargs)
1445 auto_label = (bound.arguments.get(label_namer)
1446 or bound.kwargs.get(label_namer))
File ~/software/anaconda3/envs/xga_dev/lib/python3.9/site-packages/matplotlib/axes/_axes.py:3642, in Axes.errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)
3639 res = np.zeros(err.shape, dtype=bool) # Default in case of nan
3640 if np.any(np.less(err, -err, out=res, where=(err == err))):
3641 # like err<0, but also works for timedelta and nan.
-> 3642 raise ValueError(
3643 f"'{dep_axis}err' must not contain negative values")
3644 # This is like
3645 # elow, ehigh = np.broadcast_to(...)
3646 # return dep - elow * ~lolims, dep + ehigh * ~uplims
3647 # except that broadcast_to would strip units.
3648 low, high = dep + np.row_stack([-(1 - lolims), 1 - uplims]) * err
ValueError: 'xerr' must not contain negative values
Disabling the model fits actually triggers an entirely separate plotting mechanism, which is why you see the error there and not when you've fit the model. It shouldn't be to do with your SAS version, and I'll try to sort it out today.
from xga.
This issue should now be corrected, and the fix has been merged into master.
from xga.
Related Issues (20)
- Brightness profiles still have stupid radius values and errors
- Maybe add a nice for model instances to show their fitted parameters
- Add an inverted power law model to enable simple flipping of scaling relations
- An XMM + eROSITA sample is assigning an XMM image to the wrong source (it doesn't have that ObsID) HOT 8
- Getting an argument list too long error from spectrum generation HOT 4
- Overdensity radius measurement system (a la hydrostatic mass profile method) for the gas mass profiles HOT 3
- Instrument not associated error being raised when assigning spec results to spectra HOT 2
- Tx and Lx get methods should except any product not available errors
- Timeout warnings for XSPEC fits should be lumped together and given at the end
- BaseSample nHs calls np.Quantity for some reason
- Why have a separate _shape attribute in Image - just dynamically get it from _data??
- Used Euclidean rather than Haversine distance in the offset calculation in 'offset' method of BaseSource
- Implement the LoVoCCS centroid measurements actually in XGA (rather than in a notebook) when I'm happy they are as automated as possible
- Review ClusterSample name checking and why I'm doing it
- Not sure radii-based retrieval of combined projected met profiles works
- Unintended behaviour - profiles have save_view() but aggregate profiles still has save_path argument in view
- Duplicate events in different eRASS Obs_IDS HOT 8
- Change the name of the LT pipeline in XGA
- get_interloper_mask(telescope='erosita') returns unhelpful error
- Retrieving existing SB/dens profiles is very hit or miss
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xga.