The simplifits library

simplifits was originally a very slim library originally developed for the EPIC EGSE

A provisional version of it is in use for the tests of interfacing mysql and FITS. The main differences between such versions and the current one are:

The complete version includes also simplinfits i.e. a further set of routines used to read FITS files.
And interfaces with the XAS VOS.
L.Chiappetti - 30-Oct-2000

These pieces of pseudocode show how to use simplifits for reading and writing a FITS file.
A prototype reader (a web-based viewer for FITS file) can be found here

reader

C...... open the file ........................................
        CALL FITSOPENOLD(N,filename,LU)
        CALL FITSSWAP(SWAP)
C
C...... read primary or extension header .....................
 1      CONTINUE         
C.....  get next keyword
        CALL FITSKWD(N,CARD,ENDED)
C       and decode it
        IF(.NOT.ENDED)THEN
          CALL FITSHDR(CARD,KEY,VALUE,COMMENT,ISCOMMENT)
          ...code to process the keywords...
C         and process next keyword
          GOTO 1
C       unless sequence of header kewyords is ended
        ELSE
          information about current HDU is automatically
          available in a COMMON block, use it if necessary
        ENDIF
C
C...... read or skip data ......................................
C       position to the wished record (for binary tables)
        CALL FITSSEEK(N,STARTREC,naxes(1))
C       loop on record
        DO I=STARTREC,ENDREC
            CALL FITSGETDATA(N,DATABUF,naxes(1))
            an user routine can use DATABUF and SWAP to extract
            and decode the content of DATABUF
        ENDDO
C
C..... process another extension ...............................
       CALL FITSHDU(N,+1,ENDED)
       IF(.NOT.ENDED)GOTO  1

writer


C...... open the file ........................................
        CALL FITSOPEN(N,filename,LU)
        CALL FITSSWAP(SWAP)
C.....  add mandatory primary header
        CALL FITSADDL(N,'SIMPLE'  ,.TRUE.)
        ....
        CALL FITSADDE(N)
C       add extension header for output file
        CALL FITSADDC(N,'XTENSION','BINTABLE' )
        ....
        CALL FITSADDE(N)
C.....  write some data
        DO loop on records
        an user routine can pack the record into BUFFER
        CALL FITSDATA(N,BUFFER(:NBYTE),NBYTE)
        ENDDO
C.....  ensure data is flushed to disk
        CALL FITSDATA(N,0,0)

A quick routine list follows The maximum number of FITS files simultaneously open is set by a PARAMETER constant in the INCLUDE file simplifits.inc (the current version for day-to-day work limits that to 2, but the original EPIC EGSE used 7, and other versions used at TESRE reached 20). Other critical constants, and the common blocks, are defined either there or in simplinfits.inc

sax.iasf-milano.inaf.it/~lucio/simplifits/ :: original creation 2009 apr 16 11:03:51 CEST :: last edit 2009 Apr 16 11:03:51 CEST