001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2016 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.io.BufferedReader; 032import java.io.InputStream; 033import java.io.InputStreamReader; 034import java.util.Map; 035import java.util.StringTokenizer; 036 037import org.slf4j.Logger; 038import org.slf4j.LoggerFactory; 039 040import visad.RealType; 041 042public class CloudSat2D extends ProfileAlongTrack { 043 044 private static final Logger logger = LoggerFactory.getLogger(CloudSat2D.class); 045 046 public CloudSat2D() { 047 } 048 049 public CloudSat2D(MultiDimensionReader reader, Map<String, Object> metadata) { 050 super(reader, metadata); 051 } 052 053 public float[] getVertBinAltitude() throws Exception { 054 String propertyFileName = null; 055 float[] altitude = new float[VertLen]; 056 try { 057 propertyFileName = (String) metadata.get(ancillary_file_name); 058 InputStream ios = getClass().getResourceAsStream(propertyFileName); 059 BufferedReader ancillaryReader = new BufferedReader(new InputStreamReader(ios)); 060 061 int line_cnt = 0; 062 while (true) { 063 String line = ancillaryReader.readLine(); 064 if (line == null) break; 065 if (line.startsWith("!")) continue; 066 StringTokenizer strTok = new StringTokenizer(line); 067 String[] tokens = new String[strTok.countTokens()]; 068 int tokCnt = 0; 069 while (strTok.hasMoreElements()) { 070 tokens[tokCnt++] = strTok.nextToken(); 071 } 072 altitude[line_cnt] = (Float.valueOf(tokens[0])) * 1000f; 073 line_cnt++; 074 } 075 ios.close(); 076 } 077 catch (Exception e) { 078 logger.error("fail on ancillary file read: " + propertyFileName); 079 } 080 return altitude; 081 } 082 083 public float[] getTrackTimes() throws Exception { 084 return null; 085 } 086 087 public RealType makeVertLocType() throws Exception { 088 return RealType.Altitude; 089 } 090 091 public RealType makeTrackTimeType() throws Exception { 092 return null; 093 } 094 095 public float[] getTrackLongitude() throws Exception { 096 int[] start = new int[] {0}; 097 int[] count = new int[] {TrackLen}; 098 int[] stride = new int[] {1}; 099 float[] vals = reader.getFloatArray((String)metadata.get(longitude_name), start, count, stride); 100 return vals; 101 } 102 103 public float[] getTrackLatitude() throws Exception { 104 int[] start = new int[] {0}; 105 int[] count = new int[] {TrackLen}; 106 int[] stride = new int[] {1}; 107 float[] vals = reader.getFloatArray((String)metadata.get(latitude_name), start, count, stride); 108 return vals; 109 } 110 111 public Map<String, double[]> getDefaultSubset() { 112 Map<String, double[]> subset = ProfileAlongTrack.getEmptySubset(); 113 114 double[] coords = subset.get("TrackDim"); 115 coords[0] = 1000.0; 116 coords[1] = (TrackLen - 1000.0) - 1; 117 coords[2] = TrackSelection.DEFAULT_TRACK_STRIDE; 118 subset.put("TrackDim", coords); 119 120 coords = subset.get("VertDim"); 121 coords[0] = 10.0; 122 coords[1] = (VertLen) - 1; 123 coords[2] = TrackSelection.DEFAULT_VERTICAL_STRIDE; 124 subset.put("VertDim", coords); 125 return subset; 126 } 127 128}