Package com.mockturtlesolutions.snifflib.datatypes

Examples of com.mockturtlesolutions.snifflib.datatypes.DataSet


    //Recall there can be multiple experiments and each experiment
    //can have multiple subsamples.
    String expname,subsample,obs,titrant,concentration,volume,thepH,remark;
    String[] headers = new String[]{"Experiment","Subsample","Observation","Titrant","Concentration"};
    Class[] classes = new Class[]{String.class,String.class,String.class,String.class,Double.class};
    DataSet dataSet = new DataSet(headers,classes);
   
    Double conc,vol,pH;
   
    NumberFormat nf = NumberFormat.getInstance();
    Number n = null;
    if (expnames.size() != 0) //There is some experimental support.
    {
      int row=0;
      for (int i=0;i<expnames.size();i++)
      {
        expname = (String)expnames.get(i);
        subsamples = this.getContainedSubsampleIDs(expname);
        for (int j=0;j<subsamples.size();j++)
        {
          subsample = (String)subsamples.get(j);
         
          obsnums = this.getContainedObservationNumbers(expname,subsample);
          for (int k=0;k<obsnums.size();k++)
          {
            obs = (String)obsnums.get(k);
            titrant = this.getTitrant(expname,subsample,obs);
            concentration = this.getContainedConcentration(expname,subsample,obs);
            try
            {
                                conc = new Double(nf.parse(concentration).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of concentration " + concentration + " failed.");
                        }
           
           
           
         
           
            dataSet.setValueAt(expname,row,0);
            dataSet.setValueAt(subsample,row,1);
            dataSet.setValueAt(obs,row,2);
            dataSet.setValueAt(titrant,row,3);
            dataSet.setValueAt(conc,row,4);
           
           
            row++;   
          }
        }
View Full Code Here


    //Recall there can be multiple experiments and each experiment
    //can have multiple subsamples.
    String expname,subsample,obs,titrant,concentration,volume,thepH,remark,initvol,temperature,dielectric,pHProbe;
    String[] headers = new String[]{"Experiment","Subsample","InitialVolume","Temperature","Dielectric","pHProbe","Observation","Titrant","Concentration","VolumeAdded","pH","Remark"};
    Class[] classes = new Class[]{String.class,String.class,Double.class,Double.class,Double.class,String.class,String.class,String.class,Double.class,Double.class,Double.class,String.class};
    DataSet dataSet = new DataSet(headers,classes);
   
    Double conc,vol,pH,initv,temp,diel,probe;
   
    NumberFormat nf = NumberFormat.getInstance();
    Number n = null;
    if (expnames.size() != 0) //There is some experimental support.
    {
      int row=0;
      for (int i=0;i<expnames.size();i++)
      {
        expname = (String)expnames.get(i);
        subsamples = this.getTitrationSubsampleIDs(expname);
        for (int j=0;j<subsamples.size();j++)
        {
          subsample = (String)subsamples.get(j);
         
          initvol     = this.getInitialVolume(expname,subsample);
          temperature = this.getTemperature(expname,subsample);
          dielectric  = this.getDielectric(expname,subsample);
          pHProbe     = this.getpHProbe(expname,subsample);
         
         
          obsnums = this.getTitrationObservationNumbers(expname,subsample);
          for (int k=0;k<obsnums.size();k++)
          {
            obs = (String)obsnums.get(k);
            titrant = this.getTitrant(expname,subsample,obs);
            //initv,temp,diel,probe
            try
            {
                                initv = new Double(nf.parse(initvol).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of initial volume " + initvol + " failed.");
                        }
           
           
            try
            {
                                temp = new Double(nf.parse(temperature).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of temperature " + temperature + " failed.");
                        }
           
           
            try
            {
                                diel = new Double(nf.parse(dielectric).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of dielectric " + dielectric + " failed.");
                        }
           
           
            concentration = this.getTitrantConcentration(expname,subsample,obs);
            try
            {
                                conc = new Double(nf.parse(concentration).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of concentration " + concentration + " failed.");
                        }
           
            volume = this.getVolumeAdded(expname,subsample,obs);
            try
            {
                                vol = new Double(nf.parse(volume).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of volume " + volume + " failed.");
                        }
           
            thepH = this.getpH(expname,subsample,obs);
            try
            {
                                pH = new Double(nf.parse(thepH).doubleValue());
             
                        }
            catch (ParseException ex)
            {
                                throw new RuntimeException("Parsing of volume " + volume + " failed.");
                        }
           
            remark = this.getRemark(expname,subsample,obs);
           
            dataSet.setValueAt(expname,row,0);
            dataSet.setValueAt(subsample,row,1);
            dataSet.setValueAt(initv,row,2);
            dataSet.setValueAt(temp,row,3);
            dataSet.setValueAt(diel,row,4);
            dataSet.setValueAt(pHProbe,row,4);
            dataSet.setValueAt(obs,row,5);
            dataSet.setValueAt(titrant,row,6);
            dataSet.setValueAt(conc,row,7);
            dataSet.setValueAt(vol,row,8);
            dataSet.setValueAt(pH,row,9);
            dataSet.setValueAt(remark,row,10);
           
            row++;   
          }
        }
      } 
View Full Code Here

    //Recall there can be multiple experiments and each experiment
    //can have multiple subsamples.
    String expname,subsample,pka,pkb,salttype;
    String[] headers = new String[]{"Experiment","Subsample","pKa","pKb","SaltType"};
    Class[] classes = new Class[]{String.class,String.class,String.class,String.class,String.class};
    DataSet dataSet = new DataSet(headers,classes);
   
    Double conc,vol,pH;
   
    NumberFormat nf = NumberFormat.getInstance();
    Number n = null;
    if (expnames.size() != 0) //There is some experimental support.
    {
      int row=0;
      for (int i=0;i<expnames.size();i++)
      {
        expname = (String)expnames.get(i);
        subsamples = this.getBufferCoefficientsSubsampleIDs(expname);
        for (int j=0;j<subsamples.size();j++)
        {
          subsample = (String)subsamples.get(j);
         
          pka = this.getpKa(expname,subsample);
          pkb = this.getpKb(expname,subsample);
          salttype = this.getSaltType(expname,subsample);
         
          dataSet.setValueAt(expname,row,0);
          dataSet.setValueAt(subsample,row,1);
          dataSet.setValueAt(pka,row,2);
          dataSet.setValueAt(pkb,row,3);
          dataSet.setValueAt(salttype,row,4);


          row++;   
         
        }
View Full Code Here

    //axes.setTitleColor(Color.white);
    //axes.setAxesColor(Color.gray);
    //this.figure.drawnow();
    this.setVisible(true);

    this.outSet = new DataSet();
    this.outSet.addColumn("Observed",Double.class);
    this.outSet.addColumn("Experiment",String.class);
    this.outSet.addColumn("Subsample",String.class);
    this.outSet.addColumn("Observation",String.class);
    this.outSet.addColumn("pH",Double.class);
View Full Code Here

   
    public DataSet getEmpericalCb()
    {
      Class[] type = new Class[]{String.class,Double.class,Double.class};
      String[] hdr = new String[]{"Subsample","pH","Cb"};
      DataSet out = new DataSet(hdr,type)
   
      return(out);
    }
View Full Code Here

    //axes.setTitleColor(Color.white);
    //axes.setAxesColor(Color.gray);
    //this.figure.drawnow();
    this.setVisible(true);

    this.outSet = new DataSet();
    this.outSet.addColumn("Observed",Double.class);
    this.outSet.addColumn("Experiment",String.class);
    this.outSet.addColumn("Subsample",String.class);
    this.outSet.addColumn("Observation",String.class);
    this.outSet.addColumn("pH",Double.class);
View Full Code Here

      DblMatrix YData = FUNC.getYdata();

      Min m = new Min(this.outSet);
      m.addResponseVariable("pH");
      m.run();
      DataSet minpH = m.getResult();
      DblMatrix min = new DblMatrix((Double)minpH.getValueAt(0,1));

      Max mx = new Max(this.outSet);
      mx.addResponseVariable("pH");
      mx.run();
      DataSet maxpH = mx.getResult();
      DblMatrix max = new DblMatrix((Double)maxpH.getValueAt(0,1));

      // Get widest range based on lpreg's internal data and the current data.
      //Yes, those two data sets may be different after some time!
      min = DblMatrix.min(min,XData[0].min());
      max = DblMatrix.max(max,XData[0].max());
View Full Code Here

//     catch (Exception err)
//     {
//       showError(err.getMessage());
//     }
   
    this.BVector = new DataSet();
    this.XVector = new TargetConstraintTableModel();
    this.AMatrix = new TargetConstraintTableModel();
   
   
    // AMatrix.addColumn("Constraint",Double.class);
View Full Code Here

                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  String col;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                 
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                 
                  int i=1;
                  Plot Cbplot = new Plot(Cbdata);
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                  while (iter.hasNext())
                  {
                    col = (String)iter.next();
                    Cbplot.addResponseVariable(col);
                    //System.out.println("Next column:"+col);
                    val = (DblMatrix)Cbresult.get(col);
                    Cbdata.addColumn(col,Double.class);
                   
                    for (int j=0;j<val.getN();j++)
                    { 
                      //System.out.println("Adding Cbdata row:"+j);
                      //Cbdata.addRow(j);
                      Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                    }
                    i++;
                  }
                 
                  //Plot Cbplot = new Plot(Cbdata);
                  Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                 
                  // pHtoolsPrefs prefs = new pHtoolsPrefs();
//                   prefs.initialize();
//                  
//                  
//                   System.out.println("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
//                   plotstuff.setAxesPreferences(prefs);
//                   plotstuff.setFigurePreferences(prefs);
//                   plotstuff.setLineSegmentRendererPreferences(prefs);
//                  
                 
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Approx. Moles/L Hydroxyl Added");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                 
                }
               
                if (selection.equalsIgnoreCase("get cb density"))
                {
               
                  JProgressBar progressBar = null;
                  Container parent = getParent();
                  System.out.println("Here");
                  if (parent !=null)
                  {
                    System.out.println("Here A");
                    if (parent instanceof WorkBenchPanel)
                    {
                      System.out.println("Here B");
                      Container frame;
                      while (true)
                      {
                        frame = parent.getParent();
                        parent = frame;
                        if (frame instanceof jpHtoolsWBFrame)
                        {
                          break;
                        }
                       
                        if (frame == null)
                        {
                          break;
                        }
                     
                      }
                     
                      if (frame != null)
                      {
                        jpHtoolsWBFrame wbframe =  (jpHtoolsWBFrame)frame;
                        progressBar = wbframe.getProgressBar();
                        progressBar.setVisible(true);
                        progressBar.setString("Determining HPD for Cb...");
                        progressBar.setIndeterminate(true);
                      }
                    }
                  }
                 
                  final JProgressBar bar = progressBar;
                 
                 
                  Thread t = new Thread(new Runnable()
                  {
                    public void run()
                    {
                      HashMap CbHPDresult = null;
                      DblMatrix pH2run = getpH();
                      double prob = 0.95;

                      try
                      {
                        //CbHPDresult = ((BufferSolution)model).CbHPD(pH2run,prob,true);
                      }
                      catch (Exception err)
                      {
                        throw new RuntimeException("Problem getting Cb.",err);
                      }


                      Set keys = CbHPDresult.keySet();
                      String[] hdrs = new String[keys.size()];
                      Class[] cls = new Class[keys.size()];

                      Iterator iter = keys.iterator();
                      String col;
                      DblMatrix val;
                      DataSet Cbdata = new DataSet("pH",Double.class);


                      for (int j=0;j<pH2run.getN();j++)
                      {
                        Cbdata.addRow(j);
                        Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);

                      }


                      int i=1;// pH is in the first column (index=0) so we start at index 1 now.
                      Plot Cbplot = new Plot(Cbdata);

                      ////
                      pHtoolsPrefs prefs = new pHtoolsPrefs();
                      prefs.initialize();
                      Cbplot.setAxesPreferences(prefs);
                      Cbplot.setFigurePreferences(prefs);
                      Cbplot.setLineSegmentRendererPreferences(prefs);
                      prefs.setConfigValue(repos,"legenddomainnamefilter","none");
                      Cbplot.setLegendPreferences(prefs);

                      ////

                      while (iter.hasNext())
                      {
                        col = (String)iter.next();
                        String upperLabel = (col+"_U"+prob);
                        String lowerLabel = (col+"_L"+prob);

                        Cbplot.addResponseVariable(lowerLabel);
                        Cbplot.addResponseVariable(upperLabel);

                        //System.out.println("Next column:"+col);
                        DblMatrix[] CI = (DblMatrix[])CbHPDresult.get(col);


                        Cbdata.addColumn(lowerLabel,Double.class);
                        Cbdata.addColumn(upperLabel,Double.class);

                        for (int j=0;j<CI[0].getN();j++)
                        { 
                          //System.out.println("Adding Cbdata row:"+j);
                          //Cbdata.addRow(j);
                          Cbdata.setValueAt(CI[0].getDoubleAt(j),j,i);
                          Cbdata.setValueAt(CI[1].getDoubleAt(j),j,i+1)
                        }
                        i = i+2;
                      }

                      //Plot Cbplot = new Plot(Cbdata);
                      Cbplot.addPredictorVariable("pH");
                      //Cbplot.addResponseVariable("total");

                      PlotFrame plotstuff = new PlotFrame(Cbplot);

                      // pHtoolsPrefs prefs = new pHtoolsPrefs();
    //                   prefs.initialize();
    //                  
    //                  
    //                   System.out.println("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
    //                   plotstuff.setAxesPreferences(prefs);
    //                   plotstuff.setFigurePreferences(prefs);
    //                   plotstuff.setLineSegmentRendererPreferences(prefs);
    //                  

                      SLAxes ax = Cbplot.getAxes();
                      ax.setYLabel("Approx. Moles/L Hydroxyl Added");
                      ax.setXLabel("pH")
                      plotstuff.setVisible(true);
                     
                      if (bar != null)
                      {
                        bar.setIndeterminate(false);
                        bar.setVisible(false);
                      }
                    }
                 
                  });
       
                  t.start(); // Start it running
                }
               
               
               
                if (selection.equalsIgnoreCase("get species concentration"))
                {
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).species(pH2run);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting species concentration.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  Set ionKeys;
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  Iterator ionIter;
                  String col,ion;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                  HashMap ionMap;
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                  Plot Cbplot = new Plot(Cbdata);
                 
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                 
                  Log10 logfun = new Log10();
                  Cbplot.setYTransformation((UniUniFunction)logfun);
                 
                  Cbplot.addPredictorVariable("pH");
                  int i=1;
                  Vector labels = new Vector();
                  String label;
                  while (iter.hasNext())
                  {
                    col = (String)iter.next();
                    System.out.println("Next column:"+col);
                    ionMap = (HashMap)Cbresult.get(col);
                   
                    ionKeys = ionMap.keySet();
                    ionIter = ionKeys.iterator();
                    while (ionIter.hasNext())
                    {
                      ion = (String)ionIter.next();
                      label = col+":"+ion;
                      labels.add(label);
                      Cbdata.addColumn(label,Double.class);
                      val = (DblMatrix)ionMap.get(ion);
                      for (int j=0;j<val.getN();j++)
                      { 
                        //System.out.println("Adding Cbdata row:"+j);
                        //Cbdata.addRow(j);
                        Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                      }
                     
                      Cbplot.addResponseVariable(label);
                      i++;
                    }
                   
                  }
                 
                 
                  //Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Log10 species concentation");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                 
                 
                }
               
                if (selection.equalsIgnoreCase("get buffer capacity"))
                {
                   
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).buffCapEval(pH2run,true);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting the buffer capacity.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  String col;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                 
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                 
                  int i=1;
                  Plot Cbplot = new Plot(Cbdata);
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                  while (iter.hasNext())
                  {
                    col = (String)iter.next();
                    Cbplot.addResponseVariable(col);
                    System.out.println("Next column:"+col);
                    val = (DblMatrix)Cbresult.get(col);
                    Cbdata.addColumn(col,Double.class);
                   
                    for (int j=0;j<val.getN();j++)
                    { 
                      //System.out.println("Adding Cbdata row:"+j);
                      //Cbdata.addRow(j);
                      Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                    }
                    i++;
                  }
                 
                  //Plot Cbplot = new Plot(Cbdata);
                  Cbplot.addPredictorVariable("pH");
                  //Cbplot.addResponseVariable("total");
                 
                  PlotFrame plotstuff = new PlotFrame(Cbplot);
                  SLAxes ax = Cbplot.getAxes();
                  ax.setYLabel("Buffer Capacity");
                  ax.setXLabel("pH")
                  plotstuff.setVisible(true);
                }
               
                if (selection.equalsIgnoreCase("get ionic strength"))
                {
                  DblMatrix pH2run = getpH();
                  HashMap Cbresult = null;
                  try
                  {
                    Cbresult = ((BufferSolution)model).ionicStr(pH2run,true);
                  }
                  catch (Exception err)
                  {
                    throw new RuntimeException("Problem getting the ionic strength.",err);
                  }
                 
                  Set keys = Cbresult.keySet();
                  String[] hdrs = new String[keys.size()];
                  Class[] cls = new Class[keys.size()];
                 
                  Iterator iter = keys.iterator();
                  String col;
                  DblMatrix val;
                  DataSet Cbdata = new DataSet("pH",Double.class);
                 
                 
                  for (int j=0;j<pH2run.getN();j++)
                  {
                    Cbdata.addRow(j);
                    Cbdata.setValueAt(pH2run.getDoubleAt(j),j,0);
                 
                  }
                 
                 
                  int i=1;
                  Plot Cbplot = new Plot(Cbdata);
                 
                  ////
                  pHtoolsPrefs prefs = new pHtoolsPrefs();
                  prefs.initialize();
                  Cbplot.setAxesPreferences(prefs);
                  Cbplot.setFigurePreferences(prefs);
                  Cbplot.setLineSegmentRendererPreferences(prefs);
                  Cbplot.setLegendPreferences(prefs);
                  ////
                 
                  while (iter.hasNext())
                  {
                 
                   
                    col = (String)iter.next();
                    Cbplot.addResponseVariable(col);
                    //System.out.println("Next column:"+col);
                    val = (DblMatrix)Cbresult.get(col);
                   
                    val.show("val");
                    Cbdata.addColumn(col,Double.class);
                   
                    for (int j=0;j<val.getN();j++)
                    { 
                      System.out.println("Adding Cbdata row:"+j);
                      //Cbdata.addRow(j);
                      Cbdata.setValueAt(val.getDoubleAt(j),j,i)
                    }
                    i++;
                  }
                 
                  //Plot Cbplot = new Plot(Cbdata);
View Full Code Here

 
  public DataSet Cb(DblMatrix pHIn,boolean partial)
  {
    DblMatrix pH = DblMatrix.vec(pHIn)//Make pH a column vector.
    DblMatrix H = DblMatrix.pow(10,pH.times(-1));
    DataSet out = new DataSet();
   
    int c=0;
   
    //
    //First column will be pH.
    //
    out.addColumn("pH",Double.class);
     for (int k=0;k<pH.getN();k++)
     {
       out.setValueAt(pH.getDoubleAt(k),k,c)
     }
    c++;
   
    Set keys = this.contents.keySet();
    Iterator iter = keys.iterator();
    DblMatrix Cb=null;
    String comp;
   
    while (iter.hasNext())
     {
      Cb=new DblMatrix(H.getN());
      comp = (String)iter.next();
      out.addColumn(comp,Double.class);
      for (int k=0;k<pH.getN();k++)
       {
         out.setValueAt(new Double(k*c),k,c)
       }
      c++;
    }
   
    return(out);
View Full Code Here

TOP

Related Classes of com.mockturtlesolutions.snifflib.datatypes.DataSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.