OceanLoading.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: OceanLoading.cpp 1346 2008-08-05 14:59:55Z architest $"
00002 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "OceanLoading.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038 
00039       /* Returns the effect of ocean tides loading (meters) at the given
00040        * station and epoch, in the Up-East-North (UEN) reference frame.
00041        *
00042        * @param name  Station name (case is NOT relevant).
00043        * @param time  Epoch to look up
00044        *
00045        * @return a Triple with the ocean tidas loading effect, in meters and
00046        * in the UEN reference frame.
00047        *
00048        * @throw InvalidRequest If the request can not be completed for any
00049        * reason, this is thrown. The text may have additional information
00050        * about the reason the request failed.
00051        */
00052    Triple OceanLoading::getOceanLoading( const string& name,
00053                                          const DayTime& t )
00054       throw(InvalidRequest)
00055    {
00056 
00057       const int NUM_COMPONENTS = 3;
00058       const int NUM_HARMONICS = 11;
00059 
00060       Matrix<double> harmonics(6,11,0.0);
00061 
00062          // Get harmonics data from file
00063       harmonics = blqData.getTideHarmonics(name);
00064 
00065       Vector<double> arguments(11,0.0);
00066 
00067          // Compute arguments
00068       arguments = getArg(t);
00069 
00070       Triple oLoading;
00071 
00072       for(int i=0; i<NUM_COMPONENTS;  i++)
00073       {
00074 
00075          double temp(0.0);
00076          for(int k=0; k<NUM_HARMONICS; k++)
00077          {
00078 
00079             temp += harmonics(i,k) * 
00080                     std::cos( arguments(k) - harmonics( (i+3),k)*DEG_TO_RAD );
00081 
00082          }
00083 
00084             // This Triple is in Up, West, South reference frame
00085          oLoading[i] = temp;
00086 
00087       }  // End of 'for(int i=0; i<NUM_COMPONENTS;  i++)'
00088 
00089          // Let's change Triple to Up, East, North [UEN] reference frame
00090       oLoading[1] = -oLoading[1];
00091       oLoading[2] = -oLoading[2];
00092 
00093       return oLoading;
00094 
00095    }  // End of method 'OceanLoading::getOceanLoading()'
00096 
00097 
00098 
00099       /* Sets the name of BLQ file containing ocean tides harmonics data.
00100        *
00101        * @param name      Name of BLQ tides harmonics data file.
00102        */
00103    OceanLoading& OceanLoading::setFilename(const string& name)
00104    {
00105 
00106       fileData = name;
00107 
00108       blqData.open(fileData);
00109 
00110       return (*this);
00111 
00112    }  // End of meters 'OceanLoading::setFilename()'
00113 
00114 
00115 
00116       /* Compute the value of the corresponding astronomical arguments,
00117        * in radians. This routine is based on IERS routine ARG.f.
00118        *
00119        * @param time      Epoch of interest
00120        *
00121        * @return A Vector<double> of 11 elements with the corresponding
00122        * astronomical arguments to be used in ocean loading model.
00123        */
00124    Vector<double> OceanLoading::getArg(const DayTime& time)
00125    {
00126 
00127       const int NUM_HARMONICS = 11;
00128 
00129          // Let's store some important values
00130       Vector<double> sig(NUM_HARMONICS,0.0);
00131       sig(0) = 1.40519e-4;
00132       sig(1) = 1.45444e-4;
00133       sig(2) = 1.37880e-4;
00134       sig(3) = 1.45842e-4;
00135       sig(4) = 0.72921e-4;
00136       sig(5) = 0.67598e-4;
00137       sig(6) = 0.72523e-4;
00138       sig(7) = 0.64959e-4;
00139       sig(8) = 0.053234e-4;
00140       sig(9) = 0.026392e-4;
00141       sig(10)= 0.003982e-4;
00142 
00143       Matrix<double> angfac(4,NUM_HARMONICS,0.0);
00144       angfac(0,0) =  2.0; angfac(1,0) = -2.0;
00145          angfac(2,0) =  0.0; angfac(3,0) =  0.0;
00146       angfac(0,1) =  0.0; angfac(1,1) =  0.0;
00147          angfac(2,1) =  0.0; angfac(3,1) =  0.0;
00148       angfac(0,2) =  2.0; angfac(1,2) = -3.0;
00149          angfac(2,2) =  1.0; angfac(3,2) =  0.0;
00150       angfac(0,3) =  2.0; angfac(1,3) =  0.0;
00151          angfac(2,3) =  0.0; angfac(3,3) =  0.0;
00152       angfac(0,4) =  1.0; angfac(1,4) =  0.0;
00153          angfac(2,4) =  0.0; angfac(3,4) =  0.25;
00154       angfac(0,5) =  1.0; angfac(1,5) = -2.0;
00155          angfac(2,5) =  0.0; angfac(3,5) = -0.25;
00156       angfac(0,6) = -1.0; angfac(1,6) =  0.0;
00157          angfac(2,6) =  0.0; angfac(3,6) = -0.25;
00158       angfac(0,7) =  1.0; angfac(1,7) = -3.0;
00159          angfac(2,7) =  1.0; angfac(3,7) = -0.25;
00160       angfac(0,8) =  0.0; angfac(1,8) =  2.0;
00161          angfac(2,8) =  0.0; angfac(3,8) =  0.0;
00162       angfac(0,9) =  0.0; angfac(1,9) =  1.0;
00163          angfac(2,9) = -1.0; angfac(3,9) =  0.0;
00164       angfac(0,10)=  2.0; angfac(1,10)=  0.0;
00165          angfac(2,10)=  0.0; angfac(3,10)=  0.0;
00166 
00167 
00168       Vector<double> arguments(NUM_HARMONICS,0.0);
00169 
00170          // Get day of year
00171       short year(time.year());
00172 
00173          // Fractional part of day, in seconds
00174       double fday(time.DOYsecond());
00175 
00176          // Compute time
00177       double d(time.DOY()+365.0*(year-1975.0)+floor((year-1973.0)/4.0));
00178       double t((27392.500528+1.000000035*d)/36525.0);
00179 
00180          // Mean longitude of Sun at beginning of day
00181       double H0((279.69668+(36000.768930485+3.03e-4*t)*t)*DEG_TO_RAD);
00182 
00183          // Mean longitude of Moon at beginning of day
00184       double S0( (((1.9e-6*t - 0.001133)*t +
00185                     481267.88314137)*t + 270.434358)*DEG_TO_RAD );
00186 
00187          // Mean longitude of lunar perigee at beginning of day
00188       double P0( (((-1.2e-5*t - 0.010325)*t +
00189                     4069.0340329577)*t + 334.329653)*DEG_TO_RAD );
00190 
00191       for(int k=0; k<NUM_HARMONICS; k++)
00192       {
00193 
00194          double temp( sig(k)*fday + angfac(0,k)*H0 + 
00195                       angfac(1,k)*S0 + angfac(2,k)*P0 + angfac(3,k)*TWO_PI );
00196 
00197          arguments(k) = fmod(temp,TWO_PI);
00198 
00199          if (arguments(k) < 0.0)
00200          {
00201             arguments(k) = arguments(k) + TWO_PI;
00202          }
00203 
00204       }  // End of 'for(int k=0; k<NUM_HARMONICS; k++)'
00205 
00206       return arguments;
00207 
00208    }  // End of method 'OceanLoading::getArg()'
00209 
00210 
00211 
00212 }  // End of namespace gpstk

Generated on Thu Feb 9 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1