Commit 4138f15e authored by pfreon's avatar pfreon
Browse files

Medium changes related to new messages & warning, and extremas of axes on graphs

Improvement of the management of messages (in the code, no changes for the user). and addition of new output messages related to the results of the model fitting (MSY & MSE values and their confidene limits, visibility of the lines corresponding to fitted values for noteworthy values of V in the 3D graphs).
Management of the access to the MSY-MSY graphs in the "Plots" menu when they are not available (CPUE=f(V) and abnormal results on MSY & MSE values or width of the confidence intervals).
Improvement of the management of extremas of axes in the different plots.
parent 8f80daad
Years;Production;Effort;Environment;;
1.00;55.28034816;5.14834649;-1;
2.00;84.66992398;3.00680635;-2;
3.00;11.89964635;0.35853304;-3;
4.00;36.32895858;1.19780445;-4;
5.00;90.16381982;2.71468457;-5;
6.00;55.60481641;1.09155193;-6;
7.00;52.48768878;1.08372534;-7;
8.00;49.75958709;1.1309877;-8;
9.00;68.05856244;1.22488726;-9;
10.00;24.65675785;0.49309695;-10;
11.00;79.2071965;1.33795696;-11;
12.00;12.55295715;0.26169531;-12;
13.00;19.61945368;0.40394008;-13;
14.00;55.77918908;1.13299769;-14;
15.00;96.73988912;2.64686452;-15;
16.00;89.68769425;3.32027634;-16;
17.00;28.25080188;0.91207568;-17;
18.00;61.13059116;2.03921983;-18;
......@@ -142,7 +142,7 @@ public class CadreMain extends JFrame {
this.setIconImage(Toolkit.getDefaultToolkit().createImage(CadreMain.class.getResource("resources/images/Climprod.jpg")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new GridLayout(1, 2));
this.setTitle("Climprod 6");
this.setTitle("Climprod 2.0");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(WindowEvent e) {
......@@ -294,7 +294,7 @@ public class CadreMain extends JFrame {
});
menuPlotThreeVariate.setEnabled(false);
menuPlotThreeVariate.setMnemonic(KeyEvent.VK_T);
menuPlotThreeVariate.setText("CPUE=f() & Y=() plots");
menuPlotThreeVariate.setText("CPUE=f() & Y=f() plots");
menuPlotThreeVariate.addActionListener(new java.awt.event.ActionListener() {
@Override
......@@ -311,7 +311,7 @@ public class CadreMain extends JFrame {
menuPlotMsy_actionPerformed(e);
}
});
menuPlotMsy.setText("MSY and MS_E graphs");
menuPlotMsy.setText("MSY and MSE graphs");
menuModels.setEnabled(false);
menuModels.setText("Modelization");
menuModels.setMnemonic(KeyEvent.VK_M);
......@@ -617,27 +617,31 @@ public class CadreMain extends JFrame {
}
void this_windowActivated(WindowEvent e) {
void this_windowActivated(WindowEvent e) { // Gestion de l'acces (pas grisé) aux sous-menus de "Plots" du menu principal.
/* Frame[] liste=this.getFrames();
for (int i=0;i<liste.length;i++)
System.out.println(liste[i].getName());*/
boolean b1 = false;
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;
boolean b4 = false;
boolean b5 = false;
boolean b6 = false;
if (Global.nom_fichier != null) {
b1 = true;
b3 = Global.validationOk;
b2 = Global.modelisationOk;
b4 = b3 && (((Global.numero_modele > 5) || (Global.numero_modele < 2)) && (Global.numero_modele != 20) && (Global.numero_modele != 33));
b5 = Global.test_jackknife;
b1 = true; // Autorise Menus Files et Modelization + Time plots + Bivariate plots
b3 = Global.validationOk; // Autorise Jackknife plots
b2 = Global.modelisationOk; // Autorise Observed-fitted & residual CPUE + Resid f(E) vs V et f(V) vs E + CPUE = f() & Y = f()
b6 = Global.MSY_MSE_OK; // Co-autorise graphiques MSY et MSE //
// b4 autorise graphiques MSY et MSE (Global.MSY_MSE_OK ne marche pas si boolean)
b4 = b3 && b6 && (((Global.numero_modele > 5) || (Global.numero_modele < 2)) && (Global.numero_modele != 20) && (Global.numero_modele != 33));
b5 = Global.test_jackknife; // Autorise sous-menu Use the model for prediction
}
this.jPanData.setVisible(b1);
this.menuFileFolder.setEnabled(b1);
this.menuModels.setEnabled(b1);
this.menuModelsResults.setEnabled(b2);
// this.menuEdition.setEnabled(b1);
// this.menuEdition.setEnabled(b1);
// this.menuEditionResults.setEnabled(b2);
this.menuPlots.setEnabled(b1);
this.menuPlotTime.setEnabled(b1);
......@@ -656,7 +660,7 @@ public class CadreMain extends JFrame {
if (Global.CadreFittedPlots == null) {
Cadre_Plot dlg;
dlg = new Cadre_Plot(Global.fittedCpuePlot);
dlg.setTitle("Climprod : Fitted plots");
dlg.setTitle("Climprod: Fitted plots");
dlg.setVisible(true);
Global.CadreFittedPlots = dlg;
} else {
......@@ -830,7 +834,7 @@ public class CadreMain extends JFrame {
faits = faits + "Age at the end of environmental influence: " + Global.end_influence_period + s + s;
}
String[] cpu_relation = {"", "Linear", "Exponential", "General ", "Power", "Quadratic", "Exponential_additive", "Exponential_multiplicative"};
String[] cpu_relation = {"", "Linear", "Exponential", "General", "Power", "Quadratic", "Exponential_additive", "Exponential_multiplicative"};
//String[] cpu_e={"Linear [CPUE=a+b.E]", "General [CPUE=(a+b.E)^(1/(c-1))]","Exponential [CPUE=a.exp(b.E)]"};
if (Global.relationCPU_E != 0) {
faits = faits + "Relation between CPUE and E: " + cpu_relation[Global.relationCPU_E] + s;
......@@ -866,44 +870,59 @@ public class CadreMain extends JFrame {
}
if (Global.validationOk)
{
Validation.valide_modele();
Validation.getParamResult();
if (Global.coeff_determination == 0.0)
faits=faits + s + "*R² estimate was negative and consequently set to zero.\nThis result is due to a poor fitting by the Marquart algorithm\nand it is commonly observed when the model does not include\nan intercept parameter or when the model includes a non-linear function.\nConsequently the display of the jackknife R² graph is not available." + s;
faits=faits + s + "Parameters Jackknife t-ratio test result";
for(int i=0;i<Validation.nbre_par;i++) {
if (Global.Flag_pb_jackknife[i] != 1)
faits=faits + s + " " + Global.param$[i]+ " " + Global.Test_Jackknife_Param$[Global.Res_Test_Jackknife_Par[i]];
else
faits=faits + s + " " + Global.param$[i]+ "** " + Global.Test_Jackknife_Param$[Global.Res_Test_Jackknife_Par[i]];
//Validation.valide_modele(); Rajout du 05 08 2020 mais perturbe mise à jour des graphiques jackknife dans fit a model directly si deux ajustements consécutifs avec entre les 2 on repasse par menu principal
Validation.getParamResult();
if (Global.coeff_determination == 0.0)
faits=faits + s + "*R² estimate was negative and consequently set to zero.\nThis result is due to a poor fitting by the Marquart algorithm\nand it is commonly observed when the model does not include\nan intercept parameter or when the model includes a non-linear function.\nConsequently the display of the jackknife R² graph is not available." + s;
faits=faits + s + "Parameters Jackknife t-ratio test result";
for(int i=0;i<Validation.nbre_par;i++) {
if (Global.Flag_pb_jackknife[i] != 1)
faits=faits + s + " " + Global.param$[i]+ " " + Global.Test_Jackknife_Param$[Global.Res_Test_Jackknife_Par[i]];
else
faits=faits + s + " " + Global.param$[i]+ "** " + Global.Test_Jackknife_Param$[Global.Res_Test_Jackknife_Par[i]];
}
if (Global.Flag_pb_jackknife_Tot != 0) faits=faits + s + Global.message$[0];
if (Global.test_jackknife)
{faits = faits + s + "Overall T_Jackknife on parameters: good" + s;}
else {faits = faits + s + "Overall T_Jackknife on parameters: bad" + s;}
if(Global.r_jk != 0.00)
faits = faits + s + "Jackknife coefficient of determination R²: " + nf.format(Global.r_jk) + s;
else {
faits = faits + s + "Jackknife coefficient of determination R²***: " + nf.format(Global.r_jk) + s;
faits=faits+s+"***Jackknife R² estimate was negative and consequently set to zero.\nThis result is due to a poor fitting by the Marquart algorithm\nand it is commonly observed when the model does not include\nan intercept parameter or when the model includes a non-linear function.\nConsequently the display of the jackknife R² graph is not available.";
}
}
if (Global.AllPredictedNegativeTot >0) faits=faits + s + Global.message$[3];
if ((Global.Max_95_Noteworthy_MSE == 4 || Global.Max_95_Noteworthy_MSY == 4) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33) {
faits=faits + s + Global.message$[4];}
else {
if ((Global.Min_95_Noteworthy_MSE>=4 && Global.Min_95_Noteworthy_MSY>=4) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33) {
faits=faits + s + Global.message$[5]; }
else {
if (Global.Min_95_Noteworthy_MSE>=4 && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33) {
faits=faits + s + Global.message$[1]; }
if (Global.Min_95_Noteworthy_MSY>=4 && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33) {
faits=faits + s + Global.message$[2]; }
}
}
}
}
if (Global.Flag_pb_jackknife_Tot != 0) faits=faits + s + "**" + Global.message$[0];
if (Global.test_jackknife) {
faits = faits + s + "Overall T_Jackknife on parameters: good" + s;}
else {faits = faits + s + "Overall T_Jackknife on parameters: bad" + s;}
if(Global.r_jk != 0.00)
faits = faits + s + "Jackknife coefficient of determination R²: " + nf.format(Global.r_jk) + s;
else {
faits = faits + s + "Jackknife coefficient of determination R²***: " + nf.format(Global.r_jk) + s;
faits=faits+s+"***Jackknife R² estimate was negative and consequently set to zero.\nThis result is due to a poor fitting by the Marquart algorithm\nand it is commonly observed when the model does not include\nan intercept parameter or when the model includes a non-linear function.\nConsequently the display of the jackknife R² graph is not available." + s;
}
}
if (Global.message$[12] != "") faits=faits + s + Global.message$[12]; // The estimate of the initial value of at least one of the parameter is equal to infinity. faits=faits + s + Global.message$[6];
if (Global.message$[6] != "") // At least one of the noteworthy values of MSE is negative or \nlarger than 1.0E10
faits=faits + s + Global.message$[6];
else if (Global.message$[10] != "") // At least one of the central values of MSE is negative for noteworthy V values
faits=faits + s + Global.message$[10];
else if (Global.message$[3] != "") // All noteworthy values of MSY and/or MSE upper limits at 95% \nare null or negative
faits=faits + s + Global.message$[3];
else {
if (Global.message$[5] != "") // At least one set of predicted values of CPUE=f(E,V) and Y=f(E,V) corresponding to Vmin or Vmax presents only negative values.
faits=faits + s + Global.message$[5];
else {
if (Global.message$[4] != "") // All noteworthy values of MSY and MSE lower limits at 95% are null or negative.
faits=faits + s + Global.message$[4];
else {
if (Global.message$[1] != "") // All noteworthy values of MSE lower limit at 95% are null or negative.
faits=faits + s + Global.message$[1];
if (Global.message$[7] != "") // Please note that some MSY central values for at least one of the noteworthy V values are unexpectidly negative.
faits=faits + s + Global.message$[7];
if (Global.message$[2] != "") // All noteworthy values of MSY lower limit at 95% are null or negative.
faits=faits + s + Global.message$[2];
if (Global.message$[8] != "") // Please note that the width of the 95% confidence interval of MSY central values for at least one of the noteworthy V values is larger than the corresponding MSY value.
faits=faits + s + Global.message$[8];
if (Global.message$[9] != "") // Please note that the width of the 95% confidence interval of MSE central values for at least one of the noteworthy V values is larger than the corresponding MSE value.;
faits=faits + s + Global.message$[9];
if (Global.message$[11] != "") // Please note that the MSY central value for the mean V value is 10 times larger than the maximum observed catch value.
faits=faits + s + Global.message$[11];
}
}
}
}
}
} else {
faits = "Data file: No selected file.";
}
......
......@@ -113,7 +113,7 @@ public class Cadre_ModeleDirect extends JFrame {
chkV_actionPerformed(e);
}
});
chkEVCatchability.setText("Mixed models CPUE=f(E,V), where V influence Catchability");
chkEVCatchability.setText("Mixed models CPUE=f(E,V), where V influence catchability");
chkEVCatchability.addActionListener(new java.awt.event.ActionListener() {
@Override
......@@ -121,7 +121,7 @@ public class Cadre_ModeleDirect extends JFrame {
chkEVCatchability_actionPerformed(e);
}
});
chkEVAbundance.setText("Mixed models CPUE=f(E,V), where V influence Abundance");
chkEVAbundance.setText("Mixed models CPUE=f(E,V), where V influence abundance");
chkEVAbundance.addActionListener(new java.awt.event.ActionListener() {
@Override
......@@ -129,7 +129,7 @@ public class Cadre_ModeleDirect extends JFrame {
chkEVAbundance_actionPerformed(e);
}
});
chkEVBoth.setText("Mixed models CPUE=f(E,V), where V influence Abundance & Catchability");
chkEVBoth.setText("Mixed models CPUE=f(E,V), where V influence abundance & catchability");
chkEVBoth.addActionListener(new java.awt.event.ActionListener() {
@Override
......@@ -181,13 +181,13 @@ public class Cadre_ModeleDirect extends JFrame {
jPanChoix.add(jPanCmdChoix, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
group.add(chkE);
group.add(chkV);
group.add(chkEVCatchability);
group.add(chkEVAbundance);
group.add(chkEVCatchability);
group.add(chkEVBoth);
jPanCmdChoix.add(chkE, null);
jPanCmdChoix.add(chkV, null);
jPanCmdChoix.add(chkEVCatchability, null);
jPanCmdChoix.add(chkEVAbundance, null);
jPanCmdChoix.add(chkEVCatchability, null);
jPanCmdChoix.add(chkEVBoth, null);
jPanChoix.add(jScrollPane1, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 100, 0));
jScrollPane1.getViewport().add(jlstChoix, null);
......@@ -410,13 +410,14 @@ public class Cadre_ModeleDirect extends JFrame {
;
void cmdJackniffe_actionPerformed(ActionEvent e) {
//System.out.println("Flag cmdJackniffe_actionPerformed(ActionEvent e) dans ModeleDirect.java");
String windowTitre = "Model fitting: " + RechercheModele.getEquation() + "(fitting nb " + nbFit + ") ";
if (openWindow(windowTitre)) {
return;
}
MsgDialogBox msg;
Cadre_SplitPlot dlgSp;
if (Global.validationOk) {
if (Global.validationOk) {
dlgSp = new Cadre_SplitPlot(Global.jackknifePlot);
dlgSp.setTitle(windowTitre);
if (Global.nbre_param > 3) {
......@@ -442,7 +443,7 @@ public class Cadre_ModeleDirect extends JFrame {
dlg.setModal(true);
dlg.setVisible(true);
} else {
msg = new MsgDialogBox(0, "The model is not validated(bad jackknife test)\n You can't use it for prediction. ", 0, Global.CadreMain);
msg = new MsgDialogBox(0, "The model is not validated (bad jackknife test)\n You can't use it for prediction. ", 0, Global.CadreMain);
}
} else {
msg = new MsgDialogBox(0, "In order to do prediction\n you have to fit a model.", 0, Global.CadreMain);
......@@ -474,7 +475,7 @@ private void displayList(String[] liste) {
}
/*
Slectionne un modle
Sélectionne un modèle
*/
void jlstChoix_valueChanged(ListSelectionEvent e) {
String equation = (String) jlstChoix.getSelectedValue();
......@@ -543,6 +544,7 @@ private void displayList(String[] liste) {
if (Global.CadreResidualPlots != null) {
Global.CadreResidualPlots.dispose();
}
//System.out.println("Dans void cmdFit_actionPerformed Global.CadreJackniffePlots = " + Global.CadreJackniffePlots);
if (Global.CadreJackniffePlots != null) {
Global.CadreJackniffePlots.dispose();
}
......@@ -569,13 +571,13 @@ private void displayList(String[] liste) {
/***********************************************************
Any change in age warnings related to ages here must be
repeated in the QuestionReponse.java file, cases 17, 52 & 58.
repeated in the QuestionReponse.java file, cases 17, 52, 57 & 58.
************************************************************
*/
//System.out.println("Global.recruitment_age: " + Global.recruitment_age + "Global.nb_classes_exploitees: " + Global.nb_classes_exploitees + " Global.begin_influence_period: " + Global.begin_influence_period + "Global.end_influence_period: " + Global.end_influence_period);
if (Global.nb_classes_exploitees > 5 && Global.nb_classes_exploitees < 9) {
msg = new MsgDialogBox(0, "WARNING! \nA stock with more than 5 significantly exploited year-classes is not ideal for applying \nsurplus production models that make use of the transition prediction approach (past-effort-averaging) of \nFox (1975). This method is used in CLIMPROD to fit data on non-equilibrium conditions. It simulates the \nequilibrium by using a weighted average of fishing effort (E). \nIf interanual variability of E is too large, the results are likely to be uncertain.", 0, Global.CadreMain);
// throw new OnError("WARNING! \nA stock with more than 5 significantly exploited year-classes is not ideal for applying \nsurplus production models that make use of the transition prediction approach (past-effort-averaging) of \nFox (1975). This method is used in CLIMPROD to fit data on non-equilibrium conditions. It simulates the \nequilibrium by using a weighted average of fishing effort (E). \nIf interanual variability of E is too large, the results are likely to be uncertain.");
//msg = new MsgDialogBox(0, "WARNING! \nA stock with more than 5 significantly exploited year-classes is not ideal for applying \nsurplus production models that make use of the transition prediction approach (past-effort-averaging) of \nFox (1975). This method is used in CLIMPROD to fit data on non-equilibrium conditions. It simulates the \nequilibrium by using a weighted average of fishing effort (E). \nIf interanual variability of E is too large, the results are likely to be uncertain.", 0, Global.CadreMain);
throw new OnError("WARNING! \nA stock with more than 5 significantly exploited year-classes is not ideal for applying \nsurplus production models that make use of the transition prediction approach (past-effort-averaging) of \nFox (1975). This method is used in CLIMPROD to fit data on non-equilibrium conditions. It simulates the \nequilibrium by using a weighted average of fishing effort (E). \nIf interanual variability of E is too large, the results are likely to be uncertain.");
}
if (Global.nb_classes_exploitees > 8) {
throw new OnError("A stock with too many significantly exploited year-classes is not a situation compatible with the use of \nsurplus production models that make use of the transition prediction approach (past-effort-averaging) \nofFox (1975). This method is used in CLIMPROD to fit data on non-equilibrium conditions. It simulate the \nequilibrium by using a weighted average of fishing effort (E). \nIt is recommanded to stop here your research or revise your selection of number(s) if necessary.");
......@@ -610,24 +612,45 @@ repeated in the QuestionReponse.java file, cases 17, 52 & 58.
lblModele.setText("Model fitting: " + RechercheModele.getEquation() + " (Marquardt algorithm)");
renseignerTable(jTableModelisation, Modele.getResult());
Validation.valide_modele();
//System.out.println("Flag valide_modele() dans Cadre_ModeleDirect.java ligne 615");
renseignerTable(jTableValidation, Validation.getParamResult());
nbFit++;
MsgDialogBox msg;
if (Global.AllPredictedNegativeTot >0)
msg = new MsgDialogBox(0, Global.message$[3], 0, Global.CadreMain);
if ((Global.Max_95_Noteworthy_MSE == 4 || Global.Max_95_Noteworthy_MSY == 4) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33)
msg = new MsgDialogBox(0, Global.message$[4], 0, Global.CadreMain);
else {
if ((Global.Min_95_Noteworthy_MSE>=4 && Global.Min_95_Noteworthy_MSY>=4) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33)
msg = new MsgDialogBox(0, Global.message$[5], 0, Global.CadreMain);
else {
if ((Global.Min_95_Noteworthy_MSE>=4 && Global.numero_modele != 20) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33)
msg = new MsgDialogBox(0, Global.message$[1], 0, Global.CadreMain);
if ((Global.Min_95_Noteworthy_MSY>=4 && Global.numero_modele != 20) && Global.numero_modele != 20 && Global.numero_modele > 5 && Global.numero_modele < 2 && Global.numero_modele != 33)
msg = new MsgDialogBox(0, Global.message$[2], 0, Global.CadreMain);
}
}
if (Global.message$[12] != "") // The estimate of the initial value of at least one of the parameter is equal to infinity.
msg = new MsgDialogBox(0, Global.message$[12], 0, Global.CadreMain);
if (Global.message$[0] != "") // Likely problem in Jackknife computation.
msg = new MsgDialogBox(0, Global.message$[0], 0, Global.CadreMain);
if (Global.message$[6] != "") // At least one of the central values of MSE is larger than 1.0E10 for noteworthy V values
msg = new MsgDialogBox(0, Global.message$[6], 0, Global.CadreMain);
else if (Global.message$[10] != "") // At least one of the central values of MSE is negative for noteworthy V values
msg = new MsgDialogBox(0, Global.message$[10], 0, Global.CadreMain);
else if (Global.message$[3] != "") // All noteworthy values of MSY and/or MSE upper limits at 95% \nare null or negative
msg = new MsgDialogBox(0, Global.message$[3], 0, Global.CadreMain);
else
{
if (Global.message$[5] != "") // At least one set of predicted values of CPUE=f(E,V) and Y=f(E,V) corresponding to Vmin or Vmax presents only negative values.
msg = new MsgDialogBox(0, Global.message$[5], 0, Global.CadreMain);
else {
if (Global.message$[4] != "") // All noteworthy values of MSY and MSE lower limits at 95% are null or negative.
msg = new MsgDialogBox(0, Global.message$[4], 0, Global.CadreMain);
else {
if (Global.message$[1] != "") // All noteworthy values of MSE lower limit at 95% are null or negative.
msg = new MsgDialogBox(0, Global.message$[1], 0, Global.CadreMain);
if (Global.message$[7] != "") // Please note that some MSY central values for at least one of the noteworthy V values are unexpectidly negative.
msg = new MsgDialogBox(0, Global.message$[7], 0, Global.CadreMain);
if (Global.message$[2] != "") // All noteworthy values of MSY lower limit at 95% are null or negative.
msg = new MsgDialogBox(0, Global.message$[2], 0, Global.CadreMain);
if (Global.message$[8] != "") // Please note that the width of the 95% confidence interval of MSY central values for at least one of the noteworthy V values is larger than the corresponding MSY value.
msg = new MsgDialogBox(0, Global.message$[8], 0, Global.CadreMain);
if (Global.message$[9] != "") // Please note that the width of the 95% confidence interval of MSE central values for at least one of the noteworthy V values is larger than the corresponding MSE value.;
msg = new MsgDialogBox(0, Global.message$[9], 0, Global.CadreMain);
if (Global.message$[11] != "")// Please note that the MSY central value for the mean V value is 10 times larger than the maximum observed catch value.
msg = new MsgDialogBox(0, Global.message$[11], 0, Global.CadreMain);
}
}
}
/* if(Global.nb_classes_exploitees==0)
{
msg=new MsgDialogBox(0,"Please provide the number of significantly/n exploited year classes",0);
......
......@@ -19,7 +19,7 @@ public class Data {
private static double[] fcoeff = new double[13];
private static double[] vcoeff = new double[13];
private static double[] year;
public static double[] year;
private static double[] yexp;
private static double[] pue;
private static double[] f;
......
......@@ -977,7 +977,7 @@ public class Modele {
private static void makePlot() {
/**
* ***************** cpue plot *****************************
* ********** observed and fitted time series ***************
* ********** observed, fitted & residual time series ***************
*/
double minx = Stat1.min(Data.getYears());
PlotSerie[] ps = new PlotSerie[5];
......@@ -1111,8 +1111,8 @@ public class Modele {
if ((Global.numero_modele != 0) && (Global.numero_modele !=1) && (Global.numero_modele !=6)) { // Elimine modèles CPUE = f(E)
// pvs[2] <--> Vmini de graphique CPUE = f()
// pvs[3] <--> Vmini de graphique Y = f()
pvs[2] = new PlotSerie("Weighted effort (E)", tabxx, "Vmini: " + df.format(yy).toString(), estim1);
pvs[3] = new PlotSerie("Weighted effort (E)", tabxx, "Vmini: " + df.format(yy).toString(), estim2);
pvs[2] = new PlotSerie("Weighted effort (E)", tabxx, "Vmini: " + df.format(yy).toString(), estim1); // Ligne CPUE pour Vmin
pvs[3] = new PlotSerie("Weighted effort (E)", tabxx, "Vmini: " + df.format(yy).toString(), estim2); // Ligne Y pour Vmin
pvs[2].setCouleur(Color.blue);
pvs[3].setCouleur(Color.blue);
pvs[2].setFigure(2);
......@@ -1120,12 +1120,12 @@ public class Modele {
Global.variatePlot[0].setValeurs(pvs[2]);
Global.variatePlot[1].setValeurs(pvs[3]); }
} else if (j == 4) {
if ((Global.numero_modele == 0) || (Global.numero_modele ==1) || (Global.numero_modele ==6)) {
if ((Global.numero_modele == 0) || (Global.numero_modele ==1) || (Global.numero_modele ==6)) { // Modeles CPUE=f(V)
// pvs[4] <--> CPUE de graphique CPUE = f()
// pvs[5] <--> Y de graphique Y = f()
pvs[4] = new PlotSerie("Weighted effort (E)", tabxx, "Predicted CPUE", estim1);
pvs[5] = new PlotSerie("Weighted effort (E)", tabxx, "Predicted Y", estim2);
Global.variatePlot[0].setValeurs(pvs[4]);
Global.variatePlot[0].setValeurs(pvs[4]);
Global.variatePlot[1].setValeurs(pvs[5]);
pvs[4].setFigure(2);
pvs[5].setFigure(2);
......@@ -1140,14 +1140,15 @@ public class Modele {
pvs[4].setFigure(2);
pvs[5].setFigure(2);
}
} else if (j == 2 && ((Global.numero_modele == 10) || (Global.numero_modele == 21) || (Global.numero_modele == 23) || (Global.numero_modele == 24) || (Global.numero_modele == 25) || (Global.numero_modele == 27) || (Global.numero_modele >= 30))) {
} else if (j == 2 && ((Global.numero_modele == 10) || (Global.numero_modele == 21) || (Global.numero_modele == 23) || (Global.numero_modele == 24) || (Global.numero_modele == 25) || (Global.numero_modele == 27) || (Global.numero_modele >= 30))) // Modèles non-monotoniques
{ // Modèles mixtes où CPUE = f(V) en dôme (fonction quadratique ou Ricker)
pvs[6] = new PlotSerie("Weighted effort (E)", tabxx, "Vmiddle:" + df.format(yy).toString(), estim1);
pvs[7] = new PlotSerie("Weighted effort (E)", tabxx, "Vmiddle:" + df.format(yy).toString(), estim2);
pvs[6].setCouleur(Color.green);
pvs[7].setCouleur(Color.green);
pvs[6].setFigure(2);
pvs[7].setFigure(2);
Global.variatePlot[0].setValeurs(pvs[6]);
Global.variatePlot[0].setValeurs(pvs[6]);
Global.variatePlot[1].setValeurs(pvs[7]);
}
xx = minix;
......@@ -1186,7 +1187,7 @@ public class Modele {
xx = 0.0; // Effort, non utilisé dans EquationModele.fonction_modele(xx, yy, yy, par_alors)
PlotSerie[] pvs = new PlotSerie[8];
Global.variatePlot[0] = new Plot();
Global.variatePlot[1] = null; // Elimine graphique Y = f(V) au cas où il reste en mémoire d'un ajustement antérieur de Y = f(E,V) ou Y = f(E)
Global.variatePlot[1] = null; // Elimine graphique Y = f(V) au cas où il reste en mémoire d'un ajustement antérieur de Y = f(E,V) ou Y = f(E)
pvs[0] = new PlotSerie("Weighted environment (V)", Data.getV(), "Observed CPUE", Data.getPue());
pvs[0].setCouleur(Color.black);
Global.variatePlot[0].setValeurs(pvs[0]);
......@@ -1204,8 +1205,9 @@ public class Modele {
Global.variatePlot[0].setValeurs(pvs[4]);
pvs[4].setFigure(2);
yy = yy + pasy;
if (miniy > 0) Global.variatePlot[0].setMinAxeX(miniy*0.90); // miniy est bien minimum de V sur axe des X
else Global.variatePlot[0].setMinAxeX(miniy-miniy*0.10);
Global.variatePlot[0].setMinAxeX(miniy-(Data.stat[8][3] / 10)); // miniy est bien minimum de V sur axe des X; Data.stat[8][3] est l'étendue de V
System.out.println("Dans Modele.java miniy = " + miniy + " miniy-(Data.stat[8][3] / 10) = " + (miniy-(Data.stat[8][3] / 10)) );
Global.variatePlot[0].setMaxAxeX(maxiy+(Data.stat[8][3] / 10));
if (Data.stat[8][3] > 100) Global.variatePlot[0].setDecimalsurX(0); // Si étendue > 100. Avant setDecimalsurX(0) -> pas de décilmale sur axe des X. Avec setDecimalsurX(1) -> décimales SI NECESSAIRE. Modif 2020.
else Global.variatePlot[0].setDecimalsurX(2); // Modif 2021.
if (Data.stat[8][1] > 100) Global.variatePlot[0].setDecimalsurY(0); // Si étendue > 100.
......
......@@ -96,7 +96,7 @@ public class PanelPlot extends JPanel
}
/**
* Enregistre l'image du graphique au format JPEG. Le nom donn au fichier
* Enregistre l'image du graphique au format JPEG. Le nom donné au fichier
* est celui du titre du graphique.
*/
public void saveImage() {
......
......@@ -93,17 +93,29 @@ public class Plot implements Cloneable {
* Ajoute une série de données au graphique représentant des valeurs. La
* série est ajoutée au vecteur ListeSerie. Après l'ajout la méthode
* détermine les nouveaux extremas du graphique.
*
* Ne concerne pas les Three-variate plot.
* @param PlotSerie s.
*/
public void setValeurs(PlotSerie s) {
//System.out.println("Flag PlotSerie s, ligne 100 Plot.java"); // test 2020
int divX = 10;
if (nbSerie == 0) {
extremasSeries[0] = s.getMinX()-((s.getMaxX() - s.getMinX())/20); //Pour éloigner valeur Xmin de l'axe des Y Modif. 2020
extremasSeries[1] = s.getMaxX()+((s.getMaxX() - s.getMinX())/20); //Pour éloigner valeur Ymax du bout de l'axe des X. Modif 2020
if (nbSerie == 0) { // Ce qui suit ne concerne pas les histogrammes. Pas d'effet si résultat < 0 alors que l'axe concerné est forcé d'être coupé par l'autre à 0.
// Le if suivant filtre les variables X pour éliminer V et Years
if (s.getMinX() != Data.stat[6][3] && s.getMaxX() != Data.stat[7][3] && s.getMinX() != Stat1.min(Data.year) && s.getMaxX() != Stat1.max(Data.year))
extremasSeries[0] = 0.0;
else if (s.getMinX() != Stat1.min(Data.year) && s.getMaxX() != Stat1.max(Data.year)) // Si années
extremasSeries[0] = s.getMinX()-((s.getMaxX() - s.getMinX())/20); //Pour éloigner valeur Xmin de l'axe des Y Modif. 2020
else extremasSeries[0] = s.getMinX();
if (s.getMinX() != Stat1.min(Data.year) && s.getMaxX() != Stat1.max(Data.year))
extremasSeries[1] = s.getMaxX()+((s.getMaxX() - s.getMinX())/20); //Pour éloigner valeur Xmax du bout de l'axe des X. Modif 2020
else extremasSeries[1] = s.getMaxX();
//System.out.println("Plot Java ligne 113 nbSerie = " + nbSerie + " extremasSeries[0] = " + extremasSeries[0] + " extremasSeries[1] = " + extremasSeries[1]);
titre[0] = s.getNameX();
extremasSeries[2] = s.getMinY()-((s.getMaxY() - s.getMinY())/20); //Pour éloigner valeur Ymin de l'axe des X Modif. 2020
if (s.getMinY() != Data.stat[6][3] && s.getMaxY() != Data.stat[7][3] && s.getMinY() != Stat1.min(Data.year) && s.getMaxY() != Stat1.max(Data.year) && s.getMinY() > 0) // s.getMinY()>0 prevents setting to zero residuals (and possibly V when negative)
extremasSeries[2] = 0.0;
else extremasSeries[2] = s.getMinY()-((s.getMaxY() - s.getMinY())/20); //Pour éloigner valeur Ymin de l'axe des X Modif. 2020
//System.out.println("Plot Java ligne 119 Stat1.min(Modele.res) = " + Stat1.min(Modele.res));
extremasSeries[3] = s.getMaxY()+((s.getMaxY() - s.getMinY())/20); //Pour éloigner valeur Ymax du sommet de l'axe des Y. Modif 2020
titre[1] = s.getNameY();
} else {
......@@ -112,36 +124,36 @@ public class Plot implements Cloneable {
extremasSeries[2] = Math.min(extremasSeries[2], s.getMinY());
extremasSeries[3] = Math.max(extremasSeries[3], s.getMaxY());
}
if (s.getFigure() == Histogrammes) {
//System.out.println("Plot Java ligne 126 extremasSeries[2] = " + extremasSeries[2] + " extremasSeries[3] = " + extremasSeries[3]);
if (s.getFigure() == Histogrammes) { // Pour figures histogrammes.
extremasSeries[0] = 1;
extremasSeries[1] = s.getSize();
extremasAxes[0] = 0;
extremasAxes[1] = (double) (extremasSeries[1] + 0.5);
//System.out.println("extremasAxes[1] = " + extremasAxes[1]);
pas[0] = 1;
serieHisto = true;
} else if (!serieHisto) {
// extremasSeries[0]=extremasSeries[0]*.9;
} else if (!serieHisto) { // Pour autres figures.
// extremasSeries[0]=extremasSeries[0]*.9;
// extremasSeries[2]=extremasSeries[2]*1.1;
pas[0] = Math.abs((extremasSeries[1] - extremasSeries[0]) / 10);
pas[0] = Math.abs((extremasSeries[1] - extremasSeries[0]) / 10); // Le pas sur l'axe des X (pas[0] est égal à 1/10ème del'étendue, arondi à unité entière. Commentaire 2021
if (pas[0] > 1) {
pas[0] = Math.round(pas[0] - 0.5);
}
ajusteExtrema(0, 1);
}
//System.out.println("Ligne 133 PlotSerie s, calcul pas[1] extremasSeries[3]= " + extremasSeries[3]+" et extremasSeries[2]= " + extremasSeries[2]); // test 2020
pas[1] = Math.abs((extremasSeries[3] - extremasSeries[2]) / 10); // Le pas sur l'axe des Y (pas[1] est égal à 1/10ème del'étendue, arondi à unité entière. // Commentaire 2020
if (pas[1] > 1) {
pas[1] = Math.abs((extremasSeries[3] - extremasSeries[2]) / 10); // Le pas sur l'axe des Y (pas[1] est égal à 1/10ème del'étendue, arondi à unité entière. Commentaire 2020
// System.out.println("Ligne 140 Plot.java, calcul pas[1]. extremasSeries[3]= " + extremasSeries[3]+" extremasSeries[2]= " + extremasSeries[2] + " pas[1]= " + pas[1]); // test 2020
if (pas[1] > 1) {
pas[1] = Math.round(pas[1] + 0.5);
}
ajusteExtrema(2, 3);
// attempt to solve problematic graph drawing MS-E versus V
// with example.cli and "a V exp(b E)" direct model fit
// the PAS is equal to zero because the values are constant...
//if (pas[0] == 0 || pas[1] == 0) {
if (pas[0] == 0) {
System.out.println("We reject the serie because of the STEP");
if (pas[0] == 0.0) { // Should not be pas[1] for the Y axis? In any case PAS not equal to zero when MSY or MSY = cte because confidence interval is considered
System.out.println("We reject the serie because of the STEP");
return;
}
ListeSerie.add(s);
......@@ -171,7 +183,7 @@ System.out.println("We reject the serie because of the STEP");
/*
* Calcule l'échelle sur l'objet JPanel
*
* @param JPanel Scr, le conteneur sur lequel doit tre trac le graphique.
* @param JPanel Scr, le conteneur sur lequel doit être tracé le graphique.
*/
public void Echelle(JPanel Scr) {
......@@ -189,7 +201,9 @@ System.out.println("We reject the serie because of the STEP");
*
* @param : Graphics g, le contexte graphique.
*/
public void TraceAxes(Graphics g) {
public void TraceAxes(Graphics g) { // Appelé dans 'Select the appropriate model and fi it' et dans 'Fit a model directly' mais uniquement après click sur Plots etc.
// Rappelé ensuite lors de passage de la souris sur le graphique.
//System.out.println("Flag TraceAxes");
int i;
double x1, y1, xg, px;
double x2, y2, yg, py;
......@@ -211,11 +225,13 @@ System.out.println("We reject the serie because of the STEP");
} else {
grad = (int) (dimPlot.height * 0.01);
}
// System.out.println("extremasAxes[0] 1 = " + extremasAxes[0]);
//for (i = 0; i < 4; i++) System.out.println("Plot.java TraceAxes(Graphics g) i = " + i + " extremasAxes[i]= " + extremasAxes[i] + " paramEchelle[i] = " + paramEchelle[i]);
// Les 4 lignes suivantes apparaissent aussi dans PlotModal.java avec différence dans y2.
x1 = (extremasAxes[0] * paramEchelle[0] - paramEchelle[2]);