예제 #1
0
static void image_keywords_from_fits(image_str *image, fitsfile *fits)
{
    char card[FLEN_CARD];
    int status = 0;

    fits_read_record(fits, 0, card, &status);

    while(TRUE){
        char key[FLEN_KEYWORD];
        char value[FLEN_VALUE];
        char comment[FLEN_COMMENT];
        int length = 0;
        image_keyword_str *kw = NULL;

        status = 0;
        fits_find_nextkey(fits, include_list, include_length, exclude_list, exclude_length, card, &status);

        if(status == KEY_NO_EXIST)
            break;

        fits_get_keyname(card, key, &length, &status);
        fits_parse_value(card, value, comment, &status);

        if(key[0] != '_'){
            kw = image_keyword_add(image, key, value, comment);

            fits_get_keytype(value, &kw->type, &status);
        }
    }
}
예제 #2
0
QMap<QString, QString> fitsKeys( fitsfile *fp, int HDU ) {
  
  QMap<QString, QString> keyMap;
  
  int ret = 0;
  int nHDU;
  int hduType;
  // try to seek to the desired HDU
  if (fits_get_num_hdus(fp, &nHDU, &ret)) {
    return keyMap;
  }
  if (HDU > nHDU) {
    return keyMap;
  } else {
    if (fits_movabs_hdu(fp, HDU, &hduType, &ret)) {
      return keyMap;
    }
  }
  
  // reset keyword pointer to beginning of HDU
  int rec = 0;
  char card[FLEN_CARD];
  if (fits_read_record(fp, rec, card, &ret)) {
    return keyMap;
  } 
  
  // go through all keys and add to the QMap
  QString theKey;
  QString theVal;
  char keyval[FLEN_VALUE];
  char keycom[FLEN_COMMENT];
  char keyname[FLEN_KEYWORD];
  int keylen;
  while (!fits_find_nextkey(fp, NULL, 1, NULL, 0, card, &ret)) {
    fits_get_keyname(card, keyname, &keylen, &ret);
    fits_parse_value(card, keyval, keycom, &ret);
    theKey = keyname;
    theVal = keyval;
    keyMap.insert(theKey, theVal);
  }
  
  return keyMap;
}