Commit 072ceda2 authored by pfreon's avatar pfreon
Browse files

Major change in Data.java

Rajout d'un message d'erreur si toutes les valeurs de CPUE sont <1. Plus modif cosmétiques de sauts de lignes avant { et }.
parent a10bee02
......@@ -6,7 +6,6 @@ package fr.ird.climprod;
import java.util.StringTokenizer;
import java.text.*;//DecimalFormat;
public class Data {
private static String fileName = null;
......@@ -27,7 +26,8 @@ public class Data {
private static Object[][] dataTable;
private static Object[][] dataCorrelation;
public static void readFile(String file) {
public static void readFile(String file)
{
dataTable = null;
dataCorrelation = null;
fileName = file;
......@@ -43,17 +43,17 @@ public class Data {
{
StringTokenizer t = new StringTokenizer(dataLine[0], ";");
if (t.countTokens() != 4) {
throw new OnError("Invalid data file");
throw new OnError("Invalid data file.");
}
for (int i = 0; i < 4; i++) {
if ((t.nextToken().trim()).equals(fieldNames[i]) == false) {
throw new OnError("Invalid data file.");
}
}
}
for (int i = 1; i < dataLine.length; i++) {
StringTokenizer d = new StringTokenizer(dataLine[i], ";");
if (d.countTokens() != 4) {
throw new OnError("Invalid data file");
throw new OnError("Invalid data file.");
}
int k = 0;
while (d.hasMoreTokens()) {
......@@ -63,7 +63,6 @@ public class Data {
}
// System.out.println();
}
}
existFile = true;
init_val();
......@@ -460,14 +459,15 @@ public class Data {
*Calcule les principales statistiques sur les donn�es.
*Utilis� � la lecture du fichier (� ce stade la variable stat ne tient past cpte du d�calage)
*/
private static void statistiques() {
private static void statistiques()
{
double[][] trans = new double[4][];
trans[0] = yexp;
trans[2] = f;
trans[3] = v;
trans[1] = pue;
for (int j = 0; j < 4; j++) {
for (int j = 0; j < 4; j++)
{
stat[0][j] = nbData;
stat[1][j] = Stat1.moy(trans[j]);
stat[2][j] = Math.sqrt(Stat1.var(trans[j], true));
......@@ -475,15 +475,21 @@ public class Data {
stat[4][j] = Stat1.Kurtosis(trans[j]);
stat[5][j] = Stat1.Skewness(trans[j]);
double[] ext = Stat1.Extremas(trans[j]);
stat[6][j] = ext[0];
stat[7][j] = ext[1];
stat[8][j] = ext[1] - ext[0];
stat[6][j] = ext[0]; // Min.
stat[7][j] = ext[1]; // Max.
stat[8][j] = ext[1] - ext[0]; // Range.
ext = Stat1.quant(trans[j], 3);
stat[9][j] = ext[1];
}
try {
if (stat[7][1]<1) {throw new OnError("All of your CPUE data is < 1. \nPlease change you unit(s) for production \n(catches) and/or fishing effort.");}
}
catch (Exception e) {
nbData = 0;
MsgDialogBox msg = new MsgDialogBox(0, e.getMessage(), 0, Global.CadreMain);
}
}
/*
Donne les principaux r�sultats
@return Object[][] ou null si fichier invalide
......@@ -613,7 +619,5 @@ public class Data {
dataCorrelation[4][1] = nf.format(Stat1.rho(v, yexp));
dataCorrelation[4][2] = nf.format(Stat1.rho(v, pue));
dataCorrelation[4][3] = nf.format(Stat1.rho(v, f));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment