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/dbExtractAverages.c

    r16810 r16936  
    11# include "dvoshell.h"
     2
     3static CoordTransform *celestial_to_galactic = NULL;
     4static CoordTransform *celestial_to_ecliptic = NULL;
     5
     6static int haveGalactic = FALSE;
     7static double GLON = 0.0;
     8static double GLAT = 0.0;
     9
     10static int haveEcliptic = FALSE;
     11static double ELON = 0.0;
     12static double ELAT = 0.0;
     13
     14// define a locally-static transform
     15int dbExtractAveragesInitTransform (CoordTransformSystem target) {
     16
     17  // galactic transform is kept forever
     18  if (target == COORD_GALACTIC) {
     19    if (celestial_to_galactic != NULL) return (TRUE);
     20    celestial_to_galactic = InitTransform (COORD_CELESTIAL, target);
     21    return (TRUE);
     22  }
     23
     24  // ecliptic transform must be updated (is weakly time-dependent)
     25  if (target == COORD_ECLIPTIC) {
     26    if (celestial_to_ecliptic != NULL) {
     27      free (celestial_to_ecliptic);
     28    }
     29    celestial_to_ecliptic = InitTransform (COORD_CELESTIAL, target);
     30    return (TRUE);
     31  }
     32  return (FALSE);
     33}
     34
     35int dbExtractAveragesInit () {
     36  haveGalactic = FALSE;
     37  haveEcliptic = FALSE;
     38  return (TRUE);
     39}
    240
    341/* return average.field based on the selection */
     
    1654    case AVE_DEC:
    1755      value = average[0].D;
     56      break;
     57    case AVE_GLON:
     58      if (!haveGalactic) {
     59        ApplyTransform (&GLON, &GLAT, average[0].R, average[0].D, celestial_to_galactic);
     60        haveGalactic = TRUE;
     61      }
     62      value = GLON;
     63      break;
     64    case AVE_GLAT:
     65      if (!haveGalactic) {
     66        ApplyTransform (&GLON, &GLAT, average[0].R, average[0].D, celestial_to_galactic);
     67        haveGalactic = TRUE;
     68      }
     69      value = GLAT;
     70      break;
     71    case AVE_ELON:
     72      if (!haveEcliptic) {
     73        ApplyTransform (&ELON, &ELAT, average[0].R, average[0].D, celestial_to_ecliptic);
     74        haveEcliptic = TRUE;
     75      }
     76      value = ELON;
     77      break;
     78    case AVE_ELAT:
     79      if (!haveEcliptic) {
     80        ApplyTransform (&ELON, &ELAT, average[0].R, average[0].D, celestial_to_ecliptic);
     81        haveEcliptic = TRUE;
     82      }
     83      value = ELAT;
    1884      break;
    1985    case AVE_RA_ERR:
Note: See TracChangeset for help on using the changeset viewer.