Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Readded XDS_Integrate.HKL, but probably it will not be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gábor Náray committed Nov 28, 2014
1 parent 9786db7 commit e970ed9
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.embl.cca.utils.datahandling.file;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.Assert;

public class XDSIntegrateHKLReader extends BufferedReader {

public XDSIntegrateHKLReader(final InputStream in) {
super(new InputStreamReader(in));
}

/**
* Reads a HKL record. If there is not HKL record at the current position,
* then it tries to get to the next HKL record, and then reads the
* HKL record.
* @return HKL record, or null if the end of the stream has been reached
* @throws IOException If an I/O error occurs
*/
public XDSIntegrateHKLRecord readNextHKLRecord() throws IOException {
// double d = in.read();
// new HKL(Amount.valueOf(d, NonSI.ANGSTROM));
final XDSIntegrateHKLRecord result;
do {
final String line = readLine();
if( line == null )
return null;
if( line.startsWith("!"))
continue;
final String[] values = line.split(" ");
Assert.isTrue(values.length == 21);
//Normally a line starts with ' ', thus values[0] is empty
result = new XDSIntegrateHKLRecord(
Integer.parseInt(values[1]), Integer.parseInt(values[2]), //H, K
Integer.parseInt(values[3]), //L
Double.parseDouble(values[4]), Double.parseDouble(values[5]), //IOBS, SIGMA
Double.parseDouble(values[6]), Double.parseDouble(values[7]), //XCAL, YCAL
Double.parseDouble(values[8]), Double.parseDouble(values[9]), //ZCAL, RLP
Integer.parseInt(values[10]), Integer.parseInt(values[11]), //PEAK, CORR
Integer.parseInt(values[12]), //MAXC
Double.parseDouble(values[13]), Double.parseDouble(values[14]), //XOBS, YOBS
Double.parseDouble(values[15]), Double.parseDouble(values[16]), //ZOBS, ALF0
Double.parseDouble(values[17]), Double.parseDouble(values[18]), //BET0, ALF1
Double.parseDouble(values[19]), Double.parseDouble(values[20]) //BET1, PSI
);
break;
} while( true );
return result;
}

public List<XDSIntegrateHKLRecord> readAllHKLRecords() throws IOException {
ArrayList<XDSIntegrateHKLRecord> result = new ArrayList<XDSIntegrateHKLRecord>();
do {
final XDSIntegrateHKLRecord record = readNextHKLRecord();
if( record == null )
break;
result.add(record);
} while( true );
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.embl.cca.utils.datahandling.file;

public class XDSIntegrateHKLRecord {
protected final int h;
protected final int k;
protected final int l;
protected final double iobs;
protected final double sigma;
protected final double xcal;
protected final double ycal;
protected final double zcal;
protected final double rlp;
protected final int peak;
protected final int corr;
protected final int maxc;
protected final double xobs;
protected final double yobs;
protected final double zobs;
protected final double alf0;
protected final double bet0;
protected final double alf1;
protected final double bet1;
protected final double psi;

public XDSIntegrateHKLRecord(final int h, final int k, final int l,
final double iobs, final double sigma,
final double xcal, final double ycal, final double zcal,
final double rlp, final int peak, final int corr,
final int maxc, final double xobs, final double yobs,
final double zobs, final double alf0, final double bet0,
final double alf1, final double bet1, final double psi) {
this.h = h;
this.k = k;
this.l = l;
this.iobs = iobs;
this.sigma = sigma;
this.xcal = xcal;
this.ycal = ycal;
this.zcal = zcal;
this.rlp = rlp;
this.peak = peak;
this.corr = corr;
this.maxc = maxc;
this.xobs = xobs;
this.yobs = yobs;
this.zobs = zobs;
this.alf0 = alf0;
this.bet0 = bet0;
this.alf1 = alf1;
this.bet1 = bet1;
this.psi = psi;
}

/**
* Returns a string representation of this record and its values.
* The returned string may be empty but may not be <code>null</code>.
*
* @return a string representation of this point
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(getClass().getName()).append('[');
sb.append("h=").append(h);
sb.append(", k=").append(k);
sb.append(", l=").append(l);
sb.append(", iobs=").append(iobs);
sb.append(", sigma=").append(sigma);
sb.append(", xcal=").append(xcal);
sb.append(", ycal=").append(ycal);
sb.append(", zcal=").append(zcal);
sb.append(", rlp=").append(rlp);
sb.append(", peak=").append(peak);
sb.append(", corr=").append(corr);
sb.append(", maxc=").append(maxc);
sb.append(", xobs=").append(xobs);
sb.append(", yobs=").append(yobs);
sb.append(", zobs=").append(zobs);
sb.append(", alf0=").append(alf0);
sb.append(", bet0=").append(bet0);
sb.append(", alf1=").append(alf1);
sb.append(", bet1=").append(bet1);
sb.append(", psi=").append(psi);
sb.append(']');
return sb.toString();
}

public int getH() { return h; }
public int getK() { return k; }
public int getL() { return l; }
public double getX() { return xobs; }
public double getY() { return yobs; }
public double getZ() { return zobs; }
}

0 comments on commit e970ed9

Please sign in to comment.