Source
324
324
casacore::Bool bValid;
325
325
casacore::uInt uiNumSPW;
326
326
casacore::Vector<casacore::uInt> oSPW;
327
327
casacore::Vector<casacore::uInt> oNumChannel;
328
328
casacore::Vector<casacore::Vector<casacore::Double> > oFrequency;
329
329
SPW_INFO( const casacore::String& oTableName );
330
330
SPW_INFO( const SPW_INFO& oSPWInfoIn );
331
331
SPW_INFO( void );
332
332
~SPW_INFO( void );
333
333
SPW_INFO& operator=( const SPW_INFO& oSPWInfoIn );
334
-
casacore::Bool freq( const casacore::Vector<casacore::uInt>& oSPWIn,
334
+
casacore::Bool& freq( const casacore::Vector<casacore::uInt>& oSPWIn,
335
335
const casacore::Vector<casacore::Vector<casacore::uInt> >& oChannelIn,
336
336
casacore::Vector<casacore::Double>& oFreqOut ) const;
337
-
casacore::Bool spwInfoCheck( const casacore::Vector<casacore::uInt>& oSPWIn,
337
+
casacore::Bool& spwInfoCheck( const casacore::Vector<casacore::uInt>& oSPWIn,
338
338
const casacore::Vector<casacore::Vector<casacore::uInt> >& oChannelIn, casacore::Vector<casacore::uInt>& oSPWOut,
339
339
casacore::Vector<casacore::Vector<casacore::uInt> >& oChannelOut ) const;
340
340
};
341
341
342
342
// INPUT nested class (allowed T: CalStats::NONE, CalStatsFitter::FIT, or
343
343
// CalStatsHist::HIST), used to hold the vector output of stats<T>()
344
344
class INPUT {
345
345
public:
346
346
casacore::Vector<casacore::uInt> oField;
347
347
casacore::Vector<casacore::uInt> oAntenna1;
364
364
template <typename T>
365
365
class OUTPUT {
366
366
public:
367
367
casacore::uInt uiField;
368
368
casacore::uInt uiAntenna1;
369
369
casacore::Int iAntenna2;
370
370
RAP eRAP;
371
371
casacore::Bool bNorm;
372
372
casacore::Bool bUnwrap;
373
373
casacore::Double dJumpMax;
374
-
std::shared_ptr<casacore::Matrix<CalStats::OUT<T> >> oOut;
374
+
casacore::Matrix<CalStats::OUT<T> > oOut;
375
375
};
376
376
377
377
// Generic constructor
378
378
CalAnalysis( const casacore::String& oTableName );
379
379
380
380
// Destructor
381
381
virtual ~CalAnalysis( void );
382
382
383
383
// Return the calibration table name and keyword private variables
384
-
casacore::String calName( void ) const;
385
-
casacore::String msName( void ) const;
386
-
casacore::String visCal( void ) const;
387
-
casacore::String parType( void ) const;
388
-
casacore::String polBasis( void ) const;
384
+
casacore::String& calName( void ) const;
385
+
casacore::String& msName( void ) const;
386
+
casacore::String& visCal( void ) const;
387
+
casacore::String& parType( void ) const;
388
+
casacore::String& polBasis( void ) const;
389
389
390
390
// Get the fields, antennas, times, and feeds
391
391
// spectral windows
392
-
casacore::Vector<casacore::uInt> field( void ) const;
393
-
casacore::Vector<casacore::uInt> antenna( void ) const;
394
-
casacore::Vector<casacore::uInt> antenna1( void ) const;
395
-
casacore::Vector<casacore::Int> antenna2( void ) const;
396
-
casacore::Vector<casacore::Double> time( void ) const;
397
-
casacore::Vector<casacore::String> feed( void ) const;
392
+
casacore::Vector<casacore::uInt>& field( void ) const;
393
+
casacore::Vector<casacore::uInt>& antenna( void ) const;
394
+
casacore::Vector<casacore::uInt>& antenna1( void ) const;
395
+
casacore::Vector<casacore::Int>& antenna2( void ) const;
396
+
casacore::Vector<casacore::Double>& time( void ) const;
397
+
casacore::Vector<casacore::String>& feed( void ) const;
398
398
399
399
// Get the number of spectral windows, spectral windows, number of channels
400
400
// for each spectral window, and frequencies for each spectral window
401
-
casacore::uInt numspw( void ) const;
402
-
casacore::Vector<casacore::uInt> spw( void ) const;
403
-
casacore::Vector<casacore::uInt> numChannel( void ) const;
404
-
casacore::Vector<casacore::Vector<casacore::Double> > freq( void ) const;
401
+
casacore::uInt& numspw( void ) const;
402
+
casacore::Vector<casacore::uInt>& spw( void ) const;
403
+
casacore::Vector<casacore::uInt>& numChannel( void ) const;
404
+
casacore::Vector<casacore::Vector<casacore::Double> >& freq( void ) const;
405
405
406
406
// Calculate statistics for the specified fields, antennas, time range,
407
407
// feeds, spectral windows, and channels (allowed T: CalStats::NONE gets
408
408
// data without calculating statistics, CalStatsFitter::FIT calculates fits,
409
409
// and CalStatsHist::HIST calculates histogram statistics).
410
410
template <typename T>
411
-
std::shared_ptr<casacore::Vector<OUTPUT<T>> > stats( const INPUT& oInput,
411
+
casacore::Vector<OUTPUT<T> >& stats( const INPUT& oInput,
412
412
const CalStats::ARG<T>& oArg );
413
413
414
414
// casacore::Function to determine whether a value is present in an array
415
415
template <typename T>
416
-
static casacore::Bool exists( const T& tValue, const casacore::Vector<T>& oValue );
416
+
static casacore::Bool& exists( const T& tValue, const casacore::Vector<T>& oValue );
417
417
418
418
// casacore::Function to determine the index of a value present in an array
419
419
template <typename T>
420
-
static casacore::Bool where( const T& tValue, const casacore::Vector<T>& oInput,
420
+
static casacore::Bool& where( const T& tValue, const casacore::Vector<T>& oInput,
421
421
casacore::uInt& uiIndex );
422
422
423
-
// casacore::Function to calculate sorted unique values of a vector
423
+
// casacore::Function to return sorted unique values of a vector
424
424
template <typename T>
425
-
static void unique( const casacore::Vector<T>& oVector, casacore::Vector<T>& );
425
+
static casacore::Vector<T>& unique( const casacore::Vector<T>& oVector );
426
426
427
427
private:
428
428
429
429
// Get the calibration table name and set the private variable
430
430
casacore::String oCalName;
431
-
casacore::String calNameGet( const casacore::String& oTableName );
431
+
casacore::String& calNameGet( const casacore::String& oTableName );
432
432
void calNameSet( const casacore::String& oCalNameIn );
433
433
434
434
// Get the associated casacore::MS name and set the private variable
435
435
casacore::String oMSName;
436
-
casacore::String msNameGet( const casacore::String& oTableName );
436
+
casacore::String& msNameGet( const casacore::String& oTableName );
437
437
void msNameSet( const casacore::String& oMSNameIn );
438
438
439
439
// Get the visibility calibration type and set the private variable
440
440
casacore::String oVisCal;
441
-
casacore::String visCalGet( const casacore::String& oTableName );
441
+
casacore::String& visCalGet( const casacore::String& oTableName );
442
442
void visCalSet( const casacore::String& oVisCalIn );
443
443
444
444
// Get the parameter column type and set the private variable
445
445
casacore::String oParType;
446
-
casacore::String parTypeGet( const casacore::String& oTableName );
446
+
casacore::String& parTypeGet( const casacore::String& oTableName );
447
447
void parTypeSet( const casacore::String& oParTypeIn );
448
448
449
449
// Get the polarization basis and set the private variable
450
450
casacore::String oPolBasis;
451
-
casacore::String polBasisGet( const casacore::String& oTableName );
451
+
casacore::String& polBasisGet( const casacore::String& oTableName );
452
452
void polBasisSet( const casacore::String& oPolBasisIn );
453
453
454
454
// Get the field numbers and set the private variables
455
455
casacore::uInt uiNumField; casacore::Vector<casacore::uInt> oField;
456
-
casacore::Vector<casacore::uInt> fieldGet( const casacore::String& oTableName );
456
+
casacore::Vector<casacore::uInt>& fieldGet( const casacore::String& oTableName );
457
457
void fieldSet( const casacore::Vector<casacore::uInt>& oFieldIn );
458
-
casacore::Bool fieldCheck( const casacore::Vector<casacore::uInt>& oFieldIn,
458
+
casacore::Bool& fieldCheck( const casacore::Vector<casacore::uInt>& oFieldIn,
459
459
casacore::Vector<casacore::uInt>& oFieldOut ) const;
460
460
461
461
// Get the antenna numbers and set the private variables
462
462
casacore::uInt uiNumAntenna; casacore::Vector<casacore::uInt> oAntenna;
463
-
casacore::Vector<casacore::uInt> antennaGet( const casacore::String& oTableName );
463
+
casacore::Vector<casacore::uInt>& antennaGet( const casacore::String& oTableName );
464
464
void antennaSet( const casacore::Vector<casacore::uInt>& oAntennaIn );
465
465
466
466
// Get the antenna 1 numbers and set the private variables
467
467
casacore::uInt uiNumAntenna1; casacore::Vector<casacore::uInt> oAntenna1;
468
-
casacore::Vector<casacore::uInt> antenna1Get( const casacore::String& oTableName );
468
+
casacore::Vector<casacore::uInt>& antenna1Get( const casacore::String& oTableName );
469
469
void antenna1Set( const casacore::Vector<casacore::uInt>& oAntenna1In );
470
-
casacore::Bool antenna1Check( const casacore::Vector<casacore::uInt>& oAntenna1In,
470
+
casacore::Bool& antenna1Check( const casacore::Vector<casacore::uInt>& oAntenna1In,
471
471
casacore::Vector<casacore::uInt>& oAntenna1Out ) const;
472
472
473
473
// Get the antenna 2 numbers and set the private variables
474
474
casacore::uInt uiNumAntenna2; casacore::Vector<casacore::Int> oAntenna2;
475
-
casacore::Vector<casacore::Int> antenna2Get( const casacore::String& oTableName );
475
+
casacore::Vector<casacore::Int>& antenna2Get( const casacore::String& oTableName );
476
476
void antenna2Set( const casacore::Vector<casacore::Int>& oAntenna2In );
477
-
casacore::Bool antenna2Check( const casacore::Vector<casacore::Int>& oAntenna2In,
477
+
casacore::Bool& antenna2Check( const casacore::Vector<casacore::Int>& oAntenna2In,
478
478
casacore::Vector<casacore::Int>& oAntenna2Out ) const;
479
479
480
480
// Get the times and set the private variables
481
481
casacore::uInt uiNumTime; casacore::Vector<casacore::Double> oTime;
482
-
casacore::Vector<casacore::Double> timeGet( const casacore::String& oTableName );
482
+
casacore::Vector<casacore::Double>& timeGet( const casacore::String& oTableName );
483
483
void timeSet( const casacore::Vector<casacore::Double>& oTimeIn );
484
-
casacore::Bool timeCheck( const casacore::Double& dStartTimeIn, const casacore::Double& dStopTimeIn,
484
+
casacore::Bool& timeCheck( const casacore::Double& dStartTimeIn, const casacore::Double& dStopTimeIn,
485
485
casacore::Double& dStartTimeOut, casacore::Double& dStopTimeOut,
486
486
casacore::Vector<casacore::Double>& oTimeOut ) const;
487
487
488
488
// Get the feeds and set the private variables
489
489
casacore::uInt uiNumFeed; casacore::Vector<casacore::String> oFeed;
490
-
casacore::Vector<casacore::String> feedGet( const casacore::String& oTableName );
490
+
casacore::Vector<casacore::String>& feedGet( const casacore::String& oTableName );
491
491
void feedSet( const casacore::Vector<casacore::String>& oFeedIn );
492
-
casacore::Bool feedCheck( const casacore::Vector<casacore::String>& oFeedIn,
492
+
casacore::Bool& feedCheck( const casacore::Vector<casacore::String>& oFeedIn,
493
493
casacore::Vector<casacore::String>& oFeedOut ) const;
494
494
495
495
// Get the spectral window information and set the private variables
496
496
SPW_INFO oSPWInfo;
497
497
SPW_INFO& spwInfoGet( const casacore::String& oTableName );
498
498
void spwInfoSet( const SPW_INFO& oSPWInfoIn );
499
499
500
500
// Check and possibly fix the inputs to the stats<T>() member function
501
-
casacore::Bool statsCheckInput( const CalAnalysis::INPUT& oInputIn,
501
+
casacore::Bool& statsCheckInput( const CalAnalysis::INPUT& oInputIn,
502
502
CalAnalysis::INPUT& oInputOut );
503
503
504
504
// Gets the data from the new format calibration table grouped according to
505
505
// unique combinations of (field,antenna1,antenna2)
506
-
casacore::Bool getGroup( const NewCalTable& oNCT, const CalAnalysis::INPUT& oInput,
506
+
casacore::Bool& getGroup( const NewCalTable& oNCT, const CalAnalysis::INPUT& oInput,
507
507
casacore::Vector<casacore::uInt>& oFieldGroup, casacore::Vector<casacore::uInt>& oAntenna1Group,
508
508
casacore::Vector<casacore::Int>& oAntenna2Group, casacore::Vector<casacore::Vector<casacore::Double> >& oTimeUniqueGroup,
509
509
casacore::Vector<casacore::Vector<casacore::Double> >& oFreqGroup,
510
510
casacore::Vector<casacore::Cube<casacore::DComplex> >& oCParamGroup,
511
511
casacore::Vector<casacore::Cube<casacore::Double> >& oFParamGroup,
512
512
casacore::Vector<casacore::Cube<casacore::Double> >& oParamErrGroup,
513
513
casacore::Vector<casacore::Cube<casacore::Bool> >& oFlagGroup ) const;
514
514
515
515
// Select the rows based on the inputs
516
-
casacore::Bool rowSelect( const NewCalTable& oNCT, const CalAnalysis::INPUT& oInput,
516
+
casacore::Bool& rowSelect( const NewCalTable& oNCT, const CalAnalysis::INPUT& oInput,
517
517
casacore::Vector<casacore::uInt>& oRowSelect ) const;
518
518
519
519
// Return rows and other quantities for each group
520
-
casacore::Bool rowGroup( const NewCalTable& oNCT, const casacore::Vector<casacore::uInt>& oRowSelect,
520
+
casacore::Bool& rowGroup( const NewCalTable& oNCT, const casacore::Vector<casacore::uInt>& oRowSelect,
521
521
casacore::Vector<casacore::Vector<casacore::uInt> >& oRowGroup, casacore::Vector<casacore::uInt>& oFieldGroup,
522
522
casacore::Vector<casacore::uInt>& oAntenna1Group, casacore::Vector<casacore::Int>& oAntenna2Group,
523
523
casacore::Vector<casacore::Vector<casacore::uInt> >& oSPWGroup,
524
524
casacore::Vector<casacore::Vector<casacore::uInt> >& oSPWUniqueGroup,
525
525
casacore::Vector<casacore::Vector<casacore::Double> >& oTimeGroup,
526
526
casacore::Vector<casacore::Vector<casacore::Double> >& oTimeUniqueGroup ) const;
527
527
528
528
// casacore::Map the spectral windows and determine the start channels (for
529
529
// concatenating frequencies from different spectral windows)
530
-
casacore::Bool chanSPW( const casacore::Vector<casacore::uInt>& oSPW, const INPUT& oInput,
530
+
casacore::Bool& chanSPW( const casacore::Vector<casacore::uInt>& oSPW, const INPUT& oInput,
531
531
casacore::Vector<casacore::uInt>& oSPWMap, casacore::Vector<casacore::uInt>& oChanStart ) const;
532
532
533
533
// Get the frequencies for each goup
534
-
casacore::Bool freqGroup( const INPUT& oInput,
534
+
casacore::Bool& freqGroup( const INPUT& oInput,
535
535
const casacore::Vector<casacore::Vector<casacore::uInt> >& oSPWUniqueGroup,
536
536
casacore::Vector<casacore::Vector<casacore::Double> >& oFreqGroup ) const;
537
537
538
538
// Get the data cubes for each group
539
-
casacore::Bool cubeGroup( const NewCalTable& oNCT, const INPUT& oInput,
539
+
casacore::Bool& cubeGroup( const NewCalTable& oNCT, const INPUT& oInput,
540
540
const casacore::Vector<casacore::Vector<casacore::uInt> >& oRowGroup,
541
541
const casacore::Vector<casacore::Vector<casacore::uInt> >& oSPWGroup,
542
542
const casacore::Vector<casacore::Vector<casacore::uInt> >& oSPWUniqueGroup,
543
543
const casacore::Vector<casacore::Vector<casacore::Double> >& oTimeGroup,
544
544
const casacore::Vector<casacore::Vector<casacore::Double> >& oTimeUniqueGroup,
545
545
const casacore::Vector<casacore::Vector<casacore::Double> >& oFreqGroup,
546
546
casacore::Vector<casacore::Cube<casacore::DComplex> >& oCParamGroup,
547
547
casacore::Vector<casacore::Cube<casacore::Double> >& oFParamGroup,
548
548
casacore::Vector<casacore::Cube<casacore::Double> >& oParamErrGroup,
549
549
casacore::Vector<casacore::Cube<casacore::Bool> >& oFlagGroup ) const;
630
630
CalStats<T>().
631
631
2012 May 06 - Nick Elias, NRAO
632
632
The data reorganization has been moved to private member function
633
633
getGroup() and is called from here.
634
634
635
635
*/
636
636
637
637
// -----------------------------------------------------------------------------
638
638
639
639
template <typename T>
640
-
std::shared_ptr<casacore::Vector<CalAnalysis::OUTPUT<T>> > CalAnalysis::stats(
640
+
casacore::Vector<CalAnalysis::OUTPUT<T> >& CalAnalysis::stats(
641
641
const CalAnalysis::INPUT& oInput, const CalStats::ARG<T>& oArg ) {
642
642
643
643
// Initialize the output vector containing statistics for each field ID,
644
644
// antenna 1, and antenna 2
645
645
646
-
std::shared_ptr<casacore::Vector<CalAnalysis::OUTPUT<T> >>
647
-
poOutput(new casacore::Vector<CalAnalysis::OUTPUT<T> >());
648
-
646
+
casacore::Vector<CalAnalysis::OUTPUT<T> >* poOutput =
647
+
new casacore::Vector<CalAnalysis::OUTPUT<T> >();
649
648
650
649
651
650
// Check and fix the inputs
652
651
653
652
INPUT oInputNew;
654
653
655
654
casacore::Bool bCheck = statsCheckInput( oInput, oInputNew );
656
655
657
656
if ( !bCheck ) {
658
657
casacore::LogIO log( casacore::LogOrigin( "CalAnalysis", "stats<T>()", WHERE ) );
659
658
log << casacore::LogIO::WARN << "Invalid parameter(s)" << casacore::LogIO::POST;
660
-
return poOutput;
659
+
return( *poOutput );
661
660
}
662
661
663
662
664
663
// Create an instance of the new format calibration table class
665
664
// Use createCT to enforce backward compatibility
666
665
NewCalTable oNCT = NewCalTable::createCT( oCalName, casacore::Table::Old, casacore::Table::Memory );
667
666
668
667
669
668
// Get the cubes for each group
670
669
680
679
casacore::Vector<casacore::Cube<casacore::Double> > oParamErrGroup;
681
680
casacore::Vector<casacore::Cube<casacore::Bool> > oFlagGroup;
682
681
683
682
casacore::Bool bGetGroup = getGroup( oNCT, oInputNew, oFieldGroup, oAntenna1Group,
684
683
oAntenna2Group, oTimeUniqueGroup, oFreqGroup, oCParamGroup, oFParamGroup,
685
684
oParamErrGroup, oFlagGroup );
686
685
687
686
if ( !bGetGroup ) {
688
687
casacore::LogIO log( casacore::LogOrigin( "CalAnalysis", "stats<T>()", WHERE ) );
689
688
log << casacore::LogIO::WARN << "Cannot parse group(s)" << casacore::LogIO::POST;
690
-
return poOutput;
689
+
return( *poOutput );
691
690
}
692
691
693
692
694
693
// Resize the output vector (each group corresponds to an element of
695
694
// casacore::Vector<OUTPUT<T> >())
696
695
697
696
casacore::uInt uiNumGroup = oFieldGroup.nelements();
698
697
699
698
poOutput->resize( uiNumGroup, false );
700
699
741
740
delete poCS;
742
741
743
742
}
744
743
745
744
catch ( casacore::AipsError oAE ) {
746
745
casacore::LogIO log( casacore::LogOrigin( "CalAnalysis", "stats<T>()", WHERE ) );
747
746
log << casacore::LogIO::WARN << oAE.getMesg()
748
747
<< ", iteration (field,antenna1,antenna2) = (" << oFieldGroup[g]
749
748
<< "," << oAntenna1Group[g] << "," << oAntenna2Group[g]
750
749
<< "), continuing ..." << casacore::LogIO::POST;
751
-
poOutput->operator[](g).oOut.reset(new casacore::Matrix<CalStats::OUT<T>>);
750
+
poOutput->operator[](g).oOut = CalStats::OUT<T>();
752
751
}
753
752
754
753
}
755
754
756
755
757
756
// Return the reference to the casacore::Vector<CalAnalysis::OUTPUT<T> > instance
758
757
759
-
return poOutput;
758
+
return( *poOutput );
760
759
761
760
}
762
761
763
762
// -----------------------------------------------------------------------------
764
763
// End of CalAnalysis template public member functions
765
764
// -----------------------------------------------------------------------------
766
765
767
766
// -----------------------------------------------------------------------------
768
767
// Start of CalAnalysis template static public member functions
769
768
// -----------------------------------------------------------------------------
788
787
Modification history:
789
788
---------------------
790
789
2012 Jan 20 - Nick Elias, NRAO
791
790
Initial version.
792
791
793
792
*/
794
793
795
794
// -----------------------------------------------------------------------------
796
795
797
796
template <typename T>
798
-
casacore::Bool CalAnalysis::exists( const T& tValue, const casacore::Vector<T>& oValue ) {
797
+
casacore::Bool& CalAnalysis::exists( const T& tValue, const casacore::Vector<T>& oValue ) {
799
798
800
799
// Determine whether the value is present in an array and return the boolean
801
800
802
-
casacore::Bool pbValue = false;
801
+
casacore::Bool* pbValue = new casacore::Bool( false );
803
802
804
803
for ( casacore::uInt v=0; v<oValue.nelements(); v++ ) {
805
-
if ( tValue == oValue[v] ) pbValue = true;
804
+
if ( tValue == oValue[v] ) *pbValue = true;
806
805
}
807
806
808
-
return pbValue;
807
+
return( *pbValue );
809
808
810
809
}
811
810
812
811
// -----------------------------------------------------------------------------
813
812
814
813
/*
815
814
816
815
CalAnalysis::where<T>
817
816
818
817
Description:
834
833
Modification history:
835
834
---------------------
836
835
2012 May 06 - Nick Elias, NRAO
837
836
Initial version.
838
837
839
838
*/
840
839
841
840
// -----------------------------------------------------------------------------
842
841
843
842
template <typename T>
844
-
casacore::Bool CalAnalysis::where( const T& tValue, const casacore::Vector<T>& oInput,
843
+
casacore::Bool& CalAnalysis::where( const T& tValue, const casacore::Vector<T>& oInput,
845
844
casacore::uInt& uiIndex ) {
846
845
847
846
// Find the index in the input vector
848
847
849
848
for ( casacore::uInt i=0; i<oInput.nelements(); i++ ) {
850
849
if ( oInput[i] == tValue ) {
851
850
uiIndex = i;
852
851
break;
853
852
}
854
853
}
855
854
856
855
857
856
// If the value was found return true, otherwise return false
858
857
859
-
casacore::Bool pbSuccess;
858
+
casacore::Bool* pbSuccess = new casacore::Bool;
860
859
861
860
if ( uiIndex < oInput.nelements() ) {
862
-
pbSuccess = true;
861
+
*pbSuccess = true;
863
862
} else {
864
-
pbSuccess = false;
863
+
*pbSuccess = false;
865
864
}
866
865
867
-
return pbSuccess;
866
+
return( *pbSuccess );
868
867
869
868
}
870
869
871
870
// -----------------------------------------------------------------------------
872
871
873
872
/*
874
873
875
874
CalAnalysis::unique<T>
876
875
877
876
Description:
878
877
------------
879
-
This member produces a unique sorted vector from an input vector.
878
+
This member function returns a unique sorted vector from an input vector.
880
879
881
880
Inputs:
882
881
-------
883
882
oVector - This reference to a casacore::Vector<T> instance contains the values.
884
-
poVectorUnique - The reference to the unique sorted casacore::Vector<T> instance.
885
883
886
884
Outputs:
887
885
--------
888
-
---
886
+
The reference to the unique sorted casacore::Vector<T> instance, returned via the function
887
+
value.
889
888
890
889
Modification history:
891
890
---------------------
892
891
2012 Jan 20 - Nick Elias, NRAO
893
892
Initial version.
894
893
895
894
*/
896
895
897
896
// -----------------------------------------------------------------------------
898
897
899
898
template <typename T>
900
-
void CalAnalysis::unique( const casacore::Vector<T>& oVector,
901
-
casacore::Vector<T>& poVectorUnique) {
899
+
casacore::Vector<T>& CalAnalysis::unique( const casacore::Vector<T>& oVector ) {
900
+
901
+
// Initialize the unique vector
902
+
903
+
casacore::Vector<T>* poVectorUnique = new casacore::Vector<T>();
904
+
902
905
903
906
// Form the unique vector
904
907
905
908
for ( casacore::uInt v1=0; v1<oVector.nelements(); v1++ ) {
906
909
907
910
casacore::Bool bDupe = false;
908
911
909
912
for ( casacore::uInt v2=0; v2<v1; v2++ ) {
910
913
if ( oVector[v1] == oVector[v2] ) {
911
914
bDupe = true;
912
915
break;
913
916
}
914
917
}
915
918
916
919
if ( !bDupe ) {
917
-
poVectorUnique.resize( poVectorUnique.nelements()+1, true );
918
-
poVectorUnique.operator[](poVectorUnique.nelements()-1) = oVector[v1];
920
+
poVectorUnique->resize( poVectorUnique->nelements()+1, true );
921
+
poVectorUnique->operator[](poVectorUnique->nelements()-1) = oVector[v1];
919
922
}
920
923
921
924
}
922
925
923
926
924
927
// casacore::Sort the unique vector
925
928
926
929
casacore::Sort::Order eOrder = casacore::Sort::Ascending;
927
930
casacore::Int iOptions = casacore::Sort::QuickSort;
928
931
929
-
casacore::GenSort<T>::sort( poVectorUnique, eOrder, (int) iOptions );
932
+
casacore::GenSort<T>::sort( *poVectorUnique, eOrder, (int) iOptions );
933
+
934
+
935
+
// Return the unique sorted vector
936
+
937
+
return( *poVectorUnique );
938
+
930
939
}
931
940
932
941
// -----------------------------------------------------------------------------
933
942
// End of CalAnalysis template static public member functions
934
943
// -----------------------------------------------------------------------------
935
944
936
945
};
937
946
938
947
// -----------------------------------------------------------------------------
939
948
// End of casa namespace