Exemple #1
0
def parse_COMPLEX16FrequencySeries(elem):
	t, = elem.getElementsByTagName(ligolw.Time.tagName)
	a, = elem.getElementsByTagName(ligolw.Array.tagName)
	dims = a.getElementsByTagName(ligolw.Dim.tagName)
	f0 = ligolw_param.get_param(elem, u"f0")
	return COMPLEX16FrequencySeries(
		name = a.Name,
		# FIXME:  remove type cast when epoch can be a swig LIGOTimeGPS
		epoch = LIGOTimeGPS(str(t.pcdata)),
		f0 = f0.pcdata * float(LALUnit(f0.Unit) / LALUnit("s^-1")),
		deltaF = dims[0].Scale * float(LALUnit(dims[0].Unit) / LALUnit("s^-1")),
		sampleUnits = LALUnit(a.Unit),
		data = a.array[1] + 1j * a.array[2]
	)
Exemple #2
0
def build_COMPLEX16FrequencySeries(series, comment = None):
	elem = ligolw.LIGO_LW(Attributes({u"Name": u"COMPLEX16FrequencySeries"}))
	if comment is not None:
		elem.appendChild(ligolw.Comment()).pcdata = comment
	elem.appendChild(ligolw.Time.from_gps(series.epoch, Name = u"epoch"))
	elem.appendChild(ligolw_param.from_pyvalue(u"f0", series.f0, unit = LALUnit("s^-1")))
	data = series.data
	data = numpy.row_stack((numpy.arange(0, len(data)) * series.deltaF, numpy.real(data), numpy.imag(data)))
	a = ligolw_array.from_array(series.name, data, dim_names = (u"Frequency", u"Frequency,Real,Imaginary"))
	a.Unit = series.sampleUnits
	dim0 = a.getElementsByTagName(ligolw.Dim.tagName)[0]
	dim0.Unit = LALUnit("s^-1")
	dim0.Start = series.f0
	dim0.Scale = series.deltaF
	elem.appendChild(a)
	return elem
Exemple #3
0
def build_REAL8FrequencySeries(series, comment = None):
	elem = ligolw.LIGO_LW(Attributes({u"Name": u"REAL8FrequencySeries"}))
	if comment is not None:
		elem.appendChild(ligolw.Comment()).pcdata = comment
	elem.appendChild(ligolw.Time.from_gps(series.epoch, Name = u"epoch"))
	elem.appendChild(ligolw_param.from_pyvalue(u"f0", series.f0, unit = LALUnit("s^-1")))
	data = series.data
        try:
            # Support both the pylal-wrapped class, and the direct lal class
            datalength = data.length
            data = data.data
        except:
            datalength = len(data)
	data = numpy.row_stack((numpy.arange(0, datalength) * series.deltaF, data))
	a = ligolw_array.from_array(series.name, data, dim_names = (u"Frequency", u"Frequency,Real"))
	a.Unit = series.sampleUnits
	dim0 = a.getElementsByTagName(ligolw.Dim.tagName)[0]
	dim0.Unit = LALUnit("s^-1")
	dim0.Start = series.f0
	dim0.Scale = series.deltaF
	elem.appendChild(a)
	return elem