Verified Commit ca34343e authored by Daniel Williams's avatar Daniel Williams
Browse files

Completed work to allow MDC generation of ringdowns from XML files.

parent d937a22c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ Features
--------

* Produces burst MDCs with Gaussian, SineGaussian, and White Noise Burst ad-hoc waveforms
* Produces ringdown waveforms for MDCs
* Produces numerical relativity burst MDCs for supernovae
* Produces numerical relativity burst MDCs for long duration searches
* Produces GWF frame files for MDCs
* Produces GravEn-format log files for MDCs
* Produces hardware-injection ready data files
* Produces SimBurstTable XML files for MDCs
+9 −6
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ def source_from_row(row):
    try:
        sourceobj.time = row.time_geocent_gps
    except:
        sourceobj.time = row.geocent_start_time
        pass
    return sourceobj

@@ -128,7 +129,7 @@ class MDCSet():
                          'adi' : 'ADI',
                          # Ringdown
                          'rng' : "BBHRingdown",
                          'gng' : "Ringdown",
                          'gng' : "GenericRingdown",
                          }

    inj_families_abb = dict((v,k) for k,v in inj_families_names.iteritems())
@@ -213,6 +214,9 @@ class MDCSet():
            except:
                row = sim.RowType()
                for a in self.table_type.validcolumns.keys():
                    if a in waveform.params.keys():
                        setattr(row, a, waveform.params[a])
                    else:
                        if not hasattr(waveform, a):
                            setattr(row, a, 0)
                        else:
@@ -280,8 +284,7 @@ class MDCSet():
                sim_burst_table.waveform = "Dimmelmeier+08"

            self.waveforms.append(source_from_row(simrow))
            #self.waveforms.append(simrow)#_burst_table)
            #self.waveforms.
            
            if full:
                self._measure_hrss(i)
                self._measure_egw_rsq(i)
+65 −34
Original line number Diff line number Diff line
@@ -1021,7 +1021,7 @@ class Ringdown(Waveform):
    A class to handle Rindown waveforms.
    """
    table_type = lsctables.SimRingdownTable
    waveform = "Ringdown"
    waveform = "GenericRingdown"

        

@@ -1159,56 +1159,87 @@ class BBHRingdown(Ringdown):
    A class to represent BBH ringdowns.
    """
    #lalsimfunction = SimBlackHoleRingdown
    waveform = "BBHRingdown"
    def __init__(self, time, phi0, mass, spin, massloss, distance, inclination, sky_dist=uniform_sky):
        """
        Binary Black Hole (BBH) Ringdown waveform

    def __init__(self, time, hrss, azimuth, mass, spin, massloss, distance, inclination, l, m, sky_dist=uniform_sky, deltaT = 1/16384.0):
        Parameters
        ----------
        time : float
           The time that the waveform should be generated at, in gps seconds.
        phi0 : float
           The starting phase.
        mass : float
           The mass of the final black hole in solar masses.
        spin : float
           The dimensionless spin parameter for the final black hole.
        massloss : float
           The total mass loss of the system. (Also denoted epsilon).
        distance : float
           The effective luminosity distance at which the signal should be generated.
        inlination : float
            The inclination of the system in degrees.
        """
        self._clear_params()
        self.time = self.params['start_time_gmst'] =  time
        self.time = self.geocent_start_time = self.params['geocent_start_time'] =  time
        self.sky_dist = sky_dist
        self.params['simulation_id'] = self.simulation_id =  self.sim.get_next_id()
        #self.params['phi0'] = phi0
        self.params['azimuth'] = azimuth
        self.params['deltaT'] = deltaT
        self.params['phase'] = phi0
        self.params['mass'] = mass # in solar masses
        self.params['spin'] = spin
        self.params['massloss'] = massloss
        self.params['epsilon'] = massloss
        self.params['eff_dist_l'] = self.eff_dist_l = distance # megaparsec
        self.params['hrss'] = self.hrss = hrss
        self.params['inclination'] = self.inclination = inclination
        self.params['l'] = self.l = l
        self.params['m'] = self.m = m
        self.params['inclination'] = self.inclination = float(inclination)

    def _generate(self, rate=16384.0, half=False):
    def _generate(self, rate=16384.0, half=False, l = 2, m = 2):
        """
        Generate this BBH Ringdown waveform.

        Parameters
        ----------
        rate : float
           The signal sampling rate. Defaults to 16384.0 Hz
           The signal sampling rate. Defaults to 16384.0 Hz.
        l : int
           The azimuthal number of the mode to be generated.
        m : int 
           The polar number of the mode to be generated.    
        half : bool 
           Only compute the hp and hx once if this is true;
           these are only required if you need to compute the cross
           products. Defaults to False.

        Returns 
        ------- 
           hp : 
              The strain in the + polarisation 
           hx : 
              The strain in the x polarisation
           hp0 : 
              A copy of the strain in the + polarisation 
           hx0 : 
               A copy of the strain in the x polarisation 
        """
        dt = 1.0 / rate

        #&epoch, q, dt, M, a, e, r, i, l, m
        
        hp, hx = lalsimulation.SimBlackHoleRingdown(self.time,
                                           np.deg2rad(self.params["azimuth"]),
                                           self.params['deltaT'],
        hp, hx = lalsimulation.SimBlackHoleRingdown(self.params['geocent_start_time'],
                                                    self.params["phase"],
                                                    dt,
                                                    self.params['mass']*lal.MSUN_SI,
                                                    self.params['spin'],
                                           self.params['massloss'],
                                                    self.params['epsilon'],
                                                    self.params['eff_dist_l'] *  1e6 * lal.PC_SI,
                                                    np.deg2rad(self.params['inclination']),
                                           self.l, self.m)
                                                    l, m)
        if not half:
                    hp0, hx0 = lalsimulation.SimBlackHoleRingdown(self.time,
                                           np.deg2rad(self.params["azimuth"]),
            hp0, hx0 = lalsimulation.SimBlackHoleRingdown(self.params['geocent_start_time'],
                                                          self.params["phase"],
                                                          dt,
                                                          self.params['mass']*lal.MSUN_SI,
                                                          self.params['spin'],
                                           self.params['massloss'],
                                                          self.params['epsilon'],
                                                          self.params['eff_dist_l'] *  1e6 * lal.PC_SI,
                                                          np.deg2rad(self.params['inclination']),
                                           self.l, self.m)
                                                          l, m)
        else:
            hp0, hx0 = hp, hx
        
+19 −12
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ class TestMinke(unittest.TestCase):
        """Write out a simringdown table xml file
        """
        mdcset = mdctools.MDCSet(["L1"], table_type = "ringdown")
        waveform = sources.BBHRingdown(1000, 1e-22, 0 ,0.1, 10, 0.1, 0.01, 10, 0, 2, 2,)
        waveform = sources.BBHRingdown(1000,  0 ,0.1, 10, 0.1, 0.01, 10, 0)

        mdcset + waveform

@@ -78,6 +78,13 @@ class TestMinke(unittest.TestCase):


class TestMDC(unittest.TestCase):
    def setUp(self):

        rng = minke.sources.BBHRingdown(100.23, np.rad2deg(.1), 10., 0.97, 0.01, 1.0,45.)
        
        mdcset = mdctools.MDCSet(["L1"], table_type="ringdown")
        mdcset + rng
        mdcset.save_xml("testout/ringdowngentest.xml.gz")
    
    def test_Gaussian_Waveform_generation_in_MDC(self):
        """Check that waveforms inside an MDC are generated. """
@@ -117,13 +124,13 @@ class TestMDC(unittest.TestCase):

    def test_Ringdown_Waveform_generation_in_MDC(self):
        """Check that waveforms inside an MDC are generated. """       
        rng = minke.sources.BBHRingdown(100.23, 1e-22, np.rad2deg(.1), 10., 0.97, 0.01, 1.0,45., 2, 2)
        mdcset = mdctools.MDCSet(["L1"], table_type="ringdown")
        mdcset + rng
        mdcset.load_xml("testout/ringdowngentest.xml.gz")
        
        data = mdcset._generate_burst(0)

        testdata = np.array([ -4.14099902e-20,   4.05706892e-21,   9.44712664e-22,
        testdata = np.array([
            -4.14099902e-20,   4.05706892e-21,   9.44712664e-22,
            -2.70287547e-22,   1.98245659e-24,   9.41028314e-24,
            -1.31703741e-24,  -1.62366854e-25,   6.86331926e-26,
            -3.27763986e-27,  -2.02216144e-27,   3.85067715e-28,