Changeset 1373 for trunk/src/STMath.cpp
- Timestamp:
- 07/12/07 11:43:56 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r1336 r1373 1007 1007 } 1008 1008 1009 CountedPtr< Scantable > STMath::smoothOther( const CountedPtr< Scantable >& in, 1010 const std::string& kernel, 1011 float width ) 1012 { 1013 CountedPtr< Scantable > out = getScantable(in, false); 1014 Table& table = out->table(); 1015 ArrayColumn<Float> specCol(table, "SPECTRA"); 1016 ArrayColumn<uChar> flagCol(table, "FLAGTRA"); 1017 Vector<Float> spec; 1018 Vector<uChar> flag; 1019 for ( uInt i=0; i<table.nrow(); ++i) { 1020 specCol.get(i, spec); 1021 flagCol.get(i, flag); 1022 Vector<Bool> mask(flag.nelements()); 1023 convertArray(mask, flag); 1024 Vector<Float> specout; 1025 Vector<Bool> maskout; 1026 if ( kernel == "hanning" ) { 1027 mathutil::hanning(specout, maskout, spec , !mask); 1028 convertArray(flag, !maskout); 1029 } else if ( kernel == "rmedian" ) { 1030 mathutil::runningMedian(specout, maskout, spec , mask, width); 1031 convertArray(flag, maskout); 1032 } 1033 flagCol.put(i, flag); 1034 specCol.put(i, specout); 1035 } 1036 return out; 1037 } 1038 1009 1039 CountedPtr< Scantable > STMath::smooth( const CountedPtr< Scantable >& in, 1010 1040 const std::string& kernel, float width ) 1011 1041 { 1042 if (kernel == "rmedian" || kernel == "hanning") { 1043 return smoothOther(in, kernel, width); 1044 } 1012 1045 CountedPtr< Scantable > out = getScantable(in, false); 1013 1046 Table& table = out->table(); … … 1032 1065 convertArray(mask, flag); 1033 1066 Vector<Float> specout; 1034 if ( type == VectorKernel::HANNING ) { 1035 Vector<Bool> maskout; 1036 mathutil::hanning(specout, maskout, spec , !mask); 1037 convertArray(flag, !maskout); 1038 flagCol.put(i, flag); 1039 specCol.put(i, specout); 1040 } else { 1041 mathutil::replaceMaskByZero(specout, mask); 1042 conv.linearConv(specout, spec); 1043 specCol.put(i, specout); 1044 } 1067 mathutil::replaceMaskByZero(specout, mask); 1068 conv.linearConv(specout, spec); 1069 specCol.put(i, specout); 1045 1070 } 1046 1071 ++iter;
Note: See TracChangeset
for help on using the changeset viewer.