private TreeMap<Double, Vector<Double>> readUntunable() { TreeMap<Double, Vector<Double>> rtn = null; // Get the file String cfgFilename = System.getProperty("ot.cfgdir"); if (!cfgFilename.endsWith("/")) cfgFilename += '/'; cfgFilename += "untunable.dat"; URL url = ObservingToolUtilities.resourceURL(cfgFilename); if (url == null) { System.out.println("Unable to find file " + cfgFilename); return rtn; } // If we get here, we have the file so create a new TreeMap and // start reading the file rtn = new TreeMap<Double, Vector<Double>>(); try { InputStream is = url.openStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); String inputLine; while ((inputLine = in.readLine()) != null) { if (inputLine.startsWith("#") || inputLine.equals("")) continue; StringTokenizer st = new StringTokenizer(inputLine); Vector<Double> values = new Vector<Double>(); if (st.countTokens() == 1) { values.add(Double.parseDouble(st.nextToken()) * 1.0e9); } else if (st.countTokens() == 2) { values.add(Double.parseDouble(st.nextToken()) * 1.0e9); values.add(Double.parseDouble(st.nextToken()) * 1.0e9); } else { continue; } rtn.put(values.firstElement(), values); } in.close(); is.close(); } catch (Exception e) { e.printStackTrace(); return null; } return rtn; }
/** * Read the receiver temperature file and get the data for the specified front end. The return is * a TreeMap with frequency as the key and TRx as the value. */ public TreeMap<Double, Double> getTRx(String feName) { TreeMap<Double, Double> tRx = null; // Get the receiver temperature and open it String cfgFilename = System.getProperty("ot.cfgdir"); if (!cfgFilename.endsWith("/")) cfgFilename += '/'; cfgFilename += "receiver.info"; URL url = ObservingToolUtilities.resourceURL(cfgFilename); // Read in the data for the current front-end if (url != null) { try { String inputLine; InputStream is = url.openStream(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); // Skip over the header while (true) { while ((inputLine = in.readLine()) != null) { if (inputLine.equals("")) break; } if (inputLine == null) break; // Now keep reading the file until we find the feName lowF = Double.valueOf(new String(in.readLine())); // Low // frequency // limit lowF = lowF * 1.0e9; highF = Double.valueOf(new String(in.readLine())); // High // frequency // limit highF = highF * 1.0e9; in.readLine(); // Number of sidebands if (in.readLine().equalsIgnoreCase(feName)) { // We can start reading in the data int nLines = Integer.valueOf(in.readLine()); tRx = new TreeMap<Double, Double>(); for (int i = 0; i < nLines; i++) { String values = in.readLine(); StringTokenizer st = new StringTokenizer(values); Double frequency = Double.parseDouble(st.nextToken()) * 1.0e9; Double trx = Double.parseDouble(st.nextToken()); tRx.put(frequency, trx); } break; } else { // Read up to the next blank line continue; } } in.close(); is.close(); } catch (IOException ex) { System.out.println( "Error reading receiver file: " + System.getProperty("ot.cfgdir") + "receiver.info"); } } else { System.out.println( "Receiver info file does not exist: " + System.getProperty("ot.cfgdir") + "receiver.info"); } return tRx; }