1 C Copyright(c) 1997, Space Science and Engineering Center, UW-Madison 2 C Refer to "McIDAS Software Acquisition and Distribution Policies" 3 C in the file mcidas/data/license.txt 4 5 C *** $Id: m0grayscale.f,v 1.4 2017/07/21 00:49:29 daves Exp $ *** 6 *$ Name: 7 *$ m0grayscale - Converts ALB or TEMP to BRIT (with ORIG or EXP stretch) 8 *$ 9 *$ Interface: 10 *$ integer function 11 *$ m0grayscale(character option, real value, real brit) 12 *$ 13 *$ Input: 14 *$ option - TEMP or ALB 15 *$ value - Value being converted in K (for TEMP), percent (for ALB) 16 *$ 17 *$ Input and Output: 18 *$ none 19 *$ 20 *$ Output: 21 *$ brit - Grayscale value. 22 *$ 23 *$ Return values: 24 *$ function return =0 for OK 25 *$ 26 *$ Remarks: 27 *$ none 28 *$ 29 *$ Categories: 30 *$ converter 31 *$ calibration 32 33 integer function m0grayscale(option, value, brit) 34 implicit none 35 character*(*) option 36 character*4 coption, cunit 37 real brit 38 real value 39 40 integer m0brkset, m0brkval 41 integer m0graybrkset 42 integer istat, brkflag 43 real tlim, con1, con2 44 real tempk, ralb 45 DATA CON1 /418.0/ 46 DATA CON2 /660.0/ 47 DATA TLIM /242.0/ 48 data brkflag/0/ 49 50 coption = option 51 52 C--- CONVERT BRIGHTNESS TEMPERATURE (K) TO A GRAY SCALE 53 54 if(coption .eq. 'TEMP') then 55 tempk = value 56 if(brkflag .eq. 0) then 57 IF (TEMPK .LT. TLIM) THEN 58 BRIT = CON1 - TEMPK 59 ELSE 60 BRIT = CON2 - 2.0 * TEMPK 61 ENDIF 62 else if(brkflag .eq. 1) then 63 istat = m0brkval(tempk, brit) 64 endif 65 66 if(tempk .le. 0.0) brit = 255.0 67 68 if(brit .lt. 0.0) brit = 0.0 69 if(brit .gt. 255.0) brit = 255.0 70 71 m0grayscale = 0 72 73 C--- CONVERT ALBEDO (REFLECTANCE) (%) TO GRAY SCALE 74 75 else if(coption .eq. 'ALB') then 76 77 ralb = value 78 79 if(brkflag .eq. 0) then 80 brit = sqrt(ralb)*25.5 81 else if(brkflag .eq. 1) then 82 istat = m0brkval(ralb, brit) 83 endif 84 85 if(ralb .le. 0.0) brit = 0.0 86 87 if(brit .lt. 0.0) brit = 0.0 88 if(brit .gt. 255.0) brit = 255.0 89 90 m0grayscale = 0 91 92 else 93 m0grayscale = -1 94 endif 95 96 RETURN 97 98 entry m0graybrkset(option) 99 100 m0graybrkset = -1 101 istat = m0brkset(option, cunit) 102 if(istat .eq. 0) then 103 brkflag = 1 104 m0graybrkset = 0 105 endif 106 107 return 108 end