<p>I have M_UV(absolute UV magnitudes) and redshifts of some high z sources and I want to fit UVLF for them.</p>
<pre><code>data = [
    {&quot;ID&quot;: &quot;SM-z12-1&quot;, &quot;z_phot&quot;: 12.47, &quot;M_UV&quot;: -18.5},
    {&quot;ID&quot;: &quot;GL-z12-1&quot;, &quot;z_phot&quot;: 12.28, &quot;M_UV&quot;: -21.0},
    {&quot;ID&quot;: &quot;CR2-z12-1&quot;, &quot;z_phot&quot;: 11.63, &quot;M_UV&quot;: -19.9},
    {&quot;ID&quot;: &quot;CR2-z12-2&quot;, &quot;z_phot&quot;: 11.96, &quot;M_UV&quot;: -19.0},
    {&quot;ID&quot;: &quot;CR2-z12-3&quot;, &quot;z_phot&quot;: 11.66, &quot;M_UV&quot;: -19.2},
    {&quot;ID&quot;: &quot;CR2-z12-4&quot;, &quot;z_phot&quot;: 12.08, &quot;M_UV&quot;: -19.2},
    {&quot;ID&quot;: &quot;CR3-z12-1&quot;, &quot;z_phot&quot;: 11.05, &quot;M_UV&quot;: -18.4},
    {&quot;ID&quot;: &quot;S5-z12-1&quot;, &quot;z_phot&quot;: 12.58, &quot;M_UV&quot;: -20.2}
]
</code></pre>
<p>data from paper <a href="https://iopscience.iop.org/article/10.3847/1538-4365/acaaa9/pdf" rel="nofollow noreferrer">https://iopscience.iop.org/article/10.3847/1538-4365/acaaa9/pdf</a>
I have put the completeness as 1 for easiness</p>
<p>I divided the magnitude into bins of 0.5 , then calculated the number of galaxies within that bin.
Then calculated the co moving volume by using asrtopy.cosmology_comoving_volume(z), where z is the redshift of the sources.</p>
<p>Since i put completeness as 1, I can put the Veff as the comoving volume itself(according to the below equation)
<a href="https://i.sstatic.net/9QmCe42K.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9QmCe42K.png" alt="enter image description here" /></a></p>
<p>Then I want to calculate the space number density as ,</p>
<p><a href="https://i.sstatic.net/WiUuUobw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WiUuUobw.png" alt="enter image description here" /></a></p>
<p>I have done this in terms of the M_UV absolute magnitude (And not the apparent magnitude).
And then I plotted the LF and it looked like ,</p>
<p><a href="https://i.sstatic.net/7oEfuY1e.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7oEfuY1e.png" alt="![enter image description here" /></a></p>
<p>which doesn't seem a good one as the y range is in the order of 10^-13.</p>
<p>The plot I have from a paper is ,</p>
<p><a href="https://i.sstatic.net/itDItkuj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/itDItkuj.png" alt="enter image description here" /></a></p>
<p>which has the y lim in the range of 10^-6.</p>
<p>Can somebody help me in figuring out where could have it gone wrong. I tried changing the bin size and it changes the shape of the LF but not the range of y that occur.</p>
<p>Am I following the correct method to plot the Luminosity function</p>

CC BY-SA 4.0
2024-08-28T09:04:06.030Z
I can only say that at first glance, the orders of magnitude on the y-axis are quite different from those in the article—there might have been a numerical error. This happens quite often. While you're waiting for a more detailed response here, try checking all the units of measurement you've used (conversion to megaparsecs, etc.). You'll get it sorted!
Stephan Panarin
CC BY-SA 4.0
2024-08-28T10:48:12.893Z
I have used astropy.cosmology comoving_volume which takes input redshift value and gives output volume in Mpc^3.
Walker
CC BY-SA 4.0
2024-08-28T12:18:31.357Z
Have you perhaps misunderstood what `comoving_volume()` does? The function takes a single redshift `z` and calculates the total volume of the spherical part of the Universe that is centered on us and has a surface at a distance given by the input redshift `z`. In contrast, the volume that you want for your LF is the volume probed by the survey in which the galaxies are found. That volume is given by 1) the depth that you probe which is given by the min. and max. $z$ that your filter is sensitive to, converted to Mpc, and 2) the area that your detector covers (in ΔRA and Δdec, converted to Mpc.
pela
CC BY-SA 4.0
2024-08-28T12:22:49.390Z
Note that your galaxies are taken from different surveys, with different volumes.
pela
CC BY-SA 4.0
2024-08-29T03:40:05.087Z
may I know how I can calculate the depth from the redshift values
Walker
CC BY-SA 4.0
2024-08-29T06:48:31.237Z
Like I wanted to know the real implication of LF . In a sense that I have the magnitude and number of galaxies within a magnitude bin , now i need to divide by the volume to get the space number density. Taking the case of CEERS field the area can be calculated by 'total_area_sr = naxis1 * naxis2 * pixar_sr' right ? And then in square degrees as 'area_deg2 = total_area_sr * (180**2 / math.pi**2)' . How can I convert this into area in Mpc and also how to proceed with the depth calculation.
Walker
CC BY-SA 4.0
2024-08-31T15:02:58.563Z
@pela  could you please elaborate.
Walker
CC BY-SA 4.0
2024-08-31T16:15:32.863Z
Sorry, didn't notice your first comments. Yes, each object is observed in a volume of space. Table 1 in the paper shows you the area in arcmin$^2$. A solid angle covers an area in space that depends on how far away you look. Astropy's `kpc_comoving_per_arcmin()` can convert a _linear_ angle to kpc. For the depth, you must estimate the min. and max. redshift that a galaxy of a given $M_\mathrm{UV}$ can have in order to appear in a given survey. This will depend on the exact filters used (and the exact filter shape, on the SED fitting algorithm, and more), but it's probably fair to say…
pela
CC BY-SA 4.0
2024-08-31T16:19:16.430Z
…that $\Delta z \sim 1$. That means that a given survey's volume starts at $z\sim11.5$ and ends at $z\sim12.5$. Astropy's `comoving_distance()` can tell you the distances to these redshifts, so subtracting gives you the depth, and multiplying by the area gives you the volume that each galaxy is observed in.
pela
CC BY-SA 4.0
2024-09-01T09:03:26.010Z
@pela Thanks for the comments. So I have to calculate volume for each galaxy , which means each galaxy will be at different volume(since we put different value of z for calcualting area) and if so how will I plot the LF since we have to divide the counts by the volume to get the number denisty.  Or should we use z=12 for  area calculation and then proceed to get a volume and then use that volume to divide the counts to get the number density ?
Walker
CC BY-SA 4.0
2024-09-01T09:03:53.523Z
I saw another way in which differential_comoving_volume() in astropy which is integrated in the desired redshift range(here 11.5 to 12.5 ) could be multiplied by area in sr to get  volume
(volume  = quad(lambda z: cosmo.differential_comoving_volume(z).value, z_min, z_max)[0] * area_sr). is this method correct ?
Walker
CC BY-SA 4.0
2024-09-02T12:27:32.400Z
@Walker It depends on how accurate you want. For a first-order result, I think it would make sense to say that you surveyed five different volumes for the same type of galaxies, so that you can simply add the volumes, count how many galaxies you have in a given Muv bin, and divide by bin size and total volume. The Δz ~ 1 might be too small though. Perhaps Δz = 2 is more appropriate. Harikane+ seem to use 4 bins with dMuv = 1 (disregarding the two empty bins) starting at Muv = –21.7. The bin centers are thus at [–21.2, –20.2, –19.2, –18.2]. That gives 1, 2, 3, and 2 galaxies in…
pela
CC BY-SA 4.0
2024-09-02T12:32:21.450Z
…these bins. Dividing by volume (and by dMuv = 1) gives number densities in the right ballpark for the first three bins, but for the Muv = –18.2±0.5 bin, the number drops (i.e. N = 2), whereas their figure has a higher density. I don't know why, but perhaps one or more of the volumes isn't complete, so that the effective volume is smaller, and the density higher.
pela
CC BY-SA 4.0
2024-09-02T12:38:37.180Z
Regarding the `differential_comoving_volume()` that can also be used, and is in fact more precise, because it would allow you to weigh the volume by galaxy brightness. This is in principle important because in reality the volume is a function of Muv: Because filters don't have exact top-hat response curves, but taper off at the edges, bright galaxies can be detected even if they lie at a redshift corresponding to the edge of a filter, whereas fainter galaxies are only detected if the lie in the wavelength region where the filter is most efficient. But you can ignore this effect to first order.
pela
<photometry><luminosity><hubble-telescope><james-webb-space-telescope>
Luminosity function calculation
Walker
# Luminosity function calculation

(Asked by: username_0 on 2024-08-28)

I have M_UV(absolute UV magnitudes) and redshifts of some high z sources and I want to fit UVLF for them.
data = [
    {"ID": "SM-z12-1", "z_phot": 12.47, "M_UV": -18.5},
    {"ID": "GL-z12-1", "z_phot": 12.28, "M_UV": -21.0},
    {"ID": "CR2-z12-1", "z_phot": 11.63, "M_UV": -19.9},
    {"ID": "CR2-z12-2", "z_phot": 11.96, "M_UV": -19.0},
    {"ID": "CR2-z12-3", "z_phot": 11.66, "M_UV": -19.2},
    {"ID": "CR2-z12-4", "z_phot": 12.08, "M_UV": -19.2},
    {"ID": "CR3-z12-1", "z_phot": 11.05, "M_UV": -18.4},
    {"ID": "S5-z12-1", "z_phot": 12.58, "M_UV": -20.2}
]

data from paper https://iopscience.iop.org/article/10.3847/1538-4365/acaaa9/pdf
I have put the completeness as 1 for easiness
I divided the magnitude into bins of 0.5 , then calculated the number of galaxies within that bin.
Then calculated the co moving volume by using asrtopy.cosmology_comoving_volume(z), where z is the redshift of the sources.
Since i put completeness as 1, I can put the Veff as the comoving volume itself(according to the below equation)

Then I want to calculate the space number density as ,

I have done this in terms of the M_UV absolute magnitude (And not the apparent magnitude).
And then I plotted the LF and it looked like ,

which doesn't seem a good one as the y range is in the order of 10^-13.
The plot I have from a paper is ,

which has the y lim in the range of 10^-6.
Can somebody help me in figuring out where could have it gone wrong. I tried changing the bin size and it changes the shape of the LF but not the range of y that occur.
Am I following the correct method to plot the Luminosity function

**Tags:** photometry, luminosity, hubble-telescope, james-webb-space-telescope

> **Comments:**
> **username_1**: I can only say that at first glance, the orders of magnitude on the y-axis are quite different from those in the article—there might have been a numerical error. This happens quite often. While you're waiting for a more detailed response here, try checking all the units of measurement you've used (conversion to megaparsecs, etc.). You'll get it sorted!  
> **username_0**: I have used astropy.cosmology comoving_volume which takes input redshift value and gives output volume in Mpc^3.  
> **username_2**: Have you perhaps misunderstood what `comoving_volume()` does? The function takes a single redshift `z` and calculates the total volume of the spherical part of the Universe that is centered on us and has a surface at a distance given by the input redshift `z`. In contrast, the volume that you want for your LF is the volume probed by the survey in which the galaxies are found. That volume is given by 1) the depth that you probe which is given by the min. and max. $z$ that your filter is sensitive to, converted to Mpc, and 2) the area that your detector covers (in ΔRA and Δdec, converted to Mpc.  
> **username_2**: Note that your galaxies are taken from different surveys, with different volumes.  
> **username_0**: may I know how I can calculate the depth from the redshift values  
> **username_0**: Like I wanted to know the real implication of LF . In a sense that I have the magnitude and number of galaxies within a magnitude bin , now i need to divide by the volume to get the space number density. Taking the case of CEERS field the area can be calculated by 'total_area_sr = naxis1 * naxis2 * pixar_sr' right ? And then in square degrees as 'area_deg2 = total_area_sr * (180**2 / math.pi**2)' . How can I convert this into area in Mpc and also how to proceed with the depth calculation.  
> **username_0**: @username_2  could you please elaborate.  
> **username_2**: Sorry, didn't notice your first comments. Yes, each object is observed in a volume of space. Table 1 in the paper shows you the area in arcmin$^2$. A solid angle covers an area in space that depends on how far away you look. Astropy's `kpc_comoving_per_arcmin()` can convert a _linear_ angle to kpc. For the depth, you must estimate the min. and max. redshift that a galaxy of a given $M_\mathrm{UV}$ can have in order to appear in a given survey. This will depend on the exact filters used (and the exact filter shape, on the SED fitting algorithm, and more), but it's probably fair to say…  
> **username_2**: …that $\Delta z \sim 1$. That means that a given survey's volume starts at $z\sim11.5$ and ends at $z\sim12.5$. Astropy's `comoving_distance()` can tell you the distances to these redshifts, so subtracting gives you the depth, and multiplying by the area gives you the volume that each galaxy is observed in.  
> **username_0**: @username_2 Thanks for the comments. So I have to calculate volume for each galaxy , which means each galaxy will be at different volume(since we put different value of z for calcualting area) and if so how will I plot the LF since we have to divide the counts by the volume to get the number denisty.  Or should we use z=12 for  area calculation and then proceed to get a volume and then use that volume to divide the counts to get the number density ?  
> **username_0**: I saw another way in which differential_comoving_volume() in astropy which is integrated in the desired redshift range(here 11.5 to 12.5 ) could be multiplied by area in sr to get  volume (volume  = quad(lambda z: cosmo.differential_comoving_volume(z).value, z_min, z_max)[0] * area_sr). is this method correct ?  
> **username_2**: @username_0 It depends on how accurate you want. For a first-order result, I think it would make sense to say that you surveyed five different volumes for the same type of galaxies, so that you can simply add the volumes, count how many galaxies you have in a given Muv bin, and divide by bin size and total volume. The Δz ~ 1 might be too small though. Perhaps Δz = 2 is more appropriate. Harikane+ seem to use 4 bins with dMuv = 1 (disregarding the two empty bins) starting at Muv = –21.7. The bin centers are thus at [–21.2, –20.2, –19.2, –18.2]. That gives 1, 2, 3, and 2 galaxies in…  
> **username_2**: …these bins. Dividing by volume (and by dMuv = 1) gives number densities in the right ballpark for the first three bins, but for the Muv = –18.2±0.5 bin, the number drops (i.e. N = 2), whereas their figure has a higher density. I don't know why, but perhaps one or more of the volumes isn't complete, so that the effective volume is smaller, and the density higher.  
> **username_2**: Regarding the `differential_comoving_volume()` that can also be used, and is in fact more precise, because it would allow you to weigh the volume by galaxy brightness. This is in principle important because in reality the volume is a function of Muv: Because filters don't have exact top-hat response curves, but taper off at the edges, bright galaxies can be detected even if they lie at a redshift corresponding to the edge of a filter, whereas fainter galaxies are only detected if the lie in the wavelength region where the filter is most efficient. But you can ignore this effect to first order.  

---

## 0 answers

