001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2023
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see http://www.gnu.org/licenses.
027 */
028
029package edu.wisc.ssec.mcidasv.control;
030
031import java.util.ArrayList;
032import java.util.List;
033
034import ucar.unidata.idv.control.ImagePlanViewControl;
035
036import ucar.unidata.data.grid.GridUtil;
037import ucar.unidata.idv.control.ReadoutInfo;
038import visad.Real;
039import visad.georef.EarthLocation;
040
041public class HydrometeorClassificationControl extends ImagePlanViewControl {
042
043    @Override protected List getCursorReadoutInner(EarthLocation el,
044                                                   Real animationValue,
045                                                   int animationStep,
046                                                   List<ReadoutInfo> samples)
047              throws Exception {
048
049        if (currentSlice == null) {
050            return null;
051        }
052        List result = new ArrayList();
053        Real r = GridUtil.sampleToReal(
054                     currentSlice, el, animationValue, getSamplingModeValue(NEAREST_NEIGHBOR));
055        if (r != null) {
056            ReadoutInfo readoutInfo = new ReadoutInfo(this, r, el,
057                                          animationValue);
058            readoutInfo.setUnit(getDisplayUnit());
059            readoutInfo.setRange(getRange());
060            samples.add(readoutInfo);
061        }
062
063        if ((r != null) && !r.isMissing()) {
064            
065            // list of codes found here:
066            // (51.2.2) http://www.roc.noaa.gov/wsr88d/PublicDocs/ICDs/2620003R.pdf
067            String str;
068            switch ((int) r.getValue()) {
069                case 0:  str = "SNR&lt;Threshold";  // black
070                         break;
071                case 10:  str = "Biological";  // medium gray
072                         break;
073                case 20:  str = "AP/Ground Clutter";  // dark gray
074                         break;
075                case 30:  str = "Ice Crystals";  // light pink
076                         break;
077                case 40:  str = "Dry Snow";  // light blue
078                         break;
079                case 50:  str = "Wet Snow";  // medium blue
080                         break;
081                case 60:  str = "Light-Moderate Rain";  // light green
082                         break;
083                case 70:  str = "Heavy Rain";  // medium green
084                         break;
085                case 80:  str = "Big Drops Rain";  // dark yellow
086                         break;
087                case 90:  str = "Graupel";  // medium pink
088                         break;
089                case 100: str = "Hail, Possibly With Rain";  // red
090                         break;
091                // classification algorithm reports "unknown type" here.
092                // How to distinguish this from "McV doesnt understand the code"?
093                case 140: str = "Unknown Type";  // purple
094                         break;
095                case 150: str = "RF";  // dark purple
096                         break;
097                default: str = "code undefined";
098                         break;
099            }
100
101            result.add("<tr><td>" + getMenuLabel()
102                       + ":</td><td  align=\"right\">"
103                       + str + "</td></tr>");
104        }
105        return result;
106
107    }
108}