question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

log rebinning problems

See original GitHub issue

Hi 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:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
aarranshawcommented, Nov 14, 2017

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!

0reactions
matteobachetticommented, Jan 22, 2018

Thanks for the reminder @rtanmay. Closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do these two logarithmic binning methods give different ...
I am working on a problem involving logarithmic binning. I have a dataset consisting of individuals that have a size value and a...
Read more >
Speaking Stata: Logarithmic Binning and Labeling
Here is a common problem. You look at a histogram of a highly positively skewed variable and realize that you would be better...
Read more >
Logarithimc binning - Physics Forums
Hello everybody, I have a problem with the logarithmic binning of some data (which are expected to be distributed as a power law)....
Read more >
The Do's and Dont's of data binning for distributional analysis.
The variable binning scheme consists of logarithmic binning up till the ... This is a purely mechanical problem that can be overcome by ......
Read more >
Problems with binning data - Dr Maggie Lieu
I learned early on in my PhD that binning is not a good idea. The loss of information from binning will lead to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found