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.data.hydra;
030
031import java.util.Map;
032
033public class CloudSat_2B_GEOPROF_RangeProcessor extends RangeProcessor {
034
035        public CloudSat_2B_GEOPROF_RangeProcessor(MultiDimensionReader reader,
036                        Map<String, Object> metadata) throws Exception {
037                super(reader, metadata);
038                if (scale == null) { // use implicit default value since E05, E06 has
039                                                                // removed the scale/offset from the Radar Refl
040                                                                // variable
041                        scale = new float[] { 100f };
042                        offset = new float[] { 0f };
043                }
044        }
045
046        public float[] processRange(short[] values, Map<String, double[]> subset) {
047                float[] new_values = new float[values.length];
048                for (int k = 0; k < values.length; k++) {
049                        float val = (float) values[k];
050                        if (val == missing[0]) {
051                                new_values[k] = Float.NaN;
052                        } else if ((val < valid_low) || (val > valid_high)) {
053                                new_values[k] = -40f;
054                        } else {
055                                new_values[k] = val / scale[0] + offset[0];
056                        }
057                }
058                return new_values;
059        }
060
061}