00001 /****************************************************************************** 00002 ******************************************************************************* 00003 * European Southern Observatory 00004 * VLTI MIDI Data Reduction Software 00005 * 00006 * Module name: geometry.c 00007 * Description: Contains routines for all geometrical routines 00008 * 00009 * History: 00010 * 14-Nov-03 (csabet) Created 00011 ******************************************************************************* 00012 ******************************************************************************/ 00013 00014 /****************************************************************************** 00015 * Compiler directives 00016 ******************************************************************************/ 00017 00018 /****************************************************************************** 00019 * Include files 00020 ******************************************************************************/ 00021 #include <math.h> 00022 #include "geometry.h" 00023 #include <stdio.h> 00024 #include <cpl.h> 00025 #include "midiGlobal.h" 00026 #include "midiLib.h" 00027 00028 /********************************************************** 00029 * Constant definitions 00030 **********************************************************/ 00031 00032 /********************************************************** 00033 * Global Variables 00034 **********************************************************/ 00035 00036 /*============================ C O D E A R E A ===========================*/ 00037 00038 00039 /****************************************************************************** 00040 * European Southern Observatory 00041 * VLTI MIDI Data Reduction Software 00042 * 00043 * Module name: computeUVW 00044 * Input/Output: See function arguments to avoid duplication 00045 * Description: Computes the uvw coordinates. The base algorithm is taken from VINCI 00046 * 00047 * History: 00048 * 13-Nov-03 (csabet) Created 00049 ******************************************************************************/ 00050 void computeUVW ( 00051 double t1x, /* In: Station coordinates relative to the array centre */ 00052 double t1y, /* In: Station coordinates relative to the array centre */ 00053 double t1z, /* In: Station coordinates relative to the array centre */ 00054 double t2x, /* In: Station coordinates relative to the array centre */ 00055 double t2y, /* In: Station coordinates relative to the array centre */ 00056 double t2z, /* In: Station coordinates relative to the array centre */ 00057 double time, /* In: time */ 00058 double RA, /* In: Right Ascension */ 00059 double Dec, /* In: Declanation */ 00060 UVW *uvw) /* Ou: uvw Coordinates */ 00061 00062 { 00063 00064 /* Local Declarations 00065 --------------------*/ 00066 const char routine[] = "computeUVW"; 00067 double GST, LST, T0, T, UTdate, UTtime, julianDate, hourAngle, dx, dy, dz, 00068 ihar, decr, cha, sha, cdec, sdec, clat, slat; 00069 00070 /* Algorithm 00071 -----------*/ 00072 if (diagnostic > 4)cpl_msg_info(cpl_func,"Invoking routine '%s' \n", routine); 00073 if (diagnostic > 4) fprintf(midiReportPtr, "Invoking routine '%s' \n", routine); 00074 00075 /* TO_DO_MIDI_DRS I am not sure about the "time" used in the following statement. csabet 14-Nov-03 */ 00076 /* In VINCI it is given by (julianDate = Batch_on_processed->scan_data[I].time + 2400000.5); */ 00077 /* Here I am using the UTC derived from the primary header of the FITS file */ 00078 // csabet 29-Sep-04. We have decided to use MJD-OBS from the primary header 00079 00080 julianDate = time + 2400000.5; 00081 00082 if ((julianDate - floor (julianDate)) > 0.5) 00083 UTdate = floor (julianDate) + 0.5; 00084 else 00085 UTdate = floor (julianDate) - 0.5; 00086 00087 /* Greenwich Mean Time (UTC) in decimal hours */ 00088 UTtime = 24.0 * (julianDate - UTdate); 00089 00090 T = (UTdate - 2451545.0) / 36525.0; 00091 T0 = 6.697374558 + (2400.051336 * T) + (0.000025862 * T * T) + (UTtime * 1.0027379093); 00092 GST = 24 * (T0 / 24.0 - floor (T0 / 24.0)); 00093 00094 /* LST = local_sidereal */ 00095 LST = GST - LONGITUDE_PARANAL * (12.0 / MIDI_PI); 00096 if (LST < 0) LST = LST + 24.0; 00097 LST = 24 * (LST / 24.0 - floor (LST / 24.0)); 00098 00099 /* Beware: RA and Dec are in degrees ! */ 00100 hourAngle = LST - RA * 12.0 / 180.0; 00101 00102 dx = t2x - t1x; 00103 dy = t2y - t1y; 00104 dz = t2z - t1z; 00105 00106 ihar = hourAngle * MIDI_PI / 12.0; 00107 decr = Dec * MIDI_PI / 180.0; 00108 cha = cos (ihar); 00109 sha = sin (ihar); 00110 cdec = cos (decr); 00111 sdec = sin (decr); 00112 clat = cos (LATITUDE_PARANAL); 00113 slat = sin (LATITUDE_PARANAL); 00114 00115 uvw->uCoord = dx * cha - dy * (slat * sha) + dz * (clat * sha); 00116 uvw->vCoord = dx * (sha * sdec) + dy * (slat * cha * sdec + clat * cdec) - dz * (clat * cha * sdec - slat * cdec); 00117 00118 return; 00119 } 00120 /*****************************************************************************/