;+
; NAME: eis_get_compression_factor
;
; PURPOSE: Returns the reciprocal of the latest EIS compression factor
;
; CATEGORY: Planning
;
; CALLING SEQUENCE: eis_get_compression_factor, c
;
; INPUTS: The selected compression method (0 for none, 1 for DPCM, etc)
;
; KEYWORD PARAMETERS: None
;
; OUTPUTS: The reciprocal of the compression factor for the chosen compression
;          method or 1 if the input compression method is invalid
;
; NOTES
;          slitindex (ss) scheme is: 0/1/2/3 -> 1/266/2/40
;
; CALLS: None
;
; COMMON BLOCKS:None
;
; PROCEDURE:
;
; RESTRICTIONS: None
;
; MODIFICATION HISTORY:
;       25/04/07 mcrw   wrote from JAR template eis_compression.pro
;       27/04/07 mcrw   Ensured float values
;       30/04/07 mcrw   Added end...
;       20/09/07 mcrw   Changed factors
;       06/12/07 mcrw   Changed factors (no rounding)
;       19/03/08 mcrw   Changed factors to Hiro's values from pry email
;       19/05/08 jar    Altered to account for target and sla selection
;       19/06/06 mcrw   Updated factors
;                       Added case for SLA selection for JPEG90
;       27/07/09 jar,   Added silent keyword
;                mcrw
;       16/04/10 mcrw   Changed jpeg95 factors as per NCR 102.
;	07/11/11 mcrw	Reduced all factors by 10% on instruction from KFJ.
;			Telemetry limit being hit too often.
;
;       17/09/12 kfj    In consultation with other team members.
;                       Changed the following factors for (flare)
;                       studies (ELSE in target_string CASE
;                       statement):
;
;                       DPCM (2.00 to 2.2), JPEG98 (2.00 to 2.2), 
;                       JPEG90 (3.45 to 3.75), JPEG75 (5.27 to 6.58)
;                       JPEG50 (8.53 to 10.66), JPEG95 (2.4 to 2.66)
;                       JPEG92 (3.13 to 3.47), JPEG85 (4.1 to 5.12)
;                       and JPEG65 (6.7 to 8.37)
;                       Changes summary (flare factors): * DPCM to JPEG90 +10%
;                                                        * the rest +20%
;-
;______________________________________________________________________________
FUNCTION eis_get_compression_factor, c , ss , target = target, silent = silent

target_string = STRTRIM(STRLOWCASE(target),2)
c_string      = 'None  '
ss_add = 0.0

CASE c OF                            ; Previously... (older -> newer)
    0    : cf = 1.0                               ; None
    1    : BEGIN
               c_string = 'DPCM  '
               CASE target_string OF
                   'quiet sun'     : cf = 2.00
                   'active region' : cf = 2.00
                   ELSE            : cf = 2.20
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.2  ; SLIT
               ENDCASE
           END
    2    : BEGIN
               c_string = 'JPEG98'
               CASE target_string OF
                   'quiet sun'     : cf = 2.23
                   'active region' : cf = 2.00
                   ELSE            : cf = 2.20    ; JPEG98
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.1  ; SLIT
               ENDCASE
           END
    3    : BEGIN
               c_string = 'JPEG90'
               CASE target_string OF
                   'quiet sun'     : cf = 3.63
                   'active region' : cf = 3.45
                   ELSE            : cf = 3.75    ; JPEG90
               ENDCASE
               CASE (ss eq 1) OR (ss eq 3) OF
                   1               : ss_add = 0.0 ; SLOT
                   ELSE            : ss_add = 0.1 ; SLIT
               ENDCASE
           END
    4    : BEGIN
               c_string = 'JPEG75'
               CASE target_string OF
                   'quiet sun'     : cf = 5.45
                   'active region' : cf = 5.27
                   ELSE            : cf = 6.58    ; JPEG75
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.0  ; SLIT
               ENDCASE
           END
    5    : BEGIN
               c_string = 'JPEG50'
               CASE target_string OF
                   'quiet sun'     : cf = 8.53
                   'active region' : cf = 8.53
                   ELSE            : cf = 10.66    ; JPEG50
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.0  ; SLIT
               ENDCASE
           END
    6    : BEGIN
               c_string = 'JPEG95'
               CASE target_string OF
                   'quiet sun'     : cf = 2.58
                   'active region' : cf = 2.40
                   ELSE            : cf = 2.66    ; JPEG95
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.0  ; SLIT
               ENDCASE
           END
    7    : BEGIN
               c_string = 'JPEG92'
               CASE target_string OF
                   'quiet sun'     : cf = 3.13
                   'active region' : cf = 3.13
                   ELSE            : cf = 3.47    ; JPEG92
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.0  ; SLIT
               ENDCASE
           END
    8    : BEGIN
               c_string = 'JPEG85'
               CASE target_string OF
                   'quiet sun'     : cf = 4.38
                   'active region' : cf = 4.10
                   ELSE            : cf = 5.12    ; JPEG85
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.2  ; SLIT
               ENDCASE
           END
    9    : BEGIN
               c_string = 'JPEG65'
               CASE target_string OF
                   'quiet sun'     : cf = 6.70
                   'active region' : cf = 6.70
                   ELSE            : cf = 8.37    ; JPEG65
               ENDCASE
               CASE (ss EQ 1) OR (ss EQ 3) OF
                   1               : ss_add = 0.0  ; SLOT
                   ELSE            : ss_add = 0.0  ; SLIT
               ENDCASE
           END
    ELSE : cf = 1.0                               ; Default (none)

ENDCASE

; Slitindex (ss) scheme is: 0/1/2/3 -> 1/266/2/40
CASE ss OF
    0     : ss_string = '1"   Slit'
    1     : ss_string = '266" Slot'
    2     : ss_string = '2"   Slit'
    3     : ss_string = '40"  Slot'
    ELSE  : ss_string = '1"   Slit'
ENDCASE

mText = STRJOIN(['Calculating compression scheme' ,c_string  , $
                'for',target_string, 'target' , $
                'with',ss_string] , ' ' ,/SINGLE)
IF ~ KEYWORD_SET(silent) THEN print,mText

; It's actually the inverse I'm after
cf_value = 1. / (cf + ss_add)
RETURN, cf_value

; This is required apparently...
END
