- Timestamp:
- 09/01/06 13:14:11 (18 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STFitter.cpp
r1067 r1232 64 64 funcs_.resize(0,True); 65 65 parameters_.resize(); 66 fixedpar_.resize(); 66 67 error_.resize(); 67 68 thefit_.resize(); … … 205 206 if (parameters_.nelements() > 0 && tmppar.nelements() != parameters_.nelements()) 206 207 throw (AipsError("Number of parameters inconsistent with function.")); 207 if (parameters_.nelements() == 0) 208 if (parameters_.nelements() == 0) { 208 209 parameters_.resize(tmppar.nelements()); 209 fixedpar_.resize(tmppar.nelements()); 210 fixedpar_ = False; 210 if (tmppar.nelements() != fixedpar_.nelements()) { 211 fixedpar_.resize(tmppar.nelements()); 212 fixedpar_ = False; 213 } 214 } 211 215 if (dynamic_cast<Gaussian1D<Float>* >(funcs_[0]) != 0) { 212 216 uInt count = 0; … … 224 228 } 225 229 } 230 // reset 231 if (params.size() == 0) { 232 parameters_.resize(); 233 fixedpar_.resize(); 234 } 226 235 return true; 227 236 } … … 229 238 bool Fitter::setFixedParameters(std::vector<bool> fixed) 230 239 { 231 Vector<Bool> tmp(fixed);232 240 if (funcs_.nelements() == 0) 233 241 throw (AipsError("Function not yet set.")); 234 if (fixedpar_.nelements() > 0 && tmp.nelements() != fixedpar_.nelements())242 if (fixedpar_.nelements() > 0 && fixed.size() != fixedpar_.nelements()) 235 243 throw (AipsError("Number of mask elements inconsistent with function.")); 244 if (fixedpar_.nelements() == 0) { 245 fixedpar_.resize(parameters_.nelements()); 246 fixedpar_ = False; 247 } 236 248 if (dynamic_cast<Gaussian1D<Float>* >(funcs_[0]) != 0) { 237 249 uInt count = 0; 238 250 for (uInt j=0; j < funcs_.nelements(); ++j) { 239 251 for (uInt i=0; i < funcs_[j]->nparameters(); ++i) { 240 funcs_[j]->mask(i) = ! tmp[count];241 fixedpar_[count] = !tmp[count];252 funcs_[j]->mask(i) = !fixed[count]; 253 fixedpar_[count] = fixed[count]; 242 254 ++count; 243 255 } … … 245 257 } else if (dynamic_cast<Polynomial<Float>* >(funcs_[0]) != 0) { 246 258 for (uInt i=0; i < funcs_[0]->nparameters(); ++i) { 247 fixedpar_[i] = tmp[i]; 248 funcs_[0]->mask(i) = tmp[i]; 249 } 250 } 251 //fixedpar_ = !tmpmsk; 259 fixedpar_[i] = fixed[i]; 260 funcs_[0]->mask(i) = !fixed[i]; 261 } 262 } 252 263 return true; 253 264 } … … 263 274 Vector<Bool> out(parameters_.nelements()); 264 275 if (fixedpar_.nelements() == 0) { 265 out = False;276 return std::vector<bool>(); 266 277 //throw (AipsError("No parameter mask set.")); 267 278 } else { … … 312 323 residual_ = y_; 313 324 fitter.residual(residual_,x_); 314 315 325 // use fitter.residual(model=True) to get the model 316 326 thefit_.resize(x_.nelements()); -
trunk/src/STMath.cpp
r1203 r1232 211 211 ArrayColumn<Float> tsysColOut(tout,"TSYS"); 212 212 ScalarColumn<uInt> scanColOut(tout,"SCANNO"); 213 ScalarColumn<Double> intColOut(tout, "INTERVAL"); 213 214 Table tmp = in->table().sort("BEAMNO"); 214 215 Block<String> cols(3); … … 227 228 ROArrayColumn<Float> specCol, tsysCol; 228 229 ROArrayColumn<uChar> flagCol; 230 ROScalarColumn<Double> intCol(subt, "INTERVAL"); 229 231 specCol.attach(subt,"SPECTRA"); 230 232 flagCol.attach(subt,"FLAGTRA"); … … 255 257 flagColOut.put(outrowCount, outflag); 256 258 tsysColOut.put(outrowCount, outtsys); 257 259 Double intsum = sum(intCol.getColumn()); 260 intColOut.put(outrowCount, intsum); 258 261 ++outrowCount; 259 262 ++iter; … … 1126 1129 const std::string& weight ) 1127 1130 { 1128 if (in->getPolType() != "linear" || in->npol() != 2 ) 1129 throw(AipsError("averagePolarisations can only be applied to two linear polarisations.")); 1131 if (in->npol() < 2 ) 1132 throw(AipsError("averagePolarisations can only be applied to two or more" 1133 "polarisations")); 1130 1134 bool insitu = insitu_; 1131 1135 setInsitu(false); 1132 CountedPtr< Scantable > pols = getScantable(in, false);1136 CountedPtr< Scantable > pols = getScantable(in, true); 1133 1137 setInsitu(insitu); 1134 1138 Table& tout = pols->table(); 1135 // give all rows the same POLNO 1139 std::string taql = "SELECT FROM $1 WHERE POLNO IN [0,1]"; 1140 Table tab = tableCommand(taql, in->table()); 1141 if (tab.nrow() == 0 ) 1142 throw(AipsError("Could not find any rows with POLNO==0 and POLNO==1")); 1143 TableCopy::copyRows(tout, tab); 1136 1144 TableVector<uInt> vec(tout, "POLNO"); 1137 1145 vec = 0; 1138 1146 pols->table_.rwKeywordSet().define("nPol", Int(1)); 1147 pols->table_.rwKeywordSet().define("POLTYPE", String("stokes")); 1139 1148 std::vector<CountedPtr<Scantable> > vpols; 1140 1149 vpols.push_back(pols); 1141 CountedPtr< Scantable > out = average(vpols, mask, weight, " NONE");1150 CountedPtr< Scantable > out = average(vpols, mask, weight, "SCAN"); 1142 1151 return out; 1143 1152 } … … 1159 1168 std::vector<CountedPtr<Scantable> > vbeams; 1160 1169 vbeams.push_back(beams); 1161 CountedPtr< Scantable > out = average(vbeams, mask, weight, " NONE");1170 CountedPtr< Scantable > out = average(vbeams, mask, weight, "SCAN"); 1162 1171 return out; 1163 1172 }
Note:
See TracChangeset
for help on using the changeset viewer.