Ejemplo n.º 1
0
void oskar_imager_create_fits_files(oskar_Imager* h, int* status)
{
    int i;
    if (*status) return;
    if (!h->image_root) return;
    for (i = 0; i < h->im_num_pols; ++i)
    {
        double fov_deg[2];
        char f[512];
        const char *a[] = {"I","Q","U","V"}, *b[] = {"XX","XY","YX","YY"};

        /* Construct filename based on image type. */
        switch (h->im_type)
        {
        case OSKAR_IMAGE_TYPE_STOKES:
            SNPRINTF(f, sizeof(f), "%s_%s.fits", h->image_root, a[i]); break;
        case OSKAR_IMAGE_TYPE_I:
            SNPRINTF(f, sizeof(f), "%s_I.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_Q:
            SNPRINTF(f, sizeof(f), "%s_Q.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_U:
            SNPRINTF(f, sizeof(f), "%s_U.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_V:
            SNPRINTF(f, sizeof(f), "%s_V.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_LINEAR:
            SNPRINTF(f, sizeof(f), "%s_%s.fits", h->image_root, b[i]); break;
        case OSKAR_IMAGE_TYPE_XX:
            SNPRINTF(f, sizeof(f), "%s_XX.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_XY:
            SNPRINTF(f, sizeof(f), "%s_XY.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_YX:
            SNPRINTF(f, sizeof(f), "%s_YX.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_YY:
            SNPRINTF(f, sizeof(f), "%s_YY.fits", h->image_root); break;
        case OSKAR_IMAGE_TYPE_PSF:
            SNPRINTF(f, sizeof(f), "%s_PSF.fits", h->image_root); break;
        default:
            *status = OSKAR_ERR_UNKNOWN;
            break;
        }

        fov_deg[0] = fov_deg[1] = h->fov_deg;
        h->fits_file[i] = create_fits_file(f, h->imager_prec,
                h->image_size, h->image_size, h->im_num_times,
                h->im_num_channels, h->im_centre_deg, fov_deg,
                h->im_time_start_mjd_utc, h->time_inc_sec, h->im_freq_start_hz,
                h->freq_inc_hz, status);
    }
}
static void new_fits_file(oskar_BeamPattern* h, int data_product_type,
        int stokes_in, int stokes_out, int i_station, int time_average,
        int channel_average, int* status)
{
    int i, horizon_mode;
    char* name;
    fitsfile* f;
    if (*status) return;

    /* Check polarisation type is possible. */
    if ((stokes_in > I || stokes_out > I) && h->pol_mode != OSKAR_POL_MODE_FULL)
        return;

    /* Construct the filename. */
    name = construct_filename(h, data_product_type, stokes_in, stokes_out,
            i_station, time_average, channel_average, "fits");

    /* Open the file. */
    horizon_mode = h->coord_frame_type == 'H';
    f = create_fits_file(name, h->prec, h->width, h->height,
            (time_average ? 1 : h->num_time_steps),
            (channel_average ? 1 : h->num_channels),
            h->phase_centre_deg, h->fov_deg, h->time_start_mjd_utc,
            h->time_inc_sec, h->freq_start_hz, h->freq_inc_hz,
            horizon_mode, h->settings_log, h->settings_log_length, status);
    if (!f || *status)
    {
        *status = OSKAR_ERR_FILE_IO;
        free(name);
        return;
    }
    i = data_product_index(h, data_product_type, stokes_in, stokes_out,
            i_station, time_average, channel_average);
    h->data_products[i].fits_file = f;
    free(name);
}