/** * Read data with voltages line by line, for each line get R and * use this to integrate the filter data to get the bandpass * integral B. Output V^2/(4B) vs. R. * * Glen Cowan * RHUL Physics * August 2011 */ import java.io.*; import java.util.*; public class ProcessNoiseData { public static void main(String[] args) throws IOException { BufferedReader b = new BufferedReader(new InputStreamReader(System.in)); // Declared capicitance values are from simultaneous previous fit; // option to change below: double CL = 73e-12; // Farads double CS = 49e-12; // Farads System.out.print("Enter capacitance for long cables (pF): "); CL = Double.parseDouble ( b.readLine() ) * 1.e-12; // Farads System.out.print("Enter capacitance for short cables (pF): "); CS = Double.parseDouble ( b.readLine() ) * 1.e-12; // Farads IntegrateFilterData ifd = new IntegrateFilterData("FilterData.txt"); String VrmsDataFile = new String("VrmsData.txt"); BufferedReader br = null; try { br = new BufferedReader(new FileReader(VrmsDataFile)); } catch (FileNotFoundException e){ System.out.println ("File " + VrmsDataFile + " not found"); return; // --------------------------------> exit } System.out.println("# R (Ohms) Vrms^2/(4B), long cables (V^2 s) Vrms^2/(4B), short cables (V^2 s)"); System.out.println("#"); boolean readLines = true; int n = 0; // index of line while ( readLines ) { String s; try { s = br.readLine(); } catch (IOException ioe) { System.out.println("Cannot read line " + ioe); s = null; } readLines = s != null; boolean useLine = false; final int MAXCOL = 10; double[] buffer = new double[MAXCOL]; if ( readLines ) { useLine = getLineContents(s, buffer); } if ( useLine ) { double R = buffer[0]; // Ohms double VLC = buffer[1]*1.e-6; // Vrms (V) for long cables double VSC = buffer[2]*1.e-6; // Vrms (V) for short cables double BLongCables = ifd.bandpassIntegral(R, CL); double BShortCables = ifd.bandpassIntegral(R, CS); System.out.println(R + " " + VLC*VLC/(4.*BLongCables) + " " + VSC*VSC/(4.*BShortCables)); } } // readLines } // end of main //--------------------------------------------------------------------- public static boolean getLineContents(String s, double[] buffer){ boolean useLine = !( s.startsWith("!") || s.startsWith("#") ); if ( useLine ) { // parse line, put values into buffer StringTokenizer st = new StringTokenizer(s); int column = 0; while (st.hasMoreTokens()) { String token = st.nextToken(); buffer[column] = Double.parseDouble(token); column++; } } return useLine; } } // end of class ProcessNoiseData