83#define SKYCOORDINATESTESTC_ENORM 0
84#define SKYCOORDINATESTESTC_ESUB 1
85#define SKYCOORDINATESTESTC_EARG 2
86#define SKYCOORDINATESTESTC_EMEM 3
87#define SKYCOORDINATESTESTC_ETEST 4
91#define SKYCOORDINATESTESTC_MSGENORM "Normal exit"
92#define SKYCOORDINATESTESTC_MSGESUB "Subroutine failed"
93#define SKYCOORDINATESTESTC_MSGEARG "Error parsing arguments"
94#define SKYCOORDINATESTESTC_MSGEMEM "Out of memory"
95#define SKYCOORDINATESTESTC_MSGETEST "Test case failed"
100#include <lal/LALStdio.h>
101#include <lal/LALStdlib.h>
102#include <lal/LALConstants.h>
103#include <lal/AVFactories.h>
104#include <lal/Random.h>
106#include <lal/SkyCoordinates.h>
111#define USAGE "Usage: %s [-i system lat lon] [-o system] [-z lat lon]\n" \
112"\t[-a altitude] [-c lat lon rad] [-t sec nsec] [-d debuglevel]\n"
115#define ERROR( code, msg, statement ) \
117if ( lalDebugLevel & LALERROR ) \
119 LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
120 " %s %s\n", (code), *argv, __FILE__, \
121 __LINE__, "$Id$", statement ? \
122 statement : "", (msg) ); \
126#define INFO( statement ) \
128if ( lalDebugLevel & LALINFO ) \
130 LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
131 " %s\n", *argv, __FILE__, __LINE__, \
132 "$Id$", (statement) ); \
136#define WARNING( statement ) \
138if ( lalDebugLevel & LALWARNING ) \
140 LALPrintError( "Warning[0]: program %s, file %s, line %d, %s\n" \
141 " %s\n", *argv, __FILE__, __LINE__, \
142 "$Id$", (statement) ); \
146#define SUB( func, statusptr ) \
148if ( (func), (statusptr)->statusCode ) \
150 ERROR( SKYCOORDINATESTESTC_ESUB, SKYCOORDINATESTESTC_MSGESUB, \
151 "Function call \"" #func "\" failed:" ); \
152 return SKYCOORDINATESTESTC_ESUB; \
157main(
int argc,
char **argv )
177 while ( arg < argc ) {
180 if ( !strcmp( argv[arg],
"-i" ) ) {
181 if ( argc > arg + 3 ) {
184 if ( !strncmp( argv[arg],
"h", 1 ) )
186 else if ( !strncmp( argv[arg],
"ge", 2 ) )
188 else if ( !strncmp( argv[arg],
"eq", 2 ) )
190 else if ( !strncmp( argv[arg],
"ec", 2 ) )
192 else if ( !strncmp( argv[arg],
"ga", 2 ) )
210 else if ( !strcmp( argv[arg],
"-o" ) ) {
211 if ( argc > arg + 1 ) {
214 if ( !strncmp( argv[arg],
"h", 1 ) )
216 else if ( !strncmp( argv[arg],
"ge", 2 ) )
218 else if ( !strncmp( argv[arg],
"eq", 2 ) )
220 else if ( !strncmp( argv[arg],
"ec", 2 ) )
222 else if ( !strncmp( argv[arg],
"ga", 2 ) )
238 else if ( !strcmp( argv[arg],
"-z" ) ) {
239 if ( argc > arg + 2 ) {
253 else if ( !strcmp( argv[arg],
"-a" ) ) {
254 if ( argc > arg + 1 ) {
266 else if ( !strcmp( argv[arg],
"-c" ) ) {
267 if ( argc > arg + 3 ) {
273 earth.
radius = atof( argv[arg++] );
282 else if ( !strcmp( argv[arg],
"-t" ) ) {
283 if ( argc > arg + 2 ) {
296 else if ( !strcmp( argv[arg],
"-d" ) ) {
297 if ( argc > arg + 1 ) {
307 else if ( argv[arg][0] ==
'-' ) {
321 if ( !in && !out && !gd && !gc && !alt && !t ) {
327 printf (
"Testing LALConvertSkyCoordinates()\n");
336 fprintf( stdout,
"Galactic (%7.3f,%7.3f)\n",
341 fprintf( stdout,
"Equatorial (%7.3f,%7.3f)\n",
346 fprintf( stdout,
"Ecliptic (%7.3f,%7.3f)\n",
351 fprintf( stdout,
"Equatorial (%7.3f,%7.3f)\n",
356 fprintf( stdout,
"Galactic (%7.3f,%7.3f)\n",
366 fabs( diff ) > 0.001 ) {
381 printf (
"Testing LALNormalizeSkyPosition()\n");
389 printf (
"1.) LALNormalizeSkyPosition failed: got (%f,%f) instead of (%f,%f)\n",
401 printf (
"2.) LALNormalizeSkyPosition failed: got (%f,%f) instead of (%f,%f)\n",
414 INFO( SKYCOORDINATESTESTC_MSGENORM );
426 fprintf( stdout,
"TERRESTRIAL COORDINATES\n"
427 "Geocentric: latitude = %6.2f deg, longitude = %6.2f deg,"
436 " x = %.0fm, y = %.0fm, z = %.0fm\n",
437 1.0*earth.
x, 1.0*earth.
y, 1.0*earth.
z );
440 "Geodetic: latitude = %6.2f deg, longitude = %6.2f"
441 " deg, elevation = %.0fm\n",
451 fprintf( stdout,
"TERRESTRIAL COORDINATES\n"
452 "Geodetic: latitude = %6.2f deg, longitude = %6.2f"
459 "Geocentric: latitude = %6.2f deg, longitude = %6.2f"
460 " deg, radius = %.0fm\n"
461 " x = %.0fm, y = %.0fm, z = %.0fm\n",
464 1.0*earth.
x, 1.0*earth.
y, 1.0*earth.
z );
488 fprintf( stdout,
"TIME COORDINATE\n" );
498 strftime(timeStamp->
data, timeStamp->
length,
"%F %T UTC %a", &
date);
499 fprintf( stdout,
"UTC time: %s\n", timeStamp->
data );
504 fprintf( stdout,
"Greenwich mean sidereal time: %6.2f deg\n",
522 fprintf( stdout,
"CELESTIAL COORDINATES\n" );
534 default:
fprintf( stdout,
"Unknown " );
536 fprintf( stdout,
": latitude = %6.2f deg, longitude = %6.2f deg\n",
554 default:
fprintf( stdout,
"Unknown " );
556 fprintf( stdout,
": latitude = %6.2f deg, longitude = %6.2f deg\n",
564 INFO( SKYCOORDINATESTESTC_MSGENORM );
void LALCheckMemoryLeaks(void)
#define SUB(func, statusptr)
#define ERROR(code, msg, statement)
#define SKYCOORDINATESTESTC_ENORM
Normal exit.
#define SKYCOORDINATESTESTC_ETEST
Test case failed.
#define SKYCOORDINATESTESTC_EARG
Error parsing arguments.
int main(int argc, char *argv[])
#define LAL_180_PI
pi/180 is the number of radians in one degree
#define LAL_PI_180
180/pi is the number of degrees in one radian
#define LAL_PI
Archimedes's constant, pi.
#define LAL_TWOPI
2*pi is circumference of a circle divided by its radius
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
double REAL8
Double precision real floating-point number (8 bytes).
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
int LALPrintError(const char *fmt,...)
RandomParams * XLALCreateRandomParams(INT4 seed)
REAL4 XLALUniformDeviate(RandomParams *params)
void XLALDestroyRandomParams(RandomParams *params)
void LALConvertSkyCoordinates(LALStatus *stat, SkyPosition *output, SkyPosition *input, ConvertSkyParams *params)
void LALNormalizeSkyPosition(LALStatus *stat, SkyPosition *posOut, const SkyPosition *posIn)
@ COORDINATESYSTEM_GALACTIC
The galactic coordinate system.
@ COORDINATESYSTEM_ECLIPTIC
The ecliptic coordinate system.
@ COORDINATESYSTEM_GEOGRAPHIC
The Earth-fixed geographic coordinate system.
@ COORDINATESYSTEM_HORIZON
A horizon coordinate system.
@ COORDINATESYSTEM_EQUATORIAL
The sky-fixed equatorial coordinate system.
void LALGeocentricToGeodetic(LALStatus *, EarthPosition *location)
void LALGeodeticToGeocentric(LALStatus *, EarthPosition *location)
void LALCHARCreateVector(LALStatus *, CHARVector **, UINT4)
void LALCHARDestroyVector(LALStatus *, CHARVector **)
struct tm * XLALGPSToUTC(struct tm *utc, INT4 gpssec)
Returns a pointer to a tm structure representing the time specified in seconds since the GPS epoch.
REAL8 XLALGreenwichMeanSiderealTime(const LIGOTimeGPS *gpstime)
Convenience wrapper, calling XLALGreenwichSiderealTime() with the equation of equinoxes set to 0.
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
Converts nano seconds stored as an INT8 to GPS time.
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
Converts GPS time to nano seconds stored as an INT8.
Vector of type CHAR, see DATATYPE-Vector types for more details.
CHAR * data
Pointer to the data array.
UINT4 length
Number of elements in array.
This structure stores parameters for the function LALConvertSkyPosition().
CoordinateSystem system
The coordinate system to which one is transforming.
SkyPosition * zenith
The position of the zenith of the horizon coordinate system; may be NULL if one is neither converting...
LIGOTimeGPS * gpsTime
The GPS time for conversions between Earth-fixed and sky-fixed coordinates; may be NULL if no such co...
This structure stores the location of a point on (or near) the surface of the Earth in both geodetic ...
SkyPosition geocentric
The geographic coordinates of the direction from the centre of the Earth through the point; that is,...
REAL8 radius
The distance of the point from the geocentre, in metres.
REAL8 elevation
The vertical distance of the point above the reference ellipsoid, in metres.
REAL8 z
The Earth-fixed geocentric Cartesian coordinates of the point, in metres.
SkyPosition geodetic
The geographic coordinates of the upward vertical direction from the point; that is,...
LAL status structure, see The LALStatus structure for more details.
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
INT4 gpsNanoSeconds
Residual nanoseconds.
This structure contains the parameters necessary for generating the current sequence of random number...
This structure stores the two spherical coordinates of a sky position; ie a generic latitude and long...
REAL8 longitude
The longitudinal coordinate (in radians), as defined above.
REAL8 latitude
The latitudinal coordinate (in radians), as defined above.
CoordinateSystem system
The coordinate system in which latitude/longitude are expressed.