static void create_averaged_products(oskar_BeamPattern* h, int ta, int ca, int* status) { int s, i, o; if (*status) return; /* Create station-level data products that can be averaged. */ for (s = 0; s < h->num_active_stations; ++s) { /* Text file. */ for (i = I; i <= V; ++i) for (o = I; (o <= V) && h->stokes[i] && h->auto_power_txt; ++o) new_text_file(h, AUTO_POWER, i, o, s, ta, ca, status); /* Can only create images if coordinates are on a grid. */ if (h->coord_grid_type != 'B') continue; /* FITS file. */ for (i = I; i <= V; ++i) for (o = I; (o <= V) && h->stokes[i] && h->auto_power_fits; ++o) new_fits_file(h, AUTO_POWER, i, o, s, ta, ca, status); } /* Text file. */ for (i = I; i <= V; ++i) { if (h->cross_power_raw_txt && h->stokes[i]) new_text_file(h, CROSS_POWER_RAW_COMPLEX, i, -1, -1, ta, ca, status); for (o = I; (o <= V) && h->stokes[i]; ++o) { if (h->cross_power_amp_txt) new_text_file(h, CROSS_POWER_AMP, i, o, -1, ta, ca, status); if (h->cross_power_phase_txt) new_text_file(h, CROSS_POWER_PHASE, i, o, -1, ta, ca, status); } } /* Can only create images if coordinates are on a grid. */ if (h->coord_grid_type != 'B') return; /* FITS file. */ for (i = I; i <= V; ++i) { for (o = I; (o <= V) && h->stokes[i]; ++o) { if (h->cross_power_amp_fits) new_fits_file(h, CROSS_POWER_AMP, i, o, -1, ta, ca, status); if (h->cross_power_phase_fits) new_fits_file(h, CROSS_POWER_PHASE, i, o, -1, ta, ca, status); } } }
void numbers_remove(int bin_num, int text_num) { FILE *text_file, *bin_file; int i, j, k, number, bin_array[bin_num], text_array[text_num + 1]; text_file = fopen(TEXT, "r"); bin_file = fopen(BIN, "rb"); for (i = 0; fscanf(text_file, "%d ", &number) != EOF; i++) { text_array[i] = number; } text_array[i] = -1; for (i = 0; fread(&number, sizeof(int), 1, bin_file); i++) { bin_array[i] = number; } for(j = 0; j < bin_num; j++) { for (i = 0; i < text_num; i++) { if (text_array[i] == bin_array[j]) { for (k = i; k < text_num; k++) text_array[k] = text_array[k + 1]; i--; } } } fclose(text_file); fclose(bin_file); new_text_file(text_array); }
static void set_up_host_data(oskar_BeamPattern* h, int *status) { int i, k; size_t j; if (*status) return; /* Set up pixel positions. */ oskar_beam_pattern_generate_coordinates(h, OSKAR_SPHERICAL_TYPE_EQUATORIAL, status); /* Work out how many pixel chunks have to be processed. */ h->num_chunks = (h->num_pixels + h->max_chunk_size - 1) / h->max_chunk_size; /* Create scratch arrays for output pixel data. */ if (!h->pix) { h->pix = oskar_mem_create(h->prec, OSKAR_CPU, h->max_chunk_size, status); h->ctemp = oskar_mem_create(h->prec | OSKAR_COMPLEX, OSKAR_CPU, h->max_chunk_size, status); } /* Get the contents of the log at this point so we can write a * reasonable file header. Replace newlines with zeros. */ h->settings_log_length = 0; free(h->settings_log); h->settings_log = oskar_log_file_data(h->log, &h->settings_log_length); for (j = 0; j < h->settings_log_length; ++j) { if (h->settings_log[j] == '\n') h->settings_log[j] = 0; if (h->settings_log[j] == '\r') h->settings_log[j] = ' '; } /* Return if data products already exist. */ if (h->data_products) return; /* Create a file for each requested data product. */ /* Voltage amplitude and phase can only be generated if there is * no averaging. */ if (h->separate_time_and_channel) { /* Create station-level data products. */ for (i = 0; i < h->num_active_stations; ++i) { /* Text file. */ if (h->voltage_raw_txt) new_text_file(h, RAW_COMPLEX, -1, -1, i, 0, 0, status); if (h->voltage_amp_txt) { if (h->pol_mode == OSKAR_POL_MODE_SCALAR) new_text_file(h, AMP, -1, -1, i, 0, 0, status); else for (k = XX; k <= YY; ++k) new_text_file(h, AMP, -1, k, i, 0, 0, status); } if (h->voltage_phase_txt) { if (h->pol_mode == OSKAR_POL_MODE_SCALAR) new_text_file(h, PHASE, -1, -1, i, 0, 0, status); else for (k = XX; k <= YY; ++k) new_text_file(h, PHASE, -1, k, i, 0, 0, status); } if (h->ixr_txt && h->pol_mode == OSKAR_POL_MODE_FULL) new_text_file(h, IXR, -1, -1, i, 0, 0, status); /* Can only create images if coordinates are on a grid. */ if (h->coord_grid_type != 'B') continue; /* FITS file. */ if (h->voltage_amp_fits) { if (h->pol_mode == OSKAR_POL_MODE_SCALAR) new_fits_file(h, AMP, -1, -1, i, 0, 0, status); else for (k = XX; k <= YY; ++k) new_fits_file(h, AMP, -1, k, i, 0, 0, status); } if (h->voltage_phase_fits) { if (h->pol_mode == OSKAR_POL_MODE_SCALAR) new_fits_file(h, PHASE, -1, -1, i, 0, 0, status); else for (k = XX; k <= YY; ++k) new_fits_file(h, PHASE, -1, k, i, 0, 0, status); } if (h->ixr_fits && h->pol_mode == OSKAR_POL_MODE_FULL) new_fits_file(h, IXR, -1, -1, i, 0, 0, status); } } /* Create data products that can be averaged. */ if (h->separate_time_and_channel) create_averaged_products(h, 0, 0, status); if (h->average_time_and_channel) create_averaged_products(h, 1, 1, status); if (h->average_single_axis == 'C') create_averaged_products(h, 0, 1, status); else if (h->average_single_axis == 'T') create_averaged_products(h, 1, 0, status); /* Check that at least one output file will be generated. */ if (h->num_data_products == 0 && !*status) { *status = OSKAR_ERR_FILE_IO; oskar_log_error(h->log, "No output file(s) selected."); } }