log rebinning problems
See original GitHub issueHi again - getting to grips with power spectra now I’ve fixed the gti issue I had before. Run into a few new problems, mainly to do with log rebinning my resultant power spectrum. First thing I tried was following the tutorial:
lcurve = Lightcurve(time,fl, err=fl_e, input_counts=False, gti=gti, err_dist='poisson')
lc_rebinned = lcurve.rebin(8)
powspec = AveragedPowerspectrum(lc_rebinned, 2048, norm='frac')
log_rb_ps, log_rb_freq, binning = AveragedPowerspectrum.rebin_log(powspec,f=0.02)
but this comes up with the following error:
/Users/aarranshaw/anaconda/envs/astroconda/lib/python2.7/site-packages/stingray-0.1.dev1273-py2.7.egg/stingray/utils.py:244: ComplexWarning: Casting complex values to real discards the imaginary part x.astype(np.double), y.astype(np.double), /Users/aarranshaw/anaconda/envs/astroconda/lib/python2.7/site-packages/stingray-0.1.dev1273-py2.7.egg/stingray/utils.py:248: ComplexWarning: Casting complex values to real discards the imaginary part x.astype(np.double), y_err.astype(np.double), Traceback (most recent call last): File "test_pds.py", line 44, in <module> log_rb_ps, log_rb_freq, binning = AveragedPowerspectrum.rebin_log(powspec,f=0.02) TypeError: 'AveragedPowerspectrum' object is not iterable
Which is confusing.
Then I tried just using the rebin_data_log
function like so:
freq, power, err, binning = rebin_data_log(powspec.freq,powspec.power,0.02,y_err=powspec.power_err)
But the output gives me a frequency array with a length n+1
compared to the power array of length n
e.g.
print len(freq), len(power), len(err), len(binning)
43 42 42 42
Any idea what’s happening in either of these two cases? Are the frequencies output in the second case actually bin edges rather than centres? Or is it something else? Let me know if you need any of my data or my code to reproduce the error. Sorry again to bother you guys!
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (8 by maintainers)
Well, that was an easy fix. Yep, it looks like it works. I’ll keep poking around to make sure it’s doing it correctly, but I’m fairly certain that it is. Thank you @dhuppenkothen and @matteobachetti for this fix, you guys are the best!
Thanks for the reminder @rtanmay. Closing