static PyObject* create(PyObject* self, PyObject* args)
{
    oskar_MeasurementSet* h = 0;
    PyObject *capsule = 0;
    int num_pols = 0, num_channels = 0, num_stations = 0;
    int write_autocorr = 0, write_crosscor = 0;
    double freq_start_hz = 0.0, freq_inc_hz = 0.0;
    const char* file_name = 0;
    if (!PyArg_ParseTuple(args, "siiiddii", &file_name, &num_stations,
            &num_channels, &num_pols, &freq_start_hz, &freq_inc_hz,
            &write_autocorr, &write_crosscor)) return 0;

    /* Create the Measurement Set. */
    h = oskar_ms_create(file_name, "Python script", num_stations, num_channels,
            num_pols, freq_start_hz, freq_inc_hz, write_autocorr,
            write_crosscor);

    /* Check for errors. */
    if (!h)
    {
        PyErr_Format(PyExc_RuntimeError,
                "Unable to create Measurement Set '%s'.", file_name);
        return 0;
    }

    /* Store the pointer in a capsule and return it. */
    capsule = PyCapsule_New((void*)h, name, (PyCapsule_Destructor)ms_free);
    return Py_BuildValue("N", capsule); /* Don't increment refcount. */
}
Exemple #2
0
static PyObject* create(PyObject* self, PyObject* args)
{
    oskar_MeasurementSet* h = 0;
    PyObject *capsule = 0;
    int num_pols = 0, num_channels = 0, num_stations = 0;
    int write_autocorr = 0, write_crosscor = 0;
    double ref_freq_hz = 0.0, chan_width_hz = 0.0;
    const char* file_name = 0;
    if (!PyArg_ParseTuple(args, "siiiddii", &file_name, &num_stations,
            &num_channels, &num_pols, &ref_freq_hz, &chan_width_hz,
            &write_autocorr, &write_crosscor)) return 0;
    h = oskar_ms_create(file_name, "Python script", num_stations, num_channels,
            num_pols, ref_freq_hz, chan_width_hz, write_autocorr,
            write_crosscor);
    capsule = PyCapsule_New((void*)h, name, (PyCapsule_Destructor)ms_free);
    return Py_BuildValue("N", capsule); /* Don't increment refcount. */
}