Exemplo n.º 1
0
static int callback_read_header(fitsbin_t* fb, fitsbin_chunk_t* chunk) {
    qfits_header* primheader = fitsbin_get_primary_header(fb);
    codefile_t* cf = chunk->userdata;

    cf->dimcodes = qfits_header_getint(primheader, "DIMCODES", 4);
    cf->numcodes = qfits_header_getint(primheader, "NCODES", -1);
    cf->numstars = qfits_header_getint(primheader, "NSTARS", -1);
    cf->index_scale_upper = qfits_header_getdouble(primheader, "SCALE_U", -1.0);
    cf->index_scale_lower = qfits_header_getdouble(primheader, "SCALE_L", -1.0);
    cf->indexid = qfits_header_getint(primheader, "INDEXID", 0);
    cf->healpix = qfits_header_getint(primheader, "HEALPIX", -1);
    cf->hpnside = qfits_header_getint(primheader, "HPNSIDE", 1);

    if ((cf->numcodes == -1) || (cf->numstars == -1) ||
            (cf->index_scale_upper == -1.0) || (cf->index_scale_lower == -1.0)) {
        ERROR("Couldn't find NCODES or NSTARS or SCALE_U or SCALE_L entries in FITS header");
        return -1;
    }
    if (fits_check_endian(primheader)) {
        ERROR("File was written with the wrong endianness");
        return -1;
    }
    chunk->itemsize = cf->dimcodes * sizeof(double);
    chunk->nrows = cf->numcodes;
    return 0;
}
Exemplo n.º 2
0
qidxfile* qidxfile_open_for_writing(const char* fn, int nstars, int nquads) {
    qidxfile* qf;
    qfits_header* hdr;
    qf = new_qidxfile(fn, TRUE);
    if (!qf)
        goto bailout;
    qf->numstars = nstars;
    qf->numquads = nquads;

    hdr = fitsbin_get_primary_header(qf->fb);
    fits_add_endian(hdr);
    fits_header_add_int(hdr, "NSTARS", qf->numstars, "Number of stars used.");
    fits_header_add_int(hdr, "NQUADS", qf->numquads, "Number of quads used.");
    qfits_header_add(hdr, "AN_FILE", "QIDX", "This is a quad index file.", NULL);
    qfits_header_add(hdr, "COMMENT", "The data table of this file has two parts:", NULL, NULL);
    qfits_header_add(hdr, "COMMENT", " -the index", NULL, NULL);
    qfits_header_add(hdr, "COMMENT", " -the heap", NULL, NULL);
    fits_add_long_comment(hdr, "The index contains two uint32 values for each star: the offset and "
                          "length, in the heap, of the list of quads to which it belongs.  "
                          "The offset and length are in units of uint32s, not bytes.  "
                          "Offset 0 is the first uint32 in the heap.  "
                          "The heap is ordered and tightly packed.  "
                          "The heap is a flat list of quad indices (uint32s).");
    return qf;

 bailout:
    if (qf)
        qidxfile_close(qf);
    return NULL;
}
Exemplo n.º 3
0
static int callback_read_header(fitsbin_t* fb, fitsbin_chunk_t* chunk) {
    qfits_header* primheader = fitsbin_get_primary_header(fb);
    qidxfile* qf = chunk->userdata;

    if (fits_check_endian(primheader)) {
        ERROR("qidx file was written with wrong endianness");
        return -1;
    }
    qf->numstars = qfits_header_getint(primheader, "NSTARS", -1);
    qf->numquads = qfits_header_getint(primheader, "NQUADS", -1);
    qf->dimquads = qfits_header_getint(primheader, "DIMQUADS", 4);
    if ((qf->numstars == -1) || (qf->numquads == -1)) {
        ERROR("Couldn't find NSTARS or NQUADS entries in FITS header");
        return -1;
    }

    chunk->nrows = qf->numstars * 2 + qf->numquads * qf->dimquads;
    return 0;
}
Exemplo n.º 4
0
qfits_header* codefile_get_header(const codefile_t* cf) {
    return fitsbin_get_primary_header(cf->fb);
}
Exemplo n.º 5
0
qfits_header* qidxfile_get_header(const qidxfile* qf) {
    return fitsbin_get_primary_header(qf->fb);
}