IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32854


Ignore:
Timestamp:
Dec 2, 2011, 11:47:26 AM (15 years ago)
Author:
eugene
Message:

testing the parallax factor; use slightly more accurate solar ephemeris

Location:
branches/eam_branches/ipp-20111122/Ohana/src/relastro
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/Makefile

    r32346 r32854  
    1818
    1919relastro: $(BIN)/relastro.$(ARCH)
    20 install: $(DESTBIN)/relastro
     20install: $(DESTBIN)/relastro $(DESTBIN)/testparallax
    2121
    2222RELASTRO = \
     
    6868$(RELASTRO): $(INC)/relastro.h $(KAPA_INCS)
    6969$(BIN)/relastro.$(ARCH): $(RELASTRO) $(KAPA_LIBS)
     70
     71testparallax: $(BIN)/testparallax.$(ARCH)
     72
     73TESTPAR = \
     74$(SRC)/FitPMandPar.$(ARCH).o         \
     75$(SRC)/ParFactor.$(ARCH).o           \
     76$(SRC)/fitpoly.$(ARCH).o             \
     77$(SRC)/mkpolyterm.$(ARCH).o            \
     78$(SRC)/testparallax.$(ARCH).o
     79
     80$(TESTPAR): $(INC)/relastro.h $(KAPA_INCS)
     81$(BIN)/testparallax.$(ARCH): $(TESTPAR) $(KAPA_LIBS)
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/ParFactor.c

    r32740 r32854  
    11# include "relastro.h"
     2# define J2000 2451545.       /* Julian date at standard epoch */
    23
    34# if (0)
     
    3132  double n, L, g;
    3233
    33 # define J2000 2451545.       /* Julian date at standard epoch */
    3434
    3535  n = jd - J2000;
     
    4646int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon, double *Radius) {
    4747
    48 # define J2000 2451545.       /* Julian date at standard epoch */
    49 
    5048  double n = jd - J2000;              // day number
    5149  double L = 280.460 + 0.9856474 * n; // mean solar longitute (corr. for aberration)
     
    6058
    6159/* given RA, DEC, Time, calculate the parallax factor */
     60// Time is relative to Tmean, Tmean is years relative to J2000
    6261int ParFactor (double *pR, double *pD, double RA, double DEC, double Time, double Tmean) {
    6362
     
    6665  /* given a time T in UNIX seconds, determine the solar longitude S */
    6766
    68   jd = ohana_sec_to_jd (365.25*86400.0*(Time + Tmean));
     67  // jd = ohana_sec_to_jd (365.25*86400.0*(Time + Tmean));
     68  jd = 365.25*(Time + Tmean) + J2000;
     69  // fprintf (stderr, "Time: %f, jd: %f\n", Time, jd);
     70
    6971  sun_ecliptic (jd, &lambda, &beta, &epsilon, &Radius);
    7072
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/UpdateObjects.c

    r32695 r32854  
    133133        R[N] = getMeanR (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);
    134134        D[N] = getMeanD (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]);
     135
     136        // XXX I think this is a problem: T[] is time in years relative to J2000, but ParFactor expects
     137        // to get Time in years relative to UNIX Tzero (1970/01/01)
    135138        T[N] = (catalog[i].measure[m].t - T2000) / (86400*365.25) ; // time relative to J2000 in years
    136139
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/testparallax.c

    r32741 r32854  
    11# include "relastro.h"
     2# define NPTS 64
     3# define J2000 2451545.       /* Julian date at standard epoch */
     4# define T1970 2440587.500000 /* JD at UNIX ref time */
    25
    36int main (int argc, char **argv) {
     7   
     8  int i, Npts;
     9  char line[1024];
     10  double R[NPTS], D[NPTS], Time[NPTS], JD[NPTS];
     11  double X[NPTS], Y[NPTS], dX[NPTS], dY[NPTS], pX[NPTS], pY[NPTS];
     12  double Tref[NPTS], Tjyrs[NPTS], TrefS, TjyrsS, TrefMean, TjyrsMean, Ro, Do;
     13  Coords coords;
     14  PMFit fitPAR;
    415
    5     if (argc != N) {
    6         fprintf (stderr, "USAGE: testparallax (file.dat)\n");
    7         exit (1);
     16  if (argc != 2) {
     17    fprintf (stderr, "USAGE: testparallax (file.dat)\n");
     18    exit (1);
     19  }
     20
     21  // test parallax program
     22  FILE *f = fopen (argv[1], "r");
     23  if (!f) { fprintf (stderr, "failed to open %s\n", argv[1]); exit (2); }
     24
     25  // XXX uncomment to skip first line scan_line(f, line);
     26   
     27  Npts = 0;
     28  for (i = 0; scan_line(f, line) != EOF; i++) {
     29    if (Npts == NPTS) {
     30      fprintf (stderr, "too many point: use dynamic alloc\n");
     31      exit (2);
    832    }
     33    if (line[0] == '#') continue;
     34    dparse (&R[Npts],    1, line);
     35    dparse (&D[Npts],    2, line);
     36    dparse (&JD[Npts],   3, line);
     37    dparse (&Time[Npts], 3, line);
    938
    10     // test parallax program
    11     FILE *f = fopen (argv[1], "r");
    12     if (!f) { fprintf (stderr, "failed to open %s\n", argv[1]); exit (2); }
     39    dparse (&dX[Npts],   4, line);
     40    dparse (&dY[Npts],   4, line);
    1341
    14     char buffer[1024];
    15     scan_line(f, line);
    16    
    17     while (scan_line(f, line) != EOF) {
    18         dparse (&jd,   1, line);
    19         dparse (&time, 2, line);
    20         dparse (&ra,   3, line);
    21         dparse (&dec,  4, line);
     42    // trent's file
     43    // dparse (&JD[Npts],   1, line);
     44    // dparse (&Time[Npts], 2, line);
     45    // dparse (&R[Npts],    3, line);
     46    // dparse (&D[Npts],    4, line);
     47    Npts ++;
     48  }
    2249
    23     }
     50  /* project coordinates to a plane centered on the object with units of arcsec */
     51  coords.crval1 = 0;
     52  coords.crval2 = 0;
     53  coords.crpix1 = 0;
     54  coords.crpix2 = 0;
     55  coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0;
     56  coords.pc1_1  = coords.pc2_2 = 1.0;
     57  coords.pc1_2  = coords.pc2_1 = 0.0;
     58  coords.Npolyterms = 1;
     59  strcpy (coords.ctype, "RA---SIN");
    2460
    25     // project to local coords
     61  // use one point as a local reference
     62  coords.crval1 = R[0];
     63  coords.crval2 = D[0];
    2664
    27     // run fitter
    28     FitPMandPar
     65  TrefS = TjyrsS = 0.0;
    2966
     67  // project to local coords
     68  for (i = 0; i < Npts; i++) {
     69    RD_to_XY (&X[i], &Y[i], R[i], D[i], &coords);
    3070
     71    Tjyrs[i] = Time[i] / 365.25;
     72    Tref[i] = Time[i] / 365.25;
     73    // Tunix[i] = (JD[i] - T1970) / 365.25; // time relative to T1970 in years
     74    // Tjyrs[i] = (JD[i] - J2000) / 365.25; // time relative to J2000 in years
     75
     76    TrefS   += Tref[i];
     77    TjyrsS   += Tjyrs[i];
     78
     79    // nominal for PS1
     80    // dX[i] = 0.020;
     81    // dY[i] = 0.020;
     82  }
     83  TrefMean = TrefS / Npts;
     84  TjyrsMean = TjyrsS / Npts;
     85
     86  for (i = 0; i < Npts; i++) {
     87    Tref[i] -= TrefMean;
     88    ParFactor (&pX[i], &pY[i], R[i], D[i], Tjyrs[i], 0.0);
     89    fprintf (stderr, "%f %f : %f %f : %f %f : %f %f\n", R[i], D[i], X[i], Y[i], Tref[i], Tjyrs[i], pX[i], pY[i]);
     90  }
     91
     92  // run fitter
     93  // FitPMandPar (&fitPAR, X, dX, Y, dY, Tref, pX, pY, Npts, TRUE);
     94  FitPMandPar (&fitPAR, X, dX, Y, dY, Tjyrs, pX, pY, Npts, TRUE);
     95  XY_to_RD (&Ro, &Do, fitPAR.Ro, fitPAR.Do, &coords);
     96
     97  fprintf (stderr, "Rx   : %f\n", fitPAR.Ro);
     98  fprintf (stderr, "Dx   : %f\n", fitPAR.Do);
     99  fprintf (stderr, "Ro   : %f\n", Ro);
     100  fprintf (stderr, "Do   : %f\n", Do);
     101  fprintf (stderr, "dRo  : %f\n", fitPAR.dRo);
     102  fprintf (stderr, "dDo  : %f\n", fitPAR.dDo);
     103  fprintf (stderr, "uR   : %f\n", fitPAR.uR);
     104  fprintf (stderr, "uD   : %f\n", fitPAR.uD);
     105  fprintf (stderr, "duR  : %f\n", fitPAR.duR);
     106  fprintf (stderr, "duD  : %f\n", fitPAR.duD);
     107  fprintf (stderr, "p    : %f\n", fitPAR.p);
     108  fprintf (stderr, "dp   : %f\n", fitPAR.dp);
     109  fprintf (stderr, "uTot : %f\n", hypot(fitPAR.uR,fitPAR.uD));
     110  fprintf (stderr, "PA   : %f\n", DEG_RAD*atan2(fitPAR.uR,fitPAR.uD) + 360.0);
     111 
     112  exit (0);
    31113}
     114
Note: See TracChangeset for help on using the changeset viewer.