IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38183


Ignore:
Timestamp:
Apr 24, 2015, 3:40:47 PM (11 years ago)
Author:
eugene
Message:

add PROJ_ZPN (currently only valid for UKIRT data with P1 & P3 non-zero)

Location:
branches/eam_branches/ipp-20150419/Ohana/src/libdvo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150419/Ohana/src/libdvo/include/libdvo_astro.h

    r37807 r38183  
    2626  PROJ_GLS, // pseudocyl
    2727  PROJ_PAR, // pseudocyl
     28  PROJ_ZPN, // zenithal
    2829} OhanaProjection;
    2930
  • branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/coordops.c

    r37807 r38183  
    11# include <dvo.h>
     2# define UKIRT_ONLY 1
    23
    34/* note that Coords.ctype carries the DEC (ctype2) value */
     
    8182
    8283  /** extra polynomial terms **/
    83   if (coords[0].Npolyterms > 1) {
     84  if ((coords[0].Npolyterms > 1) && (proj != PROJ_ZPN)) {
    8485    X2 = X*X;
    8586    Y2 = Y*Y;
     
    171172        stht = cos (RAD_DEG * R);
    172173        break;
     174
     175      case PROJ_ZPN:
     176        // R = 90 - theta (degrees)
     177        // this is wrong because we are ignoring the distortion
     178        // XXX For now, just solve for terms up to n = 3
     179
     180        // Ro = (pi/180)(90 - theta)
     181        // R = (180/pi)sum (P_i R^i)
     182
     183        if (UKIRT_ONLY) {
     184          double Ro = RAD_DEG * R;
     185          double P1 = coords[0].polyterms[0][1];
     186          double P3 = coords[0].polyterms[0][3];
     187
     188          // find the roots of f(gamma) = P1 gamma + P3 gamma^3 - Ro
     189          // starting guess for gamma is Ro / P1
     190          double gamma = Ro / P1;
     191
     192          int i;
     193          for (i = 0; i < 5; i++) {
     194            double F = P1*gamma + P3*gamma*gamma*gamma - Ro;
     195            double dFdgamma = P1 + 3.0*P3*gamma*gamma;
     196
     197            double gamma_new = gamma - F / dFdgamma;
     198            gamma = gamma_new;
     199          }
     200         
     201          double theta = 90.0 - gamma * DEG_RAD ;
     202          ctht = cos (RAD_DEG * theta);
     203          stht = sin (RAD_DEG * theta);
     204          break;
     205        }
     206
    173207      case PROJ_ZEA:
    174208      case PROJ_ZPL:
     
    238272int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords) {
    239273
     274  int i;
    240275  double phi, theta;
    241276  double sphi, cphi, stht, ctht;
     
    303338        *M = -DEG_RAD * cphi;
    304339        return (stht > 0);
     340
    305341      case PROJ_ARC:
    306342        // R = 90 - theta
     
    311347        *M = (ctht == 0.0) ? 0.0 : -Rc * cphi / ctht ;
    312348        return (TRUE);
     349
     350      case PROJ_ZPN:
     351        // Ro = (pi/180)(90 - theta)
     352        // R = (180/pi)sum (P_i R^i)
     353        ctht = hypot(sphi, cphi);
     354        theta = atan2 (stht, ctht);
     355
     356        double Rc;
     357        if (UKIRT_ONLY) {
     358          double P1 = coords[0].polyterms[0][1];
     359          double P3 = coords[0].polyterms[0][3];
     360          double gamma = RAD_DEG * (90 - DEG_RAD * theta);
     361          Rc = P1*gamma + P3*gamma*gamma*gamma;
     362        } else {
     363          double Ro = RAD_DEG * (90 - DEG_RAD * theta);
     364
     365          // i = 0 .. Npolyterms - 1 (1 <= Npolyterms <= 21)
     366          i = coords[0].Npolyterms - 1;
     367          Rc = 0.0;
     368          while (i > 0) {
     369            if (i < 7) {
     370              Rc = (Rc + coords[0].polyterms[0][i])*Ro;
     371            } else {
     372              Rc = (Rc + coords[0].polyterms[1][i-7])*Ro;
     373            }
     374            i --;
     375          }
     376          Rc += coords[0].polyterms[0][i];
     377        }
     378        Rc = DEG_RAD * Rc;
     379
     380        *L = (ctht == 0.0) ? 0.0 : +Rc * sphi / ctht ;
     381        *M = (ctht == 0.0) ? 0.0 : -Rc * cphi / ctht ;
     382        return (TRUE);
     383
    313384      case PROJ_ZEA:
    314385      case PROJ_ZPL:
     
    386457
    387458  /** extra polynomial terms **/
    388   if (coords[0].Npolyterms > 1) {
     459  // polyterm values are only valid for some projections.  for PROJ_ZPN, they are applied to R, not X,Y
     460  if ((coords[0].Npolyterms > 1) && (proj != PROJ_ZPN)) {
    389461    for (i = 0; i < 10; i++) {
    390462      // find derivatives at Xo, Yo
     
    531603int GetCoords (Coords *coords, Header *header) {
    532604 
    533   int status, status1, status2, itmp, Polynomial, Polyterm;
     605  int i, status, status1, status2, itmp, Polynomial, Polyterm;
    534606  double Lambda, rotate, rotate1, rotate2, scale;
    535607  double equinox;
     
    663735      coords[0].pc2_1 /= scale;
    664736      coords[0].pc2_2 /= scale;
     737
     738      if (!strcmp (&coords[0].ctype[4], "-ZPN")) {
     739        int found;
     740        for (i = 0; i < 14; i++) {
     741          char name[64];
     742          sprintf (name, "PV2_%d", i);
     743          if (i < 7) {
     744            found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[0][i]);
     745          } else {
     746            found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[1][i-7]);
     747          }
     748          if ((i == 0) && !found) {
     749            coords[0].polyterms[0][0] = 0.0;
     750            continue;
     751          }
     752          if ((i == 1) && !found) {
     753            coords[0].polyterms[0][1] = 1.0;
     754            continue;
     755          }
     756          if (!found) {
     757            coords[0].Npolyterms = i;
     758            break;
     759          }
     760        }
     761      }
    665762      break;
    666763
     
    895992  if (!strcmp(&ctype[4], "-ZEA")) return PROJ_ZEA;
    896993  if (!strcmp(&ctype[4], "-ZPL")) return PROJ_ZPL;
     994  if (!strcmp(&ctype[4], "-ZPN")) return PROJ_ZPN;
    897995  if (!strcmp(&ctype[4], "-ARC")) return PROJ_ARC;
    898996  if (!strcmp(&ctype[4], "-STG")) return PROJ_STG;
     
    9161014    case PROJ_ZEA: strcpy(&ctype[4], "-ZEA"); return TRUE;
    9171015    case PROJ_ZPL: strcpy(&ctype[4], "-ZPL"); return TRUE;
     1016    case PROJ_ZPN: strcpy(&ctype[4], "-ZPN"); return TRUE;
    9181017    case PROJ_ARC: strcpy(&ctype[4], "-ARC"); return TRUE;
    9191018    case PROJ_STG: strcpy(&ctype[4], "-STG"); return TRUE;
     
    9371036    case PROJ_ZEA:
    9381037    case PROJ_ZPL:
     1038    case PROJ_ZPN:
    9391039    case PROJ_ARC:
    9401040    case PROJ_STG:
Note: See TracChangeset for help on using the changeset viewer.