pro spc_struct, spc_header = spc_header, spc_index = spc_index
;+
;	NAME:
;		spc_struct  V0.9
;	PURPOSE:
;		Define structures for reading/writing SPC files
;
;	CALLING SEQUENCE:
;		SPC_struct
;	HISTORY:
;		wrote for spc files by atp 6/7/92 (july)
;		cleanup/rationalisation of version numbers atp 7/7/92
;
;       notes: 
;		** in the descriptor field of an entry will 
;                indicate that this entry is not in the file.
;-

spc_header = {spc_h, $
	spcnam: bytarr(64), $ 	; 00- name of the SPC file 
	bsdnam: bytarr(64), $   ; 00- name of the BSD file
	bpcnam: bytarr(64), $ 	; 00- name of the BPC file used by bsdfit
	balcal: bytarr(64), $   ; 00- name of the Ionization balance used
	version: bytarr(64),$  	; 00- version number
	vernum: long(0), $	; 00- version number of spc file format
 	totspc: long(0), $	; 04- total number of theory spectra
	totbsd: long(0), $	; 08- total number of bsd spectra
	totpri: long(0), $	; 12- total number of primary cpnt spectra
	numbsd: lonarr(4), $	; 16- no of raw spectra in bsd file
	numthe: lonarr(4), $	; 32- no of theory spectra in each channel
	firchn: lonarr(4), $	; 48- Spectral number of first theory spectra
				;     in the file.
	ptrdmp: lonarr(4), $	; 00- Pointer to start of roadmap.
	spare1: bytarr(48) }    ; 16- Spare - should be spaces.

spc_index = {spc_r_h, $
	chan:  long(0), $	; 00- Channel number
	spec:  long(0), $	; 04- Spectrum number
	nbinssp:long(0), $	; 08- Number of bins in this spectrum.
	time:  lonarr(7), $	; 12- Time of the spectrum, in external format
	sumdgi:float(0), $	; 40- Integration time
	wo:    float(0), $	; 44- Wavelength offset
 	dw:    float(0), $ 	; 48- Dispersion. 
	kmax:  long(0), $ 	; 52- Max number of BSDFIT iterations
	kit:   long(0), $	; 56- Actual number of bsdfit iterations
	nfree: long(0), $	; 60- Number of degrees of freedom
	param: dblarr(8), $	; 00- Fitting parameters 8 in total,
				;     Te, Td, Tdk, Back, EM, EM2, UpVel, Spare.
	chisqr:float(0), $	; 00- Reduced chisqr
	cier:  long(0), $	; 04- IER from Curfith
	velfit:long(0), $	; 08- Velocity Component if Velfit > 0
	spare1:bytarr(52), $	; 12- Spare should be blank
	sparam:dblarr(8)}	; 00- Uncertainties on fit parameters 

SPC_roadmap = { SPC_road, $     ; SPC roadmap records also called pointers.
        offset: lonarr(4), $    ; 00- Pointer offset values.
        exist:  bytarr(4)}      ; 16- **Flag =1 if data exist for this channel.
        
spc_data = { spc_data, $        ; Bsd Data structure.
        counts: fltarr(256), $  ; 00- Counts 
        primary:fltarr(256)}    ; 04*256- Primary component of a 2comp fit. 
				; - may not be present see index.velfit
end
	
