;+
;
; NAME: 
;	EIT_SUB_CONVOFF
;
; PURPOSE:
;	Convert between EIT grid subfield offset (0-1023) and offset 
;	coordinate block (column,row).  And vice verse.
;	Or when either is input along with the subfield pattern then
;	[xcen, ycen, xsize, ysize] is returned as arcsec.
;
; CATEGORY:
;	EIT SUBFIELD 
;
; CALLING SEQUENCE:
;	result = EIT_SUB_CONVOFF(offset=offset,[sub_ids=sub_ids, /text])
;	result = EIT_SUB_CONVOFF(coor=[column,row],[sub_ids=sub_ids])	
;
; CALLED BY:
;	Any
;
; CALLS TO:
;	none
;
; INPUTS:
;       none
;
; OPTIONAL INPUTS:
;	OFFSET	When present this scalar is the individual EIT grid block 
;		ranging from 0 to 1023, that is the offset. 
;		When both OFFSET and COOR are present OFFSET take precedence.
;	COOR	When present this 2-D vector is the column and the row of
;		the EIT offset.
;		When both OFFSET and COOR are present OFFSET take precedence.
;	SUB_IDS	An array of size 1024 representing which of the EIT blocks
;		are selected.  (1 represents select, 0 is not selected)
;	TEXT    When present with OFFSET then the (column and row are 
;		returned as a string in the form "column, row"
;
; OUTPUTS:
;	When OFFSET is input, returns the COOR vector (intarr)
;			      if TEXT is set then return string "col, row"
;	When COOR is input,   returns the OFFSET (integer)
;
; OPTIONAL OUTPUTS:
;	none
;
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	When OFFSET is input, modulo by the number of blocks in a column to
;	get the column and divide by the number of blocks in a row to get
;	the row.
;	When COOR is input, multiply row by number of blocks in a row and
;	add to the column value to get the OFFSET. 
;
; MODIFICATION HISTORY:
;	1995 February 17, Elaine Einfalt (HSTX)
;-

function EIT_SUB_CONVOFF, offset=offset, coor=coor, text=text


  if n_elements(offset) ne 0 then begin
     if keyword_set(text) $
	then result = strtrim(offset mod 32,2) + ', ' + strtrim(offset/32,2) $
	else result = [offset mod 32, offset/32] 
  endif else if n_elements(coor) ne 0 then result = fix((coor(1)*32)+coor(0)) $
  else result = -1

return, result
end
