コード例 #1
0
ファイル: uvsubs_old.c プロジェクト: guille-c/VIR
int copy_history(fitsfile *infptr, fitsfile *outfptr, char *infile)
{
  int status = 0;
  int i, nkeys;
  char card[81];

  /* Position files at main HDU */

  fits_movabs_hdu(outfptr, 1, NULL, &status);
  fits_movabs_hdu(infptr,  1, NULL, &status);

  /* Find the number of cards in the input header */

  fits_get_hdrspace(infptr, &nkeys, NULL, &status);

  /* Write an optional separator in the output history */

  if (infile != NULL) {
    sprintf(card, "History from file %.40s:", infile);
    fits_write_history(outfptr, "-------------------------------------------------------------------", &status);
    fits_write_history(outfptr, card, &status);
  }

  /* Read all the input cards and copy those that are HISTORY */

  for (i = 0; i < nkeys; i++) {
    fits_read_record(infptr, i+1, card, &status);
    if (strncmp(card, "HISTORY", 7) == 0)
      fits_write_record(outfptr, card, &status);
  }

  return status;
}
コード例 #2
0
//----------------------------------------------------------
int write_primary_header(etfits_t * etf) {
//----------------------------------------------------------
    int * status_p = &(etf->status);
    *status_p = 0;

    int itmp;
    char ctmp[40];

//fprintf(stderr, "writing primary header\n");

    if(! *status_p) fits_get_system_time(ctmp, &itmp, status_p);      // date the file was written

    if(! *status_p) fits_movabs_hdu(etf->fptr, 1, NULL, status_p);    // go to primary HDU

    if(! *status_p) fits_update_key(etf->fptr, TSTRING, "DATE",     ctmp,                            NULL, status_p);
    if(! *status_p) fits_update_key(etf->fptr, TSTRING, "TELESCOP", &(etf->primary_hdr.receiver),    NULL, status_p);
    if(! *status_p) fits_update_key(etf->fptr, TINT,    "NSUBBAND", &(etf->primary_hdr.n_subband),   NULL, status_p); 
    if(! *status_p) fits_update_key(etf->fptr, TINT,    "NCHAN",    &(etf->primary_hdr.n_chan),      NULL, status_p); 
    if(! *status_p) fits_update_key(etf->fptr, TINT,    "NINPUTS",  &(etf->primary_hdr.n_inputs),    NULL, status_p); 
    // TODO not yet implemented
    //if(! *status_p) fits_update_key(etf->fptr, TINT,    "BANDWID",  &(etf->primary_hdr.bandwidth),       NULL, status_p); 
    //if(! *status_p) fits_update_key(etf->fptr, TINT,    "CHAN_BW",  &(etf->primary_hdr.chan_bandwidth),  NULL, status_p); 
    //if(! *status_p) its_update_key(etf->fptr, TINT,    "FREQRES",  &(etf->primary_hdr.freq_res),        NULL, status_p);    // redundant w/ CHAN_BW? 

    //if(! *status_p) fits_flush_file(etf->fptr, status_p);

    if (*status_p) {
        hashpipe_error(__FUNCTION__, "Error updating primary header");
        //fprintf(stderr, "Error updating primary header.\n");
        fits_report_error(stderr, *status_p);
    }

    return *status_p;
}
コード例 #3
0
ファイル: jsfitsio.c プロジェクト: nancyirisarri/js9
// gotoFITSHDU: try to go to a reasonable HDU if the primary is useless
// we look for specified extensions and if not found, go to hdu #2
// this is how xray binary tables are imaged automatically
fitsfile *gotoFITSHDU(fitsfile *fptr, char *extlist, int *hdutype, int *status){
  int hdunum, naxis, thdutype, gotext;
  char *ext, *textlist;
  // if this is the primary array and it does not contain an image,
  // try to move to something more reasonble
  fits_get_hdu_num(fptr, &hdunum); *status = 0;
  fits_get_img_dim(fptr, &naxis, status); *status = 0;
  if( (hdunum == 1) && (naxis == 0) ){ 
    // look through the extension list
    if( extlist ){
      gotext = 0;
      textlist = (char *)strdup(extlist);
      for(ext=(char *)strtok(textlist, " "); ext != NULL; 
	  ext=(char *)strtok(NULL," ")){
	fits_movnam_hdu(fptr, ANY_HDU, ext, 0, status);
	if( *status == 0 ){
	  gotext = 1;
	  break;
	} else {
	  *status = 0;
	}
      }
      free(textlist);      
    }
    if( !gotext ){
      // if all else fails, move to extension #2 and hope for the best
      fits_movabs_hdu(fptr, 2, &thdutype, status);
    }
  }
  fits_get_hdu_type(fptr, hdutype, status);
  return fptr;
}
コード例 #4
0
int fitscopy ( char *infile, char *outfile) 
{
	fitsfile *infptr, *outfptr;   /* FITS file pointers defined in fitsio.h */
	int status = 0, ii = 1;       /* status must always be initialized = 0  */

	/* Open the input file */
	if ( !fits_open_file(&infptr, infile, READONLY, &status) )
	{
		/* Create the output file */
		if ( !fits_create_file(&outfptr, outfile, &status) )
		{
			/* Copy every HDU until we get an error */
			while( !fits_movabs_hdu(infptr, ii++, NULL, &status) )
				fits_copy_hdu(infptr, outfptr, 0, &status);
 
			/* Reset status after normal error */
			if (status == END_OF_FILE) status = 0;

			fits_close_file(outfptr,  &status);
		}
		fits_close_file(infptr, &status);
	}

	/* if error occured, print out error message */
	if (status) fits_report_error(stderr, status);
	return(status);
}
コード例 #5
0
FitsReader::FitsReader(const FitsReader& source) :
	_filename(source._filename),
	_fitsPtr(0),
	_imgWidth(source._imgWidth), _imgHeight(source._imgHeight),
	_nFrequencies(source._nFrequencies),
	_phaseCentreRA(source._phaseCentreRA), _phaseCentreDec(source._phaseCentreDec),
	_pixelSizeX(source._pixelSizeX), _pixelSizeY(source._pixelSizeY),
	_phaseCentreDL(source._phaseCentreDL), _phaseCentreDM(source._phaseCentreDM),
	_frequency(source._frequency), _bandwidth(source._bandwidth), _dateObs(source._dateObs),
	_hasBeam(source._hasBeam),
	_beamMajorAxisRad(source._beamMajorAxisRad), _beamMinorAxisRad(source._beamMinorAxisRad), _beamPositionAngle(source._beamPositionAngle),
	_polarization(source._polarization),
	_unit(source._unit),
	_telescopeName(source._telescopeName), _observer(source._observer), _objectName(source._objectName),
	_origin(source._origin), _originComment(source._originComment),
	_history(source._history),
	_checkCType(source._checkCType)
{
	int status = 0;
	fits_open_file(&_fitsPtr, _filename.c_str(), READONLY, &status);
	checkStatus(status, _filename);
	
	// Move to first HDU
	int hduType;
	fits_movabs_hdu(_fitsPtr, 1, &hduType, &status);
	checkStatus(status, _filename);
	if(hduType != IMAGE_HDU) throw std::runtime_error("First HDU is not an image");
}
コード例 #6
0
void FitsFile::MoveToHDU(int hduNumber)
{
	CheckOpen();
	int status = 0;
	fits_movabs_hdu(_fptr, hduNumber, NULL, &status);
	CheckStatus(status);
}
コード例 #7
0
ファイル: uvsubs_old.c プロジェクト: guille-c/VIR
int get_fqtable(fitsfile *fptr, int hdu, struct uvf_header *header)
{
  int status = 0, i;
  int hdutype, col_iff, type_iff;
  long nrows, rpt_iff, wid_iff;
  double f;

  fits_movabs_hdu(fptr, hdu, &hdutype, &status);
  fits_get_num_rows(fptr, &nrows,  &status);
  fits_get_colnum(fptr, CASEINSEN, "IF FREQ", &col_iff, &status);
  fits_get_coltype(fptr, col_iff, &type_iff, &rpt_iff, &wid_iff,
		   &status);
  if (status || type_iff != TDOUBLE || nrows != 1 || rpt_iff !=
      header->nif)
    fprintf(stderr, "    Warning: Invalid AIPS frequency table\n");
  for (i=0; i < rpt_iff; i++) {
    fits_read_col(fptr, TDOUBLE, col_iff, 1, i+1, 1,
		  NULL, &f, NULL, &status);
    header->iffreq[i] = header->freq + f;
  }
  fprintf(stderr, "    %d IFs ", header->nif);
  for (i=0; i < header->nif; i++)
    fprintf(stderr, " %.2f", header->iffreq[i]*1e-9);
  fprintf(stderr, "\n");
  return status ? 1 : 0;
}
コード例 #8
0
vtkDataArray *
avtFITSFileFormat::GetVar(const char *varname)
{
    vtkFloatArray *arr =0;

    Initialize(0);

    StringIntMap::const_iterator pos = varToHDU.find(varname);
    if(pos != varToHDU.end())
    {
        // Move to the right HDU.
        int hdutype = 0, status = 0;
        if(fits_movabs_hdu(fits, pos->second, &hdutype, &status))
        {
            PrintError(status);
            EXCEPTION1(InvalidVariableException, varname);
        }

        //
        // Determine the size of the image.
        //
        StringStringMap::const_iterator vit = varToMesh.find(varname);
        if(vit == varToMesh.end())
        {
            EXCEPTION1(InvalidVariableException, varname);
        }
        // Now that we have the mesh name, get the dimensions.
        MeshNameMap::const_iterator mit = meshDimensions.find(vit->second);
        if(mit == meshDimensions.end())
        {
            EXCEPTION1(InvalidVariableException, varname);
        }
        long nelements = 1;
        for(size_t i = 0; i < mit->second.size(); ++i)
            nelements *= mit->second[i];

        // Allocate the VTK return array.
        arr = vtkFloatArray::New();
        arr->SetNumberOfTuples(nelements);
        float *fptr = (float *)arr->GetVoidPointer(0); 

        // Now that we're at the right HDU, read the whole image array.
        float nulval = -1.; // Value to use for no data
        int anynul = 0;
        long fpixel = 1;
        if(fits_read_img(fits, TFLOAT, fpixel, nelements,
           &nulval, fptr, &anynul, &status))
        {
            PrintError(status);
            arr->Delete();
            EXCEPTION1(InvalidVariableException, varname);
        }
    }
    else
    {
        EXCEPTION1(InvalidVariableException, varname);
    }

    return arr;
}
コード例 #9
0
ファイル: healpix_extra.c プロジェクト: slosar/CRIME
flouble *he_read_healpix_map(char *fname,long *nside,int nfield)
{
  //////
  // Reads a healpix map from file fname. The map will be
  // read from column #nfield. It also returns the map's nside.
  int status=0,hdutype,nfound,anynul;
  long naxes,*naxis,npix;
  fitsfile *fptr;
  flouble *map,nulval;
  char order_in_file[32];
  int nested_in_file=0;

  fits_open_file(&fptr,fname,READONLY,&status);
  fits_movabs_hdu(fptr,2,&hdutype,&status);
  fits_read_key_lng(fptr,"NAXIS",&naxes,NULL,&status);
  naxis=(long *)malloc(naxes*sizeof(long));
  fits_read_keys_lng(fptr,"NAXIS",1,naxes,naxis,&nfound,&status);
  fits_read_key_lng(fptr,"NSIDE",nside,NULL,&status);
  npix=12*(*nside)*(*nside);
  if(npix%naxis[1]!=0) {
    fprintf(stderr,"CRIME: WTFFF\n");
    exit(1);
  }

  if (fits_read_key(fptr, TSTRING, "ORDERING", order_in_file, NULL, &status)) {
    fprintf(stderr, "WARNING: Could not find %s keyword in in file %s\n",
            "ORDERING",fname);
    exit(1);
  }
  if(!strncmp(order_in_file,"NEST",4))
    nested_in_file=1;

  map=(flouble *)my_malloc(npix*sizeof(flouble));
#ifdef _SPREC
  fits_read_col(fptr,TFLOAT,nfield+1,1,1,npix,&nulval,map,&anynul,&status);
#else //_SPREC
  fits_read_col(fptr,TDOUBLE,nfield+1,1,1,npix,&nulval,map,&anynul,&status);
#endif //_SPREC
  free(naxis);

  fits_close_file(fptr,&status);

  flouble *map_ring;
  if(nested_in_file) {
    long ipring,ipnest;

    printf("read_healpix_map: input is nested. Transforming to ring.\n");
    map_ring=(flouble *)my_malloc(npix*sizeof(flouble));
    for(ipnest=0;ipnest<npix;ipnest++) {
      nest2ring(*nside,ipnest,&ipring);
      map_ring[ipring]=map[ipnest];
    }
    free(map);
  }
  else
    map_ring=map;

  return map_ring;
}
コード例 #10
0
ファイル: ReadHdr.c プロジェクト: rferdman/afr
int ReadHdr(struct ASPHdr *hdr, fitsfile *Fin, struct RunVars *RunMode)
{
  int     hdutype, status=0;


  /* Move to primary header */
  if (fits_movabs_hdu(Fin, 1, &hdutype, &status)) {
    fprintf(stderr, "ERROR ReadPSRFITSHdr: Cannot move to primary HDU\n");
    return -1;
  }

/* Header version no. */
  fits_read_key(Fin, TSTRING, "HDRVER", hdr->gen.HdrVer, NULL, &status); 
  status=0; 
/* Header FITS definition type */
  fits_read_key(Fin, TSTRING, "FITSTYPE", hdr->gen.FitsType, NULL, &status); 
  status=0;
/****** DATE GOES HERE ******/ 

/* Backend name ASP/ABPP/WAPP/GUPPI etc */
  fits_read_key(Fin, TSTRING, "BACKEND", hdr->gen.BEName, NULL, &status); 
  status=0; 


  /* If data comes from ASP then do ReadASPData */
  if(!strcmp(hdr->gen.BEName, "xASP")) {
   /* Read in values for header variables */
    if(ReadASPHdr(hdr, Fin) < 0){
      /* Return with error */
      return -1;
    } 
      
  }
  else {  

    /* Otherwise, if data is in PSRFITS format, then do ReadPSRFITSData */
    if(!strcmp(hdr->gen.FitsType, "PSRFITS")) {
      //printf("PSRFITS Data!!\n");

      /* Read in values for header variables */
      if(ReadPSRFITSHdr(hdr, Fin, RunMode) < 0){
	/* Return with error */
	return -1;
      }


    }
    else {
      /* Do not recognize data format! */
      fprintf(stderr, "ReadHdr ERROR: Do not recognize file format.\n");
      return -1;
    }

   }


  return 0;
}
コード例 #11
0
void InputFileFITS::moveToHeader(int number) {
	int status = 0;

	if(!isOpened())
		throwException("Error in InputFileFITS::jumpToChuck() ", status);

	fits_movabs_hdu(infptr, number+1, 0, &status);

	if (status)
		throwException("Error in InputFileFITS::jumpToChuck() ", status);
}
コード例 #12
0
int cfits_movabs_hdu (int hdunum, cfitsfile *fptr)
{
   int status = 0;
   int *hdutype = NULL;

   (void) fits_movabs_hdu((fitsfile *) fptr, hdunum, hdutype, &status);
   cfits_report_error (status);

   if (status != 0) return -1;
   return 0;
}
コード例 #13
0
ファイル: spc_CD.c プロジェクト: spacetelescope/aXe_c_code
/**
 * Function: get_fits_header
 * Returns the header of extension hdunum from a fits file filename
 *
 * Parameters:
 * @param filename The name of the FITS file
 * @param hdunum the number of the HDU to access
 *  
 * Returns:
 * @return a pointer to a newly allocated string containing the entire header
 */
char *
get_fits_header (char filename[], int hdunum)
{

  fitsfile *input;
  int f_status = 0, hdutype;
  int nkeys, i;
  char card[FLEN_CARD];
  
  char *header, *p;

  //  Open the file for creating/appending
  fits_open_file (&input, filename, READONLY, &f_status);
  if (f_status)
    {
      ffrprt (stderr, f_status);
      aXe_message (aXe_M_FATAL, __FILE__, __LINE__,
		   "get_fits_header: Could not open" " file:", filename);
    }
  fits_movabs_hdu (input, hdunum, &hdutype, &f_status);
  if (f_status)
    {
      ffrprt (stderr, f_status);
      aXe_message (aXe_M_FATAL, __FILE__, __LINE__,
		   "get_fits_header: "
		   "Could not read extention %d from file: %s", hdunum,
		   filename);
    }
  


  fits_get_hdrspace (input, &nkeys, NULL, &f_status);	/* get # of keywords */
  
  header = (char *) malloc ((nkeys + 1) * FLEN_CARD * sizeof (char));
  p = header;
  for (i = 0; i < nkeys; i++)
    {			/* Read and print each keywords */
      
      if (fits_read_record (input, i + 1, card, &f_status))
	break;
      
      sprintf(p,"%-80s", card);
      p = p + 80;
    }
  /* Add END keyword */
  
  sprintf (card, "END");
  sprintf(p,"%-80s", card);
  
  return header;
}
コード例 #14
0
int init_filter_file(const char *fname, int nspec, int nchan, int nphase,
        int imjd0, double fmjd0) {
    int status=0;
    fitsfile *fptr;
    fits_create_file(&fptr, fname, &status);
    fits_movabs_hdu(fptr, 1, NULL, &status);
    long naxes[3] = {2, nchan, nspec};
    fits_create_img(fptr, FLOAT_IMG, 3, naxes, &status);
    fits_write_key(fptr, TINT, "IMJD", &imjd0, NULL, &status);
    fits_write_key(fptr, TDOUBLE, "FMJD", &fmjd0, NULL, &status);
    naxes[0] = nphase;
    naxes[1] = nspec;
    fits_create_img(fptr, FLOAT_IMG, 2, naxes, &status);
    fits_movabs_hdu(fptr, 2, NULL, &status);
    fits_write_key(fptr, TSTRING, "EXTNAME", "PROFILE", NULL, &status);
    fits_close_file(fptr, &status);
    if (status) {
        fprintf(stderr, "Error in init_filter_file:\n");
        fits_report_error(stderr, status);
        return(-1);
    }
    return(0);
}
コード例 #15
0
ファイル: read_fits_lib.c プロジェクト: zonca/binner
int nelem(const char* filename, long *length)
{
    int status = 0;
    fitsfile *fptr;         
    fits_open_file(&fptr, filename, READONLY, &status);
    fprintf(stderr, "%s :reading.\n", filename);
    //fits_movnam_hdu(fptr, BINARY_TBL, "DATA", 0, &status);
    fits_movabs_hdu(fptr, 2, NULL, &status);
    fits_read_key(fptr, TLONG, "NAXIS2", length , NULL, &status);
    fits_close_file(fptr, &status);
    if (status)          /* print any error messages */
        fits_report_error(stderr, status);
    return(status);
}
コード例 #16
0
ファイル: fitscopy.c プロジェクト: chopley/controlCode
int main(int argc, char *argv[])
{
    fitsfile *infptr, *outfptr;
    int status = 0, hdutype, ii;
    char infile[FLEN_FILENAME],outfile[FLEN_FILENAME]; 

    if (argc != 3)
    {
        printf("Usage: fitscopy inputfile outputfile\n");
        return(1);
    }

    strcpy(infile,  argv[1] );  
    strcpy(outfile, argv[2] );  

    if ( fits_open_file(&infptr, infile, READONLY, &status) )
    {
         fits_report_error(stderr, status);
         return(status);
    }

    if ( fits_create_file(&outfptr, outfile, &status) )
    {
         fits_close_file(infptr, &status);
         fits_report_error(stderr, status);
         return(status);
    }

    /* attempt to move to next HDU, until we get an EOF error */
    for (ii = 1; !(fits_movabs_hdu(infptr, ii, &hdutype, &status) ); ii++) 
    {
        if ( fits_copy_hdu(infptr, outfptr, 0, &status) )
        {
            fits_report_error(stderr, status);
            break;
        }
    }

    if (status == END_OF_FILE)   
        status = 0;              /* got the expected EOF error; reset = 0  */

    fits_close_file(infptr,  &status);
    fits_close_file(outfptr, &status);

    if (status)
        fits_report_error(stderr, status);

    return(0);
}
コード例 #17
0
ファイル: listhead.c プロジェクト: chopley/controlCode
int main(int argc, char *argv[])
{
    fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */

    int status, nkeys, keypos, hdutype, ii, jj;
    char filename[FLEN_FILENAME];    /* input FITS file */
    char card[FLEN_CARD];   /* standard string lengths defined in fitsioc.h */

    status = 0;

    if (argc == 1)
        strcpy(filename, "-");  /* no command line name, so assume stdin */
    else
        strcpy(filename, argv[1] );   /* name of file to list */


    if ( fits_open_file(&fptr, filename, READONLY, &status) ) 
         printerror( status );

    /* get the current HDU number */
    fits_get_hdu_num(fptr, &ii);

    /* attempt to move to next HDU, until we get an EOF error */
    for (; !(fits_movabs_hdu(fptr, ii, &hdutype, &status) ); ii++) 
    {
        /* get no. of keywords */
        if (fits_get_hdrpos(fptr, &nkeys, &keypos, &status) )
            printerror( status );

        printf("Header listing for HDU #%d:\n", ii);
        for (jj = 1; jj <= nkeys; jj++)  {
            if ( fits_read_record(fptr, jj, card, &status) )
                 printerror( status );

            printf("%s\n", card); /* print the keyword card */
        }
        printf("END\n\n");  /* terminate listing with END */
    }

    if (status == END_OF_FILE)   /* status values are defined in fitsio.h */
        status = 0;              /* got the expected EOF error; reset = 0  */
    else
       printerror( status );     /* got an unexpected error                */

    if ( fits_close_file(fptr, &status) )
         printerror( status );

    return(0);
}
コード例 #18
0
ファイル: fits.c プロジェクト: eddyem/eddys_snippets
bool readFITS(char *filename, IMAGE **fits){
	FNAME();
	bool ret = TRUE;
	fitsfile *fp;
//	float nullval = 0., imBits, bZero = 0., bScale = 1.;
	int i, j, hdunum, hdutype, nkeys, keypos;
	int naxis;
	long naxes[2];
	char card[FLEN_CARD];
	IMAGE *img = MALLOC(IMAGE, 1);

	TRYFITS(fits_open_file, &fp, filename, READONLY);
	FITSFUN(fits_get_num_hdus, fp, &hdunum);
	if(hdunum < 1){
		WARNX(_("Can't read HDU"));
		ret = FALSE;
		goto returning;
	}
	// get image dimensions
	TRYFITS(fits_get_img_param, fp, 2, &img->dtype, &naxis, naxes);
	if(naxis > 2){
		WARNX(_("Images with > 2 dimensions are not supported"));
		ret = FALSE;
		goto returning;
	}
	img->width = naxes[0];
	img->height = naxes[1];
	DBG("got image %ldx%ld pix, bitpix=%d", naxes[0], naxes[1], img->dtype);
	// loop through all HDUs
	for(i = 1; !(fits_movabs_hdu(fp, i, &hdutype, &fitsstatus)); ++i){
		TRYFITS(fits_get_hdrpos, fp, &nkeys, &keypos);
		int oldnkeys = img->keynum;
		img->keynum += nkeys;
		if(!(img->keylist = realloc(img->keylist, sizeof(char*) * img->keynum))){
			ERR(_("Can't realloc"));
		}
		char **currec = &(img->keylist[oldnkeys]);
		DBG("HDU # %d of %d keys", i, nkeys);
		for(j = 1; j <= nkeys; ++j){
			FITSFUN(fits_read_record, fp, j, card);
			if(!fitsstatus){
				*currec = MALLOC(char, FLEN_CARD);
				memcpy(*currec, card, FLEN_CARD);
				DBG("key %d: %s", oldnkeys + j, *currec);
				++currec;
			}
		}
	}
コード例 #19
0
ファイル: hdu.c プロジェクト: rforge/rfitsio
/* Wrapper to fits_movabs_hdu */
SEXP
cfitsio_movabs_hdu (SEXP fits_object,
		    SEXP hdu_num)
{
    fits_file_t * fits = R_ExternalPtrAddr (fits_object);

    if (NULL != fits && NULL != fits->cfitsio_ptr)
    {
	int hdu_type;

	fits_movabs_hdu (fits->cfitsio_ptr, asInteger (hdu_num),
			 &hdu_type, &(fits->status));
	return mkString (hdu_type_name (hdu_type));
    }
    else
	return mkString (ERROR_STR);
}
コード例 #20
0
ファイル: read_fits_lib.c プロジェクト: zonca/binner
int write_map(const char *filename, double *intensity, double *q, double *u, long nrows)
{
    
    fitsfile *fptr;
    int status = 0;
    int hdutype;
    int tfields=3;
    char extname[] = "BINTABLE";   /* extension name */
    char *ttype[] = { "I","Q","U" };
    char *tform[] = { "1E","1E","1E" };
    char *tunit[] = { " "," ", " " };
    if (fits_create_file(&fptr, filename, &status)) 
    fprintf(stderr, "%s (%d): Could not create new fits file.\n", 
        __FILE__, __LINE__);

    /* move to 1st HDU  */
    fits_movabs_hdu(fptr, 1, &hdutype, &status);
    //long nrows = 12L*nside*nside*2;
    //long nside = sqrtl(nrows/12L);
    long nside = 1024; //FIXME compute it

    /* append a new empty binary table onto the FITS file */
    fits_create_tbl( fptr, BINARY_TBL, nrows, tfields, ttype, tform,
            tunit, extname, &status);

    fits_write_key(fptr, TSTRING, "ORDERING", "NESTED", 
             "Pixel ordering scheme, either RING or NESTED", &status);

    fits_write_key(fptr, TLONG, "NSIDE", &nside, "Resolution parameter for HEALPIX", &status);
    long firstrow  = 1;  /* first row in table to write   */
    long firstelem = 1;  /* first element in row  (ignored in ASCII tables)  */

    if (fits_write_col(fptr, TDOUBLE, 1, firstrow, firstelem, nrows, intensity,
             &status))
    fprintf(stderr, "%s (%d): Could not write signal.\n", __FILE__, __LINE__);
    if (fits_write_col(fptr, TDOUBLE, 2, firstrow, firstelem, nrows, q,
             &status))
    fprintf(stderr, "%s (%d): Could not write signal.\n", __FILE__, __LINE__);
    if (fits_write_col(fptr, TDOUBLE, 3, firstrow, firstelem, nrows, u,
             &status))
    fprintf(stderr, "%s (%d): Could not write signal.\n", __FILE__, __LINE__);

    fits_close_file(fptr, &status);

    return true;
}
コード例 #21
0
ファイル: fits.c プロジェクト: lajus/monetinr
str
FITStest(int *res, str *fname)
{
	fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */
	str msg = MAL_SUCCEED;
	int status = 0, hdutype;

	*res = 0;
	if (fits_open_file(&fptr, *fname, READONLY, &status))
		msg = createException(MAL, "fits.test", "Missing FITS file %s", *fname);
	else {
		fits_movabs_hdu(fptr, 2, &hdutype, &status);
		*res = hdutype;
		fits_close_file(fptr, &status);
	}

	return msg;
}
コード例 #22
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;
}
コード例 #23
0
void readheader( char *filename )

     /**********************************************************************/
     /* Print out all the header keywords in all extensions of a FITS file */
     /**********************************************************************/
{
  fitsfile *fptr;       /* pointer to the FITS file, defined in fitsio.h */

  int status, nkeys, keypos, hdutype, ii, jj;
  char card[FLEN_CARD];   /* standard string lengths defined in fitsioc.h */

  status = 0;

  if ( fits_open_file(&fptr, filename, READONLY, &status) ) 
    printerror( status, __LINE__ );

  /* attempt to move to next HDU, until we get an EOF error */
  for (ii = 1; !(fits_movabs_hdu(fptr, ii, &hdutype, &status) ); ii++) 
    {
      /* get no. of keywords */
      if (fits_get_hdrpos(fptr, &nkeys, &keypos, &status) )
	printerror( status, __LINE__ );

      printf("Header listing for HDU #%d:\n", ii);
      for (jj = 1; jj <= nkeys; jj++)  {
	if ( fits_read_record(fptr, jj, card, &status) )
	  printerror( status, __LINE__ );

	printf("%s\n", card); /* print the keyword card */
      }
      printf("END\n\n");  /* terminate listing with END */
    }

  if (status == END_OF_FILE)   /* status values are defined in fitsioc.h */
    status = 0;              /* got the expected EOF error; reset = 0  */
  else
    printerror( status, __LINE__ );     /* got an unexpected error                */

  if ( fits_close_file(fptr, &status) )
    printerror( status, __LINE__ );

  return;
}
コード例 #24
0
FitsReader& FitsReader::operator=(const FitsReader& rhs)
{
	_filename = rhs._filename;
	_imgWidth = rhs._imgWidth;
	_imgHeight = rhs._imgHeight;
	_nFrequencies = rhs._nFrequencies;
	_phaseCentreRA = rhs._phaseCentreRA;
	_phaseCentreDec = rhs._phaseCentreDec;
	_pixelSizeX = rhs._pixelSizeX;
	_pixelSizeY = rhs._pixelSizeY;
	_phaseCentreDL = rhs._phaseCentreDL;
	_phaseCentreDM = rhs._phaseCentreDM;
	_frequency = rhs._frequency;
	_bandwidth = rhs._bandwidth;
	_dateObs = rhs._dateObs;
	_hasBeam = rhs._hasBeam;
	_beamMajorAxisRad = rhs._beamMajorAxisRad;
	_beamMinorAxisRad = rhs._beamMinorAxisRad;
	_beamPositionAngle = rhs._beamPositionAngle;
	_polarization = rhs._polarization;
	_unit = rhs._unit;
	_telescopeName = rhs._telescopeName;
	_observer = rhs._observer;
	_objectName = rhs._objectName;
	_origin = rhs._origin;
	_originComment = rhs._originComment;
	_history = rhs._history;
	
	int status = 0;
	fits_close_file(_fitsPtr, &status);
	checkStatus(status, _filename);
	
	fits_open_file(&_fitsPtr, _filename.c_str(), READONLY, &status);
	checkStatus(status, _filename);
	
	// Move to first HDU
	int hduType;
	fits_movabs_hdu(_fitsPtr, 1, &hduType, &status);
	checkStatus(status, _filename);
	if(hduType != IMAGE_HDU) throw std::runtime_error("First HDU is not an image");
	return *this;
}
コード例 #25
0
ファイル: uvsubs_old.c プロジェクト: guille-c/VIR
int get_antable(fitsfile *fptr, int hdu, struct uvf_header *header)
{
  int status = 0, i;
  int hdutype, col_name, col_xyz, type_name, type_xyz;
  long nrows, rpt_name, rpt_xyz, wid_name, wid_xyz;
  char *string[1];
  int anynull;

  fits_movabs_hdu(fptr, hdu, &hdutype, &status);
  fits_get_num_rows(fptr, &nrows,  &status);
  header->n_antennas = (int) nrows;
  fits_get_colnum(fptr, CASEINSEN, "ANNAME", &col_name, &status);
  fits_get_coltype(fptr, col_name, &type_name, &rpt_name, &wid_name,
		   &status);
  fits_get_colnum(fptr, CASEINSEN, "STABXYZ", &col_xyz, &status);
  fits_get_coltype(fptr, col_xyz, &type_xyz, &rpt_xyz, &wid_xyz,
		   &status);
  if (status || type_name != TSTRING ||
                type_xyz != TDOUBLE || rpt_xyz != 3)
    fprintf(stderr, "    Warning: Invalid AIPS antenna table: %d %ld %d %ld\n",
	    type_name, rpt_name, type_xyz, rpt_xyz);
  for (i=0; i < nrows; i++) {
    string[0] = header->antenna[i].name;
    fits_read_col(fptr, TSTRING, col_name, i+1, 1, 1,
		  "NONAME", string, &anynull, &status);
    fits_read_col(fptr, TDOUBLE, col_xyz, i+1, 1, 1,
		  NULL, &(header->antenna[i].x), NULL, &status);
    fits_read_col(fptr, TDOUBLE, col_xyz, i+1, 2, 1,
		  NULL, &(header->antenna[i].y), NULL, &status);
    fits_read_col(fptr, TDOUBLE, col_xyz, i+1, 3, 1,
		  NULL, &(header->antenna[i].z), NULL, &status);
    if (DEBUG)
      fprintf(stderr, "    %s %8.3f %8.3f %8.3f\n", header->antenna[i].name,
	      header->antenna[i].x, header->antenna[i].y, header->antenna[i].z);
  }
  fprintf(stderr, "    %d antennas ", (int) nrows);
  for (i=0; i < nrows; i++)
    fprintf(stderr, " %s", header->antenna[i].name);
  fprintf(stderr, "\n");
  return status ? 1 : 0;
}
コード例 #26
0
ファイル: cfitsio_verify.c プロジェクト: 278261631/astropy
int main(int argc, char *argv[])
{
	fitsfile *fptr;
	int i, j, status, dataok, hduok, hdunum, hdutype;
	char *hdustr, *datastr;

	for (i=1; i<argc; i++) {

		fits_open_file(&fptr, argv[i], READONLY, &status);
		if (status) { 
			fits_report_error(stderr, status);
			exit(-1); 
		}

		fits_get_num_hdus(fptr, &hdunum, &status);
		if (status) { 
			fprintf(stderr, "Bad get_num_hdus status for '%s' = %d", 
				argv[i], status);
			exit(-1); 
		}

		for (j=0; j<hdunum; j++) {
			fits_movabs_hdu(fptr, hdunum, &hdutype, &status);
			if (status) { 
				fprintf(stderr, "Bad movabs status for '%s[%d]' = %d.", 
					argv[i], j, status);
				exit(-1);
			}
			fits_verify_chksum(fptr, &dataok, &hduok, &status);
			if (status) { 
				fprintf(stderr, "Bad verify status for '%s[%d]' = %d.", 
					argv[i], j, status);
				exit(-1);
			}
			datastr = verify_status(dataok);
			hdustr = verify_status(hduok);
			printf("Verifying '%s[%d]'  data='%s'   hdu='%s'.\n",
			       argv[i], j, datastr, hdustr);
		}
	}
}
コード例 #27
0
int append_filter(const char *fname, int ispec, int imjd, double fmjd, 
        struct filter_freq *hf) {
    int status=0;
    fitsfile *fptr;
    fits_open_file(&fptr, fname, READWRITE, &status);
    fits_movabs_hdu(fptr, 1, NULL, &status);
    int naxis;
    long naxes[3];
    fits_get_img_dim(fptr, &naxis, &status);
    if (naxis!=3) { 
        fits_close_file(fptr, &status);
        return(-1); 
    }
    fits_get_img_size(fptr, 3, naxes, &status);
    if (naxes[0]!=2 || naxes[1]!=hf->nchan || naxes[2]<ispec) {
        fits_close_file(fptr, &status);
        return(-2);
    }
    int imjd0;
    double fmjd0;
    fits_read_key(fptr, TINT, "IMJD", &imjd0, NULL, &status);
    fits_read_key(fptr, TDOUBLE, "FMJD", &fmjd0, NULL, &status);
    double toffs = (double)(imjd-imjd0) + (fmjd-fmjd0);
    toffs *= 86400.0;
    char key[80];
    sprintf(key, "DT%5.5d", ispec);
    fits_write_key(fptr, TDOUBLE, key, &toffs, "[s]", &status);
    naxes[0] = naxes[1] = 1;
    naxes[2] = ispec;
    fits_write_pix(fptr, TFLOAT, naxes, 2*hf->nchan, 
            (float *)hf->data, &status);
    fits_close_file(fptr, &status);
    if (status) {
        fprintf(stderr, "Error in append_filter:\n");
        fits_report_error(stderr, status);
        return(-1);
    }
    return(0);
}
コード例 #28
0
ファイル: FindSig.c プロジェクト: iGoab/rrat_code
/*
初始化fits信息的结构体
*/
void initFitsInfo(fitsfile* fptr,struct Fitsinfo* fi,float realDm,int* status) {
	int value;
	float tbin;
	char strVal[CVALLEN];
	//fits_read_key(fptr,TSTRING,"OBS_MODE",strVal,NULL,status);
	//strcpy(fi->obs_Mode,strVal);
	fits_movabs_hdu(fptr, 2, NULL, status);
	fits_read_key(fptr,TSTRING,"POL_TYPE",strVal,NULL,status);
	strcpy(fi->pol_type,strVal);
	fits_read_key(fptr,TINT,"NCHAN",&value,NULL,status);
	fi->nCHAN = value;
	fits_read_key(fptr,TINT,"NPOL",&value,NULL,status);
	fi->nPOL = value;
	fits_read_key(fptr,TINT,"NSBLK",&value,NULL,status);
	fi->nSBLK = value;
	fits_read_key(fptr,TINT,"NAXIS2",&value,NULL,status);
	fi->nROW = value;
	fits_read_key(fptr,TFLOAT,"TBIN",&tbin,NULL,status);
	fi->tBIN = tbin;
	initDmArr(fi->dmArr,realDm);
	fi->lowF = 280;
	fi->highF = 343;
	return;
}
コード例 #29
0
vtkDataArray *
avtFITSFileFormat::GetVectorVar(const char *varname)
{
    const char *mName = "avtFITSFileFormat::GetVectorVar: ";
    vtkFloatArray *arr =0;

    Initialize(0);

    StringIntMap::const_iterator pos = varToHDU.find(varname);
    if(pos != varToHDU.end())
    {
        // Move to the right HDU.
        int hdutype = 0, status = 0;
        if(fits_movabs_hdu(fits, pos->second, &hdutype, &status))
        {
            PrintError(status);
            EXCEPTION1(InvalidVariableException, varname);
        }

        //
        // Determine the size of the image.
        //
        StringStringMap::const_iterator vit = varToMesh.find(varname);
        if(vit == varToMesh.end())
        {
            EXCEPTION1(InvalidVariableException, varname);
        }
        // Now that we have the mesh name, get the dimensions.
        MeshNameMap::const_iterator mit = meshDimensions.find(vit->second);
        if(mit == meshDimensions.end())
        {
            EXCEPTION1(InvalidVariableException, varname);
        }
        long nelements = 1, n_xy_elements = 1;
        size_t i;
        for(i = 0; i < mit->second.size(); ++i)
            nelements *= mit->second[i];
        for(i = 0; i < mit->second.size()-1; ++i)
            n_xy_elements *= mit->second[i];
        debug4 << mName << "Number of elements: " << nelements << endl;
        debug4 << mName << "Number of XY elements: " << n_xy_elements << endl;

        // Allocate the VTK return array. Note that we're making it allocate
        // a 4-component vector since that means color in VisIt.
        arr = vtkFloatArray::New();
        arr->SetNumberOfComponents(4);
        arr->SetNumberOfTuples(n_xy_elements);
        float *fptr = (float *)arr->GetVoidPointer(0); 
        debug4 << mName << "Allocated VTK memory. Reading data." << endl;

        // Now that we're at the right HDU, read the whole image array.
        float nulval = -1.; // Value to use for no data
        int anynul = 0;
        long fpixel = 1;
        float *pixels = new float[nelements];
        if(fits_read_img(fits, TFLOAT, fpixel, nelements,
           &nulval, pixels, &anynul, &status))
        {
            PrintError(status);
            arr->Delete();
            EXCEPTION1(InvalidVariableException, varname);
        }

        debug4 << "Data has been read. Reorder it into 4-components" << endl;

        // We've read the data as RGB into the RGBA array so we need to
        // rearrange a little. We can do this by shifting values towards
        // the end of the array while inserting alpha values.
        float *rgba = fptr;
        float *r = pixels;
        float *g = pixels + n_xy_elements;
        float *b = pixels + n_xy_elements*2;
        for(i = 0; i < (size_t)n_xy_elements; ++i)
        {
            *rgba++ = *r++;
            *rgba++ = *g++;
            *rgba++ = *b++;
            *rgba++ = 255.;
        }

        delete [] pixels;
    }
    else
    {
        EXCEPTION1(InvalidVariableException, varname);
    }

    return arr;
}
コード例 #30
0
void
avtFITSFileFormat::Initialize(avtDatabaseMetaData *md)
{
    const char *mName = "avtFITSFileFormat::Initialize: ";

    if(fits == 0)
    {
        debug4 << mName << "Opening " << filename << endl;
        int status = 0;
        if(fits_open_file(&fits, filename, 0, &status))
        {
            PrintError(status);
            EXCEPTION1(InvalidFilesException, filename);
        }

        char card[FLEN_CARD], tmp[100];
        std::string fileComment;
        int hdutype = 0;

        // Iterate over the HDU's
        for(int hdu = 1; !(fits_movabs_hdu(fits, hdu, &hdutype, &status)); hdu++) 
        {
            debug4 << mName << "Looking at HDU " << hdu << endl;

            // Get no. of keywords
            int nkeys = 0, keypos = 0;
            if(fits_get_hdrpos(fits, &nkeys, &keypos, &status))
                PrintError(status);

            if(hdutype == IMAGE_HDU)
            {
                debug4 << mName << "HDU " << hdu << " contains an image" << endl;
                //int status2 = 0;
                char value[FLEN_VALUE];
                std::string objname, bunit, xlabel, ylabel, zlabel;

                // Try and get the key value for BUNIT
                if(GetKeywordValue("BUNIT", value))
                {
                    bunit = std::string(value);
                    debug4 << "\tBUNIT=" << value << endl;
                }

                // Try and get the key value for OBJECT
                if(GetKeywordValue("OBJECT", value))
                {
                    objname = std::string(value);
                    debug4 << "\tOBJECT=" << value << endl;
                }
#if 0
//
// Re-enable these someday when we read the mesh coordinates from the file
// and use them to construct a sensible mesh.
//
                // Try and get the key value for CTYPE1
                if(GetKeywordValue("CTYPE1", value))
                {
                    xlabel = std::string(value);
                    debug4 << "\tCTYPE1=" << value << endl;
                }

                // Try and get the key value for CTYPE2
                if(GetKeywordValue("CTYPE2", value))
                {
                    ylabel = std::string(value);
                    debug4 << "\tCTYPE2=" << value << endl;
                }

                // Try and get the key value for CTYPE3
                if(GetKeywordValue("CTYPE3", value))
                {
                    zlabel = std::string(value);
                    debug4 << "\tCTYPE3=" << value << endl;
                }
#endif
                // Use the keywords to create a comment.
                SNPRINTF(tmp, 100, "Header listing for HDU #%d:\n", hdu);
                fileComment += tmp;
                for(int jj = 1; jj <= nkeys; jj++)
                {
                    if(fits_read_record(fits, jj, card, &status))
                        PrintError(status);
                    std::string cs(card);
                    fileComment += cs;
                    if(cs.size() > 0 && cs[cs.size()-1] != '\n')
                        fileComment += "\n";
                }
                fileComment += "\n\n";

                //
                // Get the image's dimensions.
                //
                int ndims = 0;
                if(fits_get_img_dim(fits, &ndims, &status))
                    PrintError(status);
                debug4 << mName << "Num dimensions: " << ndims << ", status=" << status << endl;
                long *dims = new long[ndims];
                if(fits_get_img_size(fits, ndims, dims, &status))
                    PrintError(status);
                if(ndims == 0)
                {
                    debug4 << mName << "The image has no dimensions. Skip it." << endl;
                    continue;
                }

                //
                // Create a mesh name for the image.
                //
                intVector mdims;
                std::string meshName("image");
                debug4 << mName << "Image dimensions: ";
                bool dimensionsNonZero = false;
                for(int i = 0; i < ndims; ++i)
                {
                    char num[20];
                    if(i > 0)
                        SNPRINTF(num, 20, "x%d", (int)dims[i]);
                    else
                        SNPRINTF(num, 20, "%d", (int)dims[i]);
                    meshName += num;
                    mdims.push_back((int)dims[i]);
                    dimensionsNonZero |= (dims[i] != 0);
                    debug4 << dims[i] << ", ";
                }
                debug4 << endl;
                if(!dimensionsNonZero)
                {
                    debug4 << mName << "All dimensions were zero. skip." << endl;
                    continue;
                }
                if(ndims == 1 && objname != "")
                    meshName = objname;
                if(meshDimensions.find(meshName) == meshDimensions.end())
                {
                    meshDimensions[meshName] = mdims;

                    // Create metadata if necessary.
                    if(md != 0)
                    {
                        if(ndims == 1)
                        {
                            debug4 << mName << "Adding a curve called "
                                   << meshName.c_str() << " for HDU "
                                   << hdu << endl;

                            avtCurveMetaData *cmd = new avtCurveMetaData;
                            cmd->name = meshName;
                            if(xlabel != "")
                                cmd->xLabel = xlabel;
                            if(ylabel != "")
                                cmd->yLabel = ylabel;
                            md->Add(cmd);

                            // Do this because we use GetVar to read the data
                            // that we use to create the curve.
                            varToHDU[meshName] = hdu;
                            varToMesh[meshName] = meshName;
                        }
                        else
                        {
                            int sdims, tdims;
                            int nrealdims = (ndims <= 3) ? ndims : 3;
#define VECTOR_SUPPORT
#ifdef VECTOR_SUPPORT
                            if(nrealdims == 3 && dims[2] == 3)
                                nrealdims = 2;
#endif
                            sdims = tdims = nrealdims;

                            debug4 << mName << "Adding a " << sdims
                                   << " dimensional mesh called "
                                   << meshName.c_str() << " for HDU "
                                   << hdu << endl;

                            avtMeshMetaData *mmd = new avtMeshMetaData(
                                meshName, 1, 1, 1, 0, sdims, tdims,
                                AVT_RECTILINEAR_MESH);
                            if(xlabel != "")
                                mmd->xLabel = xlabel;
                            if(ylabel != "")
                                mmd->yLabel = ylabel;
                            if(zlabel != "")
                                mmd->zLabel = zlabel;

                            md->Add(mmd);
                        }
                    }
                }

                //
                // Create a name for the variable at this HDU
                //
                if(ndims > 1)
                {
                    char varname[100];
                    SNPRINTF(varname, 100, "hdu%d", hdu);
                    std::string vName(varname);
                    if(objname != "")
                        vName = objname;
                    varToHDU[vName] = hdu;
                    varToMesh[vName] = meshName;

                    // Create metadata if necessary
                    if(md != 0)
                    {
#ifdef VECTOR_SUPPORT
                        // Limit the dimensions to 3.
                        int ncomps = 1;
                        int nrealdims = (ndims <= 3) ? ndims : 3;
                        if(nrealdims == 3 && dims[2] == 3)
                            ncomps = 3;

                        if(ncomps == 1)
                        {
#endif
                            debug4 << mName << "Adding a scalar called "
                                   << vName.c_str() << " for HDU "
                                   << hdu << endl;
                            // Add the scalar metadata
                            avtScalarMetaData *smd = new avtScalarMetaData(
                                vName, meshName, AVT_ZONECENT);
                            smd->hasUnits = bunit != "";
                            smd->units = bunit;
                            md->Add(smd);
#ifdef VECTOR_SUPPORT
                        }
                        else
                        {
                            debug4 << mName << "Adding a color vector called "
                                   << vName.c_str() << " for HDU "
                                   << hdu << endl;

                            // Add the vector metadata
                            avtVectorMetaData *vmd = new avtVectorMetaData(
                                vName, meshName, AVT_ZONECENT, 4);
//                          vmd->hasUnits = true;
//                          vmd->units = 
                            md->Add(vmd);
                        }
#endif
                    }
                }

                delete [] dims;
            }
            else if(hdutype == ASCII_TBL)
            {
                debug4 << mName << "HDU " << hdu
                       << " contains an ascii table" << endl;
            }
            else if(hdutype == BINARY_TBL)
            {
                debug4 << mName << "HDU " << hdu
                       << " contains a binary table" << endl;

                // Use the keywords to create a comment.
                SNPRINTF(tmp, 100, "Header listing for HDU #%d:\n", hdu);
                debug4 << tmp;
                for(int jj = 1; jj <= nkeys; jj++)
                {
                    if(fits_read_record(fits, jj, card, &status))
                        PrintError(status);
                    std::string cs(card);
                    if(cs.size() > 0 && cs[cs.size()-1] != '\n')
                        cs += "\n";
                    debug4 << "\t" << cs.c_str();
                }
            }
        }

        if(md != 0)
            md->SetDatabaseComment(fileComment);
    }
}