sbird/fake_spectra

Understand distribution of velocities

Closed this issue · 6 comments

I took one of the Gadget3 sims and made a histogram of line of sight velocities (weighted by density), on each of the three possible axes. The relevant lines of code are:
vel=spec.get_velocity(elem='H',ion=-1)
(pdf,bins)=np.histogram(vel,bins=101,density=True)
bins=(bins[1:] + bins[:-1])/2.
plt.plot(bins,pdf,label=label)

The plot I obtain is attached. Solid lines show positive velocities, and dashed lines show negative velocities, in the three axes. There are two interesting issues:

  • there is a spike at v=0, that I guess is related to being a density weighted velocity? Since we have cells with density=0, probably the code reports velocity=0 for those.
  • there is an asymmetry between v>0 and v<0. I have NO IDEA what could cause this, and it pretty much looks like a potential bug in the code...

velocity_test_z3 0

sbird commented

I'm having difficulty reading the labels - is it true that x,y,z are all identical, even for v<0 ?

They are not quite identical, but they do look extremely similar in this plot. If I look, for instance, at the minimum, mean, and maximum value of the velocity in each of the axes (for a smaller sample), I get the following:
x: min = -74.1074, mean = -0.00549138, max = 99.0607
y: min = -80.4283, mean = -0.00141564, max = 74.0861
z: min = -78.0453, mean = -0.00507216, max = 74.547

sbird commented

Ok, thanks - that fortunately rules out an indexing error somewhere!

sbird commented

At least, it rules out one type of indexing error

sbird commented

Hmmm - what spectra are you using? When I try and reproduce this I get an asymmetry indeed, but it has a different sign depending on which axis I use, which suggests to me it is just a statistical fluctuation

sbird commented

Also, look at the distribution of the raw velocities in the snapshot - they are also slightly asymmetric, but by differing amounts for each axis. I think this might just be an artefact of the box being small.