001 /* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2013 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 029 package edu.wisc.ssec.mcidasv.data.hydra; 030 031 import visad.Data; 032 import visad.FlatField; 033 import visad.Set; 034 import visad.CoordinateSystem; 035 import visad.RealType; 036 import visad.RealTupleType; 037 import visad.SetType; 038 import visad.Linear2DSet; 039 import visad.Unit; 040 import visad.FunctionType; 041 import visad.VisADException; 042 import java.rmi.RemoteException; 043 044 import java.util.Hashtable; 045 import java.util.HashMap; 046 import java.util.StringTokenizer; 047 048 import java.io.BufferedReader; 049 import java.io.FileInputStream; 050 import java.io.IOException; 051 import java.io.InputStream; 052 import java.io.InputStreamReader; 053 054 055 public class CloudSat2D extends ProfileAlongTrack { 056 057 public CloudSat2D() { 058 } 059 060 public CloudSat2D(MultiDimensionReader reader, HashMap metadata) { 061 super(reader, metadata); 062 } 063 064 public float[] getVertBinAltitude() throws Exception { 065 String propertyFileName = null; 066 float[] altitude = new float[VertLen]; 067 try { 068 propertyFileName = (String) metadata.get(ancillary_file_name); 069 InputStream ios = getClass().getResourceAsStream(propertyFileName); 070 BufferedReader ancillaryReader = new BufferedReader(new InputStreamReader(ios)); 071 072 int line_cnt = 0; 073 while (true) { 074 String line = ancillaryReader.readLine(); 075 if (line == null) break; 076 if (line.startsWith("!")) continue; 077 StringTokenizer strTok = new StringTokenizer(line); 078 String[] tokens = new String[strTok.countTokens()]; 079 int tokCnt = 0; 080 while (strTok.hasMoreElements()) { 081 tokens[tokCnt++] = strTok.nextToken(); 082 } 083 altitude[line_cnt] = (Float.valueOf(tokens[0]))*1000f; 084 line_cnt++; 085 } 086 ios.close(); 087 } 088 catch (Exception e) { 089 System.out.println("fail on ancillary file read: "+propertyFileName); 090 } 091 return altitude; 092 } 093 094 public float[] getTrackTimes() throws Exception { 095 return null; 096 } 097 098 public RealType makeVertLocType() throws Exception { 099 return RealType.Altitude; 100 } 101 102 public RealType makeTrackTimeType() throws Exception { 103 return null; 104 } 105 106 public float[] getTrackLongitude() throws Exception { 107 int[] start = new int[] {0}; 108 int[] count = new int[] {TrackLen}; 109 int[] stride = new int[] {1}; 110 float[] vals = reader.getFloatArray((String)metadata.get(longitude_name), start, count, stride); 111 return vals; 112 } 113 114 public float[] getTrackLatitude() throws Exception { 115 int[] start = new int[] {0}; 116 int[] count = new int[] {TrackLen}; 117 int[] stride = new int[] {1}; 118 float[] vals = reader.getFloatArray((String)metadata.get(latitude_name), start, count, stride); 119 return vals; 120 } 121 122 public HashMap getDefaultSubset() { 123 HashMap subset = ProfileAlongTrack.getEmptySubset(); 124 125 double[] coords = (double[])subset.get("TrackDim"); 126 coords[0] = 1000.0; 127 coords[1] = (TrackLen - 1000.0) - 1; 128 coords[2] = 5.0; 129 subset.put("TrackDim", coords); 130 131 coords = (double[])subset.get("VertDim"); 132 coords[0] = 10.0; 133 coords[1] = (VertLen) - 1; 134 coords[2] = 2.0; 135 subset.put("VertDim", coords); 136 return subset; 137 } 138 139 }