;+
; NAME:
;	FITSW
; PURPOSE:
;	Write a FITS format image/header to disk.
; CATEGORY:
;	File IO. Low level.
; CALLING SEQUENCE:
;	FITS,OFILE,IMAGE,HEADER
; INPUTS:
;	OFILE, output file name
;	IMAGE, LP image, int*2 data to be saved.
;	HEADER, optional image header (f0 or fits)
; KEYWORD PARAMETERS:
;	none.
; OUTPUTS:
;	Writes to OFILE.
; SIDE EFFECTS:
; RESTRICTIONS:
;	Does not check errors.
; PROCEDURE:
;	Write the two structures.
; MODIFICATION HISTORY:
;	Jul. 1992  I. Zayer    LPARL. Modified to be stand-alone & renamed
;	Jan. 1990  P. Milford  Stanford University.
;-
pro fitsw,ofile,data,head

  sh=size(head)
  case sh(sh(0)+1) of
    1:
    8:head=fitsheader(head)
    else: head=fitsbasic(data)
  endcase
  openw,unit,ofile,/GET_LUN		; open file, get a lun for it.
    writeu,unit,head
    writeu,unit,data
  free_lun,unit

end