Ejemplo n.º 1
0
void
stp_channel_convert(const stp_vars_t *v, unsigned *zero_mask)
{
  if (input_has_special_channels(v))
    generate_special_channels(v);
  else if (output_has_gloss(v) && !input_needs_splitting(v))
    copy_channels(v);
  if (output_needs_gcr(v))
    do_gcr(v);
  if (input_needs_splitting(v))
    split_channels(v, zero_mask);
  else
    scale_channels(v, zero_mask);
  (void) limit_ink(v);
  (void) generate_gloss(v, zero_mask);
}
Ejemplo n.º 2
0
static PyObject* cross_correlate(PyObject* self, PyObject* args)
{
    // Parse the args
    const char* my_spc_filename;
    if (!PyArg_ParseTuple(args, "sii", &my_spc_filename, &start_channel, &stop_channel)) {
        return NULL;
    }
    printf("Cross-correlating on %s (START: %d / STOP: %d)\n", my_spc_filename, start_channel, stop_channel);

    // Reset count rates, etc
    int i;
    fifo_gap=0;
    histogram = malloc(sizeof(int)*histogram_bins);
    for (i=0; i<histogram_bins; i+=1) {
        histogram[i]=0;
    }

    // Open the file
    spc_file=fopen(my_spc_filename, "rb");
    if (spc_file==0) {
        return NULL;
    }

    // Examine all of the photons in the file.
    int finished=0;
    grab_chunk();
    while (nrecords>0 && finished!=-1) {
        finished=split_channels();
        process_chunk(0);
        process_chunk(1);
        if (finished!=-1) {
            grab_chunk();
        }
    }

    // Close the SPC file, prepare the data, free memory and return
    fclose(spc_file);
    PyObject* output = build_output_dict();
    free(histogram);
    return output;
}