IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 6, 2017, 11:30:10 AM (10 years ago)
Author:
eugene
Message:

merging changes from czw dev branch (compare with r39924)

Location:
trunk
Files:
3 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana

  • trunk/Ohana/src/relastro/src

  • trunk/Ohana/src/relastro/src/BootstrapOps.c

    r39457 r39926  
    7777    case FIT_RESULT_RA:
    7878      // result->Ro = median;
    79       result->dRo = sigma;
     79      result->dRo = MAX(sigma, result->dRo);
    8080      break;
    8181    case FIT_RESULT_DEC:
    8282      // result->Do = median;
    83       result->dDo = sigma;
     83      result->dDo = MAX(sigma, result->dDo);
    8484      break;
    8585    case FIT_RESULT_uR:
    8686      // result->uR = median;
    87       result->duR = sigma;
     87      result->duR = MAX(sigma, result->duR);
    8888      break;
    8989    case FIT_RESULT_uD:
    9090      // result->uD = median;
    91       result->duD = sigma;
     91      result->duD = MAX(sigma, result->duD);
    9292      break;
    9393    case FIT_RESULT_PLX:
    9494      // result->p = median;
    95       result->dp = sigma;
     95      result->dp = MAX(sigma, result->dp);
    9696      break;
    9797    default:
  • trunk/Ohana/src/relastro/src/BrightCatalog.c

    r39457 r39926  
    353353  /*** MeasureTiny ***/
    354354  {
    355     ohana_memcheck (1);
     355    // ohana_memcheck (1);
    356356    gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY");
    357357
    358     ohana_memcheck (1);
     358    // ohana_memcheck (1);
    359359
    360360    gfits_define_bintable_column (&theader, "D", "RA",       "ra",                         "degrees", 1.0, 0.0);
     
    429429    gfits_set_bintable_column (&theader, &ftable, "RA",         R,         catalog->Nmeasure);
    430430
    431     fprintf (stderr, "--------------- after set_bintable RA --------------");
    432     ohana_memdump_file (stderr, TRUE);
     431    // fprintf (stderr, "--------------- after set_bintable RA --------------");
     432    // ohana_memdump_file (stderr, TRUE);
    433433   
    434434    gfits_set_bintable_column (&theader, &ftable, "DEC",        D,         catalog->Nmeasure);
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r39396 r39926  
    8484  SetZeroPoint (25.0);
    8585
    86   if (USE_GALAXY_MODEL) {
    87     if (!InitGalaxyModel ("FEAST-HIPPARCOS")) {
    88       fprintf (stderr, "failed to init galaxy model\n");
    89       exit (2);
    90     }
    91   }
    92 
    9386  FreeConfigFile();
    9487  free (config);
  • trunk/Ohana/src/relastro/src/FitAstromOps.c

    r39610 r39926  
    257257  fit->converged = FALSE;
    258258 
     259  // this is an input value
     260  // if true, use the IRLS modified weight
     261  fit->useWeight = FALSE;
     262
    259263  return;
    260264}
  • trunk/Ohana/src/relastro/src/FitChip.c

    r39457 r39926  
    7878      order_use = MIN(MIN(order_use, CHIPMAP), 6); // can only go up to 6th order map (can be user limited)
    7979    } else {
    80       order_use = MIN(order_use, 3); // can only go up to 3rd order for polynomials
     80      order_use = MIN(MIN(order_use, CHIPORDER), 3); // can only go up to 3rd order for polynomials
    8181    }
    8282
     
    206206  if (VERBOSE2) fprintf (stderr, "fit sigma: %f (%f, %f) : full: %f (%f, %f), scatter limit: %f (%d full, %d bright, %d fit, %d all) (%d %d %d %d %d)\n", dRsig, dLsig, dMsig, dRsigFull, dLsigFull, dMsigFull, dRmax, NstatFull, Nstat, fit[0].Npts, Nmatch, nMask1, nMask2, nMask3, nMask4, nMask5);
    207207
    208   image[0].dXpixSys = dLsig;
    209   image[0].dYpixSys = dMsig;
     208  // need to convert dLsig, dMsig back to pixel scale (or up to arcsec)
     209
     210  float plateScale;
     211  if (image[0].coords.mosaic) {
     212    // NOTE: for the full pixel to sky plate scale, use this:
     213    // float plateScaleX = 3600.0*image[0].coords.mosaic->cdelt1*image[0].coords.cdelt1;
     214    // float plateScaleY = 3600.0*image[0].coords.mosaic->cdelt2*image[0].coords.cdelt2;
     215
     216    // since we are compare L,M values, just need to compensate for focal plate to sky:
     217    float plateScaleX = 3600.0*fabs(image[0].coords.mosaic->cdelt1);
     218    float plateScaleY = 3600.0*fabs(image[0].coords.mosaic->cdelt2);
     219    plateScale = 0.5*(plateScaleX + plateScaleY);
     220  } else {
     221    // since we are compare L,M values, just need to compensate for arcsec vs degrees:
     222    plateScale = 3600.0;
     223  }
     224
     225  image[0].dXpixSys = plateScale*dLsig;
     226  image[0].dYpixSys = plateScale*dMsig;
    210227  image[0].nFitAstrom = fit[0].Npts;
    211228
    212   // fprintf (stderr, "%s %6.3f %4d %4d\n", image[0].name, image[0].refColor, Ncolor, image[0].nFitAstrom);
     229  if (VERBOSE2) fprintf (stderr, "%s | %6.3f %6.3f | %4d %4d | %6.3f %6.3f\n", image[0].name, image[0].refColorRed, image[0].refColorBlue, Ncolor, image[0].nFitAstrom, image[0].dXpixSys, image[0].dYpixSys);
    213230
    214231  if (fit) fit_free (fit);
  • trunk/Ohana/src/relastro/src/FitPM.c

    r39612 r39926  
    2525  }
    2626
     27  fit->useWeight = FALSE; // Ordinary Least Squares
    2728  if (!FitPM_MinChisq (fit, data, points, Npoints)) return FALSE;
    2829  if (!FitPM_SetChisq (fit, data, points, Npoints)) return FALSE;
     
    4748 
    4849  // Solve OLS equation 
     50  fit->useWeight = FALSE; // Ordinary Least Squares
    4951  if (!FitPM_MinChisq(fit, data, points, Npoints)) {
    5052    return(FALSE);
     
    6971
    7072  // Iteratively reweight and solve
    71   double sigma_hat = 0.0; // save for the error model
     73  // double sigma_hat = 0.0; // save for the error model
    7274  int converged = FALSE;
    7375  int iterations = 0;
     
    9092
    9193    // Solve with the new weights
     94    fit->useWeight = TRUE; // Reweighted Least Squares
    9295    if (!FitPM_MinChisq(fit, data, points, Npoints)) {
    9396
     
    104107        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    105108      }
    106       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     109      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    107110      break;
    108111    }
     
    119122      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    120123    }
    121     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     124    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    122125   
    123126    // Check convergence
     
    159162  // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
    160163  if (data->getError) {
    161     double ax = 0.0, ay = 0.0;
    162     double bx = 0.0, by = 0.0;
    163 
    164     for (i = 0; i < Npoints; i++) {
    165       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    166       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    167 
    168       bx += SQ(points[i].Wx);
    169       by += SQ(points[i].Wy);
    170     }
    171     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    172     ay /= 1.0 * Npoints;
    173     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    174     by /= 1.0 * (Npoints - data->Nterms);
    175  
    176     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    177     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    178  
    179     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    180     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    181 
    182     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    183     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    184     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    185 
    186     fit[0].dRo = sqrt(data->Cov[0][0]);
    187     fit[0].duR = sqrt(data->Cov[1][1]);
    188     fit[0].dDo = sqrt(data->Cov[2][2]);
    189     fit[0].duD = sqrt(data->Cov[3][3]);
    190 
    191     fit[0].dRo *= sigma_final_x;
    192     fit[0].duR *= sigma_final_x;
    193     fit[0].dDo *= sigma_final_y;
    194     fit[0].duD *= sigma_final_y;
     164    FitAstromResult fitErrors;
     165    FitAstromResultInit (&fitErrors);
     166    fitErrors.useWeight = FALSE;
     167
     168    FitPM_MinChisq(&fitErrors, data, points, Npoints);
     169
     170    // we use the errors from a simple OLS, ignoring masked points
     171    fit[0].dRo = fitErrors.dRo;
     172    fit[0].duR = fitErrors.duR;
     173    fit[0].dDo = fitErrors.dDo;
     174    fit[0].duD = fitErrors.duD;
    195175  }
    196176
     
    212192    Nfit ++;
    213193
    214     wx = points[i].qx;
    215     wy = points[i].qy;
     194    if (fit->useWeight) {
     195      wx = points[i].qx;
     196      wy = points[i].qy;
     197    } else {
     198      wx = points[i].Qx;
     199      wy = points[i].Qy;
     200    }
    216201
    217202    Wx += wx;
  • trunk/Ohana/src/relastro/src/FitPMandPar.c

    r39612 r39926  
    2525  }
    2626
     27  fit->useWeight = FALSE; // Ordinary Least Squares
    2728  if (!FitPMandPar_MinChisq (fit, data, points, Npoints)) return FALSE;
    2829  if (!FitPMandPar_SetChisq (fit, data, points, Npoints)) return FALSE;
     
    4748 
    4849  // Solve OLS equation: failure here means the chisq matrix is degenerate, give up entirely
     50  fit->useWeight = FALSE; // Ordinary Least Squares
    4951  if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    5052    return(FALSE);
     
    6971
    7072  // Iteratively reweight and solve
    71   double sigma_hat = 0.0; // save for the error model
     73  // double sigma_hat = 0.0; // save for the error model
    7274  int converged = FALSE;
    7375  int iterations = 0;
     
    9092
    9193    // Solve with the new weights
     94    fit->useWeight = TRUE; // Reweighted Least Squares
    9295    if (!FitPMandPar_MinChisq(fit, data, points, Npoints)) {
    9396
     
    105108        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    106109      }
    107       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     110      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    108111      break;
    109112    }
     
    120123      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    121124    }
    122     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     125    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    123126
    124127    // Check convergence
     
    157160  }
    158161
    159   // this section calculates the formal error on the weighted fit using the covariance values
    160   // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
     162  // this section calculates the formal error on the regular (unweighted) fit using the covariance values
     163  // NOTE 20160929 : use only the unmasked points to calculate the error
    161164  if (data->getError) {
    162     double ax = 0.0, ay = 0.0;
    163     double bx = 0.0, by = 0.0;
    164 
    165     for (i = 0; i < Npoints; i++) {
    166       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    167       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    168 
    169       bx += SQ(points[i].Wx);
    170       by += SQ(points[i].Wy);
    171     }
    172     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    173     ay /= 1.0 * Npoints;
    174     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    175     by /= 1.0 * (Npoints - data->Nterms);
    176  
    177     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    178     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    179  
    180     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    181     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    182 
    183     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    184     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    185     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    186 
    187     fit[0].dRo = sqrt(data->Cov[0][0]);
    188     fit[0].duR = sqrt(data->Cov[1][1]);
    189     fit[0].dDo = sqrt(data->Cov[2][2]);
    190     fit[0].duD = sqrt(data->Cov[3][3]);
    191     fit[0].dp  = sqrt(data->Cov[4][4]);
    192 
    193     fit[0].dRo *= sigma_final_x;
    194     fit[0].duR *= sigma_final_x;
    195     fit[0].dDo *= sigma_final_y;
    196     fit[0].duD *= sigma_final_y;
    197     fit[0].dp  *= sqrt(sigma_final_x * sigma_final_y);
     165    FitAstromResult fitErrors;
     166    FitAstromResultInit (&fitErrors);
     167    fitErrors.useWeight = FALSE;
     168
     169    FitPMandPar_MinChisq(&fitErrors, data, points, Npoints);
     170
     171    // we use the errors from a simple OLS, ignoring masked points
     172    fit[0].dRo = fitErrors.dRo;
     173    fit[0].duR = fitErrors.duR;
     174    fit[0].dDo = fitErrors.dDo;
     175    fit[0].duD = fitErrors.duD;
     176    fit[0].dp  = fitErrors.dp;
    198177  }
    199178
     
    219198    Nfit ++;
    220199
    221     wx = points[i].qx;
    222     wy = points[i].qy;
     200    if (fit->useWeight) {
     201      wx = points[i].qx;
     202      wy = points[i].qy;
     203    } else {
     204      wx = points[i].Qx;
     205      wy = points[i].Qy;
     206    }
    223207
    224208    Wx += wx;
  • trunk/Ohana/src/relastro/src/FitPosPMfixed.c

    r39612 r39926  
    5454  }
    5555
     56  fit->useWeight = FALSE; // Ordinary Least Squares
    5657  if (!FitPosPMfixed_MinChisq (fit, data, points, Npoints)) {
    5758    if (!FitPosPMfixed_Single (fit, points, Npoints)) return FALSE;
     
    8384 
    8485  // Solve OLS equation 
     86  fit->useWeight = FALSE; // Ordinary Least Squares
    8587  if (!FitPosPMfixed_MinChisq(fit, data, points, Npoints)) {
    8688    return(FALSE);
     
    105107
    106108  // Iteratively reweight and solve
    107   double sigma_hat = 0.0; // save for the error model
     109  // double sigma_hat = 0.0; // save for the error model
    108110  int converged = FALSE;
    109111  int iterations = 0;
     
    126128
    127129    // Solve with the new weights
     130    fit->useWeight = TRUE; // Reweighted Least Squares
    128131    if (!FitPosPMfixed_MinChisq(fit, data, points, Npoints)) {
    129132
     
    138141        points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    139142      }
    140       sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     143      // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    141144      break;
    142145    }
     
    153156      points[i].u = sqrt(SQ(points[i].rx / points[i].dX) + SQ(points[i].ry / points[i].dY));
    154157    }
    155     sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
     158    // sigma_hat = MedianAbsDeviation(points, Npoints) / 0.6745;
    156159   
    157160    // Check convergence
     
    193196  // NOTE EAM: in tests (fitpm.c), they seem to be too large by a factor of ~5.37
    194197  if (data->getError) {
    195     double ax = 0.0, ay = 0.0;
    196     double bx = 0.0, by = 0.0;
    197 
    198     for (i = 0; i < Npoints; i++) {
    199       ax += dpsi_cauchy(points[i].rx / points[i].dX);
    200       ay += dpsi_cauchy(points[i].ry / points[i].dY);
    201 
    202       bx += SQ(points[i].Wx);
    203       by += SQ(points[i].Wy);
    204     }
    205     ax /= 1.0 * Npoints;  // mean(psi_dot(r))
    206     ay /= 1.0 * Npoints;
    207     bx /= 1.0 * (Npoints - data->Nterms); // mean(psi^2(r)) * (N / (N-p))
    208     by /= 1.0 * (Npoints - data->Nterms);
    209  
    210     double lambda_x = 1.0 + (data->Nterms / Npoints) * (1 - ax) / ax;
    211     double lambda_y = 1.0 + (data->Nterms / Npoints) * (1 - ay) / ay;
    212  
    213     double sigma_robust_x = lambda_x * sqrt(bx) * sigma_hat * 2.385 / ax;
    214     double sigma_robust_y = lambda_y * sqrt(by) * sigma_hat * 2.385 / ay;
    215 
    216     // This is actually sigma^2, as that's the factor in the covariance (dumouchel 4.1)
    217     double sigma_final_x  = MAX(SQ(sigma_robust_x), (2 * Npoints * SQ(sigma_robust_x) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    218     double sigma_final_y  = MAX(SQ(sigma_robust_y), (2 * Npoints * SQ(sigma_robust_y) + SQ(data->Nterms * sigma_ols)) / (2 * Npoints + SQ(data->Nterms)));
    219 
    220     fit[0].dRo = sqrt(data->Cov[0][0]);
    221     fit[0].dDo = sqrt(data->Cov[1][1]);
    222 
    223     fit[0].dRo *= sigma_final_x;
    224     fit[0].dDo *= sigma_final_y;
     198    FitAstromResult fitErrors;
     199    FitAstromResultInit (&fitErrors);
     200    fitErrors.useWeight = FALSE;
     201
     202    FitPosPMfixed_MinChisq(&fitErrors, data, points, Npoints);
     203
     204    // we use the errors from a simple OLS, ignoring masked points
     205    fit[0].dRo = fitErrors.dRo;
     206    fit[0].duR = fitErrors.duR;
     207    fit[0].dDo = fitErrors.dDo;
     208    fit[0].duD = fitErrors.duD;
     209    fit[0].dp  = fitErrors.dp;
    225210  }
    226211
     
    242227    Nfit ++;
    243228
    244     wx = points[i].qx;
    245     wy = points[i].qy;
     229    if (fit->useWeight) {
     230      wx = points[i].qx;
     231      wy = points[i].qy;
     232    } else {
     233      wx = points[i].Qx;
     234      wy = points[i].Qy;
     235    }
    246236
    247237    Wx += wx;
  • trunk/Ohana/src/relastro/src/GetAstromError.c

    r39457 r39926  
    4848  if (isnan(code[0].astromErrSys)) return NAN;
    4949
     50  if (measure[0].photcode == 1030) {
     51    if (mode == ERROR_MODE_RA) {
     52      dPobs = pow(10.0, (6.0 * measure[0].dXccd - 3.0));  // dXccd is a value in pixels
     53    }
     54    if (mode == ERROR_MODE_DEC) {
     55      dPobs = pow(10.0, (6.0 * measure[0].dYccd - 3.0));  // dXccd is a value in pixels
     56    }
     57  }
     58
    5059  AS    = code[0].astromErrScale;
    5160  MS    = code[0].astromErrMagScale;
     
    6978  // to match the 2MASS / Tycho / ICRS reference frame.  As Nloop gets higher, the weight
    7079  // needs to drop to allow the ps1 measurements to drive the solution
     80  int isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
    7181  int is2MASS  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013);
    7282  int isTycho  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021);
     83
     84  int hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
    7385  int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
     86  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
    7487
    7588  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
     
    7992    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    8093  }
     94  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     95    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
     96  }
     97  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
     98    dPtotal = dPtotal / LoopWeightTycho[Nloop];
     99  }
     100
    81101  if (is2MASS && LoopWeight2MASS && (Nloop >= 0)) {
    82102    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
     103  }
     104  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     105    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
    83106  }
    84107  if (isTycho && LoopWeightTycho && (Nloop >= 0)) {
     
    120143  // do not raise an exception, just send back the result
    121144  if (isnan(code[0].astromErrSys)) return NAN;
     145
     146  if (measure[0].photcode == 1030) {
     147    if (mode == ERROR_MODE_RA) {
     148      dPobs = pow(10.0, (6.0 * measure[0].dXccd - 3.0));  // dXccd is a value in pixels
     149    }
     150    if (mode == ERROR_MODE_DEC) {
     151      dPobs = pow(10.0, (6.0 * measure[0].dYccd - 3.0));  // dXccd is a value in pixels
     152    }
     153  }
    122154
    123155  AS    = code[0].astromErrScale;
     
    143175  // to match the 2MASS / Tycho / ICRS reference frame.  As Nloop gets higher, the weight
    144176  // needs to drop to allow the ps1 measurements to drive the solution
     177  int isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
    145178  int is2MASS  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013);
    146179  int isTycho  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021);
     180
     181  int hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
    147182  int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
     183  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
    148184
    149185  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
     
    153189    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    154190  }
     191  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     192    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
     193  }
     194  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
     195    dPtotal = dPtotal / LoopWeightTycho[Nloop];
     196  }
     197
    155198  if (is2MASS && LoopWeight2MASS) {
    156199    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
     200  }
     201  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
     202    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
    157203  }
    158204  if (isTycho && LoopWeightTycho) {
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r39580 r39926  
    66static Image        *image;   // list of available images
    77static off_t        Nimage;   // number of available images
     8static int         isImageSubset;
    89
    910// if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row
     
    7879}
    7980
    80 void initImages (Image *input, off_t *line_number, off_t N) {
     81void initImages (Image *input, off_t *line_number, off_t N, int isSubset) {
    8182
    8283  off_t i;
    8384
     85  isImageSubset = isSubset;
    8486  image = input;
    8587  LineNumber = line_number;
     
    136138  // we call gfits_db_free as well as this function.  sometimes those point at the same
    137139  // memory location, in which case we should only do the free once.
    138   if ((void *) dbImagePtr != (void *) image) free (image);
     140  if (((void *) dbImagePtr != (void *) image) && isImageSubset) free (image);
    139141  free_astrom_table();
    140142}
     
    793795    ref[i].D = catalog[c].average[n].D;
    794796   
     797    int XVERB = FALSE;
     798    XVERB |= (catalog[c].average[n].objID == OBJ_ID_SRC) && (catalog[c].average[n].catID == CAT_ID_SRC);
     799    XVERB |= (catalog[c].average[n].objID == OBJ_ID_DST) && (catalog[c].average[n].catID == CAT_ID_DST);
     800    if (XVERB) {
     801      fprintf (stderr, "found test object\n");
     802    }
     803
    795804    // if we are applying the galaxy model, move the reference position...
    796     if (USE_GALAXY_MODEL) {
     805    if (APPLY_PROPER_MOTION) {
    797806      // apply proper-motion from average position to measure epoch:
    798807      float dTime = (measure[0].t - catalog[c].average[n].Tmean) / (86400*365.25) ; // time relative to Tmean in years
     
    934943}
    935944
    936 # if (0)
    937 /** lifted from relphot/StarOps.clean_measures */
    938 void FlagOutliers2D(Catalog *catalog);
    939 
    940 // operates on Full values (not tiny)
    941 void FlagOutliers (Catalog *catalog) {
    942 
    943   // XXX FlagOutliers is now just using FlagOutliers2D
    944   FlagOutliers2D(catalog);
    945   return;
    946 
    947   int Ndel, Nave;
    948   off_t i, j, k, m, N, Nmax, TOOFEW, Nsecfilt;
    949   double Ns, theta, x, y;
    950   double *R, *D, *dR, *dD;
    951   StatType statsR, statsD;
    952 
    953   Nsecfilt = GetPhotcodeNsecfilt();
    954   assert(catalog[0].Nsecfilt == Nsecfilt);
    955 
    956   if (VERBOSE2) fprintf (stderr, "marking poor measures\n");
    957   Nmax = 0;
    958   for (i = 0; i < catalog[0].Naverage; i++) {
    959     Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure);
    960   }
    961 
    962   ALLOCATE (R, double, Nmax);
    963   ALLOCATE (D, double, Nmax);
    964   ALLOCATE (dR, double, Nmax);
    965   ALLOCATE (dD, double, Nmax);
    966 
    967   /* it makes no sense to mark 3-sigma outliers with <5 measurements */
    968   TOOFEW = MAX (5, SRC_MEAS_TOOFEW);
    969 
    970   Ns = CLIP_THRESH;
    971   Ndel = Nave = 0;
    972      
    973   /* loop over each object in the catalog */
    974   for (j = 0; j < catalog[0].Naverage; j++) {
    975    
    976     // pointer to this set of measurements
    977     m = catalog[0].average[j].measureOffset;
    978     Measure *measure = &catalog[0].measure[m];
    979 
    980     /* accumulate list of valid measurements */
    981     N = 0;
    982     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    983       // skip measurements based on user selected criteria
    984       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    985       R[N] = measure[k].R;
    986       D[N] = measure[k].D;
    987       dR[N] = GetAstromError (&measure[k], ERROR_MODE_RA);
    988       dD[N] = GetAstromError (&measure[k], ERROR_MODE_DEC);
    989       if (isnan(R[N]) || isnan(D[N])) continue;
    990       N++;
    991     }
    992     if (N <= TOOFEW) continue;
    993    
    994     /* 3-sigma clip based on stats of inner 50% */
    995     initstats ("MEAN");
    996     liststats (R, dR, N, &statsR);
    997     liststats (D, dD, N, &statsD);
    998    
    999     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1000     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1001    
    1002     /* compare per-object distance to this standard deviation, and flag outliers*/
    1003     N = 0;
    1004     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1005       // reset flag on each invocation
    1006       measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM;
    1007 
    1008       // skip measurements based on user selected criteria
    1009       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    1010      
    1011       x = measure[k].R - statsR.median;
    1012       y = measure[k].D - statsD.median;
    1013       theta = atan2(y,x);
    1014       if ((x*x + y*y) > (SQR(statsR.sigma * Ns * cos(theta)) +
    1015                          SQR(statsD.sigma * Ns * sin(theta)))) {   
    1016         measure[k].dbFlags |= ID_MEAS_POOR_ASTROM;
    1017         Ndel++;
    1018       }
    1019       N++;
    1020       Nave ++;
    1021     }
    1022 
    1023     // examine results
    1024     // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns);
    1025   }
    1026  
    1027   if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave);
    1028   free (R);
    1029   free (dR);
    1030   free (D);
    1031   free (dD);
    1032 }
    1033 
    1034 
    1035 /** an alternative outlier rejection scheme */
    1036 void FlagOutliers2D (Catalog *catalog) {
    1037 
    1038   int Ndel, Nave;
    1039   off_t i, j, k, m, N, Nmax, TOOFEW, Nsecfilt;
    1040   double *index;
    1041   double Ns, theta, x, y;
    1042   double *R, *D, *dR, *dD, *d2;
    1043   StatType statsR, statsD;
    1044 
    1045   // XXX we are not going to use this for now
    1046   return;
    1047 
    1048   Nsecfilt = GetPhotcodeNsecfilt();
    1049   assert(catalog[0].Nsecfilt == Nsecfilt);
    1050 
    1051   if (VERBOSE2) fprintf (stderr, "marking poor measures\n");
    1052   Nmax = 0;
    1053   for (i = 0; i < catalog[0].Naverage; i++) {
    1054     Nmax = MAX (Nmax, catalog[0].average[i].Nmeasure);
    1055   }
    1056 
    1057   ALLOCATE (R, double, Nmax);
    1058   ALLOCATE (D, double, Nmax);
    1059   ALLOCATE (dR, double, Nmax);
    1060   ALLOCATE (dD, double, Nmax);
    1061   ALLOCATE (d2, double, Nmax);
    1062   ALLOCATE (index, double, Nmax);
    1063 
    1064   /* it makes no sense to mark 3-sigma outliers with <5 measurements */
    1065   TOOFEW = MAX (5, SRC_MEAS_TOOFEW);
    1066 
    1067   Ns = CLIP_THRESH;
    1068   Ndel = Nave = 0;
    1069      
    1070   /* loop over each object in the catalog */
    1071   for (j = 0; j < catalog[0].Naverage; j++) {
    1072    
    1073     // pointer to this set of measurements
    1074     m = catalog[0].average[j].measureOffset;
    1075     Measure *measure = &catalog[0].measure[m];
    1076 
    1077     /* accumulate list of valid measurements */
    1078     N = 0;
    1079     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1080 
    1081       // reset flag on each invocation
    1082       measure[k].dbFlags &= ~ID_MEAS_POOR_ASTROM;
    1083      
    1084       // skip measurements based on user selected criteria
    1085       if (!MeasFilterTest(&measure[k], FALSE)) continue;
    1086       R[N] = measure[k].R;
    1087       D[N] = measure[k].D;
    1088       dR[N] = GetAstromError(&measure[k], ERROR_MODE_RA);
    1089       dD[N] = GetAstromError(&measure[k], ERROR_MODE_DEC);
    1090       if (isnan(R[N]) || isnan(D[N])) continue;
    1091       N++;
    1092     }
    1093     if (N <= TOOFEW) continue;
    1094    
    1095     /* calculate mean of all points*/
    1096     initstats ("MEAN");
    1097     liststats (R, dR, N, &statsR);
    1098     liststats (D, dD, N, &statsD);
    1099     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1100     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1101    
    1102     /* calculate deviations of all points*/
    1103     N = 0;
    1104     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1105       // skip bad measurements
    1106       if (!MeasFilterTest(&measure[k], FALSE)) continue; 
    1107       x = measure[k].R - statsR.median;
    1108       y = measure[k].D - statsD.median;
    1109       theta = atan2(y,x);
    1110       d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) +
    1111                              SQR(statsD.sigma * Ns * sin(theta)));     
    1112       index[N] = k;
    1113       N++;
    1114     }
    1115    
    1116     // sort d2
    1117     dsortpair(d2, index, N);
    1118     N = (N/2 > (N-1)) ? N/2 : N-1;
    1119 
    1120     // recalculate image center, sigma based on closest 50% of points
    1121     for (k = 0;  k < N; k++) {
    1122       off_t ind = (off_t) index[k];
    1123       R[k] = measure[ind].R;
    1124       D[k] = measure[ind].D;
    1125       dR[k] = GetAstromError(&measure[ind], ERROR_MODE_RA);
    1126       dD[k] = GetAstromError(&measure[ind], ERROR_MODE_DEC);
    1127     }
    1128     liststats (R, dR, N, &statsR);
    1129     liststats (D, dD, N, &statsD);
    1130     statsR.sigma = MAX (MIN_ERROR, statsR.sigma);
    1131     statsD.sigma = MAX (MIN_ERROR, statsD.sigma);
    1132    
    1133     // use these new statistics to flag outliers
    1134     N = 0;
    1135     for (k = 0; k < catalog[0].average[j].Nmeasure; k++) {
    1136       //skip bad measurements
    1137       if (!MeasFilterTest(&measure[k], FALSE)) continue; 
    1138       x = measure[k].R - statsR.median;
    1139       y = measure[k].D - statsD.median;
    1140       theta = atan2(y,x);
    1141       d2[N] = (x*x + y*y) / (SQR(statsR.sigma * Ns * cos(theta)) +
    1142                              SQR(statsD.sigma * Ns * sin(theta)));     
    1143       if ((d2[N]) > 1) {
    1144         measure[k].dbFlags |= ID_MEAS_POOR_ASTROM;
    1145         Ndel ++;
    1146       }
    1147       N++;
    1148       Nave++;
    1149     }  // done rejecting outliers
    1150 
    1151     // examine results
    1152     // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns);
    1153    
    1154   } // done looping over objects
    1155  
    1156   if (VERBOSE) fprintf (stderr, "%d measures marked poor, %d total\n", Ndel, Nave);
    1157   free (R);
    1158   free (dR);
    1159   free (D);
    1160   free (dD);
    1161   free (d2);
    1162   free (index);
    1163 }
    1164 
    1165 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */
    1166 // we only optionally apply the sigma limit: for object averages, this should not be used
    1167 int MeasFilterTestTiny(MeasureTiny *measure, int applySigmaLim) {
    1168   int found, k;
    1169   long mask;
    1170   PhotCode *code;
    1171   float mag;
    1172 
    1173   if (!finite(measure[0].R) || !finite(measure[0].D)) return FALSE;
    1174   if (!finite(measure[0].M)) return FALSE; //XXX is this necessary for all relastro tasks?
    1175   if (!finite(measure[0].dM)) return FALSE; //XXX is this necessary for all relastro tasks?
    1176  
    1177   if ((MinBadQF > 0.0) && (isGPC1chip(measure[0].photcode) || isGPC1stack(measure[0].photcode))) {
    1178     if (!isfinite(measure[0].psfQF)) { return FALSE; };
    1179     if (measure[0].psfQF < MinBadQF) { return FALSE; };
    1180   }
    1181 
    1182   /* select measurements by photcode, or equiv photcode, if specified */
    1183   if (NphotcodesKeep > 0) {
    1184     found = FALSE;
    1185     for (k = 0; (k < NphotcodesKeep) && !found; k++) {
    1186       if (photcodesKeep[k][0].code == measure[0].photcode) found = TRUE;
    1187       if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1188     }
    1189     if (!found) return FALSE;
    1190   }
    1191  
    1192   if (NphotcodesSkip > 0) {
    1193     found = FALSE;
    1194     for (k = 0; (k < NphotcodesSkip) && !found; k++) {
    1195       if (photcodesSkip[k][0].code == measure[0].photcode) found = TRUE;
    1196       if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1197     }
    1198     if (found) return FALSE;
    1199   } 
    1200  
    1201   /* select measurements by time */
    1202   if (TimeSelect) {
    1203     if (measure[0].t < TSTART) return FALSE;
    1204     if (measure[0].t > TSTOP) return FALSE;
    1205   }
    1206  
    1207   /* select measurements by quality */
    1208   if (PhotFlagSelect) {
    1209     if (PhotFlagBad) {
    1210       mask = PhotFlagBad;
    1211     } else {
    1212       code = GetPhotcodebyCode (measure[0].photcode);
    1213       if (!code) return FALSE;
    1214       mask = code[0].astromBadMask;
    1215     }
    1216     if (mask & measure[0].photFlags) return FALSE;
    1217   }
    1218 
    1219   /* select measurements by measurement error */
    1220   // this is a bit convoluted: applySigmaLim is only TRUE when this function is
    1221   // called by bcatalog.  for UpdateObjects, it is FALSE
    1222   if (applySigmaLim && (SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) {
    1223     return FALSE;
    1224   }
    1225  
    1226   /* select measurements by mag limit */
    1227   if (ImagSelect) {
    1228     mag = PhotInstTiny (measure, MAG_CLASS_PSF);
    1229     if (mag < ImagMin || mag > ImagMax) return FALSE;
    1230   }
    1231  
    1232   return TRUE;
    1233 }
    1234 
    1235 # define SUPER_VERBOSE 0
    1236 
    1237 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */
    1238 // we only optionally apply the sigma limit: for object averages, this should not be used (should it?)
    1239 int MeasFilterTest(Measure *measure, int applySigmaLim) {
    1240   int found, k;
    1241   long mask;
    1242   PhotCode *code;
    1243   float mag;
    1244 
    1245   if (!finite(measure[0].R) || !finite(measure[0].D)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 1\n"); return FALSE; };
    1246   if (!finite(measure[0].M)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 2\n"); return FALSE; }; //XXX is this necessary for all relastro tasks?
    1247   if (!finite(measure[0].dM)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 3\n"); return FALSE; }; //XXX is this necessary for all relastro tasks?
    1248  
    1249   /* select measurements by photcode, or equiv photcode, if specified */
    1250   if (NphotcodesKeep > 0) {
    1251     found = FALSE;
    1252     for (k = 0; (k < NphotcodesKeep) && !found; k++) {
    1253       if (photcodesKeep[k][0].code == measure[0].photcode) found = TRUE;
    1254       if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1255     }
    1256     if (!found) { if (SUPER_VERBOSE) fprintf (stderr, "filter 4\n"); return FALSE; };
    1257   }
    1258  
    1259   if (NphotcodesSkip > 0) {
    1260     found = FALSE;
    1261     for (k = 0; (k < NphotcodesSkip) && !found; k++) {
    1262       if (photcodesSkip[k][0].code == measure[0].photcode) found = TRUE;
    1263       if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;
    1264     }
    1265     if (found) { if (SUPER_VERBOSE) fprintf (stderr, "filter 5\n"); return FALSE; };
    1266   } 
    1267  
    1268   if ((MinBadQF > 0.0) && isGPC1chip(measure[0].photcode)) {
    1269     if (!isfinite(measure[0].psfQF)) { if (SUPER_VERBOSE) fprintf (stderr, "filter 6\n"); return FALSE; };
    1270     if (measure[0].psfQF < MinBadQF) { if (SUPER_VERBOSE) fprintf (stderr, "filter 7\n"); return FALSE; };
    1271   }
    1272 
    1273   /* select measurements by time */
    1274   if (TimeSelect) {
    1275     if (measure[0].t < TSTART) { if (SUPER_VERBOSE) fprintf (stderr, "filter 8\n"); return FALSE; };
    1276     if (measure[0].t > TSTOP) { if (SUPER_VERBOSE) fprintf (stderr, "filter 9\n"); return FALSE; };
    1277   }
    1278  
    1279   /* select measurements by quality */
    1280   if (PhotFlagSelect) {
    1281     if (PhotFlagBad) {
    1282       mask = PhotFlagBad;
    1283     } else {
    1284       code = GetPhotcodebyCode (measure[0].photcode);
    1285       if (!code) { if (SUPER_VERBOSE) fprintf (stderr, "filter 10\n"); return FALSE; };
    1286       mask = code[0].astromBadMask;
    1287     }
    1288     if (mask & measure[0].photFlags) { if (SUPER_VERBOSE) fprintf (stderr, "filter 11\n"); return FALSE; };
    1289   }
    1290 
    1291   /* select measurements by measurement error */
    1292   if (applySigmaLim && (SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) {
    1293     { if (SUPER_VERBOSE) fprintf (stderr, "filter 12\n"); return FALSE; };
    1294   }
    1295  
    1296   /* select measurements by mag limit */
    1297   if (ImagSelect) {
    1298     mag = PhotInst (measure, MAG_CLASS_PSF);
    1299     if (mag < ImagMin || mag > ImagMax) { if (SUPER_VERBOSE) fprintf (stderr, "filter 13\n"); return FALSE; };
    1300   }
    1301  
    1302   return TRUE;
    1303 }
    1304 # endif
  • trunk/Ohana/src/relastro/src/StarMaps.c

    r39457 r39926  
    166166  dLmax = dMmax = 0.0;
    167167
     168  float plateScale;
     169  if (images[N].coords.mosaic) {
     170    // NOTE: for the full pixel to sky plate scale, use this:
     171    // float plateScaleX = 3600.0*images[N].coords.mosaic->cdelt1*images[N].coords.cdelt1;
     172    // float plateScaleY = 3600.0*images[N].coords.mosaic->cdelt2*images[N].coords.cdelt2;
     173
     174    // since we are compare L,M values, just need to compensate for focal plate to sky:
     175    float plateScaleX = 3600.0*fabs(images[N].coords.mosaic->cdelt1);
     176    float plateScaleY = 3600.0*fabs(images[N].coords.mosaic->cdelt2);
     177    plateScale = 0.5*(plateScaleX + plateScaleY);
     178  } else {
     179    // since we are compare L,M values, just need to compensate for arcsec vs degrees:
     180    plateScale = 3600.0;
     181  }
     182
    168183  for (i = 0; i < starmap[N].Npoints; i++) {
    169184
     
    171186    XY_to_LM (&L, &M, starmap[N].points[i].X, starmap[N].points[i].Y, &images[N].coords);
    172187
    173     starmap[N].points[i].dL = starmap[N].points[i].L - L;
    174     starmap[N].points[i].dM = starmap[N].points[i].M - M;
     188    starmap[N].points[i].dL = plateScale*(starmap[N].points[i].L - L);
     189    starmap[N].points[i].dM = plateScale*(starmap[N].points[i].M - M);
    175190
    176191    dLmax = MAX(fabs(starmap[N].points[i].dL), dLmax);
  • trunk/Ohana/src/relastro/src/UpdateChips.c

    r39457 r39926  
    4242  AstromErrorSetLoop (Nloop, TRUE);
    4343
     44  // if ChipMapLoop or ChipOrderLoop is set use that to define the value of CHIPMAP and/or CHIPORDER this loop
     45  if (ChipMapLoop) { CHIPMAP = ChipMapLoop[Nloop]; }
     46  if (ChipOrderLoop) { CHIPORDER = ChipOrderLoop[Nloop]; }
     47 
    4448  if (NTHREADS) {
    4549    UpdateChips_threaded (catalog, Ncatalog);
     
    6064  for (i = 0; i < Nimage; i++) {
    6165
    62     VERBOSE_IMAGE = !strcmp(image[i].name, "o5745g0516o.356887.cm.982631.smf[XY54]");
     66    VERBOSE = FALSE;
     67    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5745g0516o.356887.cm.982631.smf[XY45]");
     68    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5745g0526o.356899.cm.982643.smf[XY45]");
     69    VERBOSE_IMAGE |= !strcmp(image[i].name, "o5748g0436o.358811.cm.982690.smf[XY34]");
    6370
    6471    // XXX looks like everything below is thread safe : we can unroll this into a set of
    6572    // helper functions that grab the next available chip....
    6673
     74    // allow certain cameras to stay static
     75    if (SKIP_PS1_CHIP  && isGPC1chip (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     76    if (SKIP_PS1_STACK && isGPC1stack(image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     77    if (SKIP_HSC       && isHSCchip  (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     78    if (SKIP_CFH       && isCFHchip  (image[i].photcode)) { Nskip ++;  mode[i] = 0; continue; }
     79   
    6780    /* skip all except WRP images */
    6881    if (strcmp(&image[i].coords.ctype[4], "-WRP")) {
     
    160173    setImageRaw (catalog, Ncatalog, i, raw, Nraw, MODE_MOSAIC);
    161174    if (USE_GALAXY_MODEL) {
    162       // XXX DEPRECATE?
     175      // the image calibration was calculated using a galaxy motion model
    163176      image[i].flags |= ID_IMAGE_ASTROM_GMM;
    164177    }
     
    281294    }
    282295
     296    // allow certain cameras to stay static
     297    if (SKIP_PS1_CHIP  && isGPC1chip (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     298    if (SKIP_PS1_STACK && isGPC1stack(image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     299    if (SKIP_HSC       && isHSCchip  (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     300    if (SKIP_CFH       && isCFHchip  (image[i].photcode)) { threadinfo->Nskip ++;  threadinfo->mode[i] = 0; continue; }
     301   
    283302    /* skip all except WRP images */
    284303    if (strcmp(&image[i].coords.ctype[4], "-WRP")) {
  • trunk/Ohana/src/relastro/src/UpdateMeasures.c

    r39624 r39926  
    115115
    116116      // only modify the chip coordinates
    117       if (isGPC1chip (measureT->photcode)) {
     117      if (UPDATE_PS1_STACK_MEASURE && isGPC1stack (measureT->photcode)) {
     118        measureT->R = R;
     119        measureT->D = D;
     120        if (measureB) {
     121          measureB->R = R;
     122          measureB->D = D;
     123        }
     124      }
     125      // only modify the chip coordinates
     126      if (UPDATE_PS1_CHIP_MEASURE && isGPC1chip (measureT->photcode)) {
     127        measureT->R = R;
     128        measureT->D = D;
     129        if (measureB) {
     130          measureB->R = R;
     131          measureB->D = D;
     132        }
     133      }
     134      // only modify the chip coordinates
     135      if (UPDATE_HSC_MEASURE && isGPC1chip (measureT->photcode)) {
     136        measureT->R = R;
     137        measureT->D = D;
     138        if (measureB) {
     139          measureB->R = R;
     140          measureB->D = D;
     141        }
     142      }
     143      // only modify the chip coordinates
     144      if (UPDATE_CFH_MEASURE && isGPC1chip (measureT->photcode)) {
    118145        measureT->R = R;
    119146        measureT->D = D;
  • trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c

    r39693 r39926  
    167167    strextend (&command, "relastro_client -update-offsets");
    168168    strextend (&command, "-hostID %d", group->hosts[i][0].hostID);
     169    strextend (&command, "-hostdir %s", group->hosts[i][0].pathname);
     170
    169171    strextend (&command, "-D CATDIR %s", CATDIR);
    170     strextend (&command, "-hostdir %s", group->hosts[i][0].pathname);
    171172    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    172173    strextend (&command, "-statmode %s", STATMODE);
    173174    strextend (&command, "-minerror %f", MIN_ERROR);
    174175
     176    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     177    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     178
    175179    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    176180    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
     
    180184    if (VERBOSE2)      strextend (&command, "-vv");
    181185    if (RESET)         strextend (&command, "-reset");
    182     if (UPDATE)        strextend (&command, "-update");
    183 
    184     if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
    185186
    186187    if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    187188    if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    188    
    189     if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
    190189    if (FlagOutlier)     strextend (&command, "-clip %d", CLIP_THRESH);
    191190    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    192191   
    193     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
    194192    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    195 
    196     if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
    197     if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
    198 
    199193    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    200194    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     
    204198    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    205199
    206     if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    207 
    208200    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    209201      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     
    213205    }
    214206
     207    if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
     208    if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
     209
     210    if (UPDATE_PS1_STACK_MEASURE) strextend (&command, "-update-ps1-stack");
     211    if (UPDATE_PS1_CHIP_MEASURE) strextend (&command, "-update-ps1-chip");
     212    if (UPDATE_HSC_MEASURE)      strextend (&command, "-update-hsc");
     213    if (UPDATE_CFH_MEASURE)      strextend (&command, "-update-cfh");
     214
     215    if (UPDATE)        strextend (&command, "-update");
     216    if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
     217    if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
     218    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     219
    215220    if (MinBadQF > 0.0)        strextend (&command, "-min-bad-psfqf %f", MinBadQF);
    216221    if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset  %f", MaxMeanOffset);
     222    if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    217223
    218224    if (TimeSelect) {
     
    300306    strextend (&command, "relastro_client -update-offsets");
    301307    strextend (&command, "-hostID %d", table->hosts[i].hostID);
     308    strextend (&command, "-hostdir %s", table->hosts[i].pathname);
     309
    302310    strextend (&command, "-D CATDIR %s", CATDIR);
    303     strextend (&command, "-hostdir %s", table->hosts[i].pathname);
    304311    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    305312    strextend (&command, "-statmode %s", STATMODE);
    306313    strextend (&command, "-minerror %f", MIN_ERROR);
    307314
     315    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     316    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     317
    308318    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    309319    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
     
    313323    if (VERBOSE2)      strextend (&command, "-vv");
    314324    if (RESET)         strextend (&command, "-reset");
    315     if (UPDATE)        strextend (&command, "-update");
    316 
    317     if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
    318325
    319326    if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    320327    if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    321    
    322     if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
    323328    if (FlagOutlier)     strextend (&command, "-clip %d", CLIP_THRESH);
    324329    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    325330   
    326     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
    327331    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    328 
    329     if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
    330     if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
    331 
    332332    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    333333    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     
    337337    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    338338
    339     if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    340 
    341339    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    342340      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     
    345343      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    346344    }
     345
     346    if (REPAIR_STACKS)          strextend (&command, "-repair-stacks-on-update");
     347    if (CHECK_MEASURE_TO_IMAGE) strextend (&command, "-check-measures");
     348
     349    if (UPDATE_PS1_STACK_MEASURE) strextend (&command, "-update-ps1-stack");
     350    if (UPDATE_PS1_CHIP_MEASURE) strextend (&command, "-update-ps1-chip");
     351    if (UPDATE_HSC_MEASURE)      strextend (&command, "-update-hsc");
     352    if (UPDATE_CFH_MEASURE)      strextend (&command, "-update-cfh");
     353
     354    if (UPDATE)        strextend (&command, "-update");
     355    if (RESET_BAD_IMAGES) strextend (&command, "-reset-bad-images");
     356    if (USE_BASIC_CHECK) strextend (&command, "-basic-image-search");
     357    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     358
     359    if (N_BOOTSTRAP_SAMPLES > 1) strextend (&command, "-bootstrap-samples %d", N_BOOTSTRAP_SAMPLES);
    347360
    348361    if (MinBadQF > 0.0)        strextend (&command, "-min-bad-psfqf %f", MinBadQF);
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r39617 r39926  
    55# define PAR_MIN_NPTS 7
    66# define PAR_MIN_NPTS_BOOT 6
    7 # define PM_MIN_NPTS 4
    8 # define PM_MIN_NPTS_BOOT 3
    9 # define POS_MIN_NPTS 3
    10 # define POS_MIN_NPTS_BOOT 2
     7# define PM_MIN_NPTS 5
     8# define PM_MIN_NPTS_BOOT 4
     9# define POS_MIN_NPTS 4
     10# define POS_MIN_NPTS_BOOT 4
    1111
    1212typedef enum {
    13   SELECT_MEAS_HAS_DATA  = 1,
    14   SELECT_MEAS_HAS_STACK = 2,
    15   SELECT_MEAS_HAS_2MASS = 4,
     13  SELECT_MEAS_HAS_DATA  = 0x01,
     14  SELECT_MEAS_HAS_STACK = 0x02,
     15  SELECT_MEAS_HAS_2MASS = 0x04,
     16  SELECT_MEAS_HAS_GAIA  = 0x08,
     17  SELECT_MEAS_HAS_TYCHO = 0x10,
    1618} SelectMeasureStatus;
    1719
     
    181183    if (Trange < PM_DT_MIN) {
    182184      // not enough baseline for proper motion, only set mean position
    183       mode = FIT_AVERAGE;
    184185      goto justPosition;
    185186    }
    186187    if (parRange < PAR_FACTOR_MIN) {
    187188      // not enough parallax factor range, skip parallax
    188       mode = FIT_PM_ONLY;
    189189      goto skipParallax;
    190190    }
    191191    if (fitStats->Npoints < PAR_MIN_NPTS) {
    192192      // not enough data, skip parallax
    193       mode = FIT_PM_ONLY;
    194193      goto skipParallax;
    195194    }
    196195
    197196    // we are going to use the IRLS analysis to calculate the mean solution and the masking
    198     // then run N_BOOTSTRAP_SAMPLES to measure the errors
    199     fitStats->fitdataPar->getError = !N_BOOTSTRAP_SAMPLES;
    200     if (!FitPMandPar_IRLS (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
    201       mode = FIT_PM_ONLY;
    202       goto skipParallax;
    203     }
    204 
    205     if (N_BOOTSTRAP_SAMPLES) {
     197    // then run N_BOOTSTRAP_SAMPLES to measure the errors.  We first measure the OLS error,
     198    // and choose the max of the OLS and bootstrap errors
     199    fitStats->fitdataPar->getError = TRUE;
     200    if (USE_IRLS) {
     201      if (!FitPMandPar_IRLS (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
     202        goto skipParallax;
     203      }
     204    } else {
     205      if (!FitPMandPar_Basic (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints)) {
     206        goto skipParallax;
     207      }
     208    }
     209
     210    // in the fits above, we have saved the formal error for the unmasked points. 
     211    // if we do not have enough points for bootstrap, we will keep those errors
     212    if (N_BOOTSTRAP_SAMPLES && (fitPar.Nfit >= PAR_MIN_NPTS_BOOT)) {
    206213      fitStats->Nfit = 0;
    207214      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    208       if (Nnomask < PAR_MIN_NPTS_BOOT) {
    209         // if we do not have enough points to assess parallax error, we cannot do the bootstrap analysis.
    210         mode = FIT_PM_ONLY;
    211         goto skipParallax;
    212       }
     215
     216      // if we do not have enough points to assess parallax error, skip the bootstrap analysis.
     217      // (I think the test above means we never do this skip)
     218      if (Nnomask < PAR_MIN_NPTS_BOOT) goto skipParallaxBootstrap;
     219
    213220      for (k = 0; k < fitStats->NfitAlloc; k++) {
    214221        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     
    216223        fitStats->Nfit ++;
    217224      }
    218       // these calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     225
     226      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     227      // this call expects the fitted parameters to have the formal error set: it will apply the
     228      // max of the formal and bootstrap errors
    219229      BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    220230      BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     
    224234    }
    225235
     236  skipParallaxBootstrap:
    226237    // project Ro, Do back to RA,DEC
    227238    XY_to_RD (&fitPar.Ro, &fitPar.Do, fitPar.Ro, fitPar.Do, &fitStats->coords);
     
    242253    valid = valid && (fabs(fitPar.uD) < 4.0);
    243254    valid = valid && (fabs(fitPar.p) < 2.0);
    244     if (!valid) {
    245       mode = FIT_PM_ONLY;
    246     } else {
     255    if (valid) {
    247256      average[0].flags |= ID_OBJ_USE_PAR;
    248257    }
     
    254263  if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) {
    255264    if (Trange < PM_DT_MIN) {
    256       mode = FIT_AVERAGE;
    257265      goto justPosition;
    258266    }
    259267    if (fitStats->Npoints < PM_MIN_NPTS) {
    260       mode = FIT_AVERAGE;
    261268      goto justPosition;
    262269    }
    263270
    264271    // if we have fitted (and accepted) a parallax model, get the best pm fit and chisq
    265     // given the set of points (mask is respected)
    266     if (average[0].flags & ID_OBJ_USE_PAR) {
     272    // given the set of points (mask is respected).  Alternatively, if we do not request
     273    // IRLS fitting, the just use OLS fitting (skip bootstrap)
     274    if ((average[0].flags & ID_OBJ_USE_PAR) || !USE_IRLS) {
    267275      if (!FitPM_Basic (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    268276        average[0].flags |= ID_OBJ_BAD_PM;
    269277        goto justPosition;
    270278      }
    271     } else {
    272       fitStats->fitdataPM->getError = !N_BOOTSTRAP_SAMPLES;
    273       if (!FitPM_IRLS (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    274         mode = FIT_AVERAGE;
    275         goto justPosition;
    276       }
    277       if (N_BOOTSTRAP_SAMPLES) {
    278         fitStats->Nfit = 0;
    279         int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    280         if (Nnomask < PM_MIN_NPTS_BOOT) {
    281           mode = FIT_AVERAGE;
    282           goto justPosition;
    283         }
    284         for (k = 0; k < fitStats->NfitAlloc; k++) {
    285           BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
    286           if (!FitPM_Basic (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, Nnomask)) continue;
    287           fitStats->Nfit ++;
    288         }
    289         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    290         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
    291         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR);
    292         BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD);
    293       }
    294     }
    295 
     279      goto skipProperMotionBootstrap;
     280    }
     281
     282    // we are going to use the IRLS analysis to calculate the mean solution and the masking
     283    // then run N_BOOTSTRAP_SAMPLES to measure the errors.  We first measure the OLS error,
     284    // and choose the max of the OLS and bootstrap errors
     285    fitStats->fitdataPM->getError = TRUE;
     286    if (!FitPM_IRLS (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
     287      goto justPosition;
     288    }
     289
     290    // in the fits above, we have saved the formal error for the unmasked points. 
     291    // if we do not have enough points for bootstrap, we will keep those errors
     292    if (N_BOOTSTRAP_SAMPLES && (fitPM.Nfit >= PM_MIN_NPTS_BOOT)) {
     293      fitStats->Nfit = 0;
     294      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
     295       
     296      // if we do not have enough points to assess p.m. error, skip the bootstrap analysis.
     297      // (I think the test above means we never do this skip)
     298      if (Nnomask < PM_MIN_NPTS_BOOT) goto skipProperMotionBootstrap;
     299
     300      for (k = 0; k < fitStats->NfitAlloc; k++) {
     301        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     302        if (!FitPM_Basic (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, Nnomask)) continue;
     303        fitStats->Nfit ++;
     304      }
     305
     306      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     307      // this call expects the fitted parameters to have the formal error set: it will apply the
     308      // max of the formal and bootstrap errors
     309      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
     310      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     311      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR);
     312      BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD);
     313    }
     314
     315skipProperMotionBootstrap:
    296316    // project Ro, Do back to RA,DEC
    297317    XY_to_RD (&fitPM.Ro, &fitPM.Do, fitPM.Ro, fitPM.Do, &fitStats->coords);
     
    300320    fitStats->Npm ++;
    301321
     322    // XXX a hard-wired hack...
    302323    // unless there is a clear problems (below) with the proper-motion fit or we have a parallax fit, we will use pm fit
    303324    int valid = TRUE;
     
    309330    valid = valid && (fabs(fitPM.uD) < 4.0);
    310331    if (!valid) {
    311       mode = FIT_AVERAGE;
    312332      average[0].flags |= ID_OBJ_BAD_PM;
    313333    } else {
     
    323343    // if we only have one point, this is silly...
    324344
     345    // set the proper motion (to the galaxy model or average value, if desired; else to 0,0)
    325346    FitAstromResultSetPM (&fitPos, 1, average);
    326     // fprintf (stderr, "fit 1: %f %f : %f %f\n", fitPos.Ro, fitPos.Do, fitPos.uR, fitPos.uD);
    327     if (average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM)) {
     347
     348    // if we already have a valid fit (pm or par), use OLS to fit the position
     349    // alternatively, if we do not request IRLS, use OLS
     350    // alternatively, if we do not have enough points, use OLS
     351    if ((average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM)) || (fitStats->Npoints < POS_MIN_NPTS) || !USE_IRLS) {
    328352      if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    329         // if this fails, stick with the PM and/or PAR fit from above
     353        // if this fails, stick with the PM and/or PAR fit from above, or use a single value
    330354        goto doneWithFit;
    331355      }
    332     } else {
    333       if (fitStats->Npoints < POS_MIN_NPTS) {
    334         // I will not try to outlier-reject, just calculate the weighted average
    335         if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    336           // if we have tried this, we have not masked any points; we will find a single unmasked point below
    337           goto doneWithFit;
    338         }
     356      // if we have not already gotten a good fit, use this fit
     357      if (!(average[0].flags & (ID_OBJ_USE_PAR | ID_OBJ_USE_PM))) {
    339358        average[0].flags |= ID_OBJ_USE_AVE;
    340359        average[0].flags |= ID_OBJ_RAW_AVE;
    341         goto useBasic;
    342       }
    343       if (!FitPosPMfixed_IRLS (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    344         // if the above fails, we need to clear the masks and try again below
    345         FitPointsClearMasks (fitStats->points, fitStats->Npoints);
    346         // just calculate the weighted average
    347         if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    348           // if this fails, find a single unmasked point below
    349           goto doneWithFit;
    350         }
    351         average[0].flags |= ID_OBJ_USE_AVE;
    352         average[0].flags |= ID_OBJ_RAW_AVE;
    353         goto useBasic;
    354       }
    355       // fprintf (stderr, "fit 2: %f %f : %f %f\n", fitPos.Ro, fitPos.Do, fitPos.uR, fitPos.uD);
    356       if (N_BOOTSTRAP_SAMPLES) {
    357         fitStats->Nfit = 0;
    358         int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
    359         if (Nnomask < POS_MIN_NPTS_BOOT) {
    360           // if the above fails, we need to clear the masks and try again below
    361           FitPointsClearMasks (fitStats->points, fitStats->Npoints);
    362           if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
    363             // if this fails, find a single unmasked point below
    364             goto doneWithFit;
    365           }
    366           average[0].flags |= ID_OBJ_USE_AVE;
    367           average[0].flags |= ID_OBJ_RAW_AVE;
    368           goto useBasic;
    369         }
    370         FitAstromResultSetPM (fitStats->fit, fitStats->NfitAlloc, average);
    371         for (k = 0; k < fitStats->NfitAlloc; k++) {
    372           BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
    373           if (!FitPosPMfixed_Basic (&fitStats->fit[k], fitStats->fitdataPos, fitStats->sample, Nnomask)) continue;
    374           fitStats->Nfit ++;
    375         }
    376         BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
    377         BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
     360      }
     361      goto useBasic;
     362    }
     363   
     364    // try the IRLS fitting, otherwise give up and use OLS
     365    if (!FitPosPMfixed_IRLS (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
     366      // if the above fails, we need to clear the masks and try again below
     367      FitPointsClearMasks (fitStats->points, fitStats->Npoints);
     368      // just calculate the weighted average
     369      if (!FitPosPMfixed_Basic (&fitPos, fitStats->fitdataPos, fitStats->points, fitStats->Npoints)) {
     370        // if this fails, find a single unmasked point below
     371        goto doneWithFit;
    378372      }
    379373      average[0].flags |= ID_OBJ_USE_AVE;
     374      average[0].flags |= ID_OBJ_RAW_AVE;
     375      goto useBasic;
     376    }
     377    average[0].flags |= ID_OBJ_USE_AVE;
     378
     379    if (N_BOOTSTRAP_SAMPLES && (fitPos.Nfit >= POS_MIN_NPTS_BOOT)) {
     380      fitStats->Nfit = 0;
     381      int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints);
     382     
     383      if (Nnomask < POS_MIN_NPTS_BOOT) goto useBasic;
     384     
     385      FitAstromResultSetPM (fitStats->fit, fitStats->NfitAlloc, average);
     386      for (k = 0; k < fitStats->NfitAlloc; k++) {
     387        BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask);
     388        if (!FitPosPMfixed_Basic (&fitStats->fit[k], fitStats->fitdataPos, fitStats->sample, Nnomask)) continue;
     389        fitStats->Nfit ++;
     390      }
     391     
     392      // These calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above)
     393      // this call expects the fitted parameters to have the formal error set: it will apply the
     394      // max of the formal and bootstrap errors
     395      BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);
     396      BootstrapRobustStats (&fitPos, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);
    380397    }
    381398
     
    544561  average[0].dP         = fit.dp; // parallax error in arcsec
    545562
     563
    546564  average[0].ChiSqAve   = fitPos.chisq;
    547565  average[0].ChiSqPM    = fitPM.chisq;
     
    666684
    667685  int has2MASS = FALSE;
     686  int hasGAIA  = FALSE;
     687  int hasTycho = FALSE;
    668688  int hasStack = FALSE;
    669689  if (stackEntry) *stackEntry = -1;
     
    774794    Npoints++;
    775795
    776     if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) {
    777       has2MASS = TRUE;
    778     }
     796    hasGAIA  =  (measure[k].photcode == 1030);
     797    has2MASS = ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013));
     798    hasTycho = ((measure[k].photcode >= 2020) && (measure[k].photcode <= 2021));
    779799
    780800    myAssert (Npoints <= fit->NpointsAlloc, "oops");
     
    796816      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_2MASS;
    797817    }
     818    if (hasGAIA) {
     819      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_GAIA;
     820    } else {
     821      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_GAIA;
     822    }
     823    if (hasTycho) {
     824      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_TYCHO;
     825    } else {
     826      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_TYCHO;
     827    }
    798828  }
    799829
     
    803833  if (hasStack) status |= SELECT_MEAS_HAS_STACK;
    804834  if (has2MASS) status |= SELECT_MEAS_HAS_2MASS;
     835  if (hasGAIA)  status |= SELECT_MEAS_HAS_GAIA;
     836  if (hasTycho) status |= SELECT_MEAS_HAS_TYCHO;
    805837  return status;
    806838}
     
    822854
    823855  int i;
     856
     857  myAbort ("this should not be called anymore");
    824858
    825859  // add up the chi square for the fit
     
    852886  int i;
    853887
    854   if (USE_GALAXY_MODEL) {
     888  if (APPLY_PROPER_MOTION) {
    855889    for (i = 0; i < Nfit; i++) {
    856       fit[i].uR = average->uRgal;
    857       fit[i].uD = average->uDgal;
     890      if (USE_GALAXY_MODEL) {
     891        fit[i].uR = average->uRgal;
     892        fit[i].uD = average->uDgal;
     893      } else {
     894        fit[i].uR = average->uR;
     895        fit[i].uD = average->uD;
     896      }
    858897    }
    859898  } else {
  • trunk/Ohana/src/relastro/src/UpdateStacks.c

    r39457 r39926  
    33// NOTE: we only measure the systematic floor of the astrometric scatter per stack, no change to the calibration
    44int UpdateStacks (Catalog *catalog, int Ncatalog) {
     5
     6  if (SKIP_PS1_STACK) return TRUE;
    57
    68  off_t Nimage;
     
    4648
    4749    // XXX: I need to convert dLsig, dMsig from degrees to pixels
    48     dLsig *= 3600.0 / 0.25;
    49     dMsig *= 3600.0 / 0.25;
     50    dLsig *= 3600.0;
     51    dMsig *= 3600.0;
    5052
    5153    image[i].dXpixSys = dLsig;
  • trunk/Ohana/src/relastro/src/args.c

    r39693 r39926  
    11# include "relastro.h"
    2 void usage (void);
    3 void usage_client (void);
     2void usage (int argc, char **argv);
     3void usage_client (int argc, char **argv);
    44void usage_merge_source (void);
    55void usage_merge_source_id (char *name);
    66float *ParseLoopWeights (char *rawlist);
     7int *ParseLoopOrder (char *rawlist, int minValue);
    78
    89int args (int argc, char **argv) {
     
    3940    remove_argument (N, &argc, argv);
    4041
    41     if (argc != 1) usage ();
     42    if (argc != 1) usage (argc, argv);
    4243    return TRUE;
    4344  }
     
    7677    remove_argument (N, &argc, argv);
    7778    CHECK_MEASURE_TO_IMAGE = TRUE;
     79  }
     80
     81  // catch-up mode : for a re-run, allow the sync file to be ahead of the desired location:
     82  CATCH_UP = FALSE;
     83  if ((N = get_argument (argc, argv, "-catch-up"))) {
     84    remove_argument (N, &argc, argv);
     85    CATCH_UP = TRUE;
    7886  }
    7987
     
    105113    remove_argument (N, &argc, argv);
    106114    RELASTRO_OP = OP_PARALLEL_IMAGES;
    107     if (N >= argc) usage();
     115    if (N >= argc) usage (argc, argv);
    108116    IMAGE_TABLE = strcreate (argv[N]);
    109117    remove_argument (N, &argc, argv);
    110     if (!REGION_FILE) usage();
     118    if (!REGION_FILE) usage (argc, argv);
    111119  }
    112120
     
    114122    remove_argument (N, &argc, argv);
    115123    RELASTRO_OP = OP_IMAGES;
     124  }
     125
     126  // used to decide if changes to the image parameters get applied to the measures
     127  APPLY_OFFSETS = FALSE;
     128  if ((N = get_argument (argc, argv, "-apply-offsets"))) {
     129    remove_argument (N, &argc, argv);
     130    APPLY_OFFSETS = TRUE;
     131  }
     132
     133  APPLY_PROPER_MOTION = FALSE;
     134  if ((N = get_argument (argc, argv, "-apply-proper-motion"))) {
     135    remove_argument (N, &argc, argv);
     136    APPLY_PROPER_MOTION = TRUE;
     137  }
     138
     139  SKIP_PS1_CHIP = FALSE;
     140  if ((N = get_argument (argc, argv, "-skip-ps1-chip"))) {
     141    remove_argument (N, &argc, argv);
     142    SKIP_PS1_CHIP = TRUE;
     143  }
     144  SKIP_PS1_STACK = FALSE;
     145  if ((N = get_argument (argc, argv, "-skip-ps1-stack"))) {
     146    remove_argument (N, &argc, argv);
     147    SKIP_PS1_STACK = TRUE;
     148  }
     149  SKIP_HSC = FALSE;
     150  if ((N = get_argument (argc, argv, "-skip-hsc"))) {
     151    remove_argument (N, &argc, argv);
     152    SKIP_HSC = TRUE;
     153  }
     154  SKIP_CFH = FALSE;
     155  if ((N = get_argument (argc, argv, "-skip-cfh"))) {
     156    remove_argument (N, &argc, argv);
     157    SKIP_CFH = TRUE;
     158  }
     159
     160  UPDATE_PS1_STACK_MEASURE = FALSE;
     161  if ((N = get_argument (argc, argv, "-update-ps1-stack"))) {
     162    remove_argument (N, &argc, argv);
     163    UPDATE_PS1_STACK_MEASURE = TRUE;
     164  }
     165  UPDATE_PS1_CHIP_MEASURE = FALSE;
     166  if ((N = get_argument (argc, argv, "-update-ps1-chip"))) {
     167    remove_argument (N, &argc, argv);
     168    UPDATE_PS1_CHIP_MEASURE = TRUE;
     169  }
     170  UPDATE_HSC_MEASURE = FALSE;
     171  if ((N = get_argument (argc, argv, "-update-hsc"))) {
     172    remove_argument (N, &argc, argv);
     173    UPDATE_HSC_MEASURE = TRUE;
     174  }
     175  UPDATE_CFH_MEASURE = FALSE;
     176  if ((N = get_argument (argc, argv, "-update-cfh"))) {
     177    remove_argument (N, &argc, argv);
     178    UPDATE_CFH_MEASURE = TRUE;
     179  }
     180  if (RELASTRO_OP == OP_UPDATE_OFFSETS) {
     181    if (!UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     182      fprintf (stderr, "for -update-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     183      exit (2);
     184    }
     185  }
     186  if ((RELASTRO_OP == OP_PARALLEL_IMAGES) || (RELASTRO_OP == OP_IMAGES)) {
     187    if (APPLY_OFFSETS && !UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     188      fprintf (stderr, "for [-images or -parallel-images] with -apply-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     189      exit (2);
     190    }
     191  }
     192
     193  // for fitting objects, this is always the same as 'ALLOW_IRLS' below, but for fitting
     194  // images, this is set to FALSE while doing the fit for the image parameters
     195  USE_IRLS = TRUE; 
     196  ALLOW_IRLS = TRUE;
     197  if ((N = get_argument (argc, argv, "-no-irls"))) {
     198    remove_argument (N, &argc, argv);
     199    USE_IRLS = FALSE;
     200    ALLOW_IRLS = FALSE;
    116201  }
    117202
     
    120205    remove_argument (N, &argc, argv);
    121206    RELASTRO_OP = OP_PARALLEL_REGIONS;
    122     if (!REGION_FILE) usage();
     207    if (!REGION_FILE) usage (argc, argv);
    123208    if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) {
    124209      remove_argument (N, &argc, argv);
     
    128213
    129214  if ((N = get_argument (argc, argv, "-testobj1"))) {
    130     if (N > argc - 3) usage ();
     215    if (N > argc - 3) usage (argc, argv);
    131216    remove_argument (N, &argc, argv);
    132217    OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
    133     if (*endptr) usage ();
     218    if (*endptr) usage (argc, argv);
    134219    remove_argument (N, &argc, argv);
    135220    CAT_ID_SRC = strtol(argv[N], &endptr, 0);
    136     if (*endptr) usage ();
     221    if (*endptr) usage (argc, argv);
    137222    remove_argument (N, &argc, argv);
    138223  }
    139224
    140225  if ((N = get_argument (argc, argv, "-testobj2"))) {
    141     if (N > argc - 3) usage ();
     226    if (N > argc - 3) usage (argc, argv);
    142227    remove_argument (N, &argc, argv);
    143228    OBJ_ID_DST = strtol(argv[N], &endptr, 0);
    144     if (*endptr) usage ();
     229    if (*endptr) usage (argc, argv);
    145230    remove_argument (N, &argc, argv);
    146231    CAT_ID_DST = strtol(argv[N], &endptr, 0);
    147     if (*endptr) usage ();
     232    if (*endptr) usage (argc, argv);
    148233    remove_argument (N, &argc, argv);
    149234  }
     
    167252  if ((N = get_argument (argc, argv, "-high-speed"))) {
    168253    // XXX include a parallax / no-parallax option
    169     if (N >= argc - 4) usage();
     254    if (N >= argc - 4) usage (argc, argv);
    170255    RELASTRO_OP = OP_HIGH_SPEED;
    171256    remove_argument (N, &argc, argv);
     
    181266
    182267  if ((N = get_argument (argc, argv, "-hpm"))) {
    183     if (N >= argc - 2) usage();
     268    if (N >= argc - 2) usage (argc, argv);
    184269    RELASTRO_OP = OP_HPM;
    185270    remove_argument (N, &argc, argv);
     
    212297    FIT_TARGET = TARGET_MOSAICS;
    213298  }
     299  if ((N = get_argument (argc, argv, "-set-chips"))) {
     300    remove_argument (N, &argc, argv);
     301    FIT_TARGET = SET_CHIPS;
     302  }
    214303
    215304  FlagOutlier = FALSE;
     
    231320  }
    232321
    233   if (RELASTRO_OP == OP_NONE) usage();
    234 
    235   if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage();
     322  if (RELASTRO_OP == OP_NONE) usage (argc, argv);
     323
     324  if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage (argc, argv);
    236325
    237326  /* specify portion of the sky : allow default of all sky? */
     
    303392  }
    304393
     394  KEEP_ALL_IMAGES_RA = FALSE;
     395  if ((N = get_argument (argc, argv, "-keep-all-images-ra"))) {
     396    remove_argument (N, &argc, argv);
     397    KEEP_ALL_IMAGES_RA = TRUE;
     398  }
     399
    305400  USE_BASIC_CHECK = FALSE;
    306401  if ((N = get_argument (argc, argv, "-basic-image-search"))) {
     
    315410    remove_argument (N, &argc, argv);
    316411    MaxDensityUse = TRUE;
    317   }
    318 
    319   APPLY_OFFSETS = FALSE;
    320   if ((N = get_argument (argc, argv, "-apply-offsets"))) {
    321     remove_argument (N, &argc, argv);
    322     APPLY_OFFSETS = TRUE;
    323412  }
    324413
     
    439528  }
    440529
    441   CHIPORDER = 0;
    442   if ((N = get_argument (argc, argv, "-chiporder"))) {
    443     remove_argument (N, &argc, argv);
    444     CHIPORDER = atoi(argv[N]);
    445     remove_argument (N, &argc, argv);
    446   }
    447 
    448   CHIPMAP = 0;
    449   if ((N = get_argument (argc, argv, "-chipmap"))) {
    450     remove_argument (N, &argc, argv);
    451     CHIPMAP = atoi(argv[N]);
    452     remove_argument (N, &argc, argv);
    453 
    454   }
    455 
    456530  SAVEPLOT = FALSE;
    457531  PLOTSTUFF = FALSE;
     
    580654  }
    581655
     656  // e.g., -chiporderloop 3,4,5
     657  // NOTE: this must come after -nloop above
     658  ChipOrderLoop = NULL;
     659  ChipOrderLoopStr = NULL;
     660  CHIPORDER = 1;
     661  if ((N = get_argument (argc, argv, "-chiporder"))) {
     662    remove_argument (N, &argc, argv);
     663    CHIPORDER = atoi(argv[N]);
     664    remove_argument (N, &argc, argv);
     665  }
     666  if ((N = get_argument (argc, argv, "-chiporderloop"))) {
     667    remove_argument (N, &argc, argv);
     668    ChipOrderLoopStr = strcreate(argv[N]);
     669    ChipOrderLoop = ParseLoopOrder (argv[N], 1);
     670    remove_argument (N, &argc, argv);
     671  }
     672
     673  ChipMapLoop = NULL;
     674  ChipMapLoopStr = NULL;
     675  CHIPMAP = 0;
     676  if ((N = get_argument (argc, argv, "-chipmap"))) {
     677    remove_argument (N, &argc, argv);
     678    CHIPMAP = atoi(argv[N]);
     679    remove_argument (N, &argc, argv);
     680
     681  }
     682  if ((N = get_argument (argc, argv, "-chipmaploop"))) {
     683    remove_argument (N, &argc, argv);
     684    ChipMapLoopStr = strcreate(argv[N]);
     685    ChipMapLoop = ParseLoopOrder (argv[N], 0);
     686    remove_argument (N, &argc, argv);
     687  }
     688 
     689
    582690  // e.g., -loop-weights-2mass 1000,300,300,200,200,100
    583691  // NOTE: this must come after -nloop above
     
    591699  }
    592700  LoopWeightTycho = NULL;
     701  LoopWeightTychostr = NULL;
    593702  if ((N = get_argument (argc, argv, "-loop-weights-tycho"))) {
    594703    remove_argument (N, &argc, argv);
     
    597706    remove_argument (N, &argc, argv);
    598707  }
     708  LoopWeightGAIA = NULL;
     709  LoopWeightGAIAstr = NULL;
     710  if ((N = get_argument (argc, argv, "-loop-weights-gaia"))) {
     711    remove_argument (N, &argc, argv);
     712    LoopWeightGAIAstr = strcreate(argv[N]);
     713    LoopWeightGAIA = ParseLoopWeights (argv[N]);
     714    remove_argument (N, &argc, argv);
     715  }
     716
     717  GALAXY_MODEL = NULL;
     718  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     719    remove_argument (N, &argc, argv);
     720    GALAXY_MODEL = strcreate(argv[N]);
     721    remove_argument (N, &argc, argv);
     722  }
     723  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     724
     725  // for testing, allow the galaxy model scale to be non-unity
     726  TEST_SCALE = 1.0;
     727  if ((N = get_argument (argc, argv, "-testing"))) {
     728    remove_argument (N, &argc, argv);
     729    TEST_SCALE = atof(argv[N]);
     730    remove_argument (N, &argc, argv);
     731  }
    599732
    600733  NTHREADS = 0;
     
    605738  }
    606739
    607   if (argc != 1) usage ();
     740  if (argc != 1) usage (argc, argv);
    608741  return TRUE;
    609742}
     
    614747  FREE (LoopWeight2MASSstr);
    615748  FREE (LoopWeightTychostr);
     749  FREE (LoopWeightGAIAstr);
     750  FREE (LoopWeight2MASS);
     751  FREE (LoopWeightTycho);
     752  FREE (LoopWeightGAIA);
     753
     754  FREE (ChipMapLoop);
     755  FREE (ChipMapLoopStr);
     756  FREE (ChipOrderLoop);
     757  FREE (ChipOrderLoopStr);
    616758
    617759  FREE (PHOTCODE_SKIP_LIST);
     
    628770  FREE (BCATALOG);
    629771  FREE (HOSTDIR);
     772  FREE (GALAXY_MODEL);
    630773
    631774  // these are set in initialize
     
    673816    remove_argument (N, &argc, argv);
    674817  }
    675   if (!HOST_ID) usage_client();
     818  if (!HOST_ID) usage_client (argc, argv);
    676819
    677820  HOSTDIR = NULL;
     
    681824    remove_argument (N, &argc, argv);
    682825  }
    683   if (!HOSTDIR) usage_client();
     826  if (!HOSTDIR) usage_client (argc, argv);
    684827
    685828  if ((N = get_argument (argc, argv, "-load-objects"))) {
     
    726869  }
    727870
     871  SKIP_PS1_CHIP = FALSE;
     872  if ((N = get_argument (argc, argv, "-skip-ps1-chip"))) {
     873    remove_argument (N, &argc, argv);
     874    SKIP_PS1_CHIP = TRUE;
     875  }
     876  SKIP_PS1_STACK = FALSE;
     877  if ((N = get_argument (argc, argv, "-skip-ps1-stack"))) {
     878    remove_argument (N, &argc, argv);
     879    SKIP_PS1_STACK = TRUE;
     880  }
     881  SKIP_HSC = FALSE;
     882  if ((N = get_argument (argc, argv, "-skip-hsc"))) {
     883    remove_argument (N, &argc, argv);
     884    SKIP_HSC = TRUE;
     885  }
     886  SKIP_CFH = FALSE;
     887  if ((N = get_argument (argc, argv, "-skip-cfh"))) {
     888    remove_argument (N, &argc, argv);
     889    SKIP_CFH = TRUE;
     890  }
     891
     892  UPDATE_PS1_STACK_MEASURE = FALSE;
     893  if ((N = get_argument (argc, argv, "-update-ps1-stack"))) {
     894    remove_argument (N, &argc, argv);
     895    UPDATE_PS1_STACK_MEASURE = TRUE;
     896  }
     897  UPDATE_PS1_CHIP_MEASURE = FALSE;
     898  if ((N = get_argument (argc, argv, "-update-ps1-chip"))) {
     899    remove_argument (N, &argc, argv);
     900    UPDATE_PS1_CHIP_MEASURE = TRUE;
     901  }
     902  UPDATE_HSC_MEASURE = FALSE;
     903  if ((N = get_argument (argc, argv, "-update-hsc"))) {
     904    remove_argument (N, &argc, argv);
     905    UPDATE_HSC_MEASURE = TRUE;
     906  }
     907  UPDATE_CFH_MEASURE = FALSE;
     908  if ((N = get_argument (argc, argv, "-update-cfh"))) {
     909    remove_argument (N, &argc, argv);
     910    UPDATE_CFH_MEASURE = TRUE;
     911  }
     912  if (RELASTRO_OP == OP_UPDATE_OFFSETS) {
     913    if (!UPDATE_PS1_STACK_MEASURE && !UPDATE_PS1_CHIP_MEASURE && !UPDATE_HSC_MEASURE && !UPDATE_CFH_MEASURE) {
     914      fprintf (stderr, "for -update-offsets, need to select at least one of -update-ps1-stack, -update-ps1-chip, -update-hsc, -update-cfh\n");
     915      exit (2);
     916    }
     917  }
     918
    728919  // check for object fitting modes
    729920  if ((N = get_argument (argc, argv, "-pm"))) {
     
    742933  if ((N = get_argument (argc, argv, "-high-speed"))) {
    743934    // XXX include a parallax / no-parallax option
    744     if (N >= argc - 5) usage_client();
     935    if (N >= argc - 5) usage_client (argc, argv);
    745936    RELASTRO_OP = OP_HIGH_SPEED;
    746937    remove_argument (N, &argc, argv);
     
    756947
    757948  if ((N = get_argument (argc, argv, "-hpm"))) {
    758     if (N >= argc - 3) usage();
     949    if (N >= argc - 3) usage_client (argc, argv);
    759950    RELASTRO_OP = OP_HPM;
    760951    remove_argument (N, &argc, argv);
     
    766957
    767958  if ((N = get_argument (argc, argv, "-testobj1"))) {
    768     if (N > argc - 3) usage ();
     959    if (N > argc - 3) usage_client (argc, argv);
    769960    remove_argument (N, &argc, argv);
    770961    OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
    771     if (*endptr) usage ();
     962    if (*endptr) usage_client (argc, argv);
    772963    remove_argument (N, &argc, argv);
    773964    CAT_ID_SRC = strtol(argv[N], &endptr, 0);
    774     if (*endptr) usage ();
     965    if (*endptr) usage_client (argc, argv);
    775966    remove_argument (N, &argc, argv);
    776967  }
    777968
    778969  if ((N = get_argument (argc, argv, "-testobj2"))) {
    779     if (N > argc - 3) usage ();
     970    if (N > argc - 3) usage_client (argc, argv);
    780971    remove_argument (N, &argc, argv);
    781972    OBJ_ID_DST = strtol(argv[N], &endptr, 0);
    782     if (*endptr) usage ();
     973    if (*endptr) usage_client (argc, argv);
    783974    remove_argument (N, &argc, argv);
    784975    CAT_ID_DST = strtol(argv[N], &endptr, 0);
    785     if (*endptr) usage ();
     976    if (*endptr) usage_client (argc, argv);
    786977    remove_argument (N, &argc, argv);
    787978  }
     
    805996  }
    806997
    807   if (RELASTRO_OP == OP_NONE) usage_client();
     998  GALAXY_MODEL = NULL;
     999  if ((N = get_argument (argc, argv, "-galaxy-model"))) {
     1000    remove_argument (N, &argc, argv);
     1001    GALAXY_MODEL = strcreate(argv[N]);
     1002    remove_argument (N, &argc, argv);
     1003  }
     1004  if (!GALAXY_MODEL) GALAXY_MODEL = strcreate ("FEAST-HIPPARCOS");
     1005
     1006  // for testing, allow the galaxy model scale to be non-unity
     1007  TEST_SCALE = 1.0;
     1008  if ((N = get_argument (argc, argv, "-testing"))) {
     1009    remove_argument (N, &argc, argv);
     1010    TEST_SCALE = atof(argv[N]);
     1011    remove_argument (N, &argc, argv);
     1012  }
     1013
     1014  if (RELASTRO_OP == OP_NONE) usage_client (argc, argv);
    8081015
    8091016  /* specify portion of the sky : allow default of all sky? */
     
    10321239  }
    10331240
    1034   if (argc != 1) usage_client ();
     1241  if (argc != 1) usage_client (argc, argv);
    10351242  return TRUE;
    10361243}
     
    10491256  FREE(HIGH_SPEED_DIR);
    10501257  FREE(BCATALOG);
    1051   FREE (HOSTDIR);
     1258  FREE(HOSTDIR);
     1259  FREE(GALAXY_MODEL);
    10521260
    10531261  // these are set in initialize
     
    10661274}
    10671275
    1068 void usage () {
     1276void usage (int argc, char **argv) {
    10691277  fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n");
    10701278  fprintf (stderr, "       OR:    relastro -images -update-chips [options]\n");
     
    11161324  fprintf (stderr, "  -v\n");
    11171325  fprintf (stderr, "  \n");
     1326
     1327  fprintf (stderr, "remaining args: ");
     1328  for (int i = 0; i < argc; i++) {
     1329    fprintf (stderr, "%s ", argv[i]);
     1330  }
     1331  fprintf (stderr, "\n");
     1332
    11181333  exit (2);
    11191334}
    11201335
    1121 void usage_client () {
     1336void usage_client (int argc, char **argv) {
    11221337  fprintf (stderr, "ERROR: USAGE: relastro_client -load\n");
    11231338  fprintf (stderr, "       OR:    relastro_client -update-offsets\n");
     
    11501365  fprintf (stderr, "  -v\n");
    11511366  fprintf (stderr, "  \n");
     1367
     1368  fprintf (stderr, "remaining args: ");
     1369  for (int i = 0; i < argc; i++) {
     1370    fprintf (stderr, "%s ", argv[i]);
     1371  }
     1372  fprintf (stderr, "\n");
     1373
    11521374  exit (2);
    11531375}
     
    11891411  }
    11901412
     1413  // this sets the last loops to match the last value...
    11911414  while (Nloop < NLOOP) {
    11921415    weights[Nloop] = weights[Nloop - 1];
    11931416    Nloop ++;
    11941417  }
     1418
    11951419  return weights;
    11961420}
     1421
     1422int *ParseLoopOrder (char *rawlist, int minValue) {
     1423
     1424  int *orders = NULL;
     1425  ALLOCATE (orders, int, NLOOP);
     1426
     1427  int Nloop = 0;
     1428
     1429  /* parse the comma-separated list of photcodes */
     1430  char *myList = strcreate(rawlist);
     1431  char *list = myList;
     1432  char *entry = NULL;
     1433  char *ptr = NULL;
     1434  while ((Nloop < NLOOP) && ((entry = strtok_r (list, ",", &ptr)) != NULL)) {
     1435    list = NULL; // pass NULL on successive strtok_r calls
     1436
     1437    orders[Nloop] = atoi(entry);
     1438    if (orders[Nloop] < minValue) {
     1439      fprintf (stderr, "order cannot be < %d: %s\n", minValue, rawlist);
     1440      exit (3);
     1441    }
     1442
     1443    Nloop ++;
     1444  }
     1445  free (myList);
     1446
     1447  if (Nloop == 0) {
     1448    fprintf (stderr, "syntax error parsing orders: %s\n", rawlist);
     1449    exit (3);
     1450  }
     1451
     1452  // this sets the last loops to match the last value...
     1453  while (Nloop < NLOOP) {
     1454    orders[Nloop] = orders[Nloop - 1];
     1455    Nloop ++;
     1456  }
     1457
     1458  return orders;
     1459}
  • trunk/Ohana/src/relastro/src/assign_images.c

    r39457 r39926  
    4040
    4141  // register the image array with ImageOps.c for later getimageByID calls
    42   initImages (image, NULL, Nimage);
     42  initImages (image, NULL, Nimage, FALSE);
    4343
    4444  if (VERBOSE) fprintf (stderr, "finding images\n");
     
    7272
    7373  for (j = 0; j < Nimage; j++) {
     74   
     75    // allow certain cameras to stay static
     76    if (SKIP_PS1_CHIP  && isGPC1chip (image[j].photcode)) continue;
     77    if (SKIP_PS1_STACK && isGPC1stack(image[j].photcode)) continue;
     78    if (SKIP_HSC       && isHSCchip  (image[j].photcode)) continue;
     79    if (SKIP_CFH       && isCFHchip  (image[j].photcode)) continue;
    7480   
    7581    /* select images by photcode, or equiv photcode, if specified */
  • trunk/Ohana/src/relastro/src/bcatalog.c

    r39587 r39926  
    7272
    7373  int myNskip1 = 0, myNskip2 = 0, myNskip3 = 0, myNskip4 = 0, myNskip5 = 0, myNskip6 = 0;
     74
     75  int NgaiaObject = 0;
    7476
    7577  /* exclude stars not in range or with too few measurements */
     
    187189      if (isGPC1warp(catalog[0].measure[offset].photcode)) continue;
    188190
     191      // allow certain cameras to stay static
     192      if (SKIP_PS1_CHIP  && isGPC1chip(catalog[0].measure[offset].photcode)) continue;
     193      if (SKIP_PS1_STACK && isGPC1stack(catalog[0].measure[offset].photcode)) continue;
     194      if (SKIP_HSC       && isHSCchip(catalog[0].measure[offset].photcode)) continue;
     195      if (SKIP_CFH       && isCFHchip(catalog[0].measure[offset].photcode)) continue;
     196
    189197      // filter objects based on user supplied criteria, including SIGMA_LIM
    190198      if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) {
     
    250258      }
    251259
     260      if (catalog[0].measure[offset].photcode == 1030) { NgaiaObject ++; }
     261
    252262      CopyMeasureToTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]);
    253263      // subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset];
     
    281291    }
    282292  }
    283   fprintf (stderr, "skips: %d %d %d %d %d %d\n", myNskip1, myNskip2, myNskip3, myNskip4, myNskip5, myNskip6);
     293  fprintf (stderr, "skips: %d %d %d %d %d %d, Ngaia: %d\n", myNskip1, myNskip2, myNskip3, myNskip4, myNskip5, myNskip6, NgaiaObject);
    284294  REALLOCATE (subcatalog[0].average,  Average,     MAX (Naverage, 1));
    285295  REALLOCATE (subcatalog[0].measureT, MeasureTiny, MAX (Nmeasure, 1));
  • trunk/Ohana/src/relastro/src/extra.c

    r37261 r39926  
    3939  return FALSE;
    4040}
     41
     42// for now (20160925) I need to identify HSC chips explicitly.  generalize in the future
     43int isHSCchip (int photcode) {
     44
     45  if ((photcode >= 20000) && (photcode <= 20111)) return TRUE; // g-band
     46  if ((photcode >= 21000) && (photcode <= 21111)) return TRUE; // r-band
     47  if ((photcode >= 22000) && (photcode <= 22111)) return TRUE; // i-band
     48  if ((photcode >= 23000) && (photcode <= 23111)) return TRUE; // z-band
     49  if ((photcode >= 24000) && (photcode <= 24111)) return TRUE; // y-band
     50
     51  return FALSE;
     52}
     53
     54// for now (20160925) I need to identify CFH chips explicitly.  generalize in the future
     55int isCFHchip (int photcode) {
     56
     57  if ((photcode >= 100) && (photcode <= 152)) return TRUE; // g-band
     58  if ((photcode >= 200) && (photcode <= 252)) return TRUE; // r-band
     59  if ((photcode >= 300) && (photcode <= 352)) return TRUE; // i-band
     60  if ((photcode >= 400) && (photcode <= 452)) return TRUE; // z-band
     61  if ((photcode >= 500) && (photcode <= 552)) return TRUE; // y-band
     62
     63  return FALSE;
     64}
  • trunk/Ohana/src/relastro/src/initialize.c

    r39457 r39926  
    1111  ConfigInit (&argc, argv);
    1212  args (argc, argv);
     13
     14  if (USE_GALAXY_MODEL) {
     15    if (!InitGalaxyModel (GALAXY_MODEL)) {
     16      fprintf (stderr, "failed to init galaxy model %s\n", GALAXY_MODEL);
     17      exit (2);
     18    }
     19  }
    1320
    1421  if (RELASTRO_OP == OP_MERGE_SOURCE) return;
  • trunk/Ohana/src/relastro/src/launch_region_hosts.c

    r39457 r39926  
    8181    strextend (&command, "-region-hosts %s", REGION_FILE);
    8282    strextend (&command, "-region-hostID %d", host->hostID);
     83
    8384    strextend (&command, "-D CATDIR %s", CATDIR);
    8485    strextend (&command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);
    8586    strextend (&command, "-statmode %s", STATMODE);
    8687    strextend (&command, "-minerror %f", MIN_ERROR);
    87     strextend (&command, "-nloop %d", NLOOP);
    88     strextend (&command, "-threads %d", NTHREADS);
     88
     89    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     90    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     91
     92    strextend (&command, " -D RELASTRO_MIN_DISTANCE_MOD %f",     MIN_DISTANCE_MOD);
     93    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD %f",     MAX_DISTANCE_MOD);
     94    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD_ERR %f", MAX_DISTANCE_MOD_ERR);
     95
     96    strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
     97    strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
     98
     99    strextend (&command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX);
     100    strextend (&command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);
     101
     102    strextend (&command, "-D USE_ICRF_LOCAL %d",   USE_ICRF_LOCAL);
     103    strextend (&command, "-D USE_ICRF_SHFIT %d",   USE_ICRF_SHFIT);
     104    strextend (&command, "-D USE_ICRF_POLE %d",    USE_ICRF_POLE);
    89105
    90106    switch (FIT_TARGET) {
     
    98114        strextend (&command, "-update-mosaics");
    99115        break;
     116      case SET_CHIPS:
     117        strextend (&command, "-set-chips");
     118        break;
    100119      case TARGET_NONE:
    101120        abort();
     
    105124    if (VERBOSE2)           strextend (&command, "-vv");
    106125    if (RESET)              strextend (&command, "-reset");
     126
     127    if (ImagSelect)         strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
     128    if (MaxDensityUse)      strextend (&command, "-max-density %f", MaxDensityValue);
     129    if (FlagOutlier)        strextend (&command, "-clip %d", CLIP_THRESH);
     130    if (ExcludeBogus)       strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     131
     132    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
     133    if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
     134    if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
     135    if (PhotFlagSelect)     strextend (&command, "+photflags");
     136    if (PhotFlagBad)        strextend (&command, "+photflagbad %d", PhotFlagBad);
     137    if (PhotFlagPoor)       strextend (&command, "+photflagpoor %d", PhotFlagPoor);
     138
     139    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     140      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     141    }
     142    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     143      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     144    }
     145
     146    if (TEST_SCALE != 1.0)   strextend (&command, "-testing %f", TEST_SCALE);
     147
     148    if (SKIP_PS1_CHIP)       strextend (&command, "-skip-ps1-chip");
     149    if (SKIP_PS1_STACK)      strextend (&command, "-skip-ps1-stack");
     150    if (SKIP_HSC)            strextend (&command, "-skip-hsc");
     151    if (SKIP_CFH)            strextend (&command, "-skip-cfh");
     152
     153    strextend (&command, "-nloop %d", NLOOP);
     154    strextend (&command, "-threads %d", NTHREADS);
     155   
     156    if (PHOTCODE_RESET_LIST) strextend (&command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST);
     157
    107158    if (UPDATE)             strextend (&command, "-update");
    108159    if (PARALLEL)           strextend (&command, "-parallel");
    109160    if (PARALLEL_MANUAL)    strextend (&command, "-parallel-manual");
    110161    if (PARALLEL_SERIAL)    strextend (&command, "-parallel-serial");
    111     if (PHOTCODE_KEEP_LIST) strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
    112     if (PHOTCODE_SKIP_LIST) strextend (&command, "-photcode %s", PHOTCODE_SKIP_LIST);
    113     if (PHOTCODE_RESET_LIST) strextend (&command, "-reset-to-photcode %s", PHOTCODE_RESET_LIST);
    114 
    115     if (MaxDensityUse)      strextend (&command, "-max-density %f", MaxDensityValue);
    116     if (ImagSelect)         strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    117     if (ExcludeBogus)       strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    118 
    119     if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    120       strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
    121     }
    122     if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
    123       strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    124     }
    125 
    126     if (PhotFlagSelect)     strextend (&command, "+photflags");
    127     if (PhotFlagBad)        strextend (&command, "+photflagbad %d", PhotFlagBad);
    128     if (PhotFlagPoor)       strextend (&command, "+photflagpoor %d", PhotFlagPoor);
    129 
     162
     163    strextend (&command, "-chiporder %d", CHIPORDER);
    130164    if (CHIPMAP)            strextend (&command, "-chipmap %d", CHIPMAP);
     165    if (ChipMapLoop)        strextend (&command, "-chipmaploop %s", ChipMapLoopStr);
     166    if (ChipOrderLoop)      strextend (&command, "-chiporderloop %s", ChipOrderLoopStr);
     167
    131168    if (RESET_IMAGES)       strextend (&command, "-reset-images");
    132169
     
    136173    if (LoopWeight2MASS) {  strextend (&command, "-loop-weights-2mass %s", LoopWeight2MASSstr); }
    137174    if (LoopWeightTycho) {  strextend (&command, "-loop-weights-tycho %s", LoopWeightTychostr); }
    138 
    139     strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
    140     strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
    141     strextend (&command, "-D RELASTRO_DPOS_MAX %f", DPOS_MAX);
    142     strextend (&command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);
    143 
    144     strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
    145 
    146     strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
    147     strextend (&command, "-D USE_ICRF_LOCAL %d",   USE_ICRF_LOCAL);
    148     strextend (&command, "-D USE_ICRF_SHFIT %d",   USE_ICRF_SHFIT);
    149     strextend (&command, "-D USE_ICRF_POLE %d",    USE_ICRF_POLE);
    150 
    151     if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
     175    if (LoopWeightGAIA)  {  strextend (&command, "-loop-weights-gaia %s", LoopWeightGAIAstr); }
     176    if (APPLY_PROPER_MOTION) strextend (&command, "-apply-proper-motion");
    152177
    153178    if (TimeSelect) {
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r39466 r39926  
    178178    strextend (&command, "relastro_client -load-objects %s", table->hosts[i].results);
    179179    strextend (&command, " -hostID %d", table->hosts[i].hostID);
     180    strextend (&command, " -hostdir %s", table->hosts[i].pathname);
     181
    180182    strextend (&command, " -D CATDIR %s", CATDIR);
    181     strextend (&command, " -hostdir %s", table->hosts[i].pathname);
    182183    strextend (&command, " -region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    183184    strextend (&command, " -statmode %s", STATMODE);
    184185    strextend (&command, " -minerror %f", MIN_ERROR);
     186
    185187    strextend (&command, " -D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     188    strextend (&command, " -D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     189
    186190    strextend (&command, " -D RELASTRO_MIN_DISTANCE_MOD %f",     MIN_DISTANCE_MOD);
    187191    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD %f",     MAX_DISTANCE_MOD);
    188192    strextend (&command, " -D RELASTRO_MAX_DISTANCE_MOD_ERR %f", MAX_DISTANCE_MOD_ERR);
    189193
     194    strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
     195    strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
     196
    190197    if (FIT_MODE == FIT_PM_ONLY)         strextend (&command, "-pm");
    191198    if (FIT_MODE == FIT_PAR_ONLY)        strextend (&command, "-par");
    192199    if (FIT_MODE == FIT_PM_AND_PAR)      strextend (&command, "-pmpar");
    193200
    194     if (VERBOSE)       strextend (&command, "-v");
    195     if (VERBOSE2)      strextend (&command, "-vv");
    196     if (RESET)         strextend (&command, "-reset");
    197     if (ImagSelect)    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
    198     if (MaxDensityUse) strextend (&command, "-max-density %f", MaxDensityValue);
    199     if (FlagOutlier)   strextend (&command, "-clip %d", CLIP_THRESH);
    200     if (ExcludeBogus)  strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
    201 
    202     if (USE_ICRF_CORRECT) strextend (&command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
    203     if (USE_GALAXY_MODEL) strextend (&command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
    204    
    205     if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
    206       strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
    207     }
    208     if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
    209       strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
    210     }
    211 
    212     if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     201    if (VERBOSE)             strextend (&command, "-v");
     202    if (VERBOSE2)            strextend (&command, "-vv");
     203    if (RESET)               strextend (&command, "-reset");
     204                             
     205    if (ImagSelect)          strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
     206    if (MaxDensityUse)       strextend (&command, "-max-density %f", MaxDensityValue);
     207    if (FlagOutlier)         strextend (&command, "-clip %d", CLIP_THRESH);
     208    if (ExcludeBogus)        strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     209
    213210    if (USE_FIXED_PIXCOORDS) strextend (&command, "-D USE_FIXED_PIXCOORDS 1");
    214211    if (PHOTCODE_KEEP_LIST)  strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST);
     
    217214    if (PhotFlagBad)         strextend (&command, "+photflagbad %d", PhotFlagBad);
    218215    if (PhotFlagPoor)        strextend (&command, "+photflagpoor %d", PhotFlagPoor);
     216
     217    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     218      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     219    }
     220    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     221      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     222    }
     223
     224    if (SKIP_PS1_CHIP)       strextend (&command, "-skip-ps1-chip");
     225    if (SKIP_PS1_STACK)      strextend (&command, "-skip-ps1-stack");
     226    if (SKIP_HSC)            strextend (&command, "-skip-hsc");
     227    if (SKIP_CFH)            strextend (&command, "-skip-cfh");
     228
     229    if (USE_ALL_IMAGES)      strextend (&command, "-use-all-images");
     230
    219231    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    220232
     
    282294  CatalogSplitter *catalogs = BrightCatalogSplitInit (Nsecfilt);
    283295
     296  ohana_memstats (TRUE);
     297
    284298  for (i = 0; i < table->Nhosts; i++) {
    285299
     
    296310    free (bcatalog->secfilt);
    297311    free (bcatalog);
     312
     313    ohana_memstats (TRUE);
    298314  }
    299315
     
    320336
    321337  BrightCatalogSplitFree (catalogs);
     338  ohana_memstats (TRUE);
    322339
    323340  return (catalog);
  • trunk/Ohana/src/relastro/src/load_images.c

    r39474 r39926  
    6666  }
    6767
    68   initImages (subset, LineNumber, Nsubset);
     68  initImages (subset, LineNumber, Nsubset, !USE_ALL_IMAGES);
    6969  MARKTIME("  init images: %f sec\n", dtime);
    7070 
  • trunk/Ohana/src/relastro/src/relastro_images.c

    r39580 r39926  
    1616  int finalPassMode = FIT_MODE; // start with the globally-defined fit mode
    1717  FIT_MODE = FIT_AVERAGE;
     18
     19  int RESET_ON_UPDATE = RESET; 
     20  RESET = TRUE; // we need to reset when we load the bright catalog subset
    1821
    1922  /* lock and load the image db table */
     
    6568  // XXX NOTE : for 2mass reset, photcodesKeep should now limit to 2MASS measurements
    6669
     70  USE_IRLS = FALSE;  // do not use IRLS yet -- leads to excessive outlier rejections in the loops
     71
    6772  /* major modes */
    6873  switch (FIT_TARGET) {
     
    9095      break;
    9196
     97    case SET_CHIPS:
     98      // we just want to fit the selected chips to the mean positions
     99      UpdateChips (catalog, Ncatalog, 0);   // measure.X,Y -> R,D, fit image.coords
     100      MARKTIME("update chips: %f sec\n", dtime);
     101
     102      break;
     103
    92104    case TARGET_MOSAICS:
    93105      for (i = 0; i < NLOOP; i++) {
     
    102114  }
    103115
    104   if (!UPDATE) {
    105     freeStarMaps();
    106     gfits_db_free (&db);
    107     ohana_memcheck (VERBOSE);
    108     ohana_memdump (VERBOSE);
    109     exit (0);
    110   }
    111 
    112116  // free the image / measurement pointers
    113117  freeImageBins (Ncatalog);
     
    117121  free (catalog);
    118122  freeMosaics ();
     123
     124  if (!UPDATE) {
     125    freeStarMaps();
     126    dvo_image_unlock (&db);
     127    freeImages (db.ftable.buffer);
     128    gfits_db_free (&db);
     129    return TRUE;
     130  }
    119131
    120132  // If we did NOT use all images, then we applied the measured corrections to a subset of
     
    154166  // iterate over catalogs to make detection coordinates consistant
    155167  if (APPLY_OFFSETS) {
     168    USE_IRLS = ALLOW_IRLS;  // now that we have fitted the images, choose the user's option
     169    RESET = RESET_ON_UPDATE;
    156170    UpdateObjectOffsets (skylist, 0, NULL);
    157171  }
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r39457 r39926  
    159159    strextend (&command, "relastro_client -update-objects");
    160160    strextend (&command, "-hostID %d", table->hosts[i].hostID);
     161    strextend (&command, "-hostdir %s", table->hosts[i].pathname);
     162
    161163    strextend (&command, "-D CATDIR %s", CATDIR);
    162     strextend (&command, "-hostdir %s", table->hosts[i].pathname);
    163164    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    164165    strextend (&command, "-statmode %s", STATMODE);
     166    strextend (&command, "-minerror %f", MIN_ERROR);
     167
     168    strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
     169    strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
    165170
    166171    if (FIT_MODE == FIT_PM_ONLY)         { strextend (&command, "-pm"); }
     
    171176    if (VERBOSE2)      { strextend (&command, "-vv"); }
    172177    if (RESET)         { strextend (&command, "-reset"); }
    173     if (UPDATE)        { strextend (&command, "-update"); }
     178
    174179    if (ImagSelect)    { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); }
    175180    if (MaxDensityUse) { strextend (&command, "-max-density %f", MaxDensityValue); }
    176181    if (FlagOutlier)   { strextend (&command, "-clip %d", CLIP_THRESH); }
    177 
    178     if (USE_ALL_IMAGES)      { strextend (&command, "-use-all-images"); }
     182    if (ExcludeBogus)    strextend (&command, "-exclude-bogus %f", ExcludeBogusRadius);
     183
    179184    if (USE_FIXED_PIXCOORDS) { strextend (&command, "-D USE_FIXED_PIXCOORDS 1"); }
    180185    if (PHOTCODE_KEEP_LIST)  { strextend (&command, "+photcode %s", PHOTCODE_KEEP_LIST); }
     
    185190    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
    186191
     192    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     193      strextend (&command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     194    }
     195    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     196      strextend (&command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     197    }
     198
     199    if (UPDATE)        { strextend (&command, "-update"); }
     200    if (USE_ALL_IMAGES)      { strextend (&command, "-use-all-images"); }
     201
    187202    if (MinBadQF > 0.0)          strextend (&command, "-min-bad-psfqf %f", MinBadQF);
    188203    if (MaxMeanOffset != 10.0)   strextend (&command, "-max-mean-offset  %f", MaxMeanOffset);
  • trunk/Ohana/src/relastro/src/relastro_parallel_images.c

    r39580 r39926  
    6161  initMosaics (image, Nimage);
    6262
    63   initImages (image, NULL, Nimage);
     63  initImages (image, NULL, Nimage, FALSE);
    6464
    6565  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     
    103103
    104104  client_logger_message ("starting the loops: %s\n", myHostName);
     105
     106  RESET = TRUE; // we need to reset when we load the bright catalog subset
     107  FIT_MODE = FIT_AVERAGE; // we need to only fit the average
     108  USE_IRLS = FALSE;  // do not use IRLS yet -- leads to excessive outlier rejections in the loops
    105109
    106110  /* major modes */
  • trunk/Ohana/src/relastro/src/select_images.c

    r39474 r39926  
    121121    }
    122122
     123    // allow certain cameras to stay static
     124    if (SKIP_PS1_CHIP  && isGPC1chip (timage[i].photcode)) continue;
     125    if (SKIP_PS1_STACK && isGPC1stack(timage[i].photcode)) continue;
     126    if (SKIP_HSC       && isHSCchip  (timage[i].photcode)) continue;
     127    if (SKIP_CFH       && isCFHchip  (timage[i].photcode)) continue;
     128   
    123129    /* select images by photcode, or equiv photcode, if specified */
    124130    if (NphotcodesKeep > 0) {
     
    187193    if (DmaxImage < DminSkyRegion) continue;
    188194   
     195    if (KEEP_ALL_IMAGES_RA) goto found_it;
     196
    189197    // the sky region RA is defined to be 0 - 360.0
    190198    if (RminImage > RmaxSkyRegion) continue;
  • trunk/Ohana/src/relastro/src/syncfile.c

    r36871 r39926  
    3939    int loop;
    4040    sscanf (message, "%*s %d", &loop);
     41    if (CATCH_UP && (nloop < loop)) return TRUE; // if I am behind this machine, I need to catch up!
    4142    if (loop != nloop) {
    4243      usleep (2000000);
Note: See TracChangeset for help on using the changeset viewer.