;**********************************************************************
PRO hr_v4_v5,smooth=smooth,hdr=hdr,swap=swap
;**********************************************************************

;----------------------------------------------------------------------
;	PURPOSE: Draw the contour of Dopplergram
;			of Huairou Solar Observation Station Observed
;			by the new image system based on
;				CCD:		PULNIX 6701AN
;				Grabber:	Viper-QUAD, CORECO INC.
;----------------------------------------------------------------------
;	KEYWORDS:
;		smooth: mode to smooth the raw data, default=4 pixels
;		swap: 	the high-low 8-bit conversion
;		hdr:	choose the specified data
;----------------------------------------------------------------------

;----------------------------------------------------------------------
;	Default:
		if n_elements(smooth) eq 0 then smooth=4
;----------------------------------------------------------------------

;----------------------------------------------------------------------
;	Modification:
;		Sep.26, 1997, DASOP, by Deng Y. Y., for Pulnix 560
;		Nov.14, 1997, DASOP, by DYY		for Pulnix 560
;		Oct.13, 2001, HSOS,  by DYY		for Pulnix 6701AN
;----------------------------------------------------------------------


;----------------------------------------------------------------------
;	Read Dopplergram And Preprocess It
;----------------------------------------------------------------------
if n_elements(hdr) eq 0 then filename=dialog_pickfile(filter='V*.fit')
if n_elements(hdr) ne 0 then filename=dialog_pickfile(filter=hdr)
dat=readfits(filename,header)
if n_elements(swap) ne 0 then dat=swap_endian(dat)
;dat=rotate(dat,7)

; Calibrate Magnetogram
calibration=sxpar(header,'CALIBRAT')
dat=dat*10000./calibration

dat=smooth(dat,smooth)

;----------------------------------------------------------------------
xdim=float(sxpar(header,'NAXIS1'))
ydim=float(sxpar(header,'NAXIS2'))
limit=1500
window,0,xsize=xdim,ysize=ydim

!p.position=[0.,0.,1.,1.]
tvscl,dat>(-limit)<limit

ss=where(dat gt 0,count)
print,max(dat),min(dat),count

;----------------------------------------------------------------------
;	Choose Contour Level
;----------------------------------------------------------------------
vi=[50.,100.,200.,300.,400.,600.,800.,1200.,1600.,2400.,3200.,4000.,4800.,5600.,6400.]

;----------------------------------------------------------------------

end