# NewGamePhysics.Physics.GravityMarsMroModel Class Reference

Model of earth's gravity g based on Mars Reonnaissance Orbiter (MRO) measurements and a higher-order gravity anomaly expansion model represented by a gridded map. Loader only supports GGMRO files. More...

List of all members.

## Public Member Functions
| GravityMarsMroModel ()
| Constructs an uninitialized gravity mars object.
| GravityMarsMroModel (string mapFilename)
| Constructs a gravity mars object and initializes it by loading a anomaly map.
double | Calculate (double lat, double lon, double h)
| Calculate the acceleration g from the normal gravity and anomaly map of Mars at the surface. (height is ignored) Requires a mro map file to be loaded.
void | LoadAnomalyMap (string mapFilename)
| Load the GGMRO anomaly map file.
void | UnloadAnomalyMap ()
| Dispose of the current anomaly map.
## Public Attributes
const double | Gal = 0.01
| Unit of acceleration, name: Galileo, 1cm/sec^2.
const double | G = 6.67428E-11
| Gravitational Constant (m^3 kb^-1 s^-2).
const double | GM = 42828.35796
| Mars Gravity Constant (G * M) in km^3/s^-2 Reference: ggmro model parameter file.
const double | R = 3397.0
| Mars Equatorial Radius in km. Reference: ggmro model parameter file.
const double | omega = 7.088218081e-5
| Mars's rotational speed in rad/s^-1. Reference: ggmro model parameter file.

## Detailed Description

Model of earth's gravity g based on Mars Reonnaissance Orbiter (MRO) measurements and a higher-order gravity anomaly expansion model represented by a gridded map. Loader only supports GGMRO files.

Definition at line 20 of file GravityMarsMroModel.cs.

## Constructor & Destructor Documentation

NewGamePhysics.Physics.GravityMarsMroModel.GravityMarsMroModel | ( |  | ) |

Constructs an uninitialized gravity mars object.

Definition at line 79 of file GravityMarsMroModel.cs.

    00080         {
    00081         }

NewGamePhysics.Physics.GravityMarsMroModel.GravityMarsMroModel | ( | string | mapFilename | ) |

Constructs a gravity mars object and initializes it by loading a anomaly map.

Parameters:

  | modelFilename | The anomaly map file to load.

Definition at line 88 of file GravityMarsMroModel.cs.

    00089         {
    00090             this.LoadAnomalyMap(mapFilename);
    00091         }

## Member Function Documentation

double NewGamePhysics.Physics.GravityMarsMroModel.Calculate | ( | double | lat,
|  | double | lon,
|  | double | h |
| ) |  |  |

Calculate the acceleration g from the normal gravity and anomaly map of Mars at the surface. (height is ignored) Requires a mro map file to be loaded.

Parameters:

  | lat | Latitude (deg) in the range [-90,90]
  | lon | Longitude (deg) in the range [0,360]
  | h | Height (m) above sealevel in the range [0,100000].

Returns:
  Acceleration g.

Definition at line 102 of file GravityMarsMroModel.cs.

    00103         {
    00104             if (null == this.map)
    00105             {
    00106                 throw new ApplicationException(
    00107                     "Anomaly map not initialized. Load one first.");
    00108             }
    00109
    00110             if ((lat < -90.0) || (lat > 90.0))
    00111             {
    00112                 throw new ArgumentOutOfRangeException("lat");
    00113             }
    00114
    00115             if ((lon < 0.0) || (lon > 360.0))
    00116             {
    00117                 throw new ArgumentOutOfRangeException("lon");
    00118             }
    00119
    00120             if ((h < 0.0) || (h > 100000.0))
    00121             {
    00122                 throw new ArgumentOutOfRangeException("h");
    00123             }
    00124
    00125             // Calculate index position
    00126             int intLat = (int)Math.Truncate(lat);
    00127             int intLon = (int)Math.Truncate(lon);
    00128
    00129             // Create bicubic interpolator matrix
    00130             double[,] G = new double[4, 4];
    00131             for (int i = -1; i <= 2; i++)
    00132             {
    00133                 for (int j = -1; j <= 2; j++)
    00134                 {
    00135                     int indexLat = (LatWrap(intLat + i) - LatMin) % 180;
    00136                     int indexLon = (LonWrap(intLon + j) - LonMin) % 360;
    00137                     G[i + 1, j + 1] = map[indexLat, indexLon];
    00138                 }
    00139             }
    00140
    00141             // Interpolate over grid
    00142             Bicubic bicubic = new Bicubic(G);
    00143             double x = Math.Abs(lat - (double)intLat);
    00144             double y = lon - (double)intLon;
    00145             double g = bicubic.Calc(x, y);
    00146
    00147             // Scale from mgal units
    00148             // One milligal equals 0.01 mm/s/s.
    00149             g *= 1e-5;
    00150
    00151             // Add normal gravity
    00152             double g0 = GravityMarsNormalModel.Calculate(lat);
    00153             g += g0;
    00154
    00155             return g;
    00156         }

void NewGamePhysics.Physics.GravityMarsMroModel.LoadAnomalyMap | ( | string | mapFilename | ) |

Load the GGMRO anomaly map file.

Parameters:

  | filename | The mro anomaly map file to load.

Definition at line 162 of file GravityMarsMroModel.cs.

    00163         {
    00164             // Load binary data
    00165             FileStream fileStream = new FileStream(mapFilename, FileMode.Open, FileAccess.Read);
    00166             BinaryReader binaryReader = new BinaryReader(fileStream);
    00167             long totalBytes = new FileInfo(mapFilename).Length;
    00168             byte[] byteArray = binaryReader.ReadBytes((Int32)totalBytes);
    00169             binaryReader.Close();
    00170             fileStream.Close();
    00171
    00172             // GGMRO Image format
    00173             // LINES                      = 180
    00174             // LINE_SAMPLES               = 360
    00175             // SAMPLE_TYPE                = IEEE_REAL
    00176             // SAMPLE_BITS                = 64
    00177             this.map = new double[180, 360];
    00178             int startIndex = 0;
    00179             byte[] tempArray = new byte[8];
    00180             for (int lat = 0; lat < 180; lat++)
    00181             {
    00182                 for (int lon = 0; lon < 360; lon++)
    00183                 {
    00184                     // Get sample
    00185                     // See: http://pds.jpl.nasa.gov/documents/sr/Chapter03.pdf
    00186                     // and http://pds.jpl.nasa.gov/documents/sr/stdref2003/AppendixC.pdf
    00187                     double sample;
    00188                     if (BitConverter.IsLittleEndian)
    00189                     {
    00190                         for (int i = 0; i < 8; i++)
    00191                         {
    00192                             tempArray[7 - i] = byteArray[startIndex + i];
    00193                         }
    00194
    00195                         sample = BitConverter.ToDouble(tempArray, 0);
    00196                     }
    00197                     else
    00198                     {
    00199                         sample = BitConverter.ToDouble(byteArray, startIndex);
    00200                     }
    00201
    00202                     // Data format
    00203                     // OFFSET                     = 0.0E+00
    00204                     // SCALING_FACTOR             = 1.0E+00
    00205                     // The values can be obtained by multiplying the sample in
    00206                     // the map by SCALING_FACTOR and then adding OFFSET.
    00207                     double value = (1.0 * sample + 0.0);
    00208                     this.map[lat, lon] = value ;
    00209
    00210                     // Update source index
    00211                     startIndex += (64 / 8);
    00212                 }
    00213             }
    00214         }

void NewGamePhysics.Physics.GravityMarsMroModel.UnloadAnomalyMap | ( |  | ) |

Dispose of the current anomaly map.

Definition at line 219 of file GravityMarsMroModel.cs.

    00220         {
    00221             this.map = null;
    00222         }

## Member Data Documentation

const double NewGamePhysics.Physics.GravityMarsMroModel.G = 6.67428E-11

Gravitational Constant (m^3 kb^-1 s^-2).

Definition at line 50 of file GravityMarsMroModel.cs.

const double NewGamePhysics.Physics.GravityMarsMroModel.Gal = 0.01

Unit of acceleration, name: Galileo, 1cm/sec^2.

Definition at line 45 of file GravityMarsMroModel.cs.

const double NewGamePhysics.Physics.GravityMarsMroModel.GM = 42828.35796

Mars Gravity Constant (G * M) in km^3/s^-2 Reference: ggmro model parameter file.

Definition at line 56 of file GravityMarsMroModel.cs.

const double NewGamePhysics.Physics.GravityMarsMroModel.omega = 7.088218081e-5

Mars's rotational speed in rad/s^-1. Reference: ggmro model parameter file.

Definition at line 68 of file GravityMarsMroModel.cs.

const double NewGamePhysics.Physics.GravityMarsMroModel.R = 3397.0

Mars Equatorial Radius in km. Reference: ggmro model parameter file.

Definition at line 62 of file GravityMarsMroModel.cs.

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/Physics/GravityMarsMroModel.cs