IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 11, 2008, 11:11:55 AM (18 years ago)
Author:
eugene
Message:

add galactic and ecliptic longitude and latitude as virtual fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/dbExtractMeasures.c

    r16810 r16936  
    1010static int TimeFormat;
    1111
     12static CoordTransform *celestial_to_galactic = NULL;
     13static CoordTransform *celestial_to_ecliptic = NULL;
     14
     15static int haveGalacticAve = FALSE;
     16static double GLON_AVE = 0.0;
     17static double GLAT_AVE = 0.0;
     18
     19static int haveEclipticAve = FALSE;
     20static double ELON_AVE = 0.0;
     21static double ELAT_AVE = 0.0;
     22
     23static int haveGalacticMeas = FALSE;
     24static double GLON_MEAS = 0.0;
     25static double GLAT_MEAS = 0.0;
     26
     27static int haveEclipticMeas = FALSE;
     28static double ELON_MEAS = 0.0;
     29static double ELAT_MEAS = 0.0;
     30
    1231void dbExtractMeasuresInit () {
    1332  GetTimeFormat (&TimeReference, &TimeFormat);
     33}
     34
     35// define a locally-static transform
     36int dbExtractMeasuresInitTransform (CoordTransformSystem target) {
     37
     38  // galactic transform is kept forever
     39  if (target == COORD_GALACTIC) {
     40    if (celestial_to_galactic != NULL) return (TRUE);
     41    celestial_to_galactic = InitTransform (COORD_CELESTIAL, target);
     42    return (TRUE);
     43  }
     44
     45  // ecliptic transform must be updated (is weakly time-dependent)
     46  if (target == COORD_ECLIPTIC) {
     47    if (celestial_to_ecliptic != NULL) {
     48      free (celestial_to_ecliptic);
     49    }
     50    celestial_to_ecliptic = InitTransform (COORD_CELESTIAL, target);
     51    return (TRUE);
     52  }
     53  return (FALSE);
     54}
     55
     56int dbExtractMeasuresInitAve () {
     57  haveGalacticAve = FALSE;
     58  haveEclipticAve = FALSE;
     59  return (TRUE);
     60}
     61
     62int dbExtractMeasuresInitMeas () {
     63  haveGalacticMeas = FALSE;
     64  haveEclipticMeas = FALSE;
     65  return (TRUE);
    1466}
    1567
     
    88140      value = average[0].D;
    89141      break;
     142
     143    case MEAS_GLON:
     144      if (!haveGalacticMeas) {
     145        ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);
     146        haveGalacticMeas = TRUE;
     147      }
     148      value = GLON_MEAS;
     149      break;
     150    case MEAS_GLAT:
     151      if (!haveGalacticMeas) {
     152        ApplyTransform (&GLON_MEAS, &GLAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_galactic);
     153        haveGalacticMeas = TRUE;
     154      }
     155      value = GLAT_MEAS;
     156      break;
     157    case MEAS_ELON:
     158      if (!haveEclipticMeas) {
     159        ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);
     160        haveEclipticMeas = TRUE;
     161      }
     162      value = ELON_MEAS;
     163      break;
     164    case MEAS_ELAT:
     165      if (!haveEclipticMeas) {
     166        ApplyTransform (&ELON_MEAS, &ELAT_MEAS, average[0].R - measure[0].dR / 3600.0, average[0].D - measure[0].dD / 3600.0, celestial_to_ecliptic);
     167        haveEclipticMeas = TRUE;
     168      }
     169      value = ELAT_MEAS;
     170      break;
     171
     172    case MEAS_GLON_AVE:
     173      if (!haveGalacticAve) {
     174        ApplyTransform (&GLON_AVE, &GLAT_AVE, average[0].R, average[0].D, celestial_to_galactic);
     175        haveGalacticAve = TRUE;
     176      }
     177      value = GLON_AVE;
     178      break;
     179    case MEAS_GLAT_AVE:
     180      if (!haveGalacticAve) {
     181        ApplyTransform (&GLON_AVE, &GLAT_AVE, average[0].R, average[0].D, celestial_to_galactic);
     182        haveGalacticAve = TRUE;
     183      }
     184      value = GLAT_AVE;
     185      break;
     186    case MEAS_ELON_AVE:
     187      if (!haveEclipticAve) {
     188        ApplyTransform (&ELON_AVE, &ELAT_AVE, average[0].R, average[0].D, celestial_to_ecliptic);
     189        haveEclipticAve = TRUE;
     190      }
     191      value = ELON_AVE;
     192      break;
     193    case MEAS_ELAT_AVE:
     194      if (!haveEclipticAve) {
     195        ApplyTransform (&ELON_AVE, &ELAT_AVE, average[0].R, average[0].D, celestial_to_ecliptic);
     196        haveEclipticAve = TRUE;
     197      }
     198      value = ELAT_AVE;
     199      break;
     200
    90201    case MEAS_RA_AVE_ERR: /* OK */
    91202      value = average[0].dR;
Note: See TracChangeset for help on using the changeset viewer.