コード例 #1
0
ファイル: codefile.c プロジェクト: Carl4/astrometry.net
static codefile_t* open_for_writing(const char* fn) {
    codefile_t* cf;
    qfits_header* hdr;
    if (fn)
        cf = new_codefile(fn, TRUE, FALSE);
    else
        cf = new_codefile(fn, TRUE, TRUE);
    if (!cf)
        goto bailout;
    // default
    cf->dimcodes = 4;

    // add default values to header
    hdr = codefile_get_header(cf);
    fits_add_endian(hdr);
    qfits_header_add(hdr, "AN_FILE", "CODE", "This file lists the code for each quad.", NULL);
    qfits_header_add(hdr, "NCODES", "0", "", NULL);
    qfits_header_add(hdr, "NSTARS", "0", "", NULL);
    fits_header_add_int(hdr, "DIMCODES", cf->dimcodes, "");
    qfits_header_add(hdr, "SCALE_U", "0.0", "", NULL);
    qfits_header_add(hdr, "SCALE_L", "0.0", "", NULL);
    qfits_header_add(hdr, "INDEXID", "0", "", NULL);
    qfits_header_add(hdr, "HEALPIX", "-1", "", NULL);
    qfits_header_add(hdr, "HPNSIDE", "1", "", NULL);
    fits_add_long_comment(hdr, "The first extension contains the codes "
                          "stored as %i native-endian doubles.  "
                          "(the quad location in %i-D code space)", cf->dimcodes, cf->dimcodes);
    return cf;
bailout:
    if (cf)
        codefile_close(cf);
    return NULL;
}
コード例 #2
0
ファイル: qidxfile.c プロジェクト: dstndstn/astrometry.net
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;
}