NoahSim

GRBgenerator module

class GRBgenerator.Sky(NSIDE, strength)[source]

Generates an array of GRB’s given certains strength at different sky positions.

Output should be an array.

fastcube module

The following cell contains the “FastCube” class. This is the simulation I hope to use emulate the results of state of the art simulations on GRB localization, and use these results to characterize the burstcube spacecraft.

For questions/comments please contact me, Noah Kasmanoff, at nkasmanoff@gmail.com or https://github.com/nkasmanoff

class fastcube.FastCube(background, dettilt, alternating=False)[source]
detA

BurstCube is composed of 4 separate scintillators to detect and localize events. In this software package, they are labelled A through D.

detB

BurstCube is composed of 4 separate scintillators to detect and localize events. In this software package, they are labelled A through D.

detC

BurstCube is composed of 4 separate scintillators to detect and localize events. In this software package, they are labelled A through D.

detD

BurstCube is composed of 4 separate scintillators to detect and localize events. In this software package, they are labelled A through D.

dets
normA
normB
normC
normD
response2GRB(GRB, samples, test=True, talk=False)[source]

Using x, respond2GRB will determine the sky position of an array of GRB sources assuming some inherent background noise within detectors, along with fluctuations of either Gaussian or Poissonian nature.

Parameters:
  • GRB (object) – An instance of the separately defined “GRBs” class that contains a number of evenly spaced sky positions of a given strength.
  • test (boolean) – For sanity purposes, if the simulation seems to give unrealistic results, switching to test mode allows for much quicker sampling, allowing it easier to spot potential errors.
talk : boolean
If desired, prints position by position results.
Returns:
  • localizationerrors (array) – numpy array that contains the average localization uncertainty at each sky position.
  • Additionally, response2GRB will print the sky position it is currently sampling, along with the average offset of localizations at that spot.
response2oneGRB(sourcetheta, sourcephi, sourcestrength)[source]

If you wish, will allow you to examine the localization uncertainty of one sampled GRB of some given strenth at some point in the sky. For a full/complete simulation just use the function below, “response2GRB”.

Parameters:
  • sourcetheta (float) – The displacement in degrees in the zenithal direction.
  • sourcephi (float) – The displacement in degrees in the azimuthal direction.
  • sourcestrength (float) – The stength in counts of the simulated GRB.
Returns:

recpos – The reconstructed position of the GRB based on the detectors’ response.

Return type:

float

burstutils module

burstutils.angle(v1, v2)[source]

” Finds the angle between 2 vectors

Parameters:
  • v1 (array) –
  • v2 (array) – The arrays representing the vectors who’s angle is to be calculated.
Returns:

ang – Angle between the 2 vectors.

Return type:

float

burstutils.chiresponse(A, x)[source]

Deprecated, just use normal “response” function above!

The response function used in the chi squared fitting portion of the simulation. Meant to imitate the actual response of a scintillator. Inputs 2 vectors, and responds with a cos^x dependence.

Parameters:A (float) – The angle between the two vectors who’s response is meant to be imitated.
Returns:A – The cosine dependence based on the angle, includes a mask so that terms corresponding to angular separations beyond pi/2 are 0, imitating what would happen if a GRB didn’t strike the face of a detector. Further simulations of this effect are neccessary in a different software package to confirm this assumption, but its okay for now.
Return type:float
burstutils.findAngles(v1s, v2s)[source]
burstutils.indexer(chisquareds, bottheta, toptheta, botphi, topphi, botA, topA, ntheta, nphi, nA)[source]

After obtaining an array of all the possible chi squared values, this uses an equation I tediously discovered which can backtrack to what term in each array corresponds to the minimim chi squared.

Parameters:
  • chisquareds (array) – numpy array of all possible chi squared values
  • bottheta (float) – Minimum polar angle to be tested.
  • toptheta (float) – Maximum polar angle to be tested.
  • botphi (float) – Minimum azimuthal angle to be tested.
  • topphi (float) – Maximum azimuthal angle to be tested.
  • botA (float) – Minimum signal strength to be tested.
  • topA (float) – Maximum signal strength to be tested.
  • ntheta (int) – Number of sample points between bottheta and toptheta.
  • nphi (int) – Number of sample points between botphi and topphi.
  • nA (int) – Number of sample points between botA and topA.
Returns:

  • thetaloc (float) – The reconstructed polar angle of the source.
  • philoc (float) – The reconstructeed azimuthal angle of the source.
  • Aoguess (float) – The reconstructed strength of the source.

burstutils.length(v)[source]

Finds the length of a vector

Parameters:v (array) – numpy array representative of the vector you want to find the magnitude of.
Returns:magv – magnitude of v.
Return type:float
burstutils.look_up_A(detnorm, source, array=False)[source]

The look up table for detector A. Currently for all these functions the coordinates are relative to the top of the spacecraft, not indivudial detectors. To tranform just rotate by this specific detnorm.

Parameters:
  • detnorm (array) – The vector normal to detector A.
  • source (array) – The vector pointing to where in the sky the GRB came from.
Returns:

x – The exponent of dependence for the detector’s response.

Return type:

float

burstutils.look_up_B(detnorm, source, array=False)[source]

The look up table for detector B. Currently for all these functions the coordinates are relative to the top of the spacecraft, not indivudial detectors. To tranform just rotate by this specific detnorm.

Parameters:
  • detnorm (array) – The vector normal to detector B.
  • source (array) – The vector pointing to where in the sky the GRB came from.
Returns:

x – The exponent of dependence for the detector’s response.

Return type:

float

burstutils.look_up_C(detnorm, source, array=False)[source]

The look up table for detector C.

Parameters:
  • detnorm (array) – The vector normal to detector C.
  • source (array) – The vector pointing to where in the sky the GRB came from.
Returns:

  • x (float) – The exponent of dependence for the detector’s response.
  • Example
  • Let’s say for this detector, past 30 degrees and for azimuths of
  • 60 - 180, it’s blocked. This is what it would look like
  • R = 0.76*np.ones(shape=np.shape(X)) – R[30:,60:180] = 0

burstutils.look_up_D(detnorm, source, array=False)[source]

The look up table for detector D.

Parameters:
  • detnorm (array) – The vector normal to detector D.
  • source (array) – The vector pointing to where in the sky the GRB came from.
Returns:

x – The exponent of dependence for the detector’s response.

Return type:

float

burstutils.quad_solver(detval, detnorm, bottheta, toptheta, botphi, topphi, botA, topA, ntheta, nphi, nA, background, A=False, B=False, C=False, D=False)[source]

Generates an array of all possible chi terms for a given detector and the number of counts induced in it by some source. Named quad since BurstCube is composed of 4 detectors, and this generates 1/4 of the terms.

Parameters:
  • detsvals (array) – Numpy array containing the relative counts in a BurstCube detector.
  • detnorms (array) – Numpy array containing the normal vector of a BurstCube detector.
  • bottheta (float) – Minimum polar angle to be tested.
  • toptheta (float) – Maximum polar angle to be tested.
  • botphi (float) – Minimum azimuthal angle to be tested.
  • topphi (float) – Maximum azimuthal angle to be tested.
  • botA (float) – Minimum signal strength to be tested.
  • topA (float) – Maximum signal strength to be tested.
  • ntheta (int) – Number of sample points between bottheta and toptheta.
  • nphi (int) – Number of sample points between botphi and topphi.
  • bgrd (float) – # of background counts inherent to each detector.
  • nA (int) – Number of sample points between botA and topA.
Returns:

chiterm – Numpy array containing all the chisquared terms for one BurstCube detector.

Return type:

array

burstutils.response(A, x)[source]

Meant to imitate the actual response of a scintillator. Inputs 2 vectors, and responds with a cos^x dependence.

Parameters:
  • A (float) – The angular separation in radians between the normal vector of the detector, and the position in the sky of the simulated GRB.
  • x (float) – The dependence
Returns:

R – The response function of how the scintillator will respond to a source at angle A.

Return type:

float