Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final technique for rounding of NU-switch expressions and adds PrawnFile serialization. #65

Merged
merged 2 commits into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ subprojects {
apply plugin: "java"

group = "org.cirdles"
version = "1.4.2"
version = "1.4.3"

description = "Replacement for data reduction in Ludwig's Squid 2.50 for SHRIMP"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private void reportWithinSpotRatiosAtInterpolatedTimes(ShrimpFraction shrimpFrac
for (TaskExpressionEvaluatedPerSpotPerScanModelInterface taskExpressionEval : taskExpressionsEvaluated) {
if (nDodNum < taskExpressionEval.getRatEqTime().length) {
dataLine.append(", ").append(String.valueOf(taskExpressionEval.getRatEqTime()[nDodNum]));
dataLine.append(", ").append(Utilities.roundedToSize(taskExpressionEval.getRatEqVal()[nDodNum],12));
dataLine.append(", ").append(Utilities.roundedToSize(taskExpressionEval.getRatEqVal()[nDodNum],15));
dataLine.append(", ").append(Utilities.roundedToSize(taskExpressionEval.getRatEqErr()[nDodNum],15));
} else {
dataLine.append(", ").append("n/a");
Expand Down
27 changes: 18 additions & 9 deletions core/src/main/java/org/cirdles/calamari/core/PrawnFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
Expand All @@ -62,7 +64,7 @@
public class PrawnFileHandler {

private transient Unmarshaller jaxbUnmarshaller;
// private transient Marshaller jaxbMarshaller;
private transient Marshaller jaxbMarshaller;
private String currentPrawnFileLocation;
private transient Consumer<Integer> progressSubscriber;
private transient CalamariReportsEngine reportsEngine;
Expand Down Expand Up @@ -311,22 +313,29 @@ public PrawnFile unmarshallPrawnFileXML(String prawnFileLocation)
}

/**
* Deserializes xml file to a PrawnFile object.
* @param prawnDataFile the value of prawnDataFile
* @return the PrawnFile
* @throws javax.xml.bind.JAXBException
*/
private PrawnFile readRawDataFile(File prawnDataFile) throws JAXBException {

PrawnFile myPrawnFile = (PrawnFile) jaxbUnmarshaller.unmarshal(prawnDataFile);

// // test writing it back out WORKS!
// JAXBContext jaxbContext = JAXBContext.newInstance(PrawnFile.class);
// jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// jaxbMarshaller.marshal(myPrawnFile, new File("myPrawnFile.xml"));
// // jaxbMarshaller.marshal(myPrawnFile, System.out);
return myPrawnFile;
}

/**
* Serializes a PrawnFile object to xml and intended for saving edits to original data.
* @param prawnFile for serialization
* @throws PropertyException
* @throws JAXBException
*/
public void writeRawDataFileAsXML(PrawnFile prawnFile, String fileName)
throws PropertyException, JAXBException{
JAXBContext jaxbContext = JAXBContext.newInstance(PrawnFile.class);
jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(prawnFile, new File(fileName));
}

public boolean currentPrawnFileLocationIsFile() {
return new File(currentPrawnFileLocation).isFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ private void prepareRunFractionMetaData(PrawnFile.Run runFraction) {
String[] firstIntegrations = runFraction.getSet().getScan().get(0).getMeasurement().get(0).getData().get(0).getValue().split(",");
peakMeasurementsCount = firstIntegrations.length;

String dateTime = runFraction.getSet().getPar().get(0).getValue() + " " + runFraction.getSet().getPar().get(1).getValue();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String dateTime = runFraction.getSet().getPar().get(0).getValue()
+ " " + runFraction.getSet().getPar().get(1).getValue()
+ (Integer.parseInt(runFraction.getSet().getPar().get(1).getValue().substring(0, 2)) < 12 ? " AM" : " PM");

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss aa");
try {
dateTimeMilliseconds = dateFormat.parse(dateTime).getTime();
} catch (ParseException parseException) {
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/org/cirdles/calamari/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ public void evaluateTaskExpressions(List<ShrimpFractionExpressionInterface> shri
// documented separately, and approximate the uncertainties:
shrimpFraction.setPkInterpScanArray(pkInterp[scanNum]);

// April 2017 rounding per Bodorkos
double eqValTmp = Utilities.roundedToSize(expression.eval2Array(singleSpot)[0][0], 12);
double eqValTmp = expression.eval2Array(singleSpot)[0][0];

double eqFerr;

Expand All @@ -279,8 +278,7 @@ public void evaluateTaskExpressions(List<ShrimpFractionExpressionInterface> shri
perturbed[unDupPkOrd] *= 1.0001;
shrimpFraction.setPkInterpScanArray(perturbed);

// April 2017 rounding per Bodorkos
double pertVal = Utilities.roundedToSize(expression.eval2Array(singleSpot)[0][0], 12);
double pertVal = expression.eval2Array(singleSpot)[0][0];

double fDelt = (pertVal - eqValTmp) / eqValTmp; // improvement suggested by Bodorkos
double tA = pkInterpFerr[scanNum][unDupPkOrd];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public TaskExpressionEvaluatedPerSpotPerScanModel(
int sigDigs = 12;

this.expression = expression;
this.ratEqVal = Utilities.roundedToSize(ratEqVal.clone(), sigDigs);
// this.ratEqVal = Utilities.roundedToSize(ratEqVal.clone(), sigDigs);
this.ratEqVal = ratEqVal.clone();
this.ratEqTime = ratEqTime.clone();
this.ratEqErr = ratEqErr.clone();

Expand Down
Loading