001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2025 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 https://www.gnu.org/licenses/. 027 */ 028 029package edu.wisc.ssec.mcidasv.data; 030 031import org.slf4j.Logger; 032import org.slf4j.LoggerFactory; 033 034public class SandwichSpeedup { 035 036 private static final Logger logger = 037 LoggerFactory.getLogger(SandwichSpeedup.class); 038 039 public static void sandwichSpeedup(float[] scaledFloats, 040 float[] floatsIR, 041 float[] rFloats, 042 float[] gFloats, 043 float[] bFloats, 044 float[] rTable, 045 float[] gTable, 046 float[] bTable, 047 float minIR, 048 float maxIR, 049 int nCols, 050 float noIRContribution) 051 { 052 for (int i = 0; i < scaledFloats.length; i++) { 053 // set anything colder than threshold to r,g,b from color table, 054 // otherwise just set to 1 (so that result after multiply is just 055 // the vis image) 056 if (floatsIR[i] < maxIR) { 057 058 // if anything falls below the minIR, set it to the minIR 059 // (scaledFloats=0) 060 if (floatsIR[i] < minIR) { 061 // java conversion note: "pixel" is just scaledFloats at 062 // current index 063 scaledFloats[i] = 0; 064 } 065 066 // need to convert float ranging from 0.0 to 1.0 into integer 067 // index ranging from 0 to nCols testing 068 int ind = (int)(scaledFloats[i] * nCols); 069 070 rFloats[i] = rTable[ind]; 071 gFloats[i] = gTable[ind]; 072 bFloats[i] = bTable[ind]; 073 } else { 074 rFloats[i] = noIRContribution; // previously was set to 1 075 gFloats[i] = noIRContribution; // see note for rFloats 076 bFloats[i] = noIRContribution; // see note for rFloats 077 } 078 } 079 } 080}