;+
; NAME:
;       EIS_DATA_READFOREIGN
;
; PURPOSE:
;       EIS_DATA_READFITS reads EIS data files and stores data and other
;       information in the object fields of an EIS_DATA class object. 
;
; CATEGORY:
;       Hansteen/Wikstol Data analysis SW
;
; CALLING SEQUENCE:
;
; INPUTS:
;       file:  Name of fits file (string) containing data (and headers).
;
; KEYWORD PARAMETERS:
;       hdr: Set this keyword to obtain also the header
;       information in the form of an object of type EIS_FITS_HDR. 
;
; OUTPUTS:
;       Reads fits image data files and fills the parameters of the EIS_DATA
;       object with information.
;
; CALLS:
;       FITS_HDR__DEFINE
;       FITS_HDR__READ
;       FXBOPEN
;       FXBREAD
;       FXBTFORM
;       FXBTDIM
;
; COMMON BLOCKS:
;       
;
; PROCEDURE:
;       
;       
;
; RESTRICTIONS:
;
;
; MODIFICATION HISTORY:
;
;-
pro eis_data::readforeign, file, hdr = hdr, error = error, init=init
  if n_elements(init) eq 1 then return
  if n_params() lt 1 then begin
    message, 'No datafile specified!', /informational
    message, 'usage: data->read, file, hdr = hdr', $
              /informational
    return
  endif
;
  self.hdr=ptr_new(obj_new('fits_hdr',file,/foreign))
;
  self.nexp = 1                     
  self.filename = file
  self.nwin = 1
;
  data=readfits(file,headr)
  sz=size(data)
  self.xs[0] = 0
  self.xw[0] = sz[1]
  self.ys[0] = 0
  self.yw[0] = sz[2]
  self.w[0]=ptr_new(intarr(self.xw[0],self.yw[0],1))
  *self.w[0] = data
;
  cdelt1 = fxpar(headr,'cdelt1')
  fmirr_ss = cdelt1
  cdelt2 = fxpar(headr,'cdelt2')
  self.obsmode = 'scanning'
  self.sit_and_stare = 0
;  
  for i=1,self.nexp-1 do begin
    data=read_fits(file,headr)
    sz=size(data)
    self.xs = 0
    self.xw = sz[1]
    self.ys = 0
    self.yw = sz[2]
    self.w[0]=ptr_new(intarr(self.xw[icol],self.yw[icol],self.nexp))
    ; read data:
    fxbread, lu, d, icol+1
    *self.w[icol] = d
    cdelt1 = fxpar(headr,'cdelt1')
    fmirr_ss = cdelt1
    cdelt2 = fxpar(headr,'cdelt2')
    self.obsmode = 'scanning'
    self.sit_and_stare = 0
  endfor
  
end







