Ignore:
Timestamp:
10/04/16 18:20:50 (8 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes/No?

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...


Check-in asap modifications from Jim regarding casacore namespace conversion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/components/SpectralComponents/Spectral2Estimate.tcc

    r2980 r3106  
    1818//#
    1919//# Correspondence concerning AIPS++ should be addressed as follows:
    20 //#        Internet email: aips2-request@nrao.edu.
     20//#        casacore::Internet email: aips2-request@nrao.edu.
    2121//#        Postal address: AIPS++ Project Office
    2222//#                        National Radio Astronomy Observatory
     
    4040//# Member templates
    4141template <class MT>
    42 const SpectralList &SpectralEstimate::estimate(const Vector<MT> &prof,
    43                                                Vector<MT> *der) {
     42const SpectralList &SpectralEstimate::estimate(const casacore::Vector<MT> &prof,
     43                                               casacore::Vector<MT> *der) {
    4444          if (prof.nelements() != lprof_p) {
    4545    delete [] deriv_p; deriv_p = 0; lprof_p = 0;
    4646    lprof_p = prof.nelements();
    47     deriv_p = new Double[lprof_p];
     47    deriv_p = new casacore::Double[lprof_p];
    4848  };
    4949  // Check if signal in window
    5050  if (!window(prof)) return slist_p;
    5151  // Limit window
    52   windowEnd_p = min(windowEnd_p+q_p , Int(lprof_p));
     52  windowEnd_p = min(windowEnd_p+q_p , casacore::Int(lprof_p));
    5353  windowLow_p = max(windowLow_p-q_p , 0 );
    5454  // Get the second derivatives
     
    5656  // Next for debugging
    5757  if (der) {
    58     for (uInt i=0; i<lprof_p; i++) (*der)[i] = deriv_p[i];
     58    for (casacore::uInt i=0; i<lprof_p; i++) (*der)[i] = deriv_p[i];
    5959  };
    6060  // Find the estimates (sorted)
     
    6565
    6666template <class MT>
    67 const SpectralList& SpectralEstimate::estimate(const Vector<MT>& x,
    68                                                const Vector<MT>& y)
     67const SpectralList& SpectralEstimate::estimate(const casacore::Vector<MT>& x,
     68                                               const casacore::Vector<MT>& y)
    6969{
    7070  if (x.nelements() != y.nelements()) {
     
    7777  estimate(y);
    7878  // Convert
    79   for (uInt i=0; i<slist_p.nelements(); i++) {
     79  for (casacore::uInt i=0; i<slist_p.nelements(); i++) {
    8080          if (slist_p[i]->getType() != SpectralElement::GAUSSIAN) {
    8181                  throw AipsError("Non-gaussian spectral types cannot be estimated");
     
    9090
    9191template <class MT>
    92 uInt SpectralEstimate::window(const Vector<MT> &prof) {
     92casacore::uInt SpectralEstimate::window(const casacore::Vector<MT> &prof) {
    9393  windowLow_p =0;
    9494  windowEnd_p = 0;
    9595  if (!useWindow_p || rms_p <= 0.0 || lprof_p == 0) {
    9696    if (regionEnd_p) {
    97       windowLow_p = min(max(0,regionLow_p),Int(lprof_p));
    98       windowEnd_p = min(regionEnd_p, Int(lprof_p));
     97      windowLow_p = min(max(0,regionLow_p),casacore::Int(lprof_p));
     98      windowEnd_p = min(regionEnd_p, casacore::Int(lprof_p));
    9999    } else windowEnd_p = lprof_p;
    100100    return windowEnd_p-windowLow_p;
    101101  };
    102102  // Total flux in profile and max position
    103   Double flux(0.0);
    104   Double pmax(prof(0));
    105   uInt imax(0);
    106   for (Int i=windowLow_p; i<windowEnd_p; i++) {
     103  casacore::Double flux(0.0);
     104  casacore::Double pmax(prof(0));
     105  casacore::uInt imax(0);
     106  for (casacore::Int i=windowLow_p; i<windowEnd_p; i++) {
    107107    if (prof(i)>pmax) {
    108108      pmax = prof(i);
     
    114114  if (pmax < cutoff_p) return 0;
    115115  // Window boundaries; new/old base and centre; width
    116   Int width(-1);
    117   Int nw(0);
    118   Double bnew(flux), bold;
    119   Double cnew(imax), cold;
     116  casacore::Int width(-1);
     117  casacore::Int nw(0);
     118  casacore::Double bnew(flux), bold;
     119  casacore::Double cnew(imax), cold;
    120120  do {
    121121    width++;
    122122    cold = cnew;
    123123    bold = bnew;
    124     windowLow_p = max(0, Int(cold-width+0.5));
    125     windowEnd_p = min(Int(lprof_p), Int(cold+width+1.5));
     124    windowLow_p = max(0, casacore::Int(cold-width+0.5));
     125    windowEnd_p = min(casacore::Int(lprof_p), casacore::Int(cold+width+1.5));
    126126    // flux and first moment in window
    127     Double s(0);
    128     Double c(0);
    129     for (Int i=windowLow_p; i<windowEnd_p; i++) {
     127    casacore::Double s(0);
     128    casacore::Double c(0);
     129    for (casacore::Int i=windowLow_p; i<windowEnd_p; i++) {
    130130      s += prof(i);
    131131      c += i*prof(i);
     
    142142
    143143template <class MT>
    144 void SpectralEstimate::findc2(const Vector<MT> &prof) {
    145   for (Int i=windowLow_p; i<windowEnd_p; i++) {
     144void SpectralEstimate::findc2(const casacore::Vector<MT> &prof) {
     145  for (casacore::Int i=windowLow_p; i<windowEnd_p; i++) {
    146146    // Moments
    147     Double m0(0.0);
    148     Double m2(0.0);
    149     for (Int j = -q_p; j <= q_p; j++) {
    150       Int k = i+j;
    151       if (k >= 0 && k<Int(lprof_p)) {
     147    casacore::Double m0(0.0);
     148    casacore::Double m2(0.0);
     149    for (casacore::Int j = -q_p; j <= q_p; j++) {
     150      casacore::Int k = i+j;
     151      if (k >= 0 && k<casacore::Int(lprof_p)) {
    152152        // add to moments
    153153        m0 += prof(k);
     
    161161
    162162template <class MT>
    163 void SpectralEstimate::findga(const Vector<MT> &prof) {
    164         Int i(windowLow_p-1);
     163void SpectralEstimate::findga(const casacore::Vector<MT> &prof) {
     164        casacore::Int i(windowLow_p-1);
    165165        // Window on Gaussian
    166         Int iclo(windowLow_p);
    167         Int ichi(windowLow_p);
     166        casacore::Int iclo(windowLow_p);
     167        casacore::Int ichi(windowLow_p);
    168168        // Peak counter
    169         Int nmax = 0;
     169        casacore::Int nmax = 0;
    170170        GaussianSpectralElement tspel;
    171171        while (++i < windowEnd_p) {
     
    187187                case 2: {
    188188                        // Some moments
    189                         Double m0m(0);
    190                         Double m0(0);
    191                         Double m1(0);
    192                         Double m2(0);
     189                        casacore::Double m0m(0);
     190                        casacore::Double m0(0);
     191                        casacore::Double m1(0);
     192                        casacore::Double m2(0);
    193193                        ichi = i;
    194194                        // Do Schwarz' calculation
    195                         Double b = deriv_p[iclo];
    196                         Double a = (deriv_p[ichi] - b) / (ichi-iclo);
    197                         for (Int ic=iclo; ic<=ichi; ic++) {
     195                        casacore::Double b = deriv_p[iclo];
     196                        casacore::Double a = (deriv_p[ichi] - b) / (ichi-iclo);
     197                        for (casacore::Int ic=iclo; ic<=ichi; ic++) {
    198198                                m0m += min(deriv_p[ic], 0.0);
    199                                 Double wi = deriv_p[ic] - a*(ic-iclo) - b;
     199                                casacore::Double wi = deriv_p[ic] - a*(ic-iclo) - b;
    200200                                m0 += wi;
    201201                                m1 += wi*ic;
     
    203203                        };
    204204                        // determinant
    205                         Double det = m2*m0 - m1*m1;
     205                        casacore::Double det = m2*m0 - m1*m1;
    206206                        if (det > 0.0 && fabs(m0m) >  FLT_EPSILON) {
    207                                 Double   xm = m1/m0;
    208                                 Double sg = 1.69*sqrt(det) / fabs(m0);
     207                                casacore::Double   xm = m1/m0;
     208                                casacore::Double sg = 1.69*sqrt(det) / fabs(m0);
    209209                                // Width above critical?
    210210                                if (sg > sigmin_p) {
    211                                         Int is = Int(1.73*sg+0.5);
    212                                         Int im = Int(xm+0.5);
    213                                         Double yl(0);
     211                                        casacore::Int is = casacore::Int(1.73*sg+0.5);
     212                                        casacore::Int im = casacore::Int(xm+0.5);
     213                                        casacore::Double yl(0);
    214214                                        if ((im-is) >= 0) yl = prof(im-is);
    215                                         Double yh(0);
    216                                         if ((im + is) <= Int(lprof_p-1)) yh = prof(im+is);
    217                                         Double ym = prof(im);
     215                                        casacore::Double yh(0);
     216                                        if ((im + is) <= casacore::Int(lprof_p-1)) yh = prof(im+is);
     217                                        casacore::Double ym = prof(im);
    218218                    // modified by dmehringer 2012apr03 to deal with 0 denominator
    219219                    // 0.0/0.0 produces NaN on Linux but 0 on OSX
    220                     Double pg = (ym-0.5*(yh+yl));
     220                    casacore::Double pg = (ym-0.5*(yh+yl));
    221221                                        if (pg != 0) {
    222                                                 Double denom = (1.0-exp(-0.5*(is*is)/sg/sg));
     222                                                casacore::Double denom = (1.0-exp(-0.5*(is*is)/sg/sg));
    223223                                                if (denom == 0) {
    224224                                                        throw AipsError("Bailing because division by zero is undefined");
     
    252252
    253253template <class MT>
    254 GaussianSpectralElement SpectralEstimate::convertElement (const Vector<MT>& x,
     254GaussianSpectralElement SpectralEstimate::convertElement (const casacore::Vector<MT>& x,
    255255                                                  const GaussianSpectralElement& el) const
    256256{
    257257        GaussianSpectralElement elOut = el;
    258    const Int& idxMax = x.nelements()-1;
     258   const casacore::Int& idxMax = x.nelements()-1;
    259259
    260260// Get current (pars are amp, center, width as the SpectralElement
    261261// will always be a Gaussian)
    262262
    263    Vector<Double> par, err;
     263   casacore::Vector<casacore::Double> par, err;
    264264   el.get(par);
    265265   el.getError(err);
     
    267267// Center
    268268
    269    Int cenIdx = Int(par[1]);
     269   casacore::Int cenIdx = casacore::Int(par[1]);
    270270
    271271// Get the x-increment, local to the center, as best we can from
     
    273273// vector is monotonic
    274274
    275    Double incX;
     275   casacore::Double incX;
    276276   if (cenIdx-1<0) {
    277277      incX = x[1] - x[0];
     
    287287      par[1] = incX*(par[1]-idxMax) + x[idxMax];   // Extrapolate from x[idxMax]
    288288   } else {
    289       Double dIdx = par[1] - cenIdx;
    290       par[1] = x[cenIdx] + dIdx*incX;              // Interpolate
     289      casacore::Double dIdx = par[1] - cenIdx;
     290      par[1] = x[cenIdx] + dIdx*incX;              // casacore::Interpolate
    291291   }
    292292   err[1] = abs(err[1] * incX);
Note: See TracChangeset for help on using the changeset viewer.