ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_cosmicRate::getLogRateDensityB10 Interface Reference

Generate and return the unnormalized Comoving LGRB Formation Rate (LGFR) density for a given redshift \(z\) based on the Metallicity-corrected estimates of Butler et al. (2010): B10, assuming a piecewise power-law LGFR model. More...

Detailed Description

Generate and return the unnormalized Comoving LGRB Formation Rate (LGFR) density for a given redshift \(z\) based on the Metallicity-corrected estimates of Butler et al. (2010): B10, assuming a piecewise power-law LGFR model.

The model of B10 is based on the Poweto distribution Star Formation Rate (SFR) model proposed by Hopkins and Beacom (2006).

\begin{equation} \end{equation}

Parameters
[in]logzplus1: The input scalar or contiguous array of arbitrary rank of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128) containing the natural logarithm of the redshift plus one, \(\log(z+1)\), at which the formation rate density must be computed.
Returns
logRateDensity : The output of the same type, kind, and rank as the input argument logzplus1 containing the natural logarithm of the unnormalized cosmic formation rate density of LGRBs at the requested redshift.


Possible calling interfaces

logRateDensity = getLogRateDensityB10(logzplus1)
Generate and return the unnormalized Comoving LGRB Formation Rate (LGFR) density for a given redshift...
This module contains procedures and generic interfaces for computing the cosmic rates of celestial ph...
Warning
The input argument logzplus1 must be non-negative since negative redshift is cosmologically undefined.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Remarks
The procedures under discussion are elemental.
See also
getLogRateDensityH06
getLogRateDensityL08
getLogRateDensityM14
getLogRateDensityM17
getLogRateDensityF18
getLogRateDensityP15


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK, RKG => RKD
6 use pm_io, only: display_type
7
8 implicit none
9
10 type(display_type) :: disp
11 real(RKG) :: redshift = 5.5_RKG
12 disp = display_type(file = "main.out.F90")
13
14 call disp%skip()
15 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
16 call disp%show("!Compute the log(RateDensity) according to the B10 LGRB rate density parameters for the Hopkins and Beacom (2006) SFR model.")
17 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%skip()
19
20 call disp%skip()
21 call disp%show("redshift")
22 call disp%show( redshift )
23 call disp%show("getLogRateDensityB10(log(redshift + 1))")
24 call disp%show( getLogRateDensityB10(log(redshift + 1)) )
25 call disp%skip()
26
27 ! Generate both the cosmic rate and the rate density.
28
29 block
31 integer(IK) :: fileUnit, i
32 real(RKG) :: maxRateFormLGRB, maxRateDensityFormLGRB
33 real(RKG), allocatable :: zplus1(:), logzplus1(:), rateFormLGRB(:), rateDensityFormLGRB(:)
34 logzplus1 = getLinSpace(0.01_RKG, log(13._RKG), 500_IK)
35 zplus1 = exp(logzplus1)
36 rateDensityFormLGRB = exp(getLogRateDensityB10(logzplus1))
37 rateFormLGRB = rateDensityFormLGRB * getVolComDiffNormed(zplus1, reltol = sqrt(epsilon(0._RKG)))
38 maxRateDensityFormLGRB = maxval(rateDensityFormLGRB)
39 maxRateFormLGRB = maxval(rateFormLGRB)
40 open(newunit = fileUnit, file = "getLogRateDensityB10.csv")
41 write(fileUnit, "(*(g0,:,','))") "redshift, rateFormLGRB, rateDensityFormLGRB"
42 do i = 1, size(zplus1)
43 write(fileUnit, "(*(g0,:,','))") zplus1(i) - 1, rateFormLGRB(i) / maxRateFormLGRB, rateDensityFormLGRB(i) / maxRateDensityFormLGRB
44 end do
45 close(fileUnit)
46 end block
47
48 ! Set up a Markov Chain Monte Carlo sampler to generate random sample from the target rate density model.
49
50 block
51 use pm_err, only: err_type
53 type(paradram_type) :: sampler
54 type(err_type) :: err
55 sampler%outputFileName = "./zdistB10"
56 sampler%outputStatus = "retry"
57 sampler%domainAxisName = ["redshift"]
58 sampler%domainCubeLimitLower = [0._RKG]
59 sampler%outputSampleSize = 2500
60 sampler%outputChainSize = 5000
61 sampler%proposalStart = [3]
62 err = getErrSampling(sampler, getLogFunc, 1_IK)
63 if (err%occurred) error stop err%msg
64 end block
65
66contains
67
68 recursive function getLogFunc(redshift) result(logRateDensity)
70 real(RKG), intent(in), contiguous :: redshift(:)
71 real(RKG) :: logRateDensity
72 real(RKG) :: zplus1
73 zplus1 = redshift(1) + 1
74 logRateDensity = getLogRateDensityB10(log(zplus1)) + log(getVolComDiffNormed(zplus1, reltol = sqrt(epsilon(0._RKG))))
75 end function
76
77end program example
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
Generate and return the cosmological Comoving Volume Element per unit solid angle of the sky (i....
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Generate and return .true. if the procedure fails to fully accomplish the task of Monte Carlo samplin...
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains procedures and generic interfaces and constants for cosmological calculations.
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter RKD
The double precision real kind in Fortran mode. On most platforms, this is an 64-bit real kind.
Definition: pm_kind.F90:568
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains procedures and generic interfaces for the ParaMonte library sampler routines.
Definition: pm_sampling.F90:30
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
Definition: pm_err.F90:157
Generate and return an object of type display_type.
Definition: pm_io.F90:10282
This is a derived type for constructing objects containing the optional simulation properties of the ...

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!Compute the log(RateDensity) according to the B10 LGRB rate density parameters for the Hopkins and Beacom (2006) SFR model.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7redshift
8+5.5000000000000000
9getLogRateDensityB10(log(redshift + 1))
10+2.6296316147601200
11
12

Postprocessing of the example output
1#!/usr/bin/env python
2#pip install paramonte
3
4import os
5examname = os.path.basename(os.getcwd())
6modelName = examname[-3:]
7
8
9
10import matplotlib.pyplot as plt
11import pandas as pd
12import numpy as np
13
14fontsize = 17
15
16df = pd.read_csv(examname + ".csv", delimiter = ",")
17
18fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
19ax = plt.subplot()
20
21for colname in df.columns[1:]:
22 plt.plot( df.values[:, 0]
23 , df[colname].values
24 , linestyle = "-"
25 , linewidth = 2
26 )
27
28labels = []
29for colname in list(df.columns[1:]): labels.append(modelName + ": " + colname)
30ax.legend ( labels
31 , fontsize = fontsize
32 #, loc = "center left"
33 #, bbox_to_anchor = (1, 0.5)
34 )
35
36ax.set_xlabel(df.columns[0], fontsize = fontsize)
37ax.set_ylabel("Unnormalized Density", fontsize = fontsize)
38
39plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
40ax.tick_params(axis = "y", which = "minor")
41ax.tick_params(axis = "x", which = "minor")
42plt.xticks(fontsize = fontsize)
43plt.yticks(fontsize = fontsize)
44
45plt.tight_layout()
46plt.savefig(examname + ".z.png")
47
48
49
50
51
52import glob
53linewidth = 2
54fontsize = 17
55files = glob.glob("./*_sample.txt")
56
57for file in files:
58
59 #basename = file.split("_")[0]
60 df = pd.read_csv(file, delimiter = ",")
61 if "_chain.txt" in file:
62 sindex = 7 # start column index.
63 elif "_sample.txt" in file:
64 sindex = 1 # start column index.
65 else:
66 sys.exit("Unrecognized simulation output file: " + file)
67
68 # histogram
69
70 for histname in ["z", "logzplus1"]:
71
72 fig = plt.figure(figsize = (8, 6))
73 ax = plt.subplot(1,1,1)
74 if histname == "z":
75 ax.hist(df.values[:, sindex:])
76 elif histname == "logzplus1":
77 ax.hist(np.log(df.values[:, sindex:]))
78 else:
79 sys.exit("Unrecognized histogram name: " + histname)
80 plt.minorticks_on()
81 #ax.set_xscale("log")
82 ax.set_ylabel("Count", fontsize = 17)
83 ax.set_xlabel("log( z + 1 )", fontsize = 17)
84 ax.tick_params(axis = "x", which = "minor")
85 ax.tick_params(axis = "y", which = "minor")
86 plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
87 plt.title("Histogram of the simulated redshifts from\nthe rate density model of " + modelName)
88 plt.tight_layout()
89 plt.savefig(examname + "." + histname + ".sample.png")

Visualization of the example output
Test:
test_pm_cosmicRate
Todo:
This generic interface can be extended to higher-rank input arrays.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 1039 of file pm_cosmicRate.F90.


The documentation for this interface was generated from the following file: