- Timestamp:
- 09/01/06 13:14:11 (18 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SConstruct
r1202 r1232 76 76 env = conf.Finish() 77 77 78 env["version"] = "2.1.0b "78 env["version"] = "2.1.0b1" 79 79 80 80 # general CPPFLAGS -
trunk/bin/install
r1210 r1232 29 29 for l in p.readlines(): 30 30 lsp = l.split() 31 if lsp[2] == "not": 32 unresolved.append(lsp[0]) 33 else: 34 resolved.append(lsp[2]) 31 # test this to avoid fails on linux_gate, which has no library 32 if len(lsp) >= 3: 33 if lsp[2] == "not": 34 unresolved.append(lsp[0]) 35 else: 36 resolved.append(lsp[2]) 35 37 return resolved, unresolved 36 38 … … 79 81 print " All required libraries are present." 80 82 except IOError,msg: 81 print msg+" Skipping test."83 print "Skipping test. (%s)" % msg 82 84 83 85 print 'Looking for dependent python modules...' -
trunk/python/asapfit.py
r974 r1232 55 55 } 56 56 comp.append(d) 57 k+=1 57 58 out.append(comp) 58 59 return out 60 61 def save(self, filename): 62 f = file(filename, 'w') 63 parstr = "" 64 for i in xrange(self.getcomponents()[0]): 65 pname = "P%d"% (i) 66 parstr += "%-12s " % (pname) 67 header = "#%-12s %s\n" % ("Function", parstr) 68 f.write(header) 69 i = 0 70 funcs=self.getfunctions() 71 pars=self.getparameters() 72 for c in self.getcomponents(): 73 line = " %-12s " % (funcs[i]) 74 for j in xrange(c): 75 line += "%3.8f " % (pars[i*c+j]) 76 i+=1 77 f.write(line+"\n") 78 f.close() 59 79 60 80 def _format_pars(self, pars, ftype, unit): … … 63 83 i = 0 64 84 for p in pars: 65 out += ' p%d = %3. 3f %s,' % (i,p,unit)85 out += ' p%d = %3.6f %s,' % (i,p,unit) 66 86 i+=1 67 87 out = out[1:-1] 68 88 elif ftype == 'gauss': 69 out += 'peak = %3. 3f , centre = %3.3f %s, FWHM = %3.3f %s' % (pars[0],pars[1],unit,pars[2],unit)89 out += 'peak = %3.6f , centre = %3.6f %s, FWHM = %3.6f %s' % (pars[0],pars[1],unit,pars[2],unit) 70 90 return out -
trunk/python/asapfitter.py
r1217 r1232 100 100 101 101 self.fitter.setexpression(self.fitfunc,n) 102 self.fitted = False 102 103 return 103 104 … … 142 143 self.fitter.estimate() 143 144 try: 145 fxdpar = list(self.fitter.getfixedparameters()) 146 if len(fxdpar) and fxdpar.count(0) == 0: 147 raise RuntimeError,"No point fitting, if all parameters are fixed." 144 148 converged = self.fitter.fit() 145 149 if not converged: … … 155 159 return 156 160 157 def store_fit(self): 158 """ 159 Store the fit parameters in the scantable. 161 def store_fit(self, filename=None): 162 """ 163 Save the fit parameters. 164 Parameters: 165 filename: if specified save as an ASCII file, if None (default) 166 store it in the scnatable 160 167 """ 161 168 if self.fitted and self.data is not None: … … 169 176 fit.setcomponents(self.components) 170 177 fit.setframeinfo(self.data._getcoordinfo()) 171 self.data._addfit(fit,self._fittedrow) 178 if filename is not None: 179 import os 180 filename = os.path.expandvars(os.path.expanduser(filename)) 181 if os.path.exists(filename): 182 raise IOError("File '%s' exists." % filename) 183 fit.save(filename) 184 else: 185 self.data._addfit(fit,self._fittedrow) 172 186 173 187 #def set_parameters(self, params, fixed=None, component=None): … … 224 238 Set the Parameters of a 'Gaussian' component, set with set_function. 225 239 Parameters: 226 peak, centre, f hwm: The gaussian parameters240 peak, centre, fwhm: The gaussian parameters 227 241 peakfixed, 228 242 centerfixed, … … 352 366 for i in range(len(pars)): 353 367 fix = "" 354 if fixed[i]: fix = "(fixed)"368 if len(fixed) and fixed[i]: fix = "(fixed)" 355 369 if errors : 356 370 out += ' p%d%s= %3.6f (%1.6f),' % (c,fix,pars[i], errors[i]) -
trunk/python/asapmath.py
r1085 r1232 12 12 scanav: True averages each scan separately. 13 13 False (default) averages all scans together, 14 weight: Weighting scheme. 'none, 'var' (1/var(spec) 15 weighted), 'tsys' (1/Tsys**2 weighted), 'tint' 16 (integration time weighted) or 'tintsys' (Tsys 17 and tint). The default is 'tint' 14 weight: Weighting scheme. 15 'none' (mean no weight) 16 'var' (1/var(spec) weighted) 17 'tsys' (1/Tsys**2 weighted) 18 'tint' (integration time weighted) 19 'tintsys' (Tint/Tsys**2) 20 'median' ( median averaging) 18 21 align: align the spectra in velocity before averaging. It takes 19 22 the time of the first spectrum in the first scantable … … 70 73 else: 71 74 alignedlst = lst 72 s = scantable(stm._average(alignedlst, mask, weight.upper(), scanav)) 75 if weight.upper() == 'MEDIAN': 76 # median doesn't support list of scantables - merge first 77 merged = None 78 if len(alignedlst) > 1: 79 merged = merge(alignedlst) 80 else: 81 merged = alignedlst[0] 82 s = scantable(stm._averagechannel(merged, 'MEDIAN', scanav)) 83 del merged 84 else: 85 s = scantable(stm._average(alignedlst, mask, weight.upper(), scanav)) 73 86 s._add_history("average_time",varlist) 74 87 print_log() -
trunk/python/asapplotter.py
r1217 r1232 123 123 del self._plotter.axes.patches[-1] 124 124 axvspan. __doc__ = matplotlib.axes.Axes.axvspan.__doc__ 125 125 126 def axhspan(self, *args, **kwargs): 126 self._axes_callback("a hvspan", *args, **kwargs)127 self._axes_callback("axhspan", *args, **kwargs) 127 128 # hack to preventy mpl from redrawing the patch 128 129 # it seem to convert the patch into lines on every draw. -
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.