home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / portedOneB.tar / OneB / RAConeb.h < prev    next >
C/C++ Source or Header  |  1999-07-08  |  5KB  |  172 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <string.h>
  6. #include <fcntl.h>
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <sys/times.h>
  10. #include <TimeTools.h>
  11. #include <ModelTools.h>
  12. #include <../Ingest/platform.h>
  13.  
  14. #define ushort unsigned short
  15. #define uchar unsigned char
  16. #define CHANNELS "11111000000000000000     11"
  17.  
  18. /*
  19. // Math Constants
  20.  
  21. const double
  22. m_E           = 2.7182818284590452354,    // e (natural number)
  23. m_LOG2E       = 1.4426950408889634074,
  24. m_LOG10E      = 0.43429448190325182765, // log10 x = 0.434 ln x
  25. m_LN2         = 0.69314718055994530942,    // ln 2
  26. m_LN10        = 2.30258509299404568402,    // ln x = 2.302 log10 x
  27. m_PI          = 3.14159265358979323846,    // pi
  28. m_PI_2        = 1.57079632679489661923, // pi/2
  29. m_PI_4        = 0.78539816339744830962,    // pi/4
  30. m_1_PI        = 0.31830988618379067154,    // 1/pi
  31. m_2_PI        = 0.63661977236758134308, // 2/pi
  32. m_2_SQRTPI    = 1.12837916709551257390,    // 2/sqrt(pi)
  33. m_SQRT2       = 1.41421356237309504880, // sqrt(2)
  34. m_SQRT1_2     = 0.70710678118654752440,    // sqrt(2) / 2
  35.  
  36. m_twoPi          = 6.28318530717958647692,
  37.  
  38. m_rToD          = 57.29577951308238,      // radians to deg
  39. m_dToR          = 0.01745329251994329     // deg to radians
  40. ;
  41.  
  42.  
  43. // Physical Constants
  44.  
  45. const double 
  46.  
  47. p_G    = 6.6720e-11,        // Gravitation Con. m**3 / kg sec**2
  48. p_c    = 2.99792458e+8        // velocity of light m/sec
  49. ;
  50.  
  51.  
  52. // Earth Constants
  53.  
  54. const double
  55.                                 // Spherical Harmonics
  56. e_J2 =    1082.6271e-6,         // J2
  57. e_J3 =   -2.5358868e-6,         // J3
  58. e_J4 =   -1.624618e-6,          // J4
  59. e_J5 =   -0.22698599e-6,       // J5
  60.  
  61. e_Re = 6378149.196,        // Earth equat. Radius (meters)
  62. e_Rp = 6356764.278,        // Earth polar  Radius (meters)
  63.  
  64. e_Me = 5.9742e+24,        // earth mass kg.
  65. e_GM = 3.9860064e+14,         // GM m**3 / sec**2
  66. e_SQRT_GM = 19964985.35,    // sqrt (GM)
  67.  
  68. e_ecc      = 0.081819182,        // earth eccentricity
  69. e_ecc_sq = 6.694378665e-3,    // earth eccentricity **2
  70. e_f      = 3.35281e-3,          // earth flattening factor
  71.  
  72. e_RotV   = 0.7292115850e-4    // earth rotational velocity (rad/sec)
  73. ;
  74. */
  75.  
  76. extern const LDOUBLE
  77. e_Re,        // Earth equat. Radius (meters)
  78. m_rToD,      // radians to deg
  79. m_dToR,     // deg to radians
  80. m_twoPi,
  81. ea_GM,         // GM m**3 / sec**2
  82. e_ecc_sq;    // earth eccentricity **2
  83.  
  84. ushort aInt;
  85. float aFloat;
  86.  
  87. typedef struct
  88. {
  89.   ushort Channel[5];
  90. } HRPTElement;
  91.  
  92. typedef struct
  93. {
  94.   LDOUBLE xp, yp, zp;
  95.   LDOUBLE xv, yv, zv;
  96. } rct;
  97.  
  98. typedef struct
  99. {
  100.   ushort Sync[6];
  101.   ushort ID[2];
  102.   ushort TimeCode[4];
  103.   ushort Telemetry[10];
  104.   ushort BackScanData[30];
  105.   ushort SpaceData[50];
  106.   ushort SyncDelta;
  107.   ushort TIP[520];
  108.   ushort SPARE[127];
  109.   HRPTElement Element[2048];
  110.   ushort unSync[100];
  111. } HRPTScan;
  112.  
  113. typedef struct
  114. {
  115.   char *Tag;
  116.   char **Param;
  117. } cmdPair;
  118.  
  119. /* Calibration Globals */
  120. char RFuncName[132];
  121. float RFuncWave[5], RFuncStep[5], RFuncCount[5], RFuncRead[5], RFuncSum[5];
  122. float RFuncCenterWave[5];
  123. long PRTTotal[3][5];
  124. float PRTAverage[3][5];
  125. float PRT[5];
  126. float PRTCoefficient[5][5];
  127. float PRTWeight[5];
  128. float SpaceRad[5];
  129. float AGIGain[5], AGIInter[5];
  130. float PRTTemperature[5];
  131. long PRTRead[3][5];
  132.  
  133. int ITDIndex;
  134. int ITDCount;
  135. long ITDTotal[10][5];
  136. float ITDAverage[10][5];
  137. float ITD[5];
  138. int SSDIndex;
  139. int SSDCount;
  140. long SSDTotal[10][5];
  141. float SSDAverage[10][5];
  142. float SSD[5];
  143.  
  144. float RadSum[5];
  145. float Wave;
  146. float RFuncRad[5];
  147. int RFuncIndex;
  148. float RFuncWidth[5];
  149. float SolarIrradiance[5];
  150. float RFunc[5][60];
  151. float InternalTargetTemperature;
  152.  
  153. int RACGetArgs(int argc, char **argv, cmdPair *args);
  154. int ReadScanTime(HRPTScan aScan, ttOrbitTime *oTime);
  155. unsigned int ReadLatLon(FILE *EphemFile, ttOrbitTime sTime, double **latList, double **lonList);
  156. rct getCartesian(kep_t kep);
  157. int pack2number (uchar *buffer, short scannum);
  158. int pack4number (uchar *buffer, int scannum);
  159. int encodesat(char *let, int num);
  160. int decodeTime(long msec, short *hr, short *min, double *sec);
  161. int packscantime(uchar *scanline,short scanyear,short scanday,long scangmt);
  162. int packlocation(uchar *buffer, double aLat, double aLon);
  163. int packtelem(unsigned char *buffer, ushort *telem);
  164. int packvideo(unsigned char *buffer,int datatype, ushort *ch1,ushort *ch2,ushort *ch3,ushort *ch4,ushort *ch5);
  165. void *pack1bcpy(void *s1, void *s2, size_t n);
  166. void *pack1bcpy5(void *s1, void *s2_1, void *s2_2, void *s2_3, void *s2_4, void *s2_5, size_t n);
  167. int setPRTjunk(int satellite);
  168. int grabPRTlevels(unsigned short *aux);
  169. int grabPRTgains(unsigned short *aux, float gain[5], float inter[5]);
  170. void swapint(int *tmpint);
  171.  
  172.