casa
$Rev:20696$
|
00001 00002 // --- // 00003 00004 template <typename T> 00005 Bool calanalysis::writeInput( const CalAnalysis::OUTPUT<T>& oOutput, 00006 const uInt& row, const uInt& col, ::casac::record& oRecIter ) { 00007 00008 // Write the field 00009 00010 unsigned int uiField = oOutput.uiField; 00011 std::string oFieldString( String::toString(uiField).c_str() ); 00012 oRecIter.insert( std::string("field"), oFieldString ); 00013 00014 00015 // Write the antenna 1 00016 00017 unsigned int uiAntenna1 = oOutput.uiAntenna1; 00018 std::string oAntenna1String( String::toString(uiAntenna1).c_str() ); 00019 oRecIter.insert( std::string("antenna1"), oAntenna1String ); 00020 00021 00022 // Write the antenna 2 00023 00024 int iAntenna2 = oOutput.iAntenna2; 00025 std::string oAntenna2String( String::toString(iAntenna2).c_str() ); 00026 oRecIter.insert( std::string("antenna2"), oAntenna2String ); 00027 00028 00029 // Write the feed 00030 00031 std::string oFeedKey( "feed" ); 00032 std::string oFeedValue( oOutput.oOut(row,col).oAxes.sFeed.c_str() ); 00033 00034 oRecIter.insert( oFeedKey, oFeedValue ); 00035 00036 00037 // Write the user-defined iteration axis 00038 00039 std::string oAxisIterKey; 00040 CalStats::AXIS eAxis = oOutput.oOut(row,col).oAxes.eAxisIterUserID; 00041 00042 if ( eAxis == CalStats::FREQUENCY ) { 00043 oAxisIterKey = std::string( "frequency" ); 00044 } else { 00045 oAxisIterKey = std::string( "time" ); 00046 } 00047 00048 double dAxisIterValue = oOutput.oOut(row,col).oAxes.dAxisIterUser; 00049 oRecIter.insert( oAxisIterKey, dAxisIterValue ); 00050 00051 00052 // Write the RAP parameter 00053 00054 std::string oRAPString; 00055 00056 if ( oOutput.eRAP == CalAnalysis::REAL ) { 00057 oRAPString = std::string( "REAL" ); 00058 } else if ( oOutput.eRAP == CalAnalysis::AMPLITUDE ) { 00059 oRAPString = std::string( "AMPLITUDE" ); 00060 } else { 00061 oRAPString = std::string( "PHASE" ); 00062 } 00063 00064 oRecIter.insert( std::string("rap"), oRAPString ); 00065 00066 00067 // Write the amplitude normalization boolean 00068 00069 if ( oOutput.eRAP == CalAnalysis::AMPLITUDE ) { 00070 oRecIter.insert( std::string("norm"), (bool) oOutput.bNorm ); 00071 } 00072 00073 00074 // Write the phase unwrapping boolean and the maximum phase jump parameter 00075 00076 if ( oOutput.eRAP == CalAnalysis::PHASE ) { 00077 oRecIter.insert( std::string("unwrap"), (bool) oOutput.bUnwrap ); 00078 oRecIter.insert( std::string("jumpMax"), (double) oOutput.dJumpMax ); 00079 } 00080 00081 00082 // Return True 00083 00084 return( True ); 00085 00086 } 00087 00088 // --- // 00089 00090 template <typename T> 00091 Bool calanalysis::writeData( const CalAnalysis::OUTPUT<T>& oOutput, 00092 const uInt& row, const uInt& col, ::casac::record& oRecIter ) { 00093 00094 // Write the non-iteration axis 00095 00096 std::string oAxisNonIterKey; 00097 CalStats::AXIS eAxisNon = oOutput.oOut(row,col).oAxes.eAxisNonIterID; 00098 00099 if ( eAxisNon == CalStats::FREQUENCY ) { 00100 oAxisNonIterKey = std::string( "frequency" ); 00101 } else { 00102 oAxisNonIterKey = std::string( "time" ); 00103 } 00104 00105 oRecIter.insert( std::string("abscissa"), oAxisNonIterKey ); 00106 00107 00108 // Get the number of abscissae 00109 00110 uInt uiNumAbs = oOutput.oOut(row,col).oData.oAbs.nelements(); 00111 00112 00113 // Write the abscissae from the non-iteration axis (either times or 00114 // frequencies) 00115 00116 std::vector<double> oAbs( uiNumAbs ); 00117 00118 for ( uInt a=0; a<uiNumAbs; a++ ) { 00119 oAbs[a] = oOutput.oOut(row,col).oData.oAbs[a]; 00120 } 00121 00122 oRecIter.insert( oAxisNonIterKey, oAbs ); 00123 00124 00125 // Write the values (either reals, amplitudes, or phases) 00126 00127 std::vector<double> oValue( uiNumAbs ); 00128 00129 for ( uInt a=0; a<uiNumAbs; a++ ) { 00130 oValue[a] = oOutput.oOut(row,col).oData.oValue[a]; 00131 } 00132 00133 oRecIter.insert( string("value"), oValue ); 00134 00135 00136 // Write the value errors (either real, amplitude, or phase errors) 00137 00138 std::vector<double> oValueErr( uiNumAbs ); 00139 00140 for ( uInt a=0; a<uiNumAbs; a++ ) { 00141 oValueErr[a] = oOutput.oOut(row,col).oData.oValueErr[a]; 00142 } 00143 00144 oRecIter.insert( string("valueErr"), oValueErr ); 00145 00146 00147 // Write the flags 00148 00149 std::vector<bool> oFlag( uiNumAbs ); 00150 00151 for ( uInt a=0; a<uiNumAbs; a++ ) { 00152 oFlag[a] = oOutput.oOut(row,col).oData.oFlag[a]; 00153 } 00154 00155 oRecIter.insert( string("flag"), oFlag ); 00156 00157 00158 // Return True 00159 00160 return( True ); 00161 00162 } 00163 00164 // --- // 00165 00166 template <typename T> 00167 Bool calanalysis::writeFit( const CalStats::ARG<T>& oArg, 00168 const CalAnalysis::OUTPUT<T>& oOutput, const uInt& row, const uInt& col, 00169 ::casac::record& oRecIter ) { 00170 00171 // Write the fit order, type, and weight parameters 00172 00173 oRecIter.insert( std::string("order"), 00174 CalStatsFitter::orderName(oArg.eOrder) ); 00175 00176 oRecIter.insert( std::string("type"), CalStatsFitter::typeName(oArg.eType) ); 00177 00178 oRecIter.insert( std::string("weight"), 00179 CalStatsFitter::weightName(oArg.eWeight) ); 00180 00181 00182 // Write the fit validity flag 00183 00184 bool valid = oOutput.oOut(row,col).oT.bValid; 00185 00186 oRecIter.insert( std::string("validFit"), valid ); 00187 00188 00189 // Write the fit reduced chi2 value 00190 00191 double redchi2 = oOutput.oOut(row,col).oT.dRedChi2; 00192 00193 oRecIter.insert( std::string("redChi2"), redchi2 ); 00194 00195 00196 // Write the fit parameters 00197 00198 uInt uiNumPars = oOutput.oOut(row,col).oT.oPars.nelements(); 00199 std::vector<double> oPars( uiNumPars ); 00200 00201 for ( uInt p=0; p<uiNumPars; p++ ) { 00202 oPars[p] = oOutput.oOut(row,col).oT.oPars[p]; 00203 } 00204 00205 oRecIter.insert( std::string("pars"), oPars ); 00206 00207 00208 // Write the fit variances 00209 00210 std::vector<double> oVars( uiNumPars ); 00211 00212 for ( uInt p=0; p<uiNumPars; p++ ) { 00213 oVars[p] = oOutput.oOut(row,col).oT.oCovars(p,p); 00214 } 00215 00216 oRecIter.insert( std::string("vars"), oVars ); 00217 00218 00219 // Write the fit covariances 00220 00221 std::vector<double> oCovars( uiNumPars * (uiNumPars-1) / 2 ); 00222 00223 for ( uInt pr=0,p=0; pr<uiNumPars; pr++ ) { 00224 for ( uInt pc=pr+1; pc<uiNumPars; pc++,p++ ) { 00225 oCovars[p] = oOutput.oOut(row,col).oT.oCovars(pr,pc); 00226 } 00227 } 00228 00229 oRecIter.insert( std::string("covars"), oCovars ); 00230 00231 00232 // Write the fit model 00233 00234 uInt uiNumData = oOutput.oOut(row,col).oT.oModel.nelements(); 00235 std::vector<double> oModel( uiNumData ); 00236 00237 for ( uInt d=0; d<uiNumData; d++ ) { 00238 oModel[d] = oOutput.oOut(row,col).oT.oModel[d]; 00239 } 00240 00241 oRecIter.insert( std::string("model"), oModel ); 00242 00243 00244 // Write the fit residuals 00245 00246 std::vector<double> oRes( uiNumData ); 00247 00248 for ( uInt d=0; d<uiNumData; d++ ) { 00249 oRes[d] = oOutput.oOut(row,col).oT.oRes[d]; 00250 } 00251 00252 oRecIter.insert( std::string("res"), oRes ); 00253 00254 00255 // Write the fit residual variance 00256 00257 Double dResVar = oOutput.oOut(row,col).oT.dResVar; 00258 00259 oRecIter.insert( std::string("resVar"), dResVar ); 00260 00261 00262 // Write the fit residual mean 00263 00264 Double dResMean = oOutput.oOut(row,col).oT.dResMean; 00265 00266 oRecIter.insert( std::string("resMean"), dResMean ); 00267 00268 00269 // Return True 00270 00271 return( True ); 00272 00273 }