IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16936


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

Location:
trunk/Ohana/src/opihi
Files:
6 edited

Legend:

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

    r16810 r16936  
    100100
    101101    for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
    102       m = catalog.average[j].measureOffset;
    103102      // extract the relevant values
    104103      // XXX for measure values, this could be optimized for one loop over measures...
     104
     105      m = catalog.average[j].measureOffset;
     106      dbExtractAveragesInit (); // reset counters for saved fields
    105107      for (n = 0; n < Nfields; n++) {
    106108        values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
  • 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:
  • 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;
  • trunk/Ohana/src/opihi/dvo/dbFields.c

    r16810 r16936  
    103103  field->name  = strcreate (fieldName);
    104104
     105  if (!strcasecmp (fieldName, "GLON"))       {
     106    dbExtractMeasuresInitTransform (COORD_GALACTIC);
     107    ESCAPE (MEAS_GLON, MAG_NONE);
     108  }
     109  if (!strcasecmp (fieldName, "GLAT")) {
     110    dbExtractMeasuresInitTransform (COORD_GALACTIC);
     111    ESCAPE (MEAS_GLAT, MAG_NONE);
     112  }
     113  if (!strcasecmp (fieldName, "GLON:AVE")) {
     114    dbExtractMeasuresInitTransform (COORD_GALACTIC);
     115    ESCAPE (MEAS_GLON_AVE, MAG_NONE);
     116  }
     117  if (!strcasecmp (fieldName, "GLAT:AVE")) {
     118    dbExtractMeasuresInitTransform (COORD_GALACTIC);
     119    ESCAPE (MEAS_GLAT_AVE, MAG_NONE);
     120  }
     121
     122  if (!strcasecmp (fieldName, "ELON"))       {
     123    dbExtractMeasuresInitTransform (COORD_ECLIPTIC);
     124    ESCAPE (MEAS_ELON, MAG_NONE);
     125  }
     126  if (!strcasecmp (fieldName, "ELAT")) {
     127    dbExtractMeasuresInitTransform (COORD_ECLIPTIC);
     128    ESCAPE (MEAS_ELAT, MAG_NONE);
     129  }
     130  if (!strcasecmp (fieldName, "ELON:AVE")) {
     131    dbExtractMeasuresInitTransform (COORD_ECLIPTIC);
     132    ESCAPE (MEAS_ELON_AVE, MAG_NONE);
     133  }
     134  if (!strcasecmp (fieldName, "ELAT:AVE")) {
     135    dbExtractMeasuresInitTransform (COORD_ECLIPTIC);
     136    ESCAPE (MEAS_ELAT_AVE, MAG_NONE);
     137  }
     138
    105139  if (!strcasecmp (fieldName, "RA"))         ESCAPE (MEAS_RA,           MAG_NONE);
    106140  if (!strcasecmp (fieldName, "DEC"))        ESCAPE (MEAS_DEC,          MAG_NONE);
     
    109143  if (!strcasecmp (fieldName, "RA:ERR"))     ESCAPE (MEAS_RA_AVE_ERR,   MAG_NONE);
    110144  if (!strcasecmp (fieldName, "DEC:ERR"))    ESCAPE (MEAS_DEC_AVE_ERR,  MAG_NONE);
     145
    111146  if (!strcasecmp (fieldName, "uRA"))        ESCAPE (MEAS_U_RA,         MAG_NONE);
    112147  if (!strcasecmp (fieldName, "uDEC"))       ESCAPE (MEAS_U_DEC,        MAG_NONE);
     
    175210  field->name  = strcreate (fieldName);
    176211
     212  // if either GLON or GLAT is requested, we set up a static tranformation
     213  // at prepare to calculate the values only once for each row
     214  if (!strcasecmp (fieldName, "GLON"))  {
     215    dbExtractAveragesInitTransform (COORD_GALACTIC);
     216    ESCAPE (AVE_GLON, MAG_NONE);
     217  }
     218  if (!strcasecmp (fieldName, "GLAT"))  {
     219    dbExtractAveragesInitTransform (COORD_GALACTIC);
     220    ESCAPE (AVE_GLAT, MAG_NONE);
     221  }
     222
     223  // if either ELON or ELAT is requested, we set up a static tranformation
     224  // at prepare to calculate the values only once for each row
     225  if (!strcasecmp (fieldName, "ELON"))  {
     226    dbExtractAveragesInitTransform (COORD_ECLIPTIC);
     227    ESCAPE (AVE_ELON, MAG_NONE);
     228  }
     229  if (!strcasecmp (fieldName, "ELAT"))  {
     230    dbExtractAveragesInitTransform (COORD_ECLIPTIC);
     231    ESCAPE (AVE_ELAT, MAG_NONE);
     232  }
     233
    177234  if (!strcasecmp (fieldName, "RA"))    ESCAPE (AVE_RA,        MAG_NONE);
    178235  if (!strcasecmp (fieldName, "DEC"))   ESCAPE (AVE_DEC,       MAG_NONE);
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r16810 r16936  
    121121    for (j = 0; (j < catalog.Naverage) && !interrupt; j++) {
    122122      m = catalog.average[j].measureOffset;
     123      dbExtractMeasuresInitAve (); // reset counters for saved fields
     124
    123125      for (k = 0; (k < catalog.average[j].Nmeasure); k++, m++) {
    124126
    125127        // extract the relevant values for this measurement
     128        dbExtractMeasuresInitMeas (); // reset counters for saved fields
    126129        for (n = 0; n < Nfields; n++) {
    127130          values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
  • trunk/Ohana/src/opihi/include/dvoshell.h

    r16810 r16936  
    2323/* measure fields */
    2424enum {MEAS_ZERO,
     25      MEAS_GLON,
     26      MEAS_GLAT,
     27      MEAS_GLON_AVE,
     28      MEAS_GLAT_AVE,
     29      MEAS_ELON,
     30      MEAS_ELAT,
     31      MEAS_ELON_AVE,
     32      MEAS_ELAT_AVE,
    2533      MEAS_RA,
    2634      MEAS_DEC,
     
    8492      AVE_RA_ERR,
    8593      AVE_DEC_ERR,
     94      AVE_GLON,
     95      AVE_GLAT,
     96      AVE_ELON,
     97      AVE_ELAT,
    8698      AVE_U_RA,
    8799      AVE_U_DEC,
     
    241253int wordhash (char *word);
    242254
     255int dbExtractAverageInitTransform (CoordTransformSystem target);
     256int dbExtractAverageInit ();
     257
     258int dbExtractMeasuresInitTransform (CoordTransformSystem target);
     259int dbExtractMeasuresInitAve ();
     260int dbExtractMeasuresInitMeas ();
     261
    243262# endif
Note: See TracChangeset for help on using the changeset viewer.