;+ ; Project : COURSE COMPUTER PROJECT ; ; Name : GALFLSCALE ; ; Purpose : Procedure to figure a flux scale factor and make flux label. ; ; Explanation : This procedure will take the flux from a spectrum and figure ; out a scale factor and make the appropriate label for the flux ; in order to make pretty plots containing flux. ; ; Use : GALFLSCALE, FLUX, FSC, FLAB ; ; Inputs : FLUX: The flux of the spectrum. ; ; Opt. Inputs : None. ; ; Outputs : FSC: The scale factor that one should multiply the flux by ; in order to use the label. ; ; FLAB: The label that corresponds to the scale factor. ; ; Opt. Outputs: None. ; ; Keywords : UNITS: The units of the flux. [DEFAULT: ergs/s/cm^2/A]. ; ; ERRMSG: If defined and passed, then any error messages will ; be returned to the user in this parameter rather than ; being printed internally by this procedure. If no ; errors are encountered, then a null string is ; returned. In order to use this feature, the string ; ERRMSG must be defined first, e.g., ; ; ERRMSG = '' ; GALFLSCALE, FLUX, FSC, FLAB, ERRMSG=ERRMSG ; IF ERRMSG(0) NE '' THEN ... ; ; Calls : None. ; ; Common : None. ; ; Restrictions: None. ; ; Side effects: None. ; ; Category : Class project, cosmology, Hubble's law, galaxies, spectra. ; ; Prev. Hist. : None. ; ; Written : Donald G. Luttermoser, ETSU/Physics, 1 Sep 2002. ; ; Modified : Version 1, Donald G. Luttermoser, ETSU/Physics, 1 Sep 2002 ; Initial program. ; Version 2, Donald G. Luttermoser, ETSU/Physics, 31 Mar 2007 ; Replaced the MESSAGE utility with a simple PRINT command. ; Changed the EMESSAGE internal string variable to EMESS. ; ; Version : Version 2, 31 March 2007. ; ;- PRO GALFLSCALE, FLUX, FSC, FLAB, UNITS=UNITS, ERRMSG=ERRMSG ; ON_ERROR, 2 ; Return to caller if error is encountered. EMESS = '' ; Set to non-null string if error is encountered. ; ; Check input. ; IF N_PARAMS() NE 3 THEN BEGIN EMESS = 'Syntax: GALFLSCALE, FLUX, FSC, FLAB' GOTO, HANDLE_ERROR ENDIF ; ; Check keywords. ; IF NOT KEYWORD_SET(UNITS) THEN UNITS = 'erg/s/cm!U2!N/A' ; FMAX = MAX(ABS(FLUX)) & FMAX = ALOG10(FMAX) & IMAX = FIX(FMAX) IF IMAX LT 0 THEN IMAX = IMAX - 1 FMAX = 10.^IMAX FSC = 1. / FMAX FLAB = '!6Flux (10!U' + STRTRIM(STRING(IMAX),2) + '!N ' + UNITS ; IF EMESS NE '' THEN GOTO, HANDLE_ERROR IF N_ELEMENTS(ERRMSG) GT 0 THEN ERRMSG=EMESS RETURN ; ; Error handling portion of the procedure. ; HANDLE_ERROR: ; IF N_ELEMENTS(ERRMSG) EQ 0 THEN PRINT, EMESS ERRMSG = EMESS RETURN ; END