Loading docs/index.rst +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ User Guide installation tutorial tutorial-editing usage Developer Guide Loading docs/tutorial-editing.rst 0 → 100644 +42 −0 Original line number Diff line number Diff line Tutorial: Editing an MDC XML file ================================= As well as producing new MDC specifications, Minke is capable of editing pre-existing SimBurstTable XML files in a Pythonic way. In this tutorial we will load a pre-existing XML file, and change the value of every row's "hrss" value, but the same approach can be used to edit any of the values within the SimBurstTable. First we load the required parts of minke:: >>> from minke import mdctools In order to load an XML file we need to specify an MDCSet; what we specify in this step isn't terribly important if we're just editing XML files, but is essential if we need to produce a frame file at some point. So if we assume we'll be working with the two LIGO 4km detectors:: >>> mdcset = mdctools.MDCSet(['L1', 'H1']) We'll now load our XML file into the `mdcset` object. We'll assume they're in a file, in the present working directory, called "injections.xml.gz":: >>> mdcset.load("injections.xml.gz") This loads each of the waveforms in the table into an array called `mdcset.waveforms`, which can be indexed and iterated over just like any Python list, and we can access individual rows a bit like this.:: >>> mdcset.waveforms[1] which gives us access to the underlying Swig SimBurst object from LALSuite. We can then edit the values of this by calling them as attributes, so, for example, to set the hrss,:: >>> mdcset.waveforms[1].hrss = 1e-23 In order to perform a batch edit on all of the rows we just need a loop. For example, if we wanted to set every hrss to `1e-23`,:: >>> for i in xrange(len(mdcset.waveforms)): >>> mdcset.waveforms[i].hrss = 1e-23 We then need to save this edit as an xml file,:: >>> mdcset.save_xml('edited_injections.xml.gz') and we're then free to use this xml file in other pipelines· minke/distribution.py +2 −2 Original line number Diff line number Diff line Loading @@ -39,8 +39,8 @@ def supernova_angle(num, divisions = 10): phi = numpy.linspace(0, numpy.pi*2, divisions) out_t = numpy.random.choice(theta, num, replace = True) out_p = numpy.random.choice(phi, num, replace = True) out_t = [float("%.3f" % angle) for angle in out_t] out_p = [float("%.3f" % angle) for angle in out_p] #out_t = [float("%.3f" % angle) for angle in out_t] #out_p = [float("%.3f" % angle) for angle in out_p] return zip(out_t, out_p) def uniform_sky(number=1): Loading minke/mdctools.py +4 −0 Original line number Diff line number Diff line Loading @@ -40,7 +40,11 @@ class MDCSet(): inj_families_names = {'ga' : 'Gaussian', 'sg' : 'SineGaussian', 'wnb': 'BTLWNB', # Supernova families 'd08' : 'Dimmelmeier+08' 's10' : 'Scheidegger+10', 'm12' : 'Mueller+12', 'o13' : 'Ott+13', } inj_families_abb = dict((v,k) for k,v in inj_families_names.iteritems()) Loading minke/sources.py +93 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,99 @@ class Supernova(Waveform): return output class Ott2013(Supernova): """ The Ott+2013 supernova waveform """ waveform = "Ott+13" def __init__(self, theta, phi, time, sky_dist=uniform_sky, filepath=None, family="s27fheat1p05", decomposed_path=None): """ Parameters ---------- phi : float The internal phi parameter of the supernova injection. theta : float The internal inclination parameter of the supernova injection. time : float or list The time period over which the injection should be made. If a list is given they should be the start and end times, and the waveform will be produced at some random point in that time range. If a float is given then the injection will be made at that specific time. sky_dist : func The function describing the sky distribution which the injections should be made over. Defaults to a uniform sky. filepath : str The filepath to the folder containing the pre-rotated numerical relativity waveforms. family : str The family of waveforms which are to be used for the injection set. decomposed_path : str The location where the decomposed waveform file should be stored. Optional. """ self._clear_params() self.time = time self.params['phi'] = phi self.params['incl'] = theta self.sky_dist = sky_dist self.numrel_data = filepath + "/" + family + "theta{}_phi{}".format(theta, phi) class Mueller2012(Supernova): """ The Mueller2012 waveform. """ waveform = "Mueller+12" def __init__(self, theta, phi, time, sky_dist=uniform_sky, filepath=None, family="L15-3", decomposed_path=None): """ Parameters ---------- phi : float The internal phi parameter of the supernova injection. theta : float The internal inclination parameter of the supernova injection. time : float or list The time period over which the injection should be made. If a list is given they should be the start and end times, and the waveform will be produced at some random point in that time range. If a float is given then the injection will be made at that specific time. sky_dist : func The function describing the sky distribution which the injections should be made over. Defaults to a uniform sky. filepath : str The filepath to the folder containing the pre-rotated numerical relativity waveforms. family : str The family of waveforms which are to be used for the injection set. decomposed_path : str The location where the decomposed waveform file should be stored. Optional. """ self._clear_params() self.time = time self.params['phi'] = phi self.params['incl'] = theta self.sky_dist = sky_dist self.numrel_data = filepath + "/" + family + "theta{}_phi{}".format(theta, phi) class Scheidegger2010(Supernova): """ Loading Loading
docs/index.rst +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ User Guide installation tutorial tutorial-editing usage Developer Guide Loading
docs/tutorial-editing.rst 0 → 100644 +42 −0 Original line number Diff line number Diff line Tutorial: Editing an MDC XML file ================================= As well as producing new MDC specifications, Minke is capable of editing pre-existing SimBurstTable XML files in a Pythonic way. In this tutorial we will load a pre-existing XML file, and change the value of every row's "hrss" value, but the same approach can be used to edit any of the values within the SimBurstTable. First we load the required parts of minke:: >>> from minke import mdctools In order to load an XML file we need to specify an MDCSet; what we specify in this step isn't terribly important if we're just editing XML files, but is essential if we need to produce a frame file at some point. So if we assume we'll be working with the two LIGO 4km detectors:: >>> mdcset = mdctools.MDCSet(['L1', 'H1']) We'll now load our XML file into the `mdcset` object. We'll assume they're in a file, in the present working directory, called "injections.xml.gz":: >>> mdcset.load("injections.xml.gz") This loads each of the waveforms in the table into an array called `mdcset.waveforms`, which can be indexed and iterated over just like any Python list, and we can access individual rows a bit like this.:: >>> mdcset.waveforms[1] which gives us access to the underlying Swig SimBurst object from LALSuite. We can then edit the values of this by calling them as attributes, so, for example, to set the hrss,:: >>> mdcset.waveforms[1].hrss = 1e-23 In order to perform a batch edit on all of the rows we just need a loop. For example, if we wanted to set every hrss to `1e-23`,:: >>> for i in xrange(len(mdcset.waveforms)): >>> mdcset.waveforms[i].hrss = 1e-23 We then need to save this edit as an xml file,:: >>> mdcset.save_xml('edited_injections.xml.gz') and we're then free to use this xml file in other pipelines·
minke/distribution.py +2 −2 Original line number Diff line number Diff line Loading @@ -39,8 +39,8 @@ def supernova_angle(num, divisions = 10): phi = numpy.linspace(0, numpy.pi*2, divisions) out_t = numpy.random.choice(theta, num, replace = True) out_p = numpy.random.choice(phi, num, replace = True) out_t = [float("%.3f" % angle) for angle in out_t] out_p = [float("%.3f" % angle) for angle in out_p] #out_t = [float("%.3f" % angle) for angle in out_t] #out_p = [float("%.3f" % angle) for angle in out_p] return zip(out_t, out_p) def uniform_sky(number=1): Loading
minke/mdctools.py +4 −0 Original line number Diff line number Diff line Loading @@ -40,7 +40,11 @@ class MDCSet(): inj_families_names = {'ga' : 'Gaussian', 'sg' : 'SineGaussian', 'wnb': 'BTLWNB', # Supernova families 'd08' : 'Dimmelmeier+08' 's10' : 'Scheidegger+10', 'm12' : 'Mueller+12', 'o13' : 'Ott+13', } inj_families_abb = dict((v,k) for k,v in inj_families_names.iteritems()) Loading
minke/sources.py +93 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,99 @@ class Supernova(Waveform): return output class Ott2013(Supernova): """ The Ott+2013 supernova waveform """ waveform = "Ott+13" def __init__(self, theta, phi, time, sky_dist=uniform_sky, filepath=None, family="s27fheat1p05", decomposed_path=None): """ Parameters ---------- phi : float The internal phi parameter of the supernova injection. theta : float The internal inclination parameter of the supernova injection. time : float or list The time period over which the injection should be made. If a list is given they should be the start and end times, and the waveform will be produced at some random point in that time range. If a float is given then the injection will be made at that specific time. sky_dist : func The function describing the sky distribution which the injections should be made over. Defaults to a uniform sky. filepath : str The filepath to the folder containing the pre-rotated numerical relativity waveforms. family : str The family of waveforms which are to be used for the injection set. decomposed_path : str The location where the decomposed waveform file should be stored. Optional. """ self._clear_params() self.time = time self.params['phi'] = phi self.params['incl'] = theta self.sky_dist = sky_dist self.numrel_data = filepath + "/" + family + "theta{}_phi{}".format(theta, phi) class Mueller2012(Supernova): """ The Mueller2012 waveform. """ waveform = "Mueller+12" def __init__(self, theta, phi, time, sky_dist=uniform_sky, filepath=None, family="L15-3", decomposed_path=None): """ Parameters ---------- phi : float The internal phi parameter of the supernova injection. theta : float The internal inclination parameter of the supernova injection. time : float or list The time period over which the injection should be made. If a list is given they should be the start and end times, and the waveform will be produced at some random point in that time range. If a float is given then the injection will be made at that specific time. sky_dist : func The function describing the sky distribution which the injections should be made over. Defaults to a uniform sky. filepath : str The filepath to the folder containing the pre-rotated numerical relativity waveforms. family : str The family of waveforms which are to be used for the injection set. decomposed_path : str The location where the decomposed waveform file should be stored. Optional. """ self._clear_params() self.time = time self.params['phi'] = phi self.params['incl'] = theta self.sky_dist = sky_dist self.numrel_data = filepath + "/" + family + "theta{}_phi{}".format(theta, phi) class Scheidegger2010(Supernova): """ Loading