/** * Read in filter data from file and store as * data members. * Method bandpassIntegral takes input R and C * and combines with filter data to compute B. * * Glen Cowan * RHUL Physics * August 2011 */ import java.io.*; import java.util.*; public class IntegrateFilterData { // data members int numPoints; final int MAXPOINTS = 1000; double[] x = new double[MAXPOINTS]; double[] y = new double[MAXPOINTS]; // constructors public IntegrateFilterData(String file){ this.readData(file); // sets x[], y[], numPoints } //----------------------------------------------------------------- public double bandpassIntegral (double R, double C) { final double pi = Math.PI; double bpi = 0.; for (int i=0; i exit } // Read in line from input file and assign values to array elements boolean readLines = true; int n = 0; // index of line while ( readLines ) { // try to read a line String s; try { s = br.readLine(); } catch (IOException ioe) { System.out.println("Cannot read line " + ioe); s = null; } readLines = (s != null); if ( readLines ) { boolean useLine = !( s.startsWith("!") || s.startsWith("#") ); if ( useLine ) { // parse line, put values into buffer StringTokenizer st = new StringTokenizer(s); double[] buffer = new double[MAXCOL]; int column = 0; while (st.hasMoreTokens()) { String token = st.nextToken(); buffer[column] = Double.parseDouble(token); column++; } // here use columns 0 and 3 x[n] = buffer[0]; y[n] = buffer[3]; n++; } } } // end of loop reading lines numPoints = n; // close up try { br.close(); } catch (IOException e){ System.out.println ("Cannot close buffered reader " + e); return; // ----------------------------------> exit } } // end of readData } // end of class IntegrateFilterData