signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def inverse_transform(self, maps):
out = {}<EOL>m1 = maps[parameters.mass1]<EOL>m2 = maps[parameters.mass2]<EOL>out[parameters.mchirp] = conversions.mchirp_from_mass1_mass2(m1, m2)<EOL>out[parameters.eta] = conversions.eta_from_mass1_mass2(m1, m2)<EOL>return self.format_output(maps, out)<EOL>
This function transforms from component masses to chirp mass and symmetric mass ratio. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy >>> from pycbc import transforms >>> t...
f15991:c3:m1
def jacobian(self, maps):
mchirp = maps[parameters.mchirp]<EOL>eta = maps[parameters.eta]<EOL>m1 = conversions.mass1_from_mchirp_eta(mchirp, eta)<EOL>m2 = conversions.mass2_from_mchirp_eta(mchirp, eta)<EOL>return mchirp * (m1 - m2) / (m1 + m2)**<NUM_LIT:3><EOL>
Returns the Jacobian for transforming mchirp and eta to mass1 and mass2.
f15991:c3:m2
def inverse_jacobian(self, maps):
m1 = maps[parameters.mass1]<EOL>m2 = maps[parameters.mass2]<EOL>mchirp = conversions.mchirp_from_mass1_mass2(m1, m2)<EOL>eta = conversions.eta_from_mass1_mass2(m1, m2)<EOL>return -<NUM_LIT:1.> * mchirp / eta**(<NUM_LIT>/<NUM_LIT:5>)<EOL>
Returns the Jacobian for transforming mass1 and mass2 to mchirp and eta.
f15991:c3:m3
def transform(self, maps):
out = {}<EOL>out[parameters.distance] =conversions.distance_from_chirp_distance_mchirp(<EOL>maps[parameters.chirp_distance],<EOL>maps[parameters.mchirp],<EOL>ref_mass=self.ref_mass)<EOL>return self.format_output(maps, out)<EOL>
This function transforms from chirp distance to luminosity distance, given the chirp mass. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy as np >>> from pycbc import transforms ...
f15991:c4:m1
def inverse_transform(self, maps):
out = {}<EOL>out[parameters.chirp_distance] =conversions.chirp_distance(maps[parameters.distance],<EOL>maps[parameters.mchirp], ref_mass=self.ref_mass)<EOL>return self.format_output(maps, out)<EOL>
This function transforms from luminosity distance to chirp distance, given the chirp mass. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy as np >>> from pycbc import transforms ...
f15991:c4:m2
def jacobian(self, maps):
ref_mass=<NUM_LIT><EOL>mchirp = maps['<STR_LIT>']<EOL>return (<NUM_LIT>**(-<NUM_LIT:1.>/<NUM_LIT:5>) * self.ref_mass / mchirp)**(-<NUM_LIT>/<NUM_LIT:6>)<EOL>
Returns the Jacobian for transforming chirp distance to luminosity distance, given the chirp mass.
f15991:c4:m3
def inverse_jacobian(self, maps):
ref_mass=<NUM_LIT><EOL>mchirp = maps['<STR_LIT>']<EOL>return (<NUM_LIT>**(-<NUM_LIT:1.>/<NUM_LIT:5>) * self.ref_mass / mchirp)**(<NUM_LIT>/<NUM_LIT:6>)<EOL>
Returns the Jacobian for transforming luminosity distance to chirp distance, given the chirp mass.
f15991:c4:m4
def transform(self, maps):
a, az, po = self._inputs<EOL>data = coordinates.spherical_to_cartesian(maps[a], maps[az], maps[po])<EOL>out = {param : val for param, val in zip(self._outputs, data)}<EOL>return self.format_output(maps, out)<EOL>
This function transforms from spherical to cartesian spins. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy >>> from pycbc import transforms >>> t = transforms.SphericalSpin1ToCarte...
f15991:c5:m0
def inverse_transform(self, maps):
sx, sy, sz = self._outputs<EOL>data = coordinates.cartesian_to_spherical(maps[sx], maps[sy], maps[sz])<EOL>out = {param : val for param, val in zip(self._outputs, data)}<EOL>return self.format_output(maps, out)<EOL>
This function transforms from cartesian to spherical spins. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transformed values.
f15991:c5:m1
def transform(self, maps):
out = {parameters.redshift : cosmology.redshift(<EOL>maps[parameters.distance])}<EOL>return self.format_output(maps, out)<EOL>
This function transforms from distance to redshift. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy >>> from pycbc import transforms >>> t = transforms.DistanceToRedshift() ...
f15991:c7:m0
def transform(self, maps):
mass1 = maps[parameters.mass1]<EOL>mass2 = maps[parameters.mass2]<EOL>out = {}<EOL>out[parameters.spin1z] =conversions.spin1z_from_mass1_mass2_chi_eff_chi_a(<EOL>mass1, mass2,<EOL>maps[parameters.chi_eff], maps["<STR_LIT>"])<EOL>out[parameters.spin2z] =conversions.spin2z_from_mass1_mass2_chi_eff_chi_a(<EOL>mass1, mass2...
This function transforms from aligned mass-weighted spins to cartesian spins aligned along the z-axis. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float ...
f15991:c8:m0
def inverse_transform(self, maps):
mass1 = maps[parameters.mass1]<EOL>spin1z = maps[parameters.spin1z]<EOL>mass2 = maps[parameters.mass2]<EOL>spin2z = maps[parameters.spin2z]<EOL>out = {<EOL>parameters.chi_eff : conversions.chi_eff(mass1, mass2,<EOL>spin1z, spin2z),<EOL>"<STR_LIT>" : conversions.chi_a(mass1, mass2, spin1z, spin2z),<EOL>}<EOL>return self...
This function transforms from component masses and cartesian spins to mass-weighted spin parameters aligned with the angular momentum. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and valu...
f15991:c8:m1
def transform(self, maps):
<EOL>m_p = conversions.primary_mass(maps["<STR_LIT>"], maps["<STR_LIT>"])<EOL>m_s = conversions.secondary_mass(maps["<STR_LIT>"], maps["<STR_LIT>"])<EOL>xi_p = conversions.primary_spin(maps["<STR_LIT>"], maps["<STR_LIT>"],<EOL>maps["<STR_LIT>"], maps["<STR_LIT>"])<EOL>xi_s = conversions.secondary_spin(maps["<STR_LIT>"]...
This function transforms from mass-weighted spins to caretsian spins in the x-y plane. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transfo...
f15991:c9:m0
def inverse_transform(self, maps):
<EOL>out = {}<EOL>xi1 = conversions.primary_xi(<EOL>maps[parameters.mass1], maps[parameters.mass2],<EOL>maps[parameters.spin1x], maps[parameters.spin1y],<EOL>maps[parameters.spin2x], maps[parameters.spin2y])<EOL>xi2 = conversions.secondary_xi(<EOL>maps[parameters.mass1], maps[parameters.mass2],<EOL>maps[parameters.spin...
This function transforms from component masses and cartesian spins to mass-weighted spin parameters perpendicular with the angular momentum. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name an...
f15991:c9:m1
def transform(self, maps):
out = {}<EOL>out["<STR_LIT>"] = conversions.chi_p(<EOL>maps[parameters.mass1], maps[parameters.mass2],<EOL>maps[parameters.spin1x], maps[parameters.spin1y],<EOL>maps[parameters.spin2x], maps[parameters.spin2y])<EOL>return self.format_output(maps, out)<EOL>
This function transforms from component masses and caretsian spins to chi_p. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: Returns ------- out : dict A dict with key as paramet...
f15991:c10:m0
@property<EOL><INDENT>def inputvar(self):<DEDENT>
return self._inputvar<EOL>
Returns the input parameter.
f15991:c11:m1
@property<EOL><INDENT>def outputvar(self):<DEDENT>
return self._outputvar<EOL>
Returns the output parameter.
f15991:c11:m2
@property<EOL><INDENT>def bounds(self):<DEDENT>
return self._bounds<EOL>
Returns the domain of the input parameter.
f15991:c11:m3
@staticmethod<EOL><INDENT>def logit(x, a=<NUM_LIT:0.>, b=<NUM_LIT:1.>):<DEDENT>
return numpy.log(x-a) - numpy.log(b-x)<EOL>
r"""Computes the logit function with domain :math:`x \in (a, b)`. This is given by: .. math:: \mathrm{logit}(x; a, b) = \log\left(\frac{x-a}{b-x}\right). Note that this is also the inverse of the logistic function with range :math:`(a, b)`. Parameters ---...
f15991:c11:m4
@staticmethod<EOL><INDENT>def logistic(x, a=<NUM_LIT:0.>, b=<NUM_LIT:1.>):<DEDENT>
expx = numpy.exp(x)<EOL>return (a + b*expx)/(<NUM_LIT:1.> + expx)<EOL>
r"""Computes the logistic function with range :math:`\in (a, b)`. This is given by: .. math:: \mathrm{logistic}(x; a, b) = \frac{a + b e^x}{1 + e^x}. Note that this is also the inverse of the logit function with domain :math:`(a, b)`. Parameters ---------...
f15991:c11:m5
def transform(self, maps):
x = maps[self._inputvar]<EOL>isin = self._bounds.__contains__(x)<EOL>if isinstance(isin, numpy.ndarray):<EOL><INDENT>isin = isin.all()<EOL><DEDENT>if not isin:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>out = {self._outputvar : self.logit(x, self._a, self._b)}<EOL>return self.format_output(maps, out)<EOL>
r"""Computes :math:`\mathrm{logit}(x; a, b)`. The domain :math:`a, b` of :math:`x` are given by the class's bounds. Parameters ---------- maps : dict or FieldArray A dictionary or FieldArray which provides a map between the parameter name of the variable to tran...
f15991:c11:m6
def inverse_transform(self, maps):
y = maps[self._outputvar]<EOL>out = {self._inputvar : self.logistic(y, self._a, self._b)}<EOL>return self.format_output(maps, out)<EOL>
r"""Computes :math:`y = \mathrm{logistic}(x; a,b)`. The codomain :math:`a, b` of :math:`y` are given by the class's bounds. Parameters ---------- maps : dict or FieldArray A dictionary or FieldArray which provides a map between the parameter name of the variable...
f15991:c11:m7
def jacobian(self, maps):
x = maps[self._inputvar]<EOL>isin = self._bounds.__contains__(x)<EOL>if isinstance(isin, numpy.ndarray) and not isin.all():<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>elif not isin:<EOL><INDENT>raise ValueError("<STR_LIT>".format(x))<EOL><DEDENT>return (self._b - self._a)/((x - self._a)*(self._b - x))<EOL>
r"""Computes the Jacobian of :math:`y = \mathrm{logit}(x; a,b)`. This is: .. math:: \frac{\mathrm{d}y}{\mathrm{d}x} = \frac{b -a}{(x-a)(b-x)}, where :math:`x \in (a, b)`. Parameters ---------- maps : dict or FieldArray A dictionary or FieldArr...
f15991:c11:m8
def inverse_jacobian(self, maps):
x = maps[self._outputvar]<EOL>expx = numpy.exp(x)<EOL>return expx * (self._b - self._a) / (<NUM_LIT:1.> + expx)**<NUM_LIT><EOL>
r"""Computes the Jacobian of :math:`y = \mathrm{logistic}(x; a,b)`. This is: .. math:: \frac{\mathrm{d}y}{\mathrm{d}x} = \frac{e^x (b-a)}{(1+e^y)^2}, where :math:`y \in (a, b)`. Parameters ---------- maps : dict or FieldArray A dictionary or F...
f15991:c11:m9
@classmethod<EOL><INDENT>def from_config(cls, cp, section, outputs, skip_opts=None,<EOL>additional_opts=None):<DEDENT>
<EOL>inputvar = cp.get_opt_tag(section, '<STR_LIT>', outputs)<EOL>s = '<STR_LIT:->'.join([section, outputs])<EOL>opt = '<STR_LIT>'.format(inputvar)<EOL>if skip_opts is None:<EOL><INDENT>skip_opts = []<EOL><DEDENT>if additional_opts is None:<EOL><INDENT>additional_opts = {}<EOL><DEDENT>else:<EOL><INDENT>additional_opts ...
Initializes a Logit transform from the given section. The section must specify an input and output variable name. The domain of the input may be specified using `min-{input}`, `max-{input}`. Example: .. code-block:: ini [{section}-logitq] name = logit ...
f15991:c11:m10
def transform(self, maps):
sx, sy, sz = self._inputs<EOL>data = coordinates.cartesian_to_spherical(maps[sx], maps[sy], maps[sz])<EOL>out = {param : val for param, val in zip(self._outputs, data)}<EOL>return self.format_output(maps, out)<EOL>
This function transforms from cartesian to spherical spins. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transformed values.
f15991:c15:m0
def inverse_transform(self, maps):
a, az, po = self._outputs<EOL>data = coordinates.spherical_to_cartesian(maps[a], maps[az], maps[po])<EOL>out = {param : val for param, val in zip(self._outputs, data)}<EOL>return self.format_output(maps, out)<EOL>
This function transforms from spherical to cartesian spins. Parameters ---------- maps : a mapping object Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transformed values.
f15991:c15:m1
@property<EOL><INDENT>def bounds(self):<DEDENT>
return self._bounds<EOL>
Returns the range of the output parameter.
f15991:c20:m1
@classmethod<EOL><INDENT>def from_config(cls, cp, section, outputs, skip_opts=None,<EOL>additional_opts=None):<DEDENT>
<EOL>outputvar = cp.get_opt_tag(section, '<STR_LIT>', outputs)<EOL>if skip_opts is None:<EOL><INDENT>skip_opts = []<EOL><DEDENT>if additional_opts is None:<EOL><INDENT>additional_opts = {}<EOL><DEDENT>else:<EOL><INDENT>additional_opts = additional_opts.copy()<EOL><DEDENT>s = '<STR_LIT:->'.join([section, outputs])<EOL>o...
Initializes a Logistic transform from the given section. The section must specify an input and output variable name. The codomain of the output may be specified using `min-{output}`, `max-{output}`. Example: .. code-block:: ini [{section}-q] name = logistic ...
f15991:c20:m2
def select_splitfilejob_instance(curr_exe):
if curr_exe == '<STR_LIT>':<EOL><INDENT>exe_class = PycbcSplitBankExecutable<EOL><DEDENT>elif curr_exe == '<STR_LIT>':<EOL><INDENT>exe_class = PycbcSplitBankXmlExecutable<EOL><DEDENT>elif curr_exe == '<STR_LIT>':<EOL><INDENT>exe_class = PycbcSplitInspinjExecutable<EOL><DEDENT>else:<EOL><INDENT>err_string = "<STR_LIT>" ...
This function returns an instance of the class that is appropriate for splitting an output file up within workflow (for e.g. splitbank). Parameters ---------- curr_exe : string The name of the Executable that is being used. curr_section : string The name of the section storing options for this executble Retur...
f15992:m0
def setup_splittable_workflow(workflow, input_tables, out_dir=None, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>make_analysis_dir(out_dir)<EOL>splitMethod = workflow.cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags)<EOL>if splitMethod == "<STR_LIT>":<EOL><INDENT>logging.info("<STR_LIT>")<EOL>split_table_outs = setup_splittable_dax_generated(workfl...
This function aims to be the gateway for code that is responsible for taking some input file containing some table, and splitting into multiple files containing different parts of that table. For now the only supported operation is using lalapps_splitbank to split a template bank xml file into multiple template bank xm...
f15992:m1
def setup_splittable_dax_generated(workflow, input_tables, out_dir, tags):
cp = workflow.cp<EOL>try:<EOL><INDENT>num_splits = cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags)<EOL><DEDENT>except BaseException:<EOL><INDENT>inj_interval = int(cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags))<EOL>if cp.has_option_tags("<STR_LIT>", "<STR_LIT>", tags) andcp.has_option("<STR_LIT>", "<STR_LIT>"...
Function for setting up the splitting jobs as part of the workflow. Parameters ----------- workflow : pycbc.workflow.core.Workflow The Workflow instance that the jobs will be added to. input_tables : pycbc.workflow.core.FileList The input files to be split up. out_dir : path The directory in which output w...
f15992:m2
def setup_psd_workflow(workflow, science_segs, datafind_outs,<EOL>output_dir=None, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>make_analysis_dir(output_dir)<EOL>cp = workflow.cp<EOL>try:<EOL><INDENT>psdMethod = cp.get_opt_tags("<STR_LIT>", "<STR_LIT>",<EOL>tags)<EOL><DEDENT>except:<EOL><INDENT>return FileList([])<EOL><DEDENT>if psdMethod == "<STR_LIT>":<EOL><INDEN...
Setup static psd section of CBC workflow. At present this only supports pregenerated psd files, in the future these could be created within the workflow. Parameters ---------- workflow: pycbc.workflow.core.Workflow An instanced class that manages the constructed workflow. science_segs : Keyed dictionary of glue.se...
f15993:m0
def setup_psd_pregenerated(workflow, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>psd_files = FileList([])<EOL>cp = workflow.cp<EOL>global_seg = workflow.analysis_time<EOL>user_tag = "<STR_LIT>"<EOL>try:<EOL><INDENT>pre_gen_file = cp.get_opt_tags('<STR_LIT>',<EOL>'<STR_LIT>', tags)<EOL>pre_gen_file = resolve_url(pre_gen_file)<EOL>file_url = urlparse...
Setup CBC workflow to use pregenerated psd files. The file given in cp.get('workflow','pregenerated-psd-file-(ifo)') will be used as the --psd-file argument to geom_nonspinbank, geom_aligned_bank and pycbc_plot_psd_file. Parameters ---------- workflow: pycbc.workflow.core.Workflow An instanced class that manages t...
f15993:m1
def int_gps_time_to_str(t):
if isinstance(t, int):<EOL><INDENT>return str(t)<EOL><DEDENT>elif isinstance(t, float):<EOL><INDENT>int_t = int(t)<EOL>if abs(t - int_t) > <NUM_LIT:0.>:<EOL><INDENT>raise ValueError('<STR_LIT>' % str(t))<EOL><DEDENT>return str(int_t)<EOL><DEDENT>elif isinstance(t, lal.LIGOTimeGPS):<EOL><INDENT>if t.gpsNanoSeconds == <N...
Takes an integer GPS time, either given as int or lal.LIGOTimeGPS, and converts it to a string. If a LIGOTimeGPS with nonzero decimal part is given, raises a ValueError.
f15994:m0
def select_tmpltbank_class(curr_exe):
exe_to_class_map = {<EOL>'<STR_LIT>' : PyCBCTmpltbankExecutable,<EOL>'<STR_LIT>': PyCBCTmpltbankExecutable<EOL>}<EOL>try:<EOL><INDENT>return exe_to_class_map[curr_exe]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>" % curr_exe)<EOL><DEDENT>
This function returns a class that is appropriate for setting up template bank jobs within workflow. Parameters ---------- curr_exe : string The name of the executable to be used for generating template banks. Returns -------- exe_class : Sub-class of pycbc.workflow.core.Executable...
f15994:m1
def select_matchedfilter_class(curr_exe):
exe_to_class_map = {<EOL>'<STR_LIT>' : PyCBCInspiralExecutable,<EOL>'<STR_LIT>' : PyCBCInspiralExecutable,<EOL>'<STR_LIT>' : PyCBCMultiInspiralExecutable,<EOL>}<EOL>try:<EOL><INDENT>return exe_to_class_map[curr_exe]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>" % curr...
This function returns a class that is appropriate for setting up matched-filtering jobs within workflow. Parameters ---------- curr_exe : string The name of the matched filter executable to be used. Returns -------- exe_class : Sub-class of pycbc.workflow.core.Executable that holds...
f15994:m2
def select_generic_executable(workflow, exe_tag):
exe_path = workflow.cp.get("<STR_LIT>", exe_tag)<EOL>exe_name = os.path.basename(exe_path)<EOL>exe_to_class_map = {<EOL>'<STR_LIT>' : LigolwAddExecutable,<EOL>'<STR_LIT>' : LigolwSSthincaExecutable,<EOL>'<STR_LIT>' : PycbcSqliteSimplifyExecutable,<EOL>'<STR_LIT>': SQLInOutExecutable,<EOL>'<ST...
Returns a class that is appropriate for setting up jobs to run executables having specific tags in the workflow config. Executables should not be "specialized" jobs fitting into one of the select_XXX_class functions above, i.e. not a matched filter or template bank job, which require extra setup. P...
f15994:m3
def sngl_ifo_job_setup(workflow, ifo, out_files, curr_exe_job, science_segs,<EOL>datafind_outs, parents=None,<EOL>link_job_instance=None, allow_overlap=True,<EOL>compatibility_mode=True):
if compatibility_mode and not link_job_instance:<EOL><INDENT>errMsg = "<STR_LIT>"<EOL>raise ValueError(errMsg)<EOL><DEDENT>data_length, valid_chunk, valid_length = identify_needed_data(curr_exe_job,<EOL>link_job_instance=link_job_instance)<EOL>for curr_seg in science_segs:<EOL><INDENT>segmenter = JobSegmenter(data_leng...
This function sets up a set of single ifo jobs. A basic overview of how this works is as follows: * (1) Identify the length of data that each job needs to read in, and what part of that data the job is valid for. * START LOOPING OVER SCIENCE SEGMENTS * (2) Identify how many jobs are needed (if an...
f15994:m4
def multi_ifo_coherent_job_setup(workflow, out_files, curr_exe_job,<EOL>science_segs, datafind_outs, output_dir,<EOL>parents=None, slide_dict=None, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>data_seg, job_valid_seg = curr_exe_job.get_valid_times()<EOL>curr_out_files = FileList([])<EOL>if '<STR_LIT>' in datafind_outs[-<NUM_LIT:1>].descriptionand '<STR_LIT>' in datafind_outs[-<NUM_LIT:2>].description:<EOL><INDENT>ipn_sky_points = datafind_outs[-<NUM_LIT:1>]<...
Method for setting up coherent inspiral jobs.
f15994:m5
def identify_needed_data(curr_exe_job, link_job_instance=None):
<EOL>data_lengths, valid_chunks = curr_exe_job.get_valid_times()<EOL>valid_lengths = [abs(valid_chunk) for valid_chunk in valid_chunks]<EOL>if link_job_instance:<EOL><INDENT>link_data_length, link_valid_chunk = link_job_instance.get_valid_times()<EOL>if len(link_data_length) > <NUM_LIT:1> or len(valid_lengths) > <NUM_L...
This function will identify the length of data that a specific executable needs to analyse and what part of that data is valid (ie. inspiral doesn't analyse the first or last 64+8s of data it reads in). In addition you can supply a second job instance to "link" to, which will ensure that the two jobs w...
f15994:m6
def __init__(self, data_lengths, valid_chunks, valid_lengths, curr_seg,<EOL>curr_exe_class, compatibility_mode = False):
self.exe_class = curr_exe_class<EOL>self.curr_seg = curr_seg<EOL>self.curr_seg_length = float(abs(curr_seg))<EOL>self.data_length, self.valid_chunk, self.valid_length =self.pick_tile_size(self.curr_seg_length, data_lengths,<EOL>valid_chunks, valid_lengths)<EOL>self.data_chunk = segments.segment([<NUM_LIT:0>, self.data_...
Initialize class.
f15994:c0:m0
def pick_tile_size(self, seg_size, data_lengths, valid_chunks, valid_lengths):
if len(valid_lengths) == <NUM_LIT:1>:<EOL><INDENT>return data_lengths[<NUM_LIT:0>], valid_chunks[<NUM_LIT:0>], valid_lengths[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>target_size = seg_size / <NUM_LIT:3><EOL>pick, pick_diff = <NUM_LIT:0>, abs(valid_lengths[<NUM_LIT:0>] - target_size)<EOL>for i, size in enumerate(valid...
Choose job tiles size based on science segment length
f15994:c0:m1
def get_valid_times_for_job(self, num_job, allow_overlap=True):
if self.compatibility_mode:<EOL><INDENT>return self.get_valid_times_for_job_legacy(num_job)<EOL><DEDENT>else:<EOL><INDENT>return self.get_valid_times_for_job_workflow(num_job,<EOL>allow_overlap=allow_overlap)<EOL><DEDENT>
Get the times for which this job is valid.
f15994:c0:m2
def get_valid_times_for_job_workflow(self, num_job, allow_overlap=True):
<EOL>shift_dur = self.curr_seg[<NUM_LIT:0>] + int(self.job_time_shift * num_job+ <NUM_LIT>)<EOL>job_valid_seg = self.valid_chunk.shift(shift_dur)<EOL>if not allow_overlap:<EOL><INDENT>data_per_job = (self.curr_seg_length - self.data_loss) /float(self.num_jobs)<EOL>lower_boundary = num_job*data_per_job +self.valid_chunk...
Get the times for which the job num_job will be valid, using workflow's method.
f15994:c0:m3
def get_valid_times_for_job_legacy(self, num_job):
<EOL>shift_dur = self.curr_seg[<NUM_LIT:0>] + int(self.job_time_shift * num_job)<EOL>job_valid_seg = self.valid_chunk.shift(shift_dur)<EOL>if num_job == (self.num_jobs - <NUM_LIT:1>):<EOL><INDENT>dataPushBack = self.data_length - self.valid_chunk[<NUM_LIT:1>]<EOL>job_valid_seg = segments.segment(job_valid_seg[<NUM_LIT:...
Get the times for which the job num_job will be valid, using the method use in inspiral hipe.
f15994:c0:m4
def get_data_times_for_job(self, num_job):
if self.compatibility_mode:<EOL><INDENT>job_data_seg = self.get_data_times_for_job_legacy(num_job)<EOL><DEDENT>else:<EOL><INDENT>job_data_seg = self.get_data_times_for_job_workflow(num_job)<EOL><DEDENT>if num_job == <NUM_LIT:0>:<EOL><INDENT>if job_data_seg[<NUM_LIT:0>] != self.curr_seg[<NUM_LIT:0>]:<EOL><INDENT>err= ...
Get the data that this job will read in.
f15994:c0:m5
def get_data_times_for_job_workflow(self, num_job):
<EOL>shift_dur = self.curr_seg[<NUM_LIT:0>] + int(self.job_time_shift * num_job+ <NUM_LIT>)<EOL>job_data_seg = self.data_chunk.shift(shift_dur)<EOL>return job_data_seg<EOL>
Get the data that this job will need to read in.
f15994:c0:m6
def get_data_times_for_job_legacy(self, num_job):
<EOL>shift_dur = self.curr_seg[<NUM_LIT:0>] + int(self.job_time_shift * num_job)<EOL>job_data_seg = self.data_chunk.shift(shift_dur)<EOL>if num_job == (self.num_jobs - <NUM_LIT:1>):<EOL><INDENT>dataPushBack = job_data_seg[<NUM_LIT:1>] - self.curr_seg[<NUM_LIT:1>]<EOL>assert dataPushBack >= <NUM_LIT:0><EOL>job_data_seg ...
Get the data that this job will need to read in.
f15994:c0:m7
def get_valid_times(self):
if self.cp.has_option('<STR_LIT>',<EOL>'<STR_LIT>'):<EOL><INDENT>min_analysis_segs = int(self.cp.get('<STR_LIT>',<EOL>'<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>min_analysis_segs = <NUM_LIT:0><EOL><DEDENT>if self.cp.has_option('<STR_LIT>',<EOL>'<STR_LIT>'):<EOL><INDENT>max_analysis_segs = int(self.cp.get('<STR_LIT>',<...
Determine possible dimensions of needed input and valid output
f15994:c1:m2
def zero_pad_data_extend(self, job_data_seg, curr_seg):
if self.zero_padding is False:<EOL><INDENT>return job_data_seg<EOL><DEDENT>else:<EOL><INDENT>start_pad = int(self.get_opt( '<STR_LIT>'))<EOL>end_pad = int(self.get_opt('<STR_LIT>'))<EOL>new_data_start = max(curr_seg[<NUM_LIT:0>], job_data_seg[<NUM_LIT:0>] - start_pad)<EOL>new_data_end = min(curr_seg[<NUM_LIT:1>], job_d...
When using zero padding, *all* data is analysable, but the setup functions must include the padding data where it is available so that we are not zero-padding in the middle of science segments. This function takes a job_data_seg, that is chosen for a particular node and extends it with s...
f15994:c1:m3
def create_nodata_node(self, valid_seg, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>node = Node(self)<EOL>if self.write_psd:<EOL><INDENT>node.new_output_file_opt(valid_seg, '<STR_LIT>', '<STR_LIT>',<EOL>tags=tags+['<STR_LIT>'], store_file=self.retain_files)<EOL><DEDENT>node.new_output_file_opt(valid_seg, '<STR_LIT>', '<STR_LIT>',<EOL>store_file=self.r...
A simplified version of create_node that creates a node that does not need to read in data. Parameters ----------- valid_seg : glue.segment The segment over which to declare the node valid. Usually this would be the duration of the analysis. Returns ...
f15994:c3:m2
def create_node(self, bank, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>node = Node(self)<EOL>node.add_input_opt('<STR_LIT>', bank)<EOL>out_files = FileList([])<EOL>for i in range( <NUM_LIT:0>, self.num_banks):<EOL><INDENT>curr_tag = '<STR_LIT>' %(i)<EOL>curr_tags = bank.tags + [curr_tag] + tags<EOL>job_tag = bank.description + "<STR_LIT:_...
Set up a CondorDagmanNode class to run splitbank code Parameters ---------- bank : pycbc.workflow.core.File The File containing the template bank to be split Returns -------- node : pycbc.workflow.core.Node The node to run the job
f15994:c29:m1
def create_node(self, config_file=None, seed=None, tags=None):
<EOL>tags = [] if tags is None else tags<EOL>start_time = self.cp.get("<STR_LIT>", "<STR_LIT>")<EOL>end_time = self.cp.get("<STR_LIT>", "<STR_LIT>")<EOL>analysis_time = segments.segment(int(start_time), int(end_time))<EOL>node = Node(self)<EOL>node.add_input_opt("<STR_LIT>", config_file)<EOL>if seed:<EOL><INDENT>node.a...
Set up a CondorDagmanNode class to run ``pycbc_create_injections``. Parameters ---------- config_file : pycbc.workflow.core.File A ``pycbc.workflow.core.File`` for inference configuration file to be used with ``--config-files`` option. seed : int Seed...
f15994:c32:m1
def create_node(self, channel_names, config_file, injection_file=None,<EOL>seed=None, fake_strain_seed=None, tags=None):
<EOL>tags = [] if tags is None else tags<EOL>start_time = self.cp.get("<STR_LIT>", "<STR_LIT>")<EOL>end_time = self.cp.get("<STR_LIT>", "<STR_LIT>")<EOL>analysis_time = segments.segment(int(start_time), int(end_time))<EOL>channel_names_opt = "<STR_LIT:U+0020>".join(["<STR_LIT>".format(k, v)<EOL>for k, v in channel_name...
Set up a CondorDagmanNode class to run ``pycbc_inference``. Parameters ---------- channel_names : dict A ``dict`` of ``str`` to use for ``--channel-name`` option. config_file : pycbc.workflow.core.File A ``pycbc.workflow.core.File`` for inference configuration fi...
f15994:c33:m1
def setup_datafind_workflow(workflow, scienceSegs, outputDir, seg_file=None,<EOL>tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>make_analysis_dir(outputDir)<EOL>cp = workflow.cp<EOL>datafind_method = cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags)<EOL>if cp.has_option_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags):<EOL><INDENT>checkSegmentGaps = cp.get_opt_tags("<STR...
Setup datafind section of the workflow. This section is responsible for generating, or setting up the workflow to generate, a list of files that record the location of the frame files needed to perform the analysis. There could be multiple options here, the datafind jobs could be done at run time or could be put into a...
f15995:m0
def setup_datafind_runtime_cache_multi_calls_perifo(cp, scienceSegs,<EOL>outputDir, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>connection = setup_datafind_server_connection(cp, tags=tags)<EOL>datafindouts = []<EOL>datafindcaches = []<EOL>logging.info("<STR_LIT>")<EOL>for ifo, scienceSegsIfo in scienceSegs.items():<EOL><INDENT>observatory = ifo[<NUM_LIT:0>].upper()...
This function uses the glue.datafind library to obtain the location of all the frame files that will be needed to cover the analysis of the data given in scienceSegs. This function will not check if the returned frames cover the whole time requested, such sanity checks are done in the pycbc.workflow.setup_datafind_work...
f15995:m1
def setup_datafind_runtime_cache_single_call_perifo(cp, scienceSegs, outputDir,<EOL>tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>connection = setup_datafind_server_connection(cp, tags=tags)<EOL>cp.set("<STR_LIT>","<STR_LIT>","<STR_LIT:ignore>")<EOL>datafindouts = []<EOL>datafindcaches = []<EOL>logging.info("<STR_LIT>")<EOL>for ifo, scienceSegsIfo in scienceSegs.item...
This function uses the glue.datafind library to obtain the location of all the frame files that will be needed to cover the analysis of the data given in scienceSegs. This function will not check if the returned frames cover the whole time requested, such sanity checks are done in the pycbc.workflow.setup_datafind_work...
f15995:m2
def setup_datafind_runtime_frames_single_call_perifo(cp, scienceSegs,<EOL>outputDir, tags=None):
datafindcaches, _ =setup_datafind_runtime_cache_single_call_perifo(cp, scienceSegs,<EOL>outputDir, tags=tags)<EOL>datafindouts = convert_cachelist_to_filelist(datafindcaches)<EOL>return datafindcaches, datafindouts<EOL>
This function uses the glue.datafind library to obtain the location of all the frame files that will be needed to cover the analysis of the data given in scienceSegs. This function will not check if the returned frames cover the whole time requested, such sanity checks are done in the pycbc.workflow.setup_datafind_work...
f15995:m3
def setup_datafind_runtime_frames_multi_calls_perifo(cp, scienceSegs,<EOL>outputDir, tags=None):
datafindcaches, _ =setup_datafind_runtime_cache_multi_calls_perifo(cp, scienceSegs,<EOL>outputDir, tags=tags)<EOL>datafindouts = convert_cachelist_to_filelist(datafindcaches)<EOL>return datafindcaches, datafindouts<EOL>
This function uses the glue.datafind library to obtain the location of all the frame files that will be needed to cover the analysis of the data given in scienceSegs. This function will not check if the returned frames cover the whole time requested, such sanity checks are done in the pycbc.workflow.setup_datafind_work...
f15995:m4
def setup_datafind_from_pregenerated_lcf_files(cp, ifos, outputDir, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>datafindcaches = []<EOL>for ifo in ifos:<EOL><INDENT>search_string = "<STR_LIT>" %(ifo.lower(),)<EOL>frame_cache_file_name = cp.get_opt_tags("<STR_LIT>",<EOL>search_string, tags=tags)<EOL>curr_cache = lal.Cache.fromfilenames([frame_cache_file_name],<EOL>coltype=lal.LIG...
This function is used if you want to run with pregenerated lcf frame cache files. Parameters ----------- cp : ConfigParser.ConfigParser instance This contains a representation of the information stored within the workflow configuration files ifos : list of ifo strings List of ifos to get pregenerated files...
f15995:m5
def convert_cachelist_to_filelist(datafindcache_list):
prev_file = None<EOL>prev_name = None<EOL>this_name = None<EOL>datafind_filelist = FileList([])<EOL>for cache in datafindcache_list:<EOL><INDENT>cache.sort()<EOL>curr_ifo = cache.ifo<EOL>for frame in cache:<EOL><INDENT>frame.url = frame.url.replace('<STR_LIT>','<STR_LIT>')<EOL>if prev_file:<EOL><INDENT>prev_name = os.p...
Take as input a list of glue.lal.Cache objects and return a pycbc FileList containing all frames within those caches. Parameters ----------- datafindcache_list : list of glue.lal.Cache objects The list of cache files to convert. Returns -------- datafind_filelist : FileList of frame File objects The list of f...
f15995:m6
def get_science_segs_from_datafind_outs(datafindcaches):
newScienceSegs = {}<EOL>for cache in datafindcaches:<EOL><INDENT>if len(cache) > <NUM_LIT:0>:<EOL><INDENT>groupSegs = segments.segmentlist(e.segment for e in cache).coalesce()<EOL>ifo = cache.ifo<EOL>if ifo not in newScienceSegs:<EOL><INDENT>newScienceSegs[ifo] = groupSegs<EOL><DEDENT>else:<EOL><INDENT>newScienceSegs[i...
This function will calculate the science segments that are covered in the OutGroupList containing the frame files returned by various calls to the datafind server. This can then be used to check whether this list covers what it is expected to cover. Parameters ---------- datafindcaches : OutGroupList List of all t...
f15995:m7
def get_missing_segs_from_frame_file_cache(datafindcaches):
missingFrameSegs = {}<EOL>missingFrames = {}<EOL>for cache in datafindcaches:<EOL><INDENT>if len(cache) > <NUM_LIT:0>:<EOL><INDENT>if not cache[<NUM_LIT:0>].scheme == '<STR_LIT:file>':<EOL><INDENT>warn_msg = "<STR_LIT>" %(cache[<NUM_LIT:0>].scheme,)<EOL>warn_msg += "<STR_LIT>"<EOL>logging.info(warn_msg)<EOL>continue<EO...
This function will use os.path.isfile to determine if all the frame files returned by the local datafind server actually exist on the disk. This can then be used to update the science times if needed. Parameters ----------- datafindcaches : OutGroupList List of all the datafind output files. Returns -------- miss...
f15995:m8
def setup_datafind_server_connection(cp, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>if cp.has_option_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags):<EOL><INDENT>datafind_server = cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", tags)<EOL><DEDENT>else:<EOL><INDENT>datafind_server = None<EOL><DEDENT>return datafind_connection(datafind_server)<EOL>
This function is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server.
f15995:m9
def get_segment_summary_times(scienceFile, segmentName):
<EOL>segmentName = segmentName.split('<STR_LIT::>')<EOL>if not len(segmentName) in [<NUM_LIT:2>,<NUM_LIT:3>]:<EOL><INDENT>raise ValueError("<STR_LIT>" %(segmentName))<EOL><DEDENT>ifo = segmentName[<NUM_LIT:0>]<EOL>channel = segmentName[<NUM_LIT:1>]<EOL>version = '<STR_LIT>'<EOL>if len(segmentName) == <NUM_LIT:3>:<EOL><...
This function will find the times for which the segment_summary is set for the flag given by segmentName. Parameters ----------- scienceFile : SegFile The segment file that we want to use to determine this. segmentName : string The DQ flag to search for times in the segment_summary table. Returns --------- su...
f15995:m10
def run_datafind_instance(cp, outputDir, connection, observatory, frameType,<EOL>startTime, endTime, ifo, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>seg = segments.segment([startTime, endTime])<EOL>dfKwargs = {}<EOL>dfKwargs['<STR_LIT>'] = '<STR_LIT:ignore>'<EOL>if cp.has_section("<STR_LIT>"):<EOL><INDENT>for item, value in cp.items("<STR_LIT>"):<EOL><INDENT>dfKwargs[item] = value<EOL><DEDENT><DEDENT>for tag in tag...
This function will query the datafind server once to find frames between the specified times for the specified frame type and observatory. Parameters ---------- cp : ConfigParser instance Source for any kwargs that should be sent to the datafind module outputDir : Output cache files will be written here. We also w...
f15995:m11
def log_datafind_command(observatory, frameType, startTime, endTime,<EOL>outputDir, **dfKwargs):
<EOL>gw_command = ['<STR_LIT>', '<STR_LIT>', observatory,<EOL>'<STR_LIT>', frameType,<EOL>'<STR_LIT>', str(startTime),<EOL>'<STR_LIT>', str(endTime)]<EOL>for name, value in dfKwargs.items():<EOL><INDENT>if name == '<STR_LIT>':<EOL><INDENT>gw_command.append("<STR_LIT>")<EOL>gw_command.append(str(value))<EOL><DEDENT>elif...
This command will print an equivalent gw_data_find command to disk that can be used to debug why the internal datafind module is not working.
f15995:m12
def datafind_keep_unique_backups(backup_outs, orig_outs):
<EOL>return_list = FileList([])<EOL>orig_names = [f.name for f in orig_outs]<EOL>for file in backup_outs:<EOL><INDENT>if file.name not in orig_names:<EOL><INDENT>return_list.append(file)<EOL><DEDENT>else:<EOL><INDENT>index_num = orig_names.index(file.name)<EOL>orig_out = orig_outs[index_num]<EOL>pfns = list(file.pfns)<...
This function will take a list of backup datafind files, presumably obtained by querying a remote datafind server, e.g. CIT, and compares these against a list of original datafind files, presumably obtained by querying the local datafind server. Only the datafind files in the backup list that do not app...
f15995:m13
def grouper(iterable, n, fillvalue=None):
args = [iter(iterable)] * n<EOL>return izip_longest(*args, fillvalue=fillvalue)<EOL>
Create a list of n length tuples
f15996:m0
def setup_foreground_minifollowups(workflow, coinc_file, single_triggers,<EOL>tmpltbank_file, insp_segs, insp_data_name,<EOL>insp_anal_name, dax_output, out_dir, tags=None):
logging.info('<STR_LIT>')<EOL>if not workflow.cp.has_section('<STR_LIT>'):<EOL><INDENT>logging.info('<STR_LIT>')<EOL>logging.info('<STR_LIT>')<EOL>return<EOL><DEDENT>tags = [] if tags is None else tags<EOL>makedir(dax_output)<EOL>config_path = os.path.abspath(dax_output + '<STR_LIT:/>' + '<STR_LIT:_>'.join(tags) + '<ST...
Create plots that followup the Nth loudest coincident injection from a statmap produced HDF file. Parameters ---------- workflow: pycbc.workflow.Workflow The core workflow instance we are populating coinc_file: single_triggers: list of pycbc.workflow.File A list cointaining the ...
f15996:m1
def setup_single_det_minifollowups(workflow, single_trig_file, tmpltbank_file,<EOL>insp_segs, insp_data_name, insp_anal_name,<EOL>dax_output, out_dir, veto_file=None,<EOL>veto_segment_name=None, tags=None):
logging.info('<STR_LIT>')<EOL>if not workflow.cp.has_section('<STR_LIT>'):<EOL><INDENT>msg = '<STR_LIT>'<EOL>msg += '<STR_LIT>'<EOL>logging.info(msg)<EOL>logging.info('<STR_LIT>')<EOL>return<EOL><DEDENT>tags = [] if tags is None else tags<EOL>makedir(dax_output)<EOL>curr_ifo = single_trig_file.ifo<EOL>config_path = os....
Create plots that followup the Nth loudest clustered single detector triggers from a merged single detector trigger HDF file. Parameters ---------- workflow: pycbc.workflow.Workflow The core workflow instance we are populating single_trig_file: pycbc.workflow.File The File class hol...
f15996:m2
def setup_injection_minifollowups(workflow, injection_file, inj_xml_file,<EOL>single_triggers, tmpltbank_file,<EOL>insp_segs, insp_data_name, insp_anal_name,<EOL>dax_output, out_dir, tags=None):
logging.info('<STR_LIT>')<EOL>if not workflow.cp.has_section('<STR_LIT>'):<EOL><INDENT>logging.info('<STR_LIT>')<EOL>logging.info('<STR_LIT>')<EOL>return<EOL><DEDENT>tags = [] if tags is None else tags<EOL>makedir(dax_output)<EOL>config_path = os.path.abspath(dax_output + '<STR_LIT:/>' + '<STR_LIT:_>'.join(tags) + '<ST...
Create plots that followup the closest missed injections Parameters ---------- workflow: pycbc.workflow.Workflow The core workflow instance we are populating coinc_file: single_triggers: list of pycbc.workflow.File A list cointaining the file objects associated with the merged ...
f15996:m3
def make_single_template_plots(workflow, segs, data_read_name, analyzed_name,<EOL>params, out_dir, inj_file=None, exclude=None,<EOL>require=None, tags=None, params_str=None,<EOL>use_exact_inj_params=False):
tags = [] if tags is None else tags<EOL>makedir(out_dir)<EOL>name = '<STR_LIT>'<EOL>secs = requirestr(workflow.cp.get_subsections(name), require)<EOL>secs = excludestr(secs, exclude)<EOL>files = FileList([])<EOL>for tag in secs:<EOL><INDENT>for ifo in workflow.ifos:<EOL><INDENT>if params['<STR_LIT>' % ifo] == -<NUM_LIT...
Function for creating jobs to run the pycbc_single_template code and to run the associated plotting code pycbc_single_template_plots and add these jobs to the workflow. Parameters ----------- workflow : workflow.Workflow instance The pycbc.workflow.Workflow instance to add these jobs to. ...
f15996:m4
def make_plot_waveform_plot(workflow, params, out_dir, ifos, exclude=None,<EOL>require=None, tags=None):
tags = [] if tags is None else tags<EOL>makedir(out_dir)<EOL>name = '<STR_LIT>'<EOL>secs = requirestr(workflow.cp.get_subsections(name), require)<EOL>secs = excludestr(secs, exclude)<EOL>files = FileList([])<EOL>for tag in secs:<EOL><INDENT>node = PlotExecutable(workflow.cp, '<STR_LIT>', ifos=ifos,<EOL>out_dir=out_dir,...
Add plot_waveform jobs to the workflow.
f15996:m5
def make_sngl_ifo(workflow, sngl_file, bank_file, trigger_id, out_dir, ifo,<EOL>tags=None, rank=None):
tags = [] if tags is None else tags<EOL>makedir(out_dir)<EOL>name = '<STR_LIT>'<EOL>files = FileList([])<EOL>node = PlotExecutable(workflow.cp, name, ifos=[ifo],<EOL>out_dir=out_dir, tags=tags).create_node()<EOL>node.add_input_opt('<STR_LIT>', sngl_file)<EOL>node.add_input_opt('<STR_LIT>', bank_file)<EOL>node.add_opt('...
Setup a job to create sngl detector sngl ifo html summary snippet.
f15996:m8
def make_qscan_plot(workflow, ifo, trig_time, out_dir, injection_file=None,<EOL>data_segments=None, time_window=<NUM_LIT:100>, tags=None):
tags = [] if tags is None else tags<EOL>makedir(out_dir)<EOL>name = '<STR_LIT>'<EOL>curr_exe = PlotQScanExecutable(workflow.cp, name, ifos=[ifo],<EOL>out_dir=out_dir, tags=tags)<EOL>node = curr_exe.create_node()<EOL>start = trig_time - time_window<EOL>end = trig_time + time_window<EOL>if data_segments is not None:<EOL>...
Generate a make_qscan node and add it to workflow. This function generates a single node of the singles_timefreq executable and adds it to the current workflow. Parent/child relationships are set by the input/output files automatically. Parameters ----------- workflow: pycbc.workflow.core.Work...
f15996:m10
def make_singles_timefreq(workflow, single, bank_file, trig_time, out_dir,<EOL>veto_file=None, time_window=<NUM_LIT:10>, data_segments=None,<EOL>tags=None):
tags = [] if tags is None else tags<EOL>makedir(out_dir)<EOL>name = '<STR_LIT>'<EOL>curr_exe = SingleTimeFreqExecutable(workflow.cp, name, ifos=[single.ifo],<EOL>out_dir=out_dir, tags=tags)<EOL>node = curr_exe.create_node()<EOL>node.add_input_opt('<STR_LIT>', single)<EOL>node.add_input_opt('<STR_LIT>', bank_file)<EOL>s...
Generate a singles_timefreq node and add it to workflow. This function generates a single node of the singles_timefreq executable and adds it to the current workflow. Parent/child relationships are set by the input/output files automatically. Parameters ----------- workflow: pycbc.workflow.cor...
f15996:m11
def create_noop_node():
exe = wdax.Executable('<STR_LIT>')<EOL>pfn = distutils.spawn.find_executable('<STR_LIT:true>')<EOL>exe.add_pfn(pfn)<EOL>node = wdax.Node(exe)<EOL>return node<EOL>
Creates a noop node that can be added to a DAX doing nothing. The reason for using this is if a minifollowups dax contains no triggers currently the dax will contain no jobs and be invalid. By adding a noop node we ensure that such daxes will actually run if one adds one such noop node. Adding such a noop node into a w...
f15996:m12
def chunks(l, n):
newn = int(len(l) / n)<EOL>for i in xrange(<NUM_LIT:0>, n-<NUM_LIT:1>):<EOL><INDENT>yield l[i*newn:i*newn+newn]<EOL><DEDENT>yield l[n*newn-newn:]<EOL>
Yield n successive chunks from l.
f15997:m0
def compute_inj_optimal_snr(workflow, inj_file, precalc_psd_files, out_dir,<EOL>tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>node = Executable(workflow.cp, '<STR_LIT>', ifos=workflow.ifos,<EOL>out_dir=out_dir, tags=tags).create_node()<EOL>node.add_input_opt('<STR_LIT>', inj_file)<EOL>node.add_input_list_opt('<STR_LIT>', precalc_psd_files)<EOL>node.new_output_file_opt(workflow.analysis_time, ...
Set up a job for computing optimal SNRs of a sim_inspiral file.
f15998:m1
def cut_distant_injections(workflow, inj_file, out_dir, tags=None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>node = Executable(workflow.cp, '<STR_LIT>', ifos=workflow.ifos,<EOL>out_dir=out_dir, tags=tags).create_node()<EOL>node.add_input_opt('<STR_LIT>', inj_file)<EOL>node.new_output_file_opt(workflow.analysis_time, '<STR_LIT>', '<STR_LIT>')<EOL>workflow += node<EOL>return no...
Set up a job for removing injections that are too distant to be seen
f15998:m2
def setup_injection_workflow(workflow, output_dir=None,<EOL>inj_section_name='<STR_LIT>', exttrig_file=None,<EOL>tags =None):
if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>make_analysis_dir(output_dir)<EOL>full_segment = workflow.analysis_time<EOL>ifos = workflow.ifos<EOL>inj_tags = []<EOL>inj_files = FileList([])<EOL>for section in workflow.cp.get_subsections(inj_section_name):<EOL><INDENT>inj_tag = sectio...
This function is the gateway for setting up injection-generation jobs in a workflow. It should be possible for this function to support a number of different ways/codes that could be used for doing this, however as this will presumably stay as a single call to a single code (which need not be inspinj) there are current...
f15998:m3
def set_grb_start_end(cp, start, end):
cp.set("<STR_LIT>", "<STR_LIT>", str(start))<EOL>cp.set("<STR_LIT>", "<STR_LIT>", str(end))<EOL>return cp<EOL>
Function to update analysis boundaries as workflow is generated Parameters ---------- cp : pycbc.workflow.configuration.WorkflowConfigParser object The parsed configuration options of a pycbc.workflow.core.Workflow. start : int The start of the workflow analysis time. end : int The end of the workflow analysis time....
f15999:m0
def get_coh_PTF_files(cp, ifos, run_dir, bank_veto=False, summary_files=False):
if os.getenv("<STR_LIT>") is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>lalDir = os.getenv("<STR_LIT>")<EOL>sci_seg = segments.segment(int(cp.get("<STR_LIT>", "<STR_LIT>")),<EOL>int(cp.get("<STR_LIT>", "<STR_LIT>")))<EOL>file_list = FileList([])<EOL>if bank_veto:<EOL><...
Retrieve files needed to run coh_PTF jobs within a PyGRB workflow Parameters ---------- cp : pycbc.workflow.configuration.WorkflowConfigParser object The parsed configuration options of a pycbc.workflow.core.Workflow. ifos : str String containing the analysis interferometer IDs. run_dir : str The run directory, dest...
f15999:m1
def make_exttrig_file(cp, ifos, sci_seg, out_dir):
<EOL>xmldoc = ligolw.Document()<EOL>xmldoc.appendChild(ligolw.LIGO_LW())<EOL>tbl = lsctables.New(lsctables.ExtTriggersTable)<EOL>cols = tbl.validcolumns<EOL>xmldoc.childNodes[-<NUM_LIT:1>].appendChild(tbl)<EOL>row = tbl.appendRow()<EOL>setattr(row, "<STR_LIT>", float(cp.get("<STR_LIT>", "<STR_LIT>")))<EOL>setattr(row, ...
Make an ExtTrig xml file containing information on the external trigger Parameters ---------- cp : pycbc.workflow.configuration.WorkflowConfigParser object The parsed configuration options of a pycbc.workflow.core.Workflow. ifos : str String containing the analysis interferometer IDs. sci_seg : ligo.segments.segment...
f15999:m2
def get_ipn_sky_files(workflow, file_url, tags=None):
tags = tags or []<EOL>ipn_sky_points = resolve_url(file_url)<EOL>sky_points_url = urlparse.urljoin("<STR_LIT>",<EOL>urllib.pathname2url(ipn_sky_points))<EOL>sky_points_file = File(workflow.ifos, "<STR_LIT>",<EOL>workflow.analysis_time, file_url=sky_points_url, tags=tags)<EOL>sky_points_file.PFN(sky_points_url, site="<S...
Retreive the sky point files for searching over the IPN error box and populating it with injections. Parameters ---------- workflow: pycbc.workflow.core.Workflow An instanced class that manages the constructed workflow. file_url : string The URL of the IPN sky points file. tags : list of strings If given t...
f15999:m3
def make_gating_node(workflow, datafind_files, outdir=None, tags=None):
cp = workflow.cp<EOL>if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>condition_strain_class = select_generic_executable(workflow,<EOL>"<STR_LIT>")<EOL>condition_strain_nodes = []<EOL>condition_strain_outs = FileList([])<EOL>for ifo in workflow.ifos:<EOL><INDENT>input_files = FileList([datafind_file for datafind_file...
Generate jobs for autogating the data for PyGRB runs. Parameters ---------- workflow: pycbc.workflow.core.Workflow An instanced class that manages the constructed workflow. datafind_files : pycbc.workflow.core.FileList A FileList containing the frame files to be gated. outdir : string Path of the output di...
f15999:m4
def get_sky_grid_scale(sky_error, sigma_sys=<NUM_LIT>):
return <NUM_LIT> * (sky_error**<NUM_LIT:2> + sigma_sys**<NUM_LIT:2>)**<NUM_LIT:0.5><EOL>
Calculate suitable 3-sigma radius of the search patch, incorporating Fermi GBM systematic if necessary.
f15999:m5
def make_seg_table(workflow, seg_files, seg_names, out_dir, tags=None,<EOL>title_text=None, description=None):
seg_files = list(seg_files)<EOL>seg_names = list(seg_names)<EOL>if tags is None: tags = []<EOL>makedir(out_dir)<EOL>node = PlotExecutable(workflow.cp, '<STR_LIT>', ifos=workflow.ifos,<EOL>out_dir=out_dir, tags=tags).create_node()<EOL>node.add_input_list_opt('<STR_LIT>', seg_files)<EOL>quoted_seg_names = []<EOL>for s in...
Creates a node in the workflow for writing the segment summary table. Returns a File instances for the output file.
f16000:m12
def make_veto_table(workflow, out_dir, vetodef_file=None, tags=None):
if vetodef_file is None:<EOL><INDENT>vetodef_file = workflow.cp.get_opt_tags("<STR_LIT>",<EOL>"<STR_LIT>", [])<EOL>file_url = urlparse.urljoin('<STR_LIT>',<EOL>urllib.pathname2url(vetodef_file))<EOL>vdf_file = File(workflow.ifos, '<STR_LIT>',<EOL>workflow.analysis_time, file_url=file_url)<EOL>vdf_file.PFN(file_url, sit...
Creates a node in the workflow for writing the veto_definer table. Returns a File instances for the output file.
f16000:m13
def make_seg_plot(workflow, seg_files, out_dir, seg_names=None, tags=None):
seg_files = list(seg_files)<EOL>if tags is None: tags = []<EOL>makedir(out_dir)<EOL>node = PlotExecutable(workflow.cp, '<STR_LIT>', ifos=workflow.ifos,<EOL>out_dir=out_dir, tags=tags).create_node()<EOL>node.add_input_list_opt('<STR_LIT>', seg_files)<EOL>quoted_seg_names = []<EOL>for s in seg_names:<EOL><INDENT>quoted_s...
Creates a node in the workflow for plotting science, and veto segments.
f16000:m14
def make_ifar_plot(workflow, trigger_file, out_dir, tags=None,<EOL>hierarchical_level=None):
if hierarchical_level is not None and tags:<EOL><INDENT>tags = [("<STR_LIT>".format(<EOL>hierarchical_level))] + tags<EOL><DEDENT>elif hierarchical_level is not None and not tags:<EOL><INDENT>tags = ["<STR_LIT>".format(hierarchical_level)]<EOL><DEDENT>elif hierarchical_level is None and not tags:<EOL><INDENT>tags = []<...
Creates a node in the workflow for plotting cumulative histogram of IFAR values.
f16000:m15
def _really_load(self, f, filename, ignore_discard, ignore_expires):
now = time.time()<EOL>magic = f.readline()<EOL>if not re.search(self.magic_re, magic):<EOL><INDENT>f.close()<EOL>raise LoadError(<EOL>"<STR_LIT>" %<EOL>filename)<EOL><DEDENT>try:<EOL><INDENT>while <NUM_LIT:1>:<EOL><INDENT>line = f.readline()<EOL>if line == "<STR_LIT>": break<EOL>if line.endswith("<STR_LIT:\n>"): line =...
This function is required to monkey patch MozillaCookieJar's _really_load function which does not understand the curl format cookie file created by ecp-cookie-init. It patches the code so that #HttpOnly_ get loaded. https://bugs.python.org/issue2190 https://bugs.python.org/file37625/httponly.patch
f16001:m0
def istext(s, text_characters=None, threshold=<NUM_LIT>):
text_characters = "<STR_LIT>".join(map(chr, range(<NUM_LIT:32>, <NUM_LIT>))) + "<STR_LIT>"<EOL>_null_trans = string.maketrans("<STR_LIT>", "<STR_LIT>")<EOL>if "<STR_LIT>" in s:<EOL><INDENT>return False<EOL><DEDENT>if not s:<EOL><INDENT>return True<EOL><DEDENT>t = s.translate(_null_trans, text_characters)<EOL>return len...
Determines if the string is a set of binary data or a text file. This is done by checking if a large proportion of characters are > 0X7E (0x7F is <DEL> and unprintable) or low bit control codes. In other words things that you wouldn't see (often) in a text file. (ASCII past 0x7F might appear, but rarely). Code modifie...
f16001:m1
def resolve_url(url, directory=None, permissions=None):
u = urlparse(url)<EOL>if directory is None:<EOL><INDENT>directory = os.getcwd()<EOL><DEDENT>filename = os.path.join(directory,os.path.basename(u.path))<EOL>if u.scheme == '<STR_LIT>' or u.scheme == '<STR_LIT:file>':<EOL><INDENT>if os.path.isfile(u.path):<EOL><INDENT>if os.path.isfile(filename):<EOL><INDENT>src_inode = ...
Resolves a URL to a local file, and returns the path to that file.
f16001:m2
def add_workflow_command_line_group(parser):
workflowArgs = parser.add_argument_group('<STR_LIT>',<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>workflowArgs.add_argument("<STR_LIT>", nargs="<STR_LIT:+>", action='<STR_LIT:store>',<EOL>metavar="<STR_LIT>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>workflowArgs.add_argument("<STR_LIT>", nargs="<STR_LIT:*>", action='<STR_LIT...
The standard way of initializing a ConfigParser object in workflow will be to do it from the command line. This is done by giving a --local-config-files filea.ini fileb.ini filec.ini command. You can also set config file override commands on the command line. This will be most useful when setting (for example) start ...
f16001:m3
def __init__(self, configFiles=None, overrideTuples=None, parsedFilePath=None, deleteTuples=None):
if configFiles is None:<EOL><INDENT>configFiles = []<EOL><DEDENT>if overrideTuples is None:<EOL><INDENT>overrideTuples = []<EOL><DEDENT>if deleteTuples is None:<EOL><INDENT>deleteTuples = []<EOL><DEDENT>glue.pipeline.DeepCopyableConfigParser.__init__(self)<EOL>self.optionxform = str<EOL>configFiles = [resolve_url(cFile...
Initialize an WorkflowConfigParser. This reads the input configuration files, overrides values if necessary and performs the interpolation. See https://ldas-jobs.ligo.caltech.edu/~cbc/docs/pycbc/ahope/initialization_inifile.html Parameters ----------- configFiles : Path to .ini file, or list of paths The file(s) t...
f16001:c0:m0
@classmethod<EOL><INDENT>def from_args(cls, args):<DEDENT>
<EOL>confFiles = []<EOL>if args.config_files:<EOL><INDENT>confFiles += args.config_files<EOL><DEDENT>confDeletes = args.config_delete or []<EOL>parsedDeletes = []<EOL>for delete in confDeletes:<EOL><INDENT>splitDelete = delete.split("<STR_LIT::>")<EOL>if len(splitDelete) > <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL...
Initialize a WorkflowConfigParser instance using the command line values parsed in args. args must contain the values provided by the workflow_command_line_group() function. If you are not using the standard workflow command line interface, you should probably initialize directly using __init__() Parameters ----------...
f16001:c0:m1
def read_ini_file(self, cpFile):
<EOL>self.read(cpFile)<EOL>
Read a .ini file and return it as a ConfigParser class. This function does none of the parsing/combining of sections. It simply reads the file and returns it unedited Stub awaiting more functionality - see configparser_test.py Parameters ---------- cpFile : Path to .ini file, or list of paths The path(s) to a .in...
f16001:c0:m2