void
RockPhysicsInversion4D::smoothAllDirectionsAndNormalize()
{
  DivideAndSmoothTable(1,priorDistribution_,smoothingFilter_);

  for(int i=0;i<2;i++)
  for (int j=0; j<nf_[0]; j++){
      meanRockPrediction_(i,j)->setAccessMode(FFTGrid::RANDOMACCESS);
   }

  for(int i0=0;i0<nf_[0];i0++)
     for(int i1=0;i1<nf_[1];i1++)
        for(int i2=0;i2<nf_[2];i2++)
           for(int i3=0;i3<nf_[3];i3++)
           {
             double number = GetGridValue(1,i0,i1,i2,i3);
             double normalizing =GetGridValue(0,i0,i1,i2,i3);
             double value;
             if(normalizing<1e-5)
               value=RMISSING;
             else;
               value=number/normalizing;

             SetGridValue(1,i0,i1,i2,i3,value);
           }


  for(int i=0;i<2;i++)
    for (int j=0; j<nf_[0]; j++){
      meanRockPrediction_(i,j)->endAccess();
    }

}
Ejemplo n.º 2
0
wxWindow* PropertiesWindow::createAttributesPanel(wxWindow* parent)
{
	wxPanel* panel = newd wxPanel(parent, wxID_ANY);
	wxSizer* topSizer = newd wxBoxSizer(wxVERTICAL);

	attributesGrid = newd wxGrid(panel, ITEM_PROPERTIES_ADVANCED_TAB, wxDefaultPosition, wxSize(-1, 160));
	topSizer->Add(attributesGrid, wxSizerFlags(1).Expand());

	wxFont time_font(*wxSWISS_FONT);
	attributesGrid->SetDefaultCellFont(time_font);
	attributesGrid->CreateGrid(0, 3);
	attributesGrid->DisableDragRowSize();
	attributesGrid->DisableDragColSize();
	attributesGrid->SetSelectionMode(wxGrid::wxGridSelectRows);
	attributesGrid->SetRowLabelSize(0);
	//log->SetColLabelSize(0);
	//log->EnableGridLines(false);
	attributesGrid->EnableEditing(true);

	attributesGrid->SetColLabelValue(0, "Key");
	attributesGrid->SetColSize(0, 100);
	attributesGrid->SetColLabelValue(1, "Type");
	attributesGrid->SetColSize(1, 80);
	attributesGrid->SetColLabelValue(2, "Value");
	attributesGrid->SetColSize(2, 410);

	// contents
	ItemAttributeMap attrs = edit_item->getAttributes();
	attributesGrid->AppendRows(attrs.size());
	int i = 0;
	for(ItemAttributeMap::iterator aiter = attrs.begin(); aiter != attrs.end(); ++aiter, ++i)
		SetGridValue(attributesGrid, i, aiter->first, aiter->second);

	wxSizer* optSizer = newd wxBoxSizer(wxHORIZONTAL);
	optSizer->Add(newd wxButton(panel, ITEM_PROPERTIES_ADD_ATTRIBUTE, "Add Attribute"), wxSizerFlags(0).Center());
	optSizer->Add(newd wxButton(panel, ITEM_PROPERTIES_REMOVE_ATTRIBUTE, "Remove Attribute"), wxSizerFlags(0).Center());
	topSizer->Add(optSizer, wxSizerFlags(0).Center().DoubleBorder());

	panel->SetSizer(topSizer);

	return panel;
}
Ejemplo n.º 3
0
void PropertiesWindow::OnGridValueChanged(wxGridEvent& event)
{
	if(event.GetCol() == 1) {
		wxString newType = attributesGrid->GetCellValue(event.GetRow(), 1);
		if(newType == event.GetString()) {
			return;
		}

		ItemAttribute attr;
		if(newType == "String") {
			attr.set("");
		} else if(newType == "Float") {
			attr.set(0.0f);
		} else if(newType == "Number") {
			attr.set(0);
		} else if(newType == "Boolean") {
			attr.set(false);
		}
		SetGridValue(attributesGrid, event.GetRow(), nstr(attributesGrid->GetCellValue(event.GetRow(), 0)), attr);
	}
}
Ejemplo n.º 4
0
void PropertiesWindow::OnClickAddAttribute(wxCommandEvent&)
{
	attributesGrid->AppendRows(1);
	ItemAttribute attr(0);
	SetGridValue(attributesGrid, attributesGrid->GetNumberRows() - 1, "", attr);
}
void
RockPhysicsInversion4D::DivideAndSmoothTable(int tableInd,std::vector<std::vector<double> > priorDistribution, std::vector<fftw_complex*> smoothingFilter)
{
  for (int j=0; j<nf_[0]; j++){
      meanRockPrediction_(tableInd,j)->setAccessMode(FFTGrid::RANDOMACCESS);
   }

  int cnfp=nfp_/2+1;
  int rnfp=2*cnfp;

  fftw_real*    rTemp = static_cast<fftw_real*>(fftw_malloc(sizeof(float)*rnfp));
  fftw_complex* cTemp = reinterpret_cast<fftw_complex*>(rTemp);

  double minDivisor = 1e-3;

  LogKit::LogFormatted(LogKit::Low,"\n Smoothing direction 1 of 4\n");
  float monitorSize = std::max(1.0f, static_cast<float>(nf_[0]*nf_[1]*nf_[2]*nf_[3])*0.02f);
  float nextMonitor = monitorSize;
  std::cout
    << "\n  0%       20%       40%       60%       80%      100%"
    << "\n  |    |    |    |    |    |    |    |    |    |    |  "
    << "\n  ^";

  // divide and smooth direction1
  for(int i1=0;i1<nf_[1];i1++)
    for(int i2=0;i2<nf_[2];i2++)
      for(int i3=0;i3<nf_[3];i3++)
      {
        for(int i0=0;i0<nf_[0];i0++)
        {
          double divisor=std::max(minDivisor,priorDistribution_[0][i0]);
          rTemp[i0]=float(GetGridValue(tableInd,i0,i1,i2,i3)/ divisor);
        }
        for(int i0=nf_[0];i0<nfp_;i0++)
          rTemp[i0]=0.0f;

        rfftwnd_one_real_to_complex(fftplan1_,rTemp,cTemp);

        for(int i0=0;i0<cnfp;i0++)
        {
          cTemp[i0].re=cTemp[i0].re*smoothingFilter[0][i0].re;
          cTemp[i0].im=cTemp[i0].im*smoothingFilter[0][i0].re;
        }

        rfftwnd_one_complex_to_real(fftplan2_,cTemp,rTemp);
        for(int i0=0;i0<nf_[0];i0++)
        {
          SetGridValue(tableInd,i0,i1,i2,i3, rTemp[i0]);
          if ( i1*nf_[2]*nf_[3]*nf_[0] +i2*nf_[3]*nf_[0]+ i3*nf_[0] + i0 + 1 >= static_cast<int>(nextMonitor)) {
            nextMonitor += monitorSize;
            std::cout << "^";
          }
        }
      }

  LogKit::LogFormatted(LogKit::Low,"\n\n Smoothing direction 2 of 4\n");
  monitorSize = std::max(1.0f, static_cast<float>(nf_[0]*nf_[1]*nf_[2]*nf_[3])*0.02f);
  nextMonitor = monitorSize;
  std::cout
    << "\n  0%       20%       40%       60%       80%      100%"
    << "\n  |    |    |    |    |    |    |    |    |    |    |  "
    << "\n  ^";

  // divide and smoothdirection2
  for(int i0=0;i0<nf_[0];i0++)
    for(int i2=0;i2<nf_[2];i2++)
      for(int i3=0;i3<nf_[3];i3++)
      {
        for(int i1=0;i1<nf_[1];i1++)
        {
          double divisor=std::max(minDivisor,priorDistribution_[1][i1]);
          rTemp[i1]=float(GetGridValue(tableInd,i0,i1,i2,i3)/divisor);
        }
        for(int i1=nf_[1];i1<nfp_;i1++)
          rTemp[i1]=0.0f;

        rfftwnd_one_real_to_complex(fftplan1_,rTemp,cTemp);

        for(int i1=0;i1<cnfp;i1++)
        {
          cTemp[i1].re=cTemp[i1].re*smoothingFilter[1][i1].re;
          cTemp[i1].im=cTemp[i1].im*smoothingFilter[1][i1].re;
        }

        rfftwnd_one_complex_to_real(fftplan2_,cTemp,rTemp);
        for(int i1=0;i1<nf_[1];i1++)
        {
          SetGridValue(tableInd,i0,i1,i2,i3, rTemp[i1]);
          if ( i0*nf_[2]*nf_[3]*nf_[1] +i2*nf_[3]*nf_[1]+ i3*nf_[1] + i1 + 1 >= static_cast<int>(nextMonitor)) {
            nextMonitor += monitorSize;
            std::cout << "^";
          }
        }
      }

  LogKit::LogFormatted(LogKit::Low,"\n\n Smoothing direction 3 of 4\n");
  monitorSize = std::max(1.0f, static_cast<float>(nf_[0]*nf_[1]*nf_[2]*nf_[3])*0.02f);
  nextMonitor = monitorSize;
  std::cout
    << "\n  0%       20%       40%       60%       80%      100%"
    << "\n  |    |    |    |    |    |    |    |    |    |    |  "
    << "\n  ^";

  //  divide and smoothdirection 3
  for(int i0=0;i0<nf_[0];i0++)
    for(int i1=0;i1<nf_[1];i1++)
      for(int i3=0;i3<nf_[3];i3++)
      {
        for(int i2=0;i2<nf_[2];i2++)
        {
          double divisor=std::max(minDivisor,priorDistribution_[2][i2]);
          rTemp[i2]=float(GetGridValue(tableInd,i0,i1,i2,i3)/divisor);

        }
        for(int i2=nf_[2];i2<nfp_;i2++)
          rTemp[i2]=0.0f;

        rfftwnd_one_real_to_complex(fftplan1_,rTemp,cTemp);

        for(int i2=0;i2<cnfp;i2++)
        {
          cTemp[i2].re=cTemp[i2].re*smoothingFilter[2][i2].re;
          cTemp[i2].im=cTemp[i2].im*smoothingFilter[2][i2].re;
        }

        rfftwnd_one_complex_to_real(fftplan2_,cTemp,rTemp);
        for(int i2=0;i2<nf_[2];i2++)
        {
          SetGridValue(tableInd,i0,i1,i2,i3, rTemp[i2]);
          if ( i0*nf_[1]*nf_[3]*nf_[2] +i1*nf_[3]*nf_[2]+ i3*nf_[2] + i2 + 1 >= static_cast<int>(nextMonitor)) {
            nextMonitor += monitorSize;
            std::cout << "^";
          }
        }
      }

  LogKit::LogFormatted(LogKit::Low,"\n Smoothing last direction \n");
  monitorSize = std::max(1.0f, static_cast<float>(nf_[0]*nf_[1]*nf_[2]*nf_[3])*0.02f);
  nextMonitor = monitorSize;
  std::cout
    << "\n  0%       20%       40%       60%       80%      100%"
    << "\n  |    |    |    |    |    |    |    |    |    |    |  "
    << "\n  ^";
 //  divide and smoothdirection 4
   for(int i0=0;i0<nf_[0];i0++)
    for(int i1=0;i1<nf_[1];i1++)
      for(int i2=0;i2<nf_[2];i2++)
      {
        for(int i3=0;i3<nf_[3];i3++)
        {
          double divisor=std::max(minDivisor,priorDistribution_[3][i3]);
          rTemp[i3]=float(GetGridValue(tableInd,i0,i1,i2,i3)/divisor);
        }
        for(int i3=nf_[3];i3<nfp_;i3++)
          rTemp[i3]=0.0f;

        rfftwnd_one_real_to_complex(fftplan1_,rTemp,cTemp);

        for(int i3=0;i3<cnfp;i3++)
        {
          cTemp[i3].re=cTemp[i3].re*smoothingFilter[3][i3].re;
          cTemp[i3].im=cTemp[i3].im*smoothingFilter[3][i3].re;
        }

        rfftwnd_one_complex_to_real(fftplan2_,cTemp,rTemp);
        for(int i3=0;i3<nf_[3];i3++)
        {
          SetGridValue(tableInd,i0,i1,i2,i3, rTemp[i3]);
          if ( i0*nf_[1]*nf_[2]*nf_[3] +i1*nf_[2]*nf_[3]+ i2*nf_[3] + i3 + 1 >= static_cast<int>(nextMonitor)) {
            nextMonitor += monitorSize;
            std::cout << "^";
          }
        }
      }

  for (int j=0; j<nf_[0]; j++){
      meanRockPrediction_(tableInd,j)->endAccess();
  }

  fftw_free(rTemp);

}