fruitbat.table¶
table¶
-
fruitbat.table.
create
(method, output_dir='data', filename=None, zmin=0, zmax=20, num_samples=10000, **method_kwargs)[source]¶ Creates lookup table
which can be readin using
load()
.Parameters: - method (str) – The DM-redshift relation to assume when creating the table.
- output_dir (str, optional) – The path of the output directory. If
output_dir = 'data'
, then created table will created in the same directory with the builtin tables and will be found when using functions such ascalc_redshift()
. Default: ‘data’ - filename (str, optional) – The output filename. If
name=None
then the filename will become custom_method. Default: None - zmin (int or float, optional) – The minimum redshift in the table. Default: 0
- zmax (int or float, optional) – The maximum redshift in the table. Default: 20
- num_samples (int, optional) – The number of sample dispersion measure and redshifts. Default: 10000
Keyword Arguments: - cosmo (An instance of
astropy.cosmology
, optional) – The cosmology to assume when calculating the outputs of the table. Required when creating new tables of'Ioka2003'
,'Inoue2004'
,'Zhang2018'
. - free_elec (float or int, optional) – The amount of free electrons per proton mass in the Universe.
This applies when using
'Zhang2018'
. Must be between 0 and 1. Default: 0.875. - f_igm (float or int, optional) – The fraction of baryons in the intergalactic medium. This
applies when using
'Zhang2018'
. Must be between 0 and 1. Default: 0.83
Returns: string – The path to the generated hdf5 file containing the table data.
Generates
A hdf5 file containing datasets for ‘DM’ and ‘z’`.
Example
>>> def simple_dm(z): dm = 1200 * z return dm >>> fruitbat.add_method("simple_dm", simple_dm) >>> fruitbat.table.create("simple_dm") >>> frb = fruitbat.Frb(1200) >>> frb.calc_redshift(method="simple_dm") <Quantity 1.>
-
fruitbat.table.
get_z_from_table
(dm, table, cosmology=None)[source]¶ Calculates the redshift from a dispersion measure by interpolating a lookup table
Parameters: - dm (float) – The input dispersion measure
- table (
numpy.lib.npyio.NpzFile
) – The lookup table with'dm'
and'z'
arrays.
Returns: z (float) – The redshift corresponding to the input disperison measure.
Example
>>> table = fruitbat.table.load('Zhang2018_Planck18.npz') >>> fruitbat.get_z_from_table(1000, table) 1.1087964578507539