static PyObject *__getattro__(PyObject *self, PyObject *attr_name)
{
	const char *name = PyString_AsString(attr_name);
	pylal_COMPLEX16FrequencySeries *obj = (pylal_COMPLEX16FrequencySeries *) self;

	if(!strcmp(name, "name"))
		return PyString_FromString(obj->series->name);
	if(!strcmp(name, "epoch"))
		return pylal_LIGOTimeGPS_new(obj->series->epoch);
	if(!strcmp(name, "f0"))
		return PyFloat_FromDouble(obj->series->f0);
	if(!strcmp(name, "deltaF"))
		return PyFloat_FromDouble(obj->series->deltaF);
	if(!strcmp(name, "sampleUnits"))
		return pylal_LALUnit_new(0, obj->series->sampleUnits);
	if(!strcmp(name, "data")) {
		npy_intp dims[] = {obj->series->data->length};
		PyObject *array = PyArray_SimpleNewFromData(1, dims, NPY_CDOUBLE, obj->series->data->data);
		if(!array)
			return NULL;
		/* incref self to prevent data from disappearing while
		 * array is still in use, and tell numpy to decref self
		 * when the array is deallocated */
		Py_INCREF(self);
		PyArray_SetBaseObject((PyArrayObject *) array, self);
		return array;
	}
	PyErr_SetString(PyExc_AttributeError, name);
	return NULL;
}
Example #2
0
static PyObject *__pos__(PyObject *self)
{
	LIGOTimeGPS gps;

	if(!pyobject_to_ligotimegps(self, &gps))
		return NULL;

	return pylal_LIGOTimeGPS_new(gps);
}
Example #3
0
static PyObject *__neg__(PyObject *self)
{
	LIGOTimeGPS gps;

	if(!pyobject_to_ligotimegps(self, &gps))
		return NULL;

	XLALINT8NSToGPS(&gps, -XLALGPSToINT8NS(&gps));

	return pylal_LIGOTimeGPS_new(gps);
}
Example #4
0
static PyObject *__sub__(PyObject *self, PyObject *other)
{
	LIGOTimeGPS self_gps;
	LIGOTimeGPS other_gps;

	if(!pyobject_to_ligotimegps(self, &self_gps))
		return NULL;
	if(!pyobject_to_ligotimegps(other, &other_gps))
		return NULL;

	XLALINT8NSToGPS(&self_gps, XLALGPSToINT8NS(&self_gps) - XLALGPSToINT8NS(&other_gps));

	return pylal_LIGOTimeGPS_new(self_gps);
}
Example #5
0
static PyObject *__add__(PyObject *self, PyObject *other)
{
	LIGOTimeGPS self_gps;
	LIGOTimeGPS other_gps;

	if(!pyobject_to_ligotimegps(self, &self_gps))
		return NULL;
	if(!pyobject_to_ligotimegps(other, &other_gps))
		return NULL;

	XLALGPSAddGPS(&self_gps, &other_gps);

	return pylal_LIGOTimeGPS_new(self_gps);
}
Example #6
0
static PyObject *__mod__(PyObject *self, PyObject *other)
{
	LIGOTimeGPS gps;
	const double other_double = PyFloat_AsDouble(other);

	if(PyErr_Occurred())
		return NULL;
	if(!pyobject_to_ligotimegps(self, &gps))
		return NULL;

	/* FIXME: loss of precision */
	XLALINT8NSToGPS(&gps, XLALGPSToINT8NS(&gps) % (long long) (other_double * 1e9));

	return pylal_LIGOTimeGPS_new(gps);
}
Example #7
0
static PyObject *__div__(PyObject *self, PyObject *other)
{
	LIGOTimeGPS self_gps;
	/* FIXME:  what about type(other) == LIGOTimeGPS */
	double other_double = PyFloat_AsDouble(other);

	if(PyErr_Occurred())
		return NULL;
	if(!pyobject_to_ligotimegps(self, &self_gps))
		return NULL;

	XLALGPSDivide(&self_gps, other_double);

	return pylal_LIGOTimeGPS_new(self_gps);
}
Example #8
0
static PyObject *__mul__(PyObject *self, PyObject *other)
{
	LIGOTimeGPS gps;
	double factor;

	if(pylal_LIGOTimeGPS_Check(self) && !pylal_LIGOTimeGPS_Check(other)) {
		gps = ((pylal_LIGOTimeGPS *) self)->gps;
		factor = PyFloat_AsDouble(other);
	} else if(!pylal_LIGOTimeGPS_Check(self) && pylal_LIGOTimeGPS_Check(other)) {
		gps = ((pylal_LIGOTimeGPS *) other)->gps;
		factor = PyFloat_AsDouble(self);
	} else {
		Py_INCREF(Py_NotImplemented);
		return Py_NotImplemented;
	}
	if(PyErr_Occurred())
		return NULL;

	XLALGPSMultiply(&gps, factor);

	return pylal_LIGOTimeGPS_new(gps);
}