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 031public class CrIS_SDR_Utility { 032 033 public static int[][] ifov_order = new int[][] {new int[] {2,2}, new int[] {1,2}, new int[] {0,2}, 034 new int[] {2,1}, new int[] {1,1}, new int[] {0,1}, 035 new int[] {2,0}, new int[] {1,0}, new int[] {0,0}}; 036 037 public static int LW_CHANNELS = 717; 038 public static int MW_CHANNELS = 437; 039 public static int SW_CHANNELS = 163; 040 041 public static float LW_INIT_SR = 649.75f; 042 public static float MW_INIT_SR = 1210.0f; 043 public static float SW_INIT_SR = 2155.0f; 044 045 public static float LW_SR_INCR = 0.625f; 046 public static float MW_SR_INCR = 1.25f; 047 public static float SW_SR_INCR = 2.5f; 048 049 public static float getWavenumberStart(String name) { 050 if (name.endsWith("LW")) { 051 return LW_INIT_SR; 052 } 053 else if (name.endsWith("MW")) { 054 return MW_INIT_SR; 055 } 056 else if (name.endsWith("SW")) { 057 return SW_INIT_SR; 058 } 059 else { 060 return Float.NaN; 061 } 062 } 063 064 public static float getWavenumberIncrement(String name) { 065 if (name.endsWith("LW")) { 066 return LW_SR_INCR; 067 } 068 else if (name.endsWith("MW")) { 069 return MW_SR_INCR; 070 } 071 else if (name.endsWith("SW")) { 072 return SW_SR_INCR; 073 } 074 else { 075 return Float.NaN; 076 } 077 } 078 079 public static int getNumChannels(String name) { 080 if (name.endsWith("LW")) { 081 return LW_CHANNELS; 082 } 083 else if (name.endsWith("MW")) { 084 return MW_CHANNELS; 085 } 086 else if (name.endsWith("SW")) { 087 return SW_CHANNELS; 088 } 089 else { 090 return -1; 091 } 092 } 093 094 public static float[] psuedoScanReorder(float[] values, int numElems, int numLines) { 095 float[] new_values = new float[values.length]; 096 int i2 = -1; 097 int j2 = -1; 098 int k = -1; 099 int idxMA = -1; 100 int idxA = -1; 101 for (int j = 0; j < numLines / 3; j++) { // - loop over EFOVs or FORs 102 for (int i = 0; i < numElems / 3; i++) { 103 i2 = i * 3; 104 j2 = j * 3; 105 for (int jj = 0; jj < 3; jj++) { // - loop over IFOVs 106 for (int ii = 0; ii < 3; ii++) { 107 k = jj * 3 + ii; 108 idxMA = j * (numElems / 3 * 9) + i * 9 + k; 109 idxA = (j2 + ifov_order[k][0]) * numElems + i2 110 + ifov_order[k][1]; // idxA: aligned 111 new_values[idxA] = values[idxMA]; 112 } 113 } 114 } 115 } 116 return new_values; 117 } 118 119}