Home| analysis |src.lib|aacgm|aacgm| AACGMConvert Index

AACGMConvert

Syntax
int AACGMConvert(double ilat,double ilon,double hgt,double *olat,double *olon,double *r,int flg);
Header
analysis/aacgm.h
Library
aacgm
Description

The AACGMConvert function converts to and from Altitude Adjusted Corrected Geo-Magnetic Coordinates.

The arguments ilat, ilon, and hgt give the input latitude and longitude in degrees, and height of the conversion in kilometers. The latitude and longitude after the conversion are stored at the locations pointed to by the arguments olat and olon. The accuracy of the transformation is measured in terms of how close the conversion came to the unit circle, and ideal conversion being (1.0). This value is stored at the location pointed to by the argument r. The argument flg indicates what kind of transformation should be performed, a value of (0) will convert from geographic to geomagnetic coordinates, and a value of (1) will convert back from geomagnetic to geographic coordinates.

Returns
Returns zero on success. On error, a (-1) is returned.
Errors
On error, a (-1) is returned.
Example

Source Code: AACGMConvert.c

/* AACGMConvert.c
   ==============
   Author: R.J.Barnes
*/


#include <stdio.h>
#include <stdlib.h>
#include "aacgm.h"


int main(int argc,char *argv[]) {

  double ilat,ilon,hgt;
  double olat,olon,r;
  int flg;
  int s;

  ilat=85.0;
  ilon=45.0;
  hgt=150.0;

  flg=0;
  
  s=AACGMConvert(ilat,ilon,hgt,&olat,&olon,&r,flg);
  if (s !=0) {
    fprintf(stderr,"Error in AACGM conversion.'n");
    exit(-1);
  }
  fprintf(stdout,"AACGMConvert'n");
  fprintf(stdout,"Input: lat=%g, lon=%g, height=%g'n",ilat,ilon,hgt);
  fprintf(stdout,"Output: lat=%g, lon=%g'n",olat,olon);
  return 0;
}