CMTDataComp.cpp

Go to the documentation of this file.
00001 #include "CMTDataComp.h"
00002 
00003 #ifndef _STDLIB_H_INCLUDED_ 
00004 #define _STDLIB_H_INCLUDED_
00005 #include "stdlib.h"
00006 #endif
00007 
00008 #include <cmath>
00009 #include <algorithm>
00010 
00011 CMTDataComp::CMTDataComp(const int nfreq):
00012 name("unknown"),
00013 rhoa(nfreq),
00014 phi(nfreq),
00015 drhoa(nfreq),
00016 dphi(nfreq),
00017 Z(nfreq),
00018 dZ(nfreq) 
00019 { 
00020         
00021 } 
00022 
00023 CMTDataComp::~CMTDataComp()
00024 {
00025 }
00026 
00027 void CMTDataComp::Assign(const int nfreq)
00028 {
00029         rhoa.assign(nfreq,0);
00030         phi.assign(nfreq,0);
00031         drhoa.assign(nfreq,0);
00032         dphi.assign(nfreq,0);
00033         Z.assign(nfreq,0);
00034         dZ.assign(nfreq,0);
00035 }
00036 
00037 CMTDataComp& CMTDataComp::operator= (const CMTDataComp& source)
00038 {
00039         this->rhoa.assign(source.Z.size(),0);
00040         this->phi.assign(source.Z.size(),0);
00041         this->dphi.assign(source.Z.size(),0);
00042         this->drhoa.assign(source.Z.size(),0);
00043         this->Z.assign(source.Z.size(),0);
00044         this->dZ.assign(source.Z.size(),0);
00045         this->name = source.name;
00046         copy(source.rhoa.begin(),source.rhoa.end(),this->rhoa.begin());
00047         copy(source.phi.begin(),source.phi.end(),this->phi.begin());
00048         copy(source.drhoa.begin(),source.drhoa.end(),this->drhoa.begin());
00049         copy(source.dphi.begin(),source.dphi.end(),this->dphi.begin());
00050         copy(source.Z.begin(),source.Z.end(),this->Z.begin());
00051         copy(source.dZ.begin(),source.dZ.end(),this->dZ.begin());
00052         return *this;
00053 }
00054 
00055 /*! Given a vector with frequencies
00056  * that correspond to the impedance values, Update calculates apparent
00057  * resistivity and phase
00058  */
00059 void CMTDataComp::Update(trealdata frequency)
00060 {
00061    //! If we calculate for the first time, the derived vectors have size 0
00062    if (rhoa.empty())
00063    {
00064                 //! So we have to allocate memory and set them to 0
00065                 rhoa.assign(frequency.size(),0);
00066                 phi.assign(frequency.size(),0);
00067                 drhoa.assign(frequency.size(),0);
00068                 dphi.assign(frequency.size(),0);
00069    }
00070    //! Then we can calculate the values for each frequency
00071    for (unsigned int k = 0; k < frequency.size(); ++k)
00072    {
00073                 rhoa.at(k) = 1./(2 * PI * frequency.at(k)) * mu * (pow(Z.at(k).real(),2)+pow(Z.at(k).imag(),2)) * pow(1000.0,2);
00074                 phi.at(k)  = atan(Z.at(k).imag()/Z.at(k).real())/ PI *180;
00075                 drhoa.at(k) = 1./(PI * frequency.at(k)) * mu * abs(Z.at(k)) * dZ.at(k)* pow(1000.0,2);
00076                 dphi.at(k) = dZ.at(k) * abs(Z.at(k)) * 1./(1.+ pow(Z.at(k).imag()/Z.at(k).real(),2)) * 1./pow(Z.at(k).real(),2)/ PI *180;  
00077    }
00078 }
00079 
00080 /*! If we want to erase one entry, we have to erase all the corresponding derived quantities as well*/
00081 void CMTDataComp::erase(const int index)
00082 {
00083         rhoa.erase(rhoa.begin()+index);
00084         phi.erase(phi.begin()+index);
00085         drhoa.erase(drhoa.begin()+index);
00086         dphi.erase(dphi.begin()+index);
00087         Z.erase(Z.begin()+index);
00088         dZ.erase(dZ.begin()+index);
00089 }
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 

Generated on Thu Nov 22 13:58:25 2007 for GPLIB++ by  doxygen 1.5.1