IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37623


Ignore:
Timestamp:
Nov 18, 2014, 9:30:22 AM (12 years ago)
Author:
eugene
Message:

fix up frame correction (Ylm)

Location:
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c

    r37622 r37623  
    4040  for (i = 0; i < frame->Ndec; i++) {
    4141    double D = i * scale - 89.0;
     42    if (D > 90.0) {
     43      frame->dR[i] = 0.0;
     44      frame->Nra[i] = 0;
     45      frame->Roff[i] = NULL;
     46      frame->Doff[i] = NULL;
     47      continue;
     48    }
    4249    frame->dR[i] = scale / cos(RAD_DEG*D);
    43     frame->Nra[i] = 360.0 / frame->dR[i];
     50    frame->Nra[i] = MAX (0, 360.0 / frame->dR[i]);
    4451    if (frame->Nra[i] * frame->dR[i] < 360.0) frame->Nra[i] ++;
    4552
    4653    ALLOCATE (frame->Roff[i], double, frame->Nra[i]);
    4754    ALLOCATE (frame->Doff[i], double, frame->Nra[i]);
     55    // ohana_memcheck_func (TRUE);
     56    // fprintf (stderr, "alloc : %d : %lx %lx\n", i, (long unsigned int)(size_t *) frame->Roff[i], (long unsigned int) (size_t *) frame->Doff[i]);
    4857  }
    4958  return frame;
     
    6170  }
    6271
     72  if (frame->dR)   free (frame->dR);
    6373  if (frame->Nra)  free (frame->Nra);
    6474  if (frame->Roff) free (frame->Roff);
     
    138148    SHterms *dDc = SHtermsInit (Lmax);
    139149
     150    INITTIME;
     151
    140152    FrameCorrectionFitSH (catalog, Ncatalog, dRc, dDc);
     153    MARKTIME ("done with FitSH: %f sec\n", dtime);
    141154
    142155    double pltscale = 0.5; // degrees per pixel
     
    144157 
    145158    FrameCorrectionFromSH (frame, dRc, dDc);
     159    MARKTIME ("done with FromSH: %f sec\n", dtime);
    146160
    147161    // XXX write out an image to represent the correction
     
    172186  fprintf (stderr, "start Fit %d SH l-modes for %d QSOs\n", dRc->lmax, Nicrf);
    173187
     188  FILE *f = fopen ("sh.dat", "w");
     189  myAssert (f, "oops");
     190
    174191  int i, j;
    175192  for (i = 0; i < Nicrf; i++) {
    176193
    177194    int cat, meas, ave;
    178     ICRFdata (i, &cat, &meas, &ave);
     195    ICRFdata (i, &cat, &ave, &meas);
    179196
    180197    // I need to generate a collection of values dR,dD(R,D), where dR = average.R - ICRF.R, etc. 
     
    189206    // record these in arcsec or degree?
    190207    // correct for cos(D) or not?
    191     double dR = average->R - measure->R;
    192     double dD = average->D - measure->D;
    193 
     208    double dR = 3600.0*(average->R - measure->R);
     209    double dD = 3600.0*(average->D - measure->D);
     210
     211    fprintf (f, "%12.8f %12.8f %7.3f %7.3f\n", average->R, average->D, dR, dD);
    194212    if (isnan(dR)) continue;
    195213    if (isnan(dD)) continue;
     
    205223      dDc->Fi[j] += dD * SH->Fi[j];
    206224    }
    207   }   
     225  }
     226  fclose (f);
    208227
    209228  for (j = 0; j < SH->Nterms; j++) {
    210     dRc->Fr[j] *= 4.0*M_PI/Nicrf;
    211     dRc->Fi[j] *= 4.0*M_PI/Nicrf;
    212     dDc->Fr[j] *= 4.0*M_PI/Nicrf;
    213     dDc->Fi[j] *= 4.0*M_PI/Nicrf;
     229    dRc->Fr[j] *= 4.0*M_PI/(float)Nicrf;
     230    dRc->Fi[j] *= 4.0*M_PI/(float)Nicrf;
     231    dDc->Fr[j] *= 4.0*M_PI/(float)Nicrf;
     232    dDc->Fi[j] *= 4.0*M_PI/(float)Nicrf;
    214233  }
    215234  SHtermsFree (SH);
     
    283302      if (!status) continue;
    284303
     304      R = ohana_normalize_angle (R);
     305
    285306      int iD = (D + 89.0) / frame->scale;
     307      if (iD < 0) continue;
     308      if (iD >= frame->Ndec) continue;
    286309      int iR = R / frame->dR[iD];
     310      if (iR < 0) continue;
     311      if (iR >= frame->Nra[iD]) continue;
     312
    287313
    288314      float value = NAN;
     
    507533
    508534        int iD = (D + 89.0) / frame->scale;
     535        if (iD < 0) continue;
     536        if (iD >= frame->Ndec) continue;
     537
    509538        int iR = R / frame->dR[iD];
     539        if (iR < 0) continue;
     540        if (iR >= frame->Nra[iD]) continue;
    510541
    511542        double dR = frame->Roff[iD][iR];
    512543        double dD = frame->Doff[iD][iR];
    513         average->R -= dR;
    514         average->D -= dD;
     544        average->R -= dR / 3600.0;
     545        average->D -= dD / 3600.0;
    515546      }
    516547    }
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c

    r37622 r37623  
    8585    if (USE_ICRF_CORRECT && (subcatalog[0].average[Naverage].flags & ID_ICRF_QSO)) {
    8686      Nm = 0;
     87      int savedICRF = FALSE;
    8788      for (j = 0; j < catalog[0].average[i].Nmeasure; j++) {
    8889         
     
    100101        // we need to save the location of the ICRF QSOs in the database
    101102        if (subcatalog[0].measureT[Nmeasure].dbFlags & ID_MEAS_ICRF_QSO) {
    102           ICRFsave (Nsubcatalog, Naverage, Nmeasure);
    103           fprintf (f, "%d %d %d : %f %f : %f %f\n", (int) Nsubcatalog, (int) Naverage, (int) Nmeasure,
    104                    catalog[0].average[i].R, catalog[0].average[i].D,
    105                    catalog[0].measure[offset].R, catalog[0].measure[offset].D);
    106           Nicrf ++;
     103          if (!savedICRF) {
     104            ICRFsave (Nsubcatalog, Naverage, Nmeasure);
     105            fprintf (f, "%d %d %d : %f %f : %f %f\n", (int) Nsubcatalog, (int) Naverage, (int) Nmeasure,
     106                     catalog[0].average[i].R, catalog[0].average[i].D,
     107                     catalog[0].measure[offset].R, catalog[0].measure[offset].D);
     108            Nicrf ++;
     109            savedICRF = TRUE;
     110          }
    107111        }
    108112
Note: See TracChangeset for help on using the changeset viewer.