Esempio n. 1
0
  /**
  Overlay the overlap 1D workspace over the original 1D workspace. overlap shouuld overwrite values on the sum workspace.
  @param original : Original 1D workspace to be overwritten only in the region of the overlap.
  @param overlap : Overlap 1D workspace to overwrite with
  */
  void Stitch1DMD::overlayOverlap(MDHistoWorkspace_sptr original, IMDHistoWorkspace_sptr overlap)
  {
    const auto targetDim = original->getDimension(0);
    const double targetQMax = targetDim->getMaximum();
    const double targetQMin = targetDim->getMinimum();
    const size_t targetNbins = targetDim->getNBins();
    const double targetStep = double(targetNbins) / (targetQMax - targetQMin); 
    const double targetC = -1 * targetStep * targetQMin;

    const auto overlapDim = overlap->getDimension(0);
    const double overlapQMax = overlapDim->getMaximum();
    const double overlapQMin = overlapDim->getMinimum();
    const size_t overlapNBins = overlapDim->getNBins();
    const double overlapStep = (overlapQMax - overlapQMin) / double(overlapNBins);
    const double overlapC = overlapQMin;

    for(size_t i = 0; i < overlapNBins; ++i)
    {
      // Calculate the q value for each index in the overlap region.
      const double q = (overlapStep * double(i)) + overlapC;
      // Find the target index by recentering (adding 0.5) and then truncating to an integer.
      size_t targetIndex = size_t((targetStep * q) + targetC + 0.5) ;
      // Overwrite signal
      original->setSignalAt(targetIndex, overlap->signalAt(i));
      // Overwrite error
      original->setErrorSquaredAt(targetIndex, overlap->errorSquaredAt(i));
    }
  }
Esempio n. 2
0
void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws,
                                int currentDim, coord_t *idx) {
  if (currentDim == rank) {
    int Cindex = calculateCAddress(idx);
    int val = data[Cindex];
    MDHistoWorkspace_sptr mdws =
        boost::dynamic_pointer_cast<MDHistoWorkspace>(ws);
    size_t F77index = mdws->getLinearIndexAtCoord(idx);
    mdws->setSignalAt(F77index, signal_t(val));
    mdws->setErrorSquaredAt(F77index, signal_t(val));
  } else {
    for (int i = 0; i < dim[currentDim]; i++) {
      idx[currentDim] = static_cast<coord_t>(i);
      recurseDim(data, ws, currentDim + 1, idx);
    }
  }
}
Esempio n. 3
0
void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS)
{
	double val, *inVal;
	unsigned int xdim, ydim, zdim, idx;

	boost::shared_ptr<const IMDDimension> x,y,z;
	x = inWS->getXDimension();
	y = inWS->getYDimension();
	z = inWS->getZDimension();

	std::vector<IMDDimension_sptr> dimensions;
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(y));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(x));
    dimensions.push_back(boost::const_pointer_cast<IMDDimension>(z));

    MDHistoWorkspace_sptr outWS (new MDHistoWorkspace(dimensions));
    outWS->setTo(.0,.0,.0);

    xdim = static_cast<unsigned int>(x->getNBins());
    ydim = static_cast<unsigned int>(y->getNBins());
    zdim = static_cast<unsigned int>(z->getNBins());
    inVal = inWS->getSignalArray();
    for(unsigned int xx = 0; xx < xdim; xx++){
    	for(unsigned int yy = 0; yy < ydim; yy++){
    		for(unsigned zz = 0; zz < zdim; zz++){
    			//idx = ydim*zdim*xx + zdim*yy + zz;
    			idx = ydim*zdim*xx + zdim*yy + zz;
    			val = inVal[idx];
    			outWS->setSignalAt(outWS->getLinearIndex(yy,xx,zz),val);
    			outWS->setErrorSquaredAt(outWS->getLinearIndex(yy,xx,zz),val);
    		}
    	}
    }

    copyMetaData(inWS, outWS);

    // assign the workspace
	setProperty("OutputWorkspace",outWS);

}