mclib.py¶
-
mclib.
Lorentz_Boost
(boost, P_ph)¶ This routine performs a Lorentz boost of a 4-momentum. The boost is specified with a 3-vel.
- Parameters
boost – The velocity vector of the frame that the photon will be boosted into.
P_ph – The photon 4 momentum that will be boosted into the desired frame of reference.
- Returns
the boosted photon 4 mometum
-
mclib.
event3D
(r_obs, theta_deg, phi_deg, dtheta_deg, path, lastfile, sim_type, riken_switch=False)¶ Place holder function to conduct a synthetic observation of MCRaT simulated outflow using a 3D hydro simulationp.
- Parameters
r_obs –
theta_deg –
phi_deg –
dtheta_deg –
path –
lastfile –
sim_type –
riken_switch –
- Returns
-
mclib.
event4
(r_obs, theta_deg, dtheta_deg, path, lastfile, sim_type, withintheta_deg=False, riken_switch=False, save_event=True)¶ Function to collect MCRaT photons in space that will be observed. legacy code from when MCRaT produced text files as its output.
- Parameters
r_obs – radius of where the detector will be placed, should be at a radius such that all the photons have propagated past the detector by the end of the MCRaT simulation
theta_deg – observer viewing angle in degrees
dtheta_deg – delta theta of the observer viewieng angle for accepting photons, also in degrees
path – path to the directory that holds ll the output MCRaT files, should be a string
lastfile – the number of the last MCRaT output file, this should be an int
sim_type – A string that will be the name of the output file of this function
withintheta_deg – this is a depreciated key
riken_switch – this is a depreciated key
save_event – switch to create the event file that will be read in by other functions
- Returns
returns photon’s that would be observed and thier energy, detector crossing time, and their weight
-
mclib.
event_h5
(r_obs, theta_deg, dtheta_deg, path, lastfile, sim_type, fps=5, read_comv=False, read_stokes=False, read_type=False, save_event_file=True, append=False)¶ Function to collect MCRaT photons in space that will be observed. Saves event files in EVENT_FILES/ directory that must be created before calling this functionp.
- Parameters
r_obs – radius of where the detector will be placed, should be at a radius such that all the photons have propagated past the detector by the end of the MCRaT simulation
theta_deg – observer viewing angle in degrees
dtheta_deg – delta theta of the observer viewing angle for accepting photons, also in degrees
path – path to the directory that holds ll the output MCRaT files, should be a string
lastfile – the number of the last MCRaT output file, this should be an int
sim_type – A string that will be the name of the output file of this function
fps – an int that represents the number fo frames per second in the hydro simulation used
read_comv – switch to denote of the MCRaT files contain the comoving photon 4 momenta
read_stokes – switch to denote if the MCRaT output files have the stokes parameters
save_event_file – switch to determine if the function should save the event file or not
append – switch to denote if the function should append the extracted data to a pre-existing event file
- Returns
returns (N,8) array where N is the number of photons ‘detected’. The array contains: the crossing time of the photon, the lab energy in keV, the weight, the index in the list of photons, the stokes parameters and the comoving energy in keV
-
mclib.
lcur
(simid, t, units='erg/s', theta=1.0, dtheta=1.0, phi=0, dphi=1, sim_dims=2, h5=True, photon_type=None, energy_range=None)¶ reads in the event file and bins photons in uniform time bins to create light curves
- Parameters
simid – a string of the event file base name of the event file created in event_h5 (everything but the .evt)
t – an array of time bin edges
units – string specifying units, can be erg/s or cts/s
theta – observer viewing angle in degrees
dtheta – the size of the observer viewing angle bin in degrees (same as is specified in event_h5 function)
phi – azimuthal angle for mock observer in degrees (only for 3D simulations, not fully supported)
dphi – the size of the observer azimuthal viewing angle bin in degrees (only for 3D simulations, not fully supported)
sim_dims – The number of dimensions of the hydro simulation used
h5 – specify if the format of the MCRaT output files is hdf5 files or not (denotes if using an old format or a newer format of saving files)
photon_type – can be set to ‘s’, ‘i’, or left as None in order to select thermal synchrotron photons, injected photons, or all the photons in the simulation for analysis
energy_range – has units of keV, can be left as None to choose photons of all energy ranges for analysis or it can be set to an array with [min energy, max energy] e.g. [1, 10] for 1 to 10 keV (limits inclusive)
- Returns
returns the time binned quantities of luminosity, luminosity error, number of photons in each bin, the average eenrgy of photons in each bin, polarization, the stokes parameters, polarization error and polarization angle
-
mclib.
lcur_old
(simid, t, units='erg/s', theta=1.0, dtheta=1.0, phi=0, dphi=1, sim_dims=2, h5=True, photon_type=None, energy_range=None)¶ reads in the event file and bins photons in uniform time bins to create light curves
- Parameters
simid – a string of the event file base name of the event file created in event_h5 (everything but the .evt)
t – an array of time bin edges
units – string specifying units, can be erg/s or cts/s
theta – observer viewing angle in degrees
dtheta – the size of the observer viewing angle bin in degrees (same as is specified in event_h5 function)
phi – azimuthal angle for mock observer in degrees (only for 3D simulations, not fully supported)
dphi – the size of the observer azimuthal viewing angle bin in degrees (only for 3D simulations, not fully supported)
sim_dims – The number of dimensions of the hydro simulation used
h5 – specify if the format of the MCRaT output files is hdf5 files or not (denotes if using an old format or a newer format of saving files)
photon_type – can be set to ‘s’, ‘i’, or left as None in order to select thermal synchrotron photons, injected photons, or all the photons in the simulation for analysis
energy_range – has units of keV, can be left as None to choose photons of all energy ranges for analysis or it can be set to an array with [min energy, max energy] e.g. [1, 10] for 1 to 10 keV (limits inclusive)
- Returns
returns the time binned quantities of luminosity, luminosity error, number of photons in each bin, the average eenrgy of photons in each bin, polarization, the stokes parameters, polarization error and polarization angle
-
mclib.
lcur_var_t
(simid, time_start, time_end, dt, dt_min=0.2, liso_c=1e+50, units='erg/s', theta=1.0, dtheta=1.0, phi=0, dphi=1, sim_dims=2, h5=True, photon_type=None, energy_range=None, use_Lcrit=False)¶ Produces time binned quantities for non-uniform time bins. The time bins must be larger than some critical luminosity and some minimum dt that the user specifies.
- Parameters
simid – a string of the event file base name of the event file created in event_h5 (everything but the .evt)
time_start – starting time of the light curve
time_end – end time of the light curve binning
dt – initial dt of the time bins
dt_min – the minimum acceptable dt for the light curve
liso_c – the mimimum isotropic luminosity for a given time bin (in the same units specified by units)
units – a string of the units of the light curve that will be produced (erg/s or cts/s)
theta – the observer viewing angle in degrees
dtheta – the size of the observer viewing angle bin in degrees (same as is specified in event_h5 function)
phi – azimuthal angle for mock observer in degrees (only for 3D simulations, not fully supported)
dphi – the size of the observer azimuthal viewing angle bin in degrees (only for 3D simulations, not fully supported)
sim_dims – The number of dimensions of the hydro simulation used
h5 – specify if the format of the MCRaT output files is hdf5 files or not (denotes if using an old format or a newer format of saving files)
photon_type – can be set to ‘s’, ‘i’, or left as None in order to select thermal synchrotron photons, injected photons, or all the photons in the simulation for analysis
energy_range – has units of keV, can be left as None to choose photons of all energy ranges for analysis or it can be set to an array with [min energy, max energy] e.g. [1, 10] for 1 to 10 keV (limits inclusive)
- Returns
returns the time binned quantities of luminosity, luminosity error, number of photons in each bin, the average eenrgy of photons in each bin, polarization, the stokes parameters, polarization error and polarization angle
-
mclib.
lorentzBoostVectorized
(boost, P_ph)¶ Function to quickly lorentz boost a set of photon 4 momenta, and ensures that the 0 norm condition is met.
- Parameters
boost – The velocity vector of the frame that the photon will be boosted into. The shape of the array should be (3,N), where N is the number of photons that will be lorentz boosted
P_ph – The photon’s 4 momentum that will be boosted into the desired frame of reference. The shape of the array should be (4,N)
- Returns
returns (4,N) array of the boosted photon’s 4 momenta
-
mclib.
read_event_file
(simid, h5=True)¶ An example function for reading the event files produced by event_h5.
- Parameters
simid – the name of the event file to be read
h5 – switch to set whether the MCRaT simulation used hdf5 files (should always be set to true for the current versions of MCRaT)
- Returns
returns the data from the event file
-
mclib.
readanddecimate
(fnam, inj_radius)¶ Legacy code from the python version of MCRaT to read and process FLASH files
- Parameters
fnam – string of directory and file name of the FLASH file that will be loaded and processed
inj_radius – The radius that photons are injected in cm
- Returns
returns FLASH values of various quantities at cells
-
mclib.
single_cs
(P_el, P_ph)¶ This function conducts a single compton scatter in the electron rest frame. The photon has to be in the comoving frame first. Legacy code from Python version of MCRaT.
- Parameters
P_el – electron 4 momentum
P_ph – photon comoving 4 momentum
- Returns
returns post-scattered photon 4 momentum in the comoving frame
-
mclib.
single_electron
(T, P_ph)¶ This routine simulates one electron from a thermal distribution at a temperature T. The electron has the correct angular distribution for a photon traveling with direction P_ph
-
mclib.
spex
(simid, numin, numax, tmin, tmax, units='erg/s', h5=True, photon_type=None, calc_pol=False)¶ Produces spectra of phtons detected within any time interval
- Parameters
simid – a string of the event file base name of the event file created in event_h5 (everything but the .evt)
numin – array of energy values of the left most cutoff of the energy bins in the spectrum in keV
numax – array of energy values of the right most cutoff of the energy bins in the spectrum in keV
tmin – minimum of time bin that we are interested in collecting photons in to analyze
tmax – max of time bin that we are interested in collecting photons in to analyze
units – a string of the units of the spectrum that will be produced (erg/s or cts/s), each unit is then divided by the width of the enrgy bin in keV
h5 – specify if the format of the MCRaT output files is hdf5 files or not (denotes if using an old format or a newer format of saving files)
photon_type – can be set to ‘s’, ‘i’, or left as None in order to select thermal synchrotron photons, injected photons, or all the photons in the simulation for analysis
energy_range – has units of keV, can be left as None to choose photons of all energy ranges for analysis or it can be set to an array with [min energy, max energy] e.g. [1, 10] for 1 to 10 keV (limits inclusive)
- Returns
returns the spectrum with the specified units, for the photons in each energy bin
-
mclib.
zero_norm
(P)¶ Takes a photon 4 momentum and checks if it satisfies the 0 norm condition of photons. If not, it corrects the 4 mometum by assuming that the energy is correct.
- Parameters
P – photon 4 monetum
- Returns
returns the correct 0 normed photon 4 momentum