
;+
; NAME:
;        HXA_PARMS
; PURPOSE:
;        Returns numerical values of various parameters used in suncenter
;        calculations, including HXA detector properties.
;
;        This second version returns updated and corrected parameters.
;        Note: the use of cox, coy has slightly changed.  The polynomial
;        is not in time since sunrise in minutes, but tofac*t/(t_lms-t_fms).
; CATEGORY:
; CALLING SEQUENCE:
;        hxa_parms,...
; INPUTS:
; KEYWORDS (INPUT):
; OUTPUTS:
; KEYWORDS (OUTPUT):
;        hpix = HXA pixel size (in arcseconds)
;        h_xx, h_yy = HXA detector crossing point coordinates
;        spix = SXT pixel size  (Note: in hxa_suncenter: spix = hpix/spix!)
;        phi = angle between SXT (E->W) and HXA (SE->NW)
;        sxt_off = SXT coordinates of HXA detector crossing point
;        naban_o = offset between NaBan filter image and SXT X-ray image
;        wdban_o = offset between WdBan filter image and SXT X-ray image
;        cox, coy = coefficients for orbital phase correction
;        tofac = multiplier for orbital phase
;        clx, cly = coefficients for orbit duration correction
;        tloff = time offset for orbit duration correction (in minutes)
;        cmx, cmy = coefficients for mission time correction
;        tmoff = time offset for mission time correction (in days)
;        tmcut = last day for which mission time correction shall be applied
;        gpix = gyro unit (in arcseconds)
; COMMON BLOCKS:
;        None.
; SIDE EFFECTS:
; RESTRICTIONS:
;        correction coefficients cmx, cmy only work for first year of
;        mission.  A zero correction is ok for 1993 and early 1994.
;        This correction cannot be predicted for future times.
; PROCEDURE:
; MODIFICATION HISTORY:
;	 19-Jul-93 (JPW) - Constants mostly from hxa-suncenter.
;        20-Sep-94 (JPW) - Updated parameters, plus cutoff date for
;                          mission time correction
;        24-sep-94 (SLF) - added VERSION keyword (output), Set VERSION=1
;         3-oct-96 (JPW) - set VERSION=2, to reflect modified hxa2hxaxy
;-

pro hxa_parms,hpix=hpix,h_xx=h_xx,h_yy=h_yy,spix=spix,phi=phi, $
              sxt_off=sxt_off,naban_o=naban_o,wdban_o=wdban_o, $
              cox=cox,coy=coy,tofac=tofac,clx=clx,cly=cly,tloff=tloff, $
              cmx=cmx,cmy=cmy,tmoff=tmoff,tmcut=tmcut,gpix=gpix, $
	      version=version

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

; old constants used until Sep-94
;
;VERSION=0			    ; historical comment / slf, 24-sep-94
;hpix = 2.072                       ; factor hxa -> sun_r
;h_xx = 1006.0                      ; hxa axes cross at x = h_xx
;h_yy = 1038.0                      ; hxa axes cross at y = h_yy
;spix = 2.455 ; slightly different to gt_pix_size, replace only after checking
;             ; consistency of all parameters
;gpix = 0.08                        ; gyro unit (in arcseconds)
;phi = 44.35
;sxt_off = [503.6 + 0.36, 665.1 - 1.47]
;sxt_off = sxt_off + 0.5             ; pixel def. OFR -> FRE (21-jul-93 JPW)
;naban_o = [-0.36, +1.47]
;wdban_o = [-0.36 + 0.6, +1.47 - 0.2]
;cox = [+0.21,-6.23e-4,+1.82e-7]     ; coefficients for orbital time correction
;coy = [+1.22,-1.326e-3,+2.82e-7]
;clx = [0.0, 0.0, 0.0]
;cly = [+0.32,+1.198e-3,-1.019e-6]   ; coefficients for orbit duration (y only)
;tloff = 4000.0/60.0                 ; time offset for orbit duration (min.)
;cmx = [+1.88,-3.130e-3,+1.068e-6]   ; coefficients for mission correction
;cmy = [-8.57,+1.889e-2,-1.024e-5]   ; as of Sept. 1992
;tmoff = 4000                        ; day offset for mission time corr. (days)
;
;ttt = [1.0,60.0,3.6e3]     ; converts constants for use with times in minutes
;cox = cox*ttt
;coy = coy*ttt
;clx = clx*ttt
;cly = cly*ttt
;-----------------------------------------------------------------------

; Sources of the updated constants below:
; 1. hpix, h_xx, h_yy
;    Parameters determined by fitting all available hxa data of offpoints
;    for which none of the solar limb was hidden behind a fiducial mark.
;    Program: find_hxaparm1.pro (uses the atr database).
;    The results agree very well with Masuda's results.
;    Note: this hxa pixel size is only used to reconstruct the hidden limbs,
;    and has been tuned to best serve this purpose.  There may be a small
;    difference between hpix and the actual hxa plate scale.
; 2. spix, phi
;    Two methods: a) fit sxc and atr data for all offpoints,
;    b) co-register all images of a particularly well-observed set of E-W
;    offpoints on 8-may-92.
;    Method a) uses many observations of lower accuracy, and method b)
;    uses fewer observations of higher accuracy.
;    Programs: a) do_hpix_phi.pro, b) run_s_h_limbs.pro and hxa_sxt_phi_r.pro.
;    Note: spix is only used for the hxa to sxt pixel size ration (hpix/spix),
;    thus the programs determine this ratio.  Official (red book) value is
;    0.8460, but the Mercury passage observations indicate that the SXT
;    pixel size is actually slightly larger (2.455").  The value for spix is
;    hpix divided by the average of methods a) and b) (=0.8450).
;    The average for phi is 44.33 degrees, consistent with Masuda's 44.35.
; 3. gpix
;    Determine gpix/hpix with atr data of offpoints throughout the mission.
;    The ratio varies with time, especially when a gyro starts having
;    problems (shortly before the switch to the S-gyro).  The adopted ratio
;    is an average for good gyro's.  The resulting gyro "plate scale" is
;    0.082"/step (larger than the official 0.080"/step).
;    Program: find_iruparm2.pro.
; 4. sxt_off, cox/y, clx/y, cmx/y, tloff, tmoff, tmcut
;    Determine the offset between SXT and the crossing points of the hxa
;    detectors using the sxc database.  Determine the coefficients for
;    three time-dependant corrections: orbital phase correction (cox/y),
;    orbital length correction (clx/y), time into mission correction (cmx/y).
;    The time into mission correction is most significant for the first
;    year of the mission, and flattened out thereafter.  Future significant
;    deviations are possible but cannot be predicted.  tmcut indicates the
;    last day for which the mission correction can be applied, for later dates
;    the correction shall be 0.
;    Programs: off_sxt_nab.pro and do_sxt_off.pro.
;    Note: the values for tofac, tloff, and tmoff are definitions.
;    The various correction coefficients are for 2nd degree polynomials in
;    time (tofac*t/(t_lms-t_fms) for cox/y (new def.!), minutes for clx/y,
;    days for cmx/y).  The polynomial fit works well for the first two
;    correction, but only up to jan-93 for the mission correction.
; 5. Offset between SXT and aspect telescope.  The offset is different for
;    the two optical filters.  Metcalf determined the offset between
;    SXT and the NaBan images and Wuelser determined the offset between
;    the two optical filters in 1992.  These values are within 0.10 pixels
;    of the average of all SXC and SOT suncenter locations until fall 1992.
;    (Program off_sxt_nab.pro.  This program corrects for a 0.4 pixel offset
;    between suncenter locations obtained with the old and new sxt_center
;    algorithm.  That offset in turn was determined by comparing old and new
;    SXC suncenter positions for the (random) weeks 92_20, 92_25, 92_26 ,92_27.
;    Result: sunc_new_x - sunc_old_x = 0.0 , sunc_new_y - sunc_old_y = +0.40).


;VERSION=1			    ; slf, 24-sep-1994
VERSION=2			    ; jpw,  3-oct-1996
                                    ; version=2 indicates modified hxa2hxaxy,
                                    ; even though hxa_parms was not changed
; Updated constants
hpix = 2.073                        ; factor hxa -> sun_r
h_xx = 1006.0                       ; hxa axes cross at x = h_xx
h_yy = 1039.0                       ; hxa axes cross at y = h_yy

spix = hpix/0.8450                  ; 0.845 is best estimate for hpix/spix
phi = 44.33                         ; angle between hxa and sxt
gpix = hpix*0.0396                  ; gyro unit (in arcseconds)

sxt_off = [504.76, 663.19]          ; average loc. of hxa crossing pt. on SXT
cox = [+0.31,-4.10e-2,+7.52e-4]     ; coefficients for orbital time correction
coy = [+0.97,-7.14e-2,+9.83e-4]
tofac = 60.0                        ; multiplier for relative orbital phase
clx = [+0.06,+1.60e-2,-1.31e-3]     ; coefficients for orbit duration
cly = [+0.31,+9.03e-2,-4.76e-3]
tloff = 4000.0/60.0                 ; time offset for orbit duration (min.)
cmx = [ +4.09, -7.69e-3, +3.62e-6]  ; coefficients for mission correction
cmy = [-10.50,+2.389e-2,-1.299e-5]  ; use only up to 1-jan-93, (0 thereafter)
tmoff = 4000                        ; day offset for mission time corr. (days)
tmcut = 5115                        ; end day for mission corr. (1-jan-93)

naban_o = [-0.36, +1.47]               ; offset betw. NaBan and SXT sunc. loc.
wdban_o = [-0.36 + 0.6, +1.47 - 0.2]   ; offset betw. WdBan and SXT sunc. loc.

end
