Changeset 992
- Timestamp:
- 04/06/06 10:12:03 (19 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r984 r992 232 232 233 233 def unique(x): 234 """ 235 Return the unique values in a list 236 Parameters: 237 x: the list to reduce 238 Examples: 239 x = [1,2,3,3,4] 240 print unique(x) 241 [1,2,3,4] 242 """ 234 243 return dict([ (val, 1) for val in x]).keys() 244 245 def list_files(path=".",suffix="rpf"): 246 """ 247 Return a list files readable by asap, such as rpf, sdfits, mbf, asap 248 Parameters: 249 path: The directory to list (default '.') 250 suffix: The file extension (default rpf) 251 Example: 252 files = list_files("data/","sdfits") 253 print files 254 ['data/2001-09-01_0332_P363.sdfits', 255 'data/2003-04-04_131152_t0002.sdfits', 256 'data/Sgr_86p262_best_SPC.sdfits'] 257 """ 258 import os 259 if not os.path.isdir(path): 260 return None 261 valid = "rpf sdf sdfits mbf asap".split() 262 if not suffix in valid: 263 return None 264 files = [os.path.expanduser(os.path.expandvars(path+"/"+f)) for f in os.listdir(path)] 265 return filter(lambda x: x.endswith(suffix),files) 235 266 236 267 # workaround for ipython, which redirects this if banner=0 in ipythonrc … … 335 366 all polarisations will contain the 336 367 averaged spectrum. 368 convert_pol - convert to a different polarisation type 337 369 auto_quotient - return the on/off quotient with 338 370 automatic detection of the on/off scans … … 417 449 print - print details about a variable 418 450 list_scans - list all scantables created bt the user 451 list_files - list all files readable by asap (default rpf) 419 452 del - delete the given variable from memory 420 453 range - create a list of values, e.g. -
trunk/python/scantable.py
r989 r992 974 974 if mask is None: 975 975 mask = () 976 s = s elf._math._averagepol(self, mask, weight)976 s = scantable(self._math._averagepol(self, mask, weight)) 977 977 s._add_history("average_pol",varlist) 978 978 print_log() 979 return scantable(s) 979 return s 980 981 def convert_pol(self, poltype=None): 982 """ 983 Convert the data to a different polarisation type. 984 Parameters: 985 poltype: The new polarisation type. Valid types are: 986 "linear", "stokes" and "circular" 987 """ 988 varlist = vars() 989 try: 990 s = scantable(self._math._convertpol(self, poltype)) 991 except RuntimeError,msg: 992 if rcParams['verbose']: 993 print msg 994 return 995 else: 996 raise 997 s._add_history("convert_pol",varlist) 998 print_log() 999 return s 980 1000 981 1001 def smooth(self, kernel="hanning", width=5.0, insitu=None): -
trunk/src/STMath.cpp
r985 r992 1128 1128 return out; 1129 1129 } 1130 1131 CountedPtr<Scantable> 1132 asap::STMath::convertPolarisation( const CountedPtr<Scantable>& in, 1133 const std::string & newtype ) 1134 { 1135 if (in->npol() != 2 && in->npol() != 4) 1136 throw(AipsError("Can only convert two or four polarisations.")); 1137 if ( in->getPolType() == newtype ) 1138 throw(AipsError("No need to convert.")); 1139 bool insitu = insitu_; 1140 setInsitu(false); 1141 CountedPtr< Scantable > out = getScantable(in, true); 1142 setInsitu(insitu); 1143 Table& tout = out->table(); 1144 tout.rwKeywordSet().define("POLTYPE", String(newtype)); 1145 1146 Block<String> cols(4); 1147 cols[0] = "SCANNO"; 1148 cols[1] = "CYCLENO"; 1149 cols[2] = "BEAMNO"; 1150 cols[3] = "IFNO"; 1151 TableIterator it(in->originalTable_, cols); 1152 String basetype = in->getPolType(); 1153 STPol* stpol = STPol::getPolClass(in->factories_, basetype); 1154 try { 1155 while ( !it.pastEnd() ) { 1156 Table tab = it.table(); 1157 uInt row = tab.rowNumbers()[0]; 1158 stpol->setSpectra(in->getPolMatrix(row)); 1159 Float fang,fhand,parang; 1160 fang = in->focusTable_.getTotalFeedAngle(in->mfocusidCol_(row)); 1161 fhand = in->focusTable_.getFeedHand(in->mfocusidCol_(row)); 1162 parang = in->paraCol_(row); 1163 /// @todo re-enable this 1164 // disable total feed angle to support paralactifying Caswell style 1165 stpol->setPhaseCorrections(parang, -parang, fhand); 1166 Int npolout = 0; 1167 for (uInt i=0; i<tab.nrow(); ++i) { 1168 Vector<Float> outvec = stpol->getSpectrum(i, newtype); 1169 if ( outvec.nelements() > 0 ) { 1170 tout.addRow(); 1171 TableCopy::copyRows(tout, tab, tout.nrow()-1, 0, 1); 1172 ArrayColumn<Float> sCol(tout,"SPECTRA"); 1173 ScalarColumn<uInt> pCol(tout,"POLNO"); 1174 sCol.put(tout.nrow()-1 ,outvec); 1175 pCol.put(tout.nrow()-1 ,uInt(npolout)); 1176 npolout++; 1177 } 1178 } 1179 tout.rwKeywordSet().define("nPol", npolout); 1180 ++it; 1181 } 1182 } catch (AipsError& e) { 1183 delete stpol; 1184 throw(e); 1185 } 1186 delete stpol; 1187 return out; 1188 } -
trunk/src/STMath.h
r977 r992 122 122 const std::string& method = "cubic" ); 123 123 124 casa::CountedPtr<Scantable> 125 convertPolarisation( const casa::CountedPtr<Scantable>& in, 126 const std::string& newtype); 127 124 128 private: 125 129 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in, -
trunk/src/STMathWrapper.h
r978 r992 126 126 { return ScantableWrapper(STMath::frequencyAlign(in.getCP())); } 127 127 128 ScantableWrapper convertPolarisation( const ScantableWrapper& in, 129 const std::string& newtype ) 130 { return ScantableWrapper(STMath::convertPolarisation(in.getCP(),newtype)); } 131 128 132 }; 129 133
Note:
See TracChangeset
for help on using the changeset viewer.