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

Frequencies and wavelengths in output spectra refer to bin edges, not centers #1132

Open
lazygun37 opened this issue Dec 10, 2024 · 0 comments

Comments

@lazygun37
Copy link
Collaborator

We create spectra on grids spaced linear in frequency (or log-frequency). Most of the relevant code is in spectra.c. These grids are created via code like:

freqmin = f1;
freqmax = f2;
dfreq = (freqmax - freqmin) / NWAVE_NOW;

When we populate the spectra, we do that by calculating the index of the bin in which to add a photon via

k = (int) ((p[nphot].freq - freqmin) / dfreq);

When we write out the spectra, the frequencies (and associated wavelengths) we print are calculated via

freq = freqmin + i * dfreq;

Here, i is the integer counter of the loop over all bins.

What that means is that we actually print out the lower edge of each frequency bin, not its center.

What I think we should really write out is

freq = freqmin + (i + 0.5) * dfreq;

Not a big deal in general, but it means our spectra are all shifted by half a frequency bin at the moment.

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

No branches or pull requests

1 participant