/* * StarData.java * * Created on June 13, 2002, 11:00 PM */ //package readstardump; import java.io.*; import jas.hist.*; /** * * @author karlen * @version */ public class StarDumpData implements Rebinnable1DHistogramData { static final int nChan = 1152; int[][] data = new int[nChan][]; int nBin; boolean goodData = false; int channel = 0; /** Creates new StarData */ public StarDumpData(File readFile, int nBin) { this.nBin = nBin; for (int i=0; i= nChan) { iCh = 0; iBin++; } start += 5; if (start > 47) { line = in.readLine(); start = 11; } data[iCh][iBin] = Integer.parseInt(line.substring(start,start+4),16); } } catch (Exception e) { System.err.println("Exception " +e+ " while reading file."); return false; } return true; } boolean readIrqData(File readFile) { try { // Read STAR IRQ data BufferedReader in = new BufferedReader(new FileReader(readFile)); String line = in.readLine(); // skip header information: while (line.length() < 40 || !line.substring(0,10).equals("0xc0001000")) { if (line.length() > 40 && line.substring(0,10).equals("0xc0000030")) { //System.out.println(" Check for dead face in "+line); if (line.substring(17,19).equals("de") && line.substring(26,28).equals("ad") && line.substring(35,37).equals("fa") && line.substring(44,46).equals("ce")) { //System.out.println(" Found dead face"); } else { System.out.println(" Did NOT find dead face in "+line); return false; } } line = in.readLine(); } int iCh = -1; int iBin = 0; int nDat = nBin*nChan; int start = 2; for (int i=0; i= nChan) { iCh = 0; iBin++; } if (iCh%2 == 0) { start += 13; } else { start -= 4; } if (start > 62) { line = in.readLine(); start = 15; } data[iCh][iBin] = Integer.parseInt(line.substring(start,start+4),16); } } catch (Exception e) { System.err.println("Exception " +e+ " while reading file."); return false; } return true; } public boolean isGood() { return goodData; } public int getLoc(int iLoc, String half, int iPin, int iBin) { int iHalf = 0; if (half.equals("B")) iHalf = 1; return getLoc(iLoc,iHalf,iPin,iBin); } public int getLoc(int iLoc, int iHalf, int iPin, int iBin) { channel = mapSequence[iHalf][iLoc] + iPin*72; return data[channel][iBin]; } void setChannel(int channel) { this.channel = channel; } void setChannel(int iLoc, int iHalf, int iPin) { channel = mapSequence[iHalf][iLoc] + iPin*72; } public double[][] rebin(int rBins,double rMin,double rMax, boolean wantErrors,boolean hurry) { double[][] result = new double[3][nBin]; for (int i=0; i