void SBConvolve::SBConvolveImpl::add(const SBProfile& rhs) { dbg<<"Start SBConvolveImpl::add. Adding item # "<<_plist.size()+1<<std::endl; // Add new terms(s) to the _plist: assert(GetImpl(rhs)); const SBProfileImpl* p = GetImpl(rhs); const SBConvolveImpl* sbc = dynamic_cast<const SBConvolveImpl*>(p); const SBAutoConvolve::SBAutoConvolveImpl* sbc2 = dynamic_cast<const SBAutoConvolve::SBAutoConvolveImpl*>(p); const SBAutoCorrelate::SBAutoCorrelateImpl* sbc3 = dynamic_cast<const SBAutoCorrelate::SBAutoCorrelateImpl*>(p); if (sbc) { dbg<<" (Item is really "<<sbc->_plist.size()<<" items.)"<<std::endl; // If rhs is an SBConvolve, copy its list here for (ConstIter pptr = sbc->_plist.begin(); pptr!=sbc->_plist.end(); ++pptr) { if (!pptr->isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!pptr->isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(*pptr); } } else if (sbc2) { dbg<<" (Item is really AutoConvolve.)"<<std::endl; // If rhs is an SBAutoConvolve, put two of its item here: const SBProfile& obj = sbc2->getAdaptee(); if (!obj.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!obj.isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(obj); _plist.push_back(obj); } else if (sbc3) { dbg<<" (Item is really AutoCorrelate items.)"<<std::endl; // If rhs is an SBAutoCorrelate, put its item and 180 degree rotated verion here: const SBProfile& obj = sbc3->getAdaptee(); if (!obj.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!obj.isAnalyticX() && _real_space) throw SBError("Real_space SBConvolve requires members to be analytic in x"); _plist.push_back(obj); SBProfile temp = obj; temp.applyRotation(180. * degrees); _plist.push_back(temp); } else { if (!rhs.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!rhs.isAnalyticX() && _real_space) throw SBError("Real-space SBConvolve requires members to be analytic in x"); _plist.push_back(rhs); } }
tmv::SymMatrix<double, tmv::FortranStyle|tmv::Upper> calculateCovarianceSymMatrix( const SBProfile& sbp, const Bounds<int>& bounds, double dx) { // Calculate the required dimensions int idim = 1 + bounds.getXMax() - bounds.getXMin(); int jdim = 1 + bounds.getYMax() - bounds.getYMin(); int covdim = idim * jdim; int k, ell; // k and l are indices that refer to image pixel separation vectors in the // correlation func. double x_k, y_ell; // physical vector separations in the correlation func, dx * k etc. tmv::SymMatrix<double, tmv::FortranStyle|tmv::Upper> cov = tmv::SymMatrix< double, tmv::FortranStyle|tmv::Upper>(covdim); for (int i=1; i<=covdim; i++){ // note that the Image indices use the FITS convention and // start from 1!! for (int j=i; j<=covdim; j++){ k = ((j - 1) / jdim) - ((i - 1) / idim); // using integer division rules here ell = ((j - 1) % jdim) - ((i - 1) % idim); x_k = double(k) * dx; y_ell = double(ell) * dx; Position<double> p = Position<double>(x_k, y_ell); cov(i, j) = sbp.xValue(p); // fill in the upper triangle with the correct value } } return cov; }
void SBConvolve::SBConvolveImpl::add(const SBProfile& sbp) { dbg<<"Start SBConvolveImpl::add. Adding item # "<<_plist.size()+1<<std::endl; // Add new terms(s) to the _plist: assert(GetImpl(sbp)); const SBProfileImpl* p = GetImpl(sbp); const SBConvolveImpl* sbc = dynamic_cast<const SBConvolveImpl*>(p); const SBAutoConvolve::SBAutoConvolveImpl* sbc2 = dynamic_cast<const SBAutoConvolve::SBAutoConvolveImpl*>(p); const SBAutoCorrelate::SBAutoCorrelateImpl* sbc3 = dynamic_cast<const SBAutoCorrelate::SBAutoCorrelateImpl*>(p); if (sbc) { dbg<<" (Item is really "<<sbc->_plist.size()<<" items.)"<<std::endl; // If sbp is an SBConvolve, copy its list here for (ConstIter pptr = sbc->_plist.begin(); pptr!=sbc->_plist.end(); ++pptr) add(*pptr); } else if (sbc2) { dbg<<" (Item is really AutoConvolve.)"<<std::endl; // If sbp is an SBAutoConvolve, put two of its item here: const SBProfile& obj = sbc2->getAdaptee(); add(obj); add(obj); } else if (sbc3) { dbg<<" (Item is really AutoCorrelate items.)"<<std::endl; // If sbp is an SBAutoCorrelate, put its item and 180 degree rotated verion here: const SBProfile& obj = sbc3->getAdaptee(); add(obj); SBProfile temp = obj.rotate(180. * degrees); add(temp); } else { if (!sbp.isAnalyticK() && !_real_space) throw SBError("SBConvolve requires members to be analytic in k"); if (!sbp.isAnalyticX() && _real_space) throw SBError("Real-space SBConvolve requires members to be analytic in x"); _plist.push_back(sbp); } _x0 += sbp.centroid().x; _y0 += sbp.centroid().y; _isStillAxisymmetric = _isStillAxisymmetric && sbp.isAxisymmetric(); _fluxProduct *= sbp.getFlux(); }
double SBAutoCorrelate::SBAutoCorrelateImpl::xValue(const Position<double>& pos) const { SBProfile temp = _adaptee; temp.applyRotation(180. * degrees); return RealSpaceConvolve(_adaptee,temp,pos,getFlux(),this->gsparams); }