IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41467 for trunk


Ignore:
Timestamp:
Jan 12, 2021, 4:13:42 PM (6 years ago)
Author:
eugene
Message:

updated relphot rules to handle transition from fitting TGroups, Mosaics, Images

Location:
trunk/Ohana/src/relphot
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/include/relphot.h

    r41462 r41467  
    2828  int NINDEX;
    2929} myIndexType;
     30
     31typedef enum {
     32  ZPT_TGROUP,
     33  ZPT_MOSAIC,
     34  ZPT_IMAGES,
     35} ZptFitModeType;
    3036
    3137typedef enum {
     
    791797void relphot_free (SkyTable *sky, SkyList *skylist);
    792798void freeImages (char *dbImagePtr);
     799void freeMosaics (void);
    793800void relphot_client_free (SkyTable *sky, SkyList *skylist);
    794801void BrightCatalogFree (BrightCatalog *bcatalog);
     
    828835
    829836void SetZeroPointModes (int nloop);
     837int UseStandardOLS (int nloop, ZptFitModeType mode);
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r41462 r41467  
    610610
    611611  // until the analysis has converged a bit, do not use the IRLS analysis
    612   if (Nloop < 3) {
     612  // default is MaxIterations = 10
     613  if (UseStandardOLS(Nloop, ZPT_IMAGES)) {
    613614    brightStars.MaxIterations = 0;
    614615    kronStars.MaxIterations = 0;
    615616    psfStars.MaxIterations = 0;
    616617  }
    617 
    618618
    619619  Nfew = Nbad = Nmos = Ngrp = Ngrid = Nrel = Nsys = 0;
     
    635635    }     
    636636
    637     // if requested, freeze mosaic chips:
    638     if (FREEZE_IMAGES && isMosaicChip (image[i].photcode)) continue;
    639637    if (image[i].photcode == 0) continue; // skip the PHU images
    640638
    641639    int badNight  = (image[i].flags & ID_IMAGE_NIGHT_POOR);
    642640    int badMosaic = (image[i].flags & ID_IMAGE_MOSAIC_POOR);
     641    int isMosaic  = isMosaicChip(image[i].photcode);
     642
     643    // if requested, freeze mosaic chips:
     644    if (FREEZE_IMAGES && isMosaic) continue;
    643645
    644646    // in BAD_NIGHT mode, we fit ONLY images in bad nights
     
    650652    if ((IMAGE_ZPT_MODE == IMAGE_ZPT_MODE_BAD_NIGHT_BAD_MOSAIC)) {
    651653      if (!badNight) continue;
    652       if (!badMosaic) continue;
     654      if (!badMosaic && isMosaic) continue; // skip good mosaics (but not good images)
    653655    }
    654656
    655657    // in BAD_MOSAIC mode, we fit bad mosaics ignoring night state
    656658    if ((IMAGE_ZPT_MODE == IMAGE_ZPT_MODE_BAD_MOSAIC)) {
    657       if (badMosaic) continue;
     659      if (badMosaic && isMosaic) continue; // skip bad mosaics (but not bad images)
    658660    }
    659661
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r41462 r41467  
    321321  fprintf (stderr, "matched %d images to %d mosaics, %d simple chips not matched to mosaics\n", (int) (Nsubset - Nsimple), (int) Nmosaic, (int) Nsimple);
    322322  return;
    323 }
    324 
    325 void freeMosaics () {
    326  
    327 
    328323}
    329324
     
    845840}
    846841
     842void freeMosaics () {
     843 
     844  if (!MOSAIC_ZEROPT) return;
     845
     846  for (int i = 0; i < Nmosaic; i++) {
     847    FREE (MosaicToImage[i]);
     848  }
     849 
     850  FREE (mosaic);
     851  FREE (MosaicToImage);
     852  FREE (MosaicN_Image);
     853  FREE (ImageToMosaic); // mosaic to which image belongs
     854}
     855
    847856int findMosaics (Catalog *catalog, int Ncatalog, int doMosaicList) {
    848857 
     
    10071016
    10081017    // until the analysis has converged a bit, do not use the IRLS analysis
    1009     if (Nloop < 3) {
     1018    if (UseStandardOLS(Nloop, ZPT_MOSAIC)) {
    10101019      info->brightStars.MaxIterations = 0;
    10111020      info->kronStars.MaxIterations = 0;
     
    11331142  int badNight  = (myMosaic[0].flags & ID_IMAGE_NIGHT_POOR);
    11341143  int badMosaic = (myMosaic[0].flags & ID_IMAGE_MOSAIC_POOR);
     1144
     1145  myMosaic->flags &= ~ID_IMAGE_MOSAIC_PHOTCAL;  // unset this flag
    11351146
    11361147  // if we are fitting TGroup zero points, when we identify the bad TGroups, we proceed
     
    13561367  }
    13571368
     1369  myMosaic->flags |= ID_IMAGE_MOSAIC_PHOTCAL;  // set this flag
     1370
    13581371  if (testImage) {
    13591372    fprintf (stderr, "%f %f  :  %f\n", myMosaic[0].McalPSF, myMosaic[0].dMsys, myMosaic[0].McalChiSq);
     
    13711384  }
    13721385 
     1386  fprintf (stderr, "MOSAIC time %.6f photcode %d Mcal: %f, dMcal: %f, chisq: %f, %d of %d\n",
     1387           ohana_sec_to_mjd(myMosaic[0].start), myMosaic[0].photcode, myMosaic[0].McalPSF, myMosaic[0].dMcal, myMosaic[0].McalChiSq, myMosaic[0].nFitPhotom, myMosaic[0].nValPhotom);
     1388
    13731389  return TRUE;
    13741390}
     
    18621878
    18631879  for (i = N = 0; i < Nmosaic; i++) {
    1864     if (mosaic[i].flags & IMAGE_BAD) continue;
     1880    // if (mosaic[i].flags & IMAGE_BAD) continue;
     1881    if (!(mosaic[i].flags & ID_IMAGE_MOSAIC_PHOTCAL)) continue;
    18651882    if (mosaic[i].skipCal) continue;
    18661883    mlist[N] = mosaic[i].McalPSF;
  • trunk/Ohana/src/relphot/src/TGroupOps.c

    r41462 r41467  
    324324        Mosaic *mosaic = getMosaicForImage (imageIdx);
    325325
     326        if (!mosaic) continue; // this is a simple chip, not part of a mosaic
    326327        if (mosaic->inTGroup) continue;
    327328
     
    687688
    688689    // until the analysis has converged a bit, do not use the IRLS analysis
    689     if (Nloop < 100) {
     690    if (UseStandardOLS(Nloop, ZPT_TGROUP)) {
    690691      info->brightStars.MaxIterations = 0;
    691692      info->kronStars.MaxIterations = 0;
  • trunk/Ohana/src/relphot/src/ZeroPointModes.c

    r41462 r41467  
    1313      clean_tgroups(); // do this on every pass to update the status of nights
    1414    }
    15     if ((nloop > 8) && (nloop <= 12)) {
     15    if ((nloop > 8) && (nloop <= 999)) {
    1616      // after iterating a few times on the TGroup & Mosaic zero points:
    1717      // * identify the good / bad Mosaics
     
    2626
    2727  if (TGROUP_ZEROPT && !MOSAIC_ZEROPT) {
    28     if ((nloop > 4) && (nloop <= 8)) {
     28    if ((nloop > 4) && (nloop <= 999)) {
    2929      // after iterating a few times on the TGroup zero points:
    3030      // * identify the photometric nights
     
    3838
    3939  if (!TGROUP_ZEROPT && MOSAIC_ZEROPT) {
    40     if ((nloop > 4) && (nloop <= 8)) {
     40    if ((nloop > 4) && (nloop <= 999)) {
    4141      // after iterating a few times on the Mosaic zero points:
    4242      // * identify the good / bad mosaics
     
    5050
    5151  if (!TGROUP_ZEROPT && !MOSAIC_ZEROPT) {
    52     if ((nloop > 4) && (nloop <= 8)) {
     52    if ((nloop > 4) && (nloop <= 999)) {
    5353      // after iterating a few times on the Image zero points:
    5454      // * ???
     
    6060}
    6161
    62       // if (i < NLOOP - 1) rationalize_mosaics (catalog, Ncatalog);
    63       // if (i % 6 == 1) rationalize_images ();
     62// mode = TGROUP, MOSAIC, IMAGE
     63// should we use IRLS or OLS?  depends on nloop and which stage we are in.
     64int UseStandardOLS (int nloop, ZptFitModeType mode) {
    6465
    65       // NOTE : in the past, I was not iterating enough before cleaning.  make sure we do
    66       // at least 8 loops first -- that should get the systematic errors down to the ~1%
    67       // level, even in cases where we have an even split between photometric data and
    68       // data with 1 mag of extinction.
     66  if (TGROUP_ZEROPT && MOSAIC_ZEROPT) {
     67    switch (mode) {
     68      case ZPT_TGROUP:
     69        if (nloop < 3) return TRUE;
     70        return FALSE;
     71      case ZPT_MOSAIC:
     72        if (nloop < 7) return TRUE;
     73        return FALSE;
     74      case ZPT_IMAGES:
     75      default:
     76        if (nloop < 11) return TRUE;
     77        return FALSE;
     78    }
     79  }
    6980
    70       // if ((i > 8) && (i % 8 == 2)) clean_measures (catalog, Ncatalog, FALSE, flatcorr);
    71       // if ((i > 8) && (i % 8 == 3)) clean_stars (catalog, Ncatalog);
    72       // if ((i > 8) && (i % 8 == 5)) clean_mosaics ();
    73       // if ((i > 8) && (i % 8 == 5)) clean_tgroups ();
    74       // if ((i > 8) && (i % 8 == 5)) clean_images ();
     81  if (TGROUP_ZEROPT && !MOSAIC_ZEROPT) {
     82    switch (mode) {
     83      case ZPT_TGROUP:
     84      case ZPT_MOSAIC:
     85        if (nloop < 3) return TRUE;
     86        return FALSE;
     87      case ZPT_IMAGES:
     88      default:
     89        if (nloop < 7) return TRUE;
     90        return FALSE;
     91    }
     92  }
    7593
     94  if (!TGROUP_ZEROPT && MOSAIC_ZEROPT) {
     95    switch (mode) {
     96      case ZPT_TGROUP:
     97      case ZPT_MOSAIC:
     98        if (nloop < 3) return TRUE;
     99        return FALSE;
     100      case ZPT_IMAGES:
     101      default:
     102        if (nloop < 7) return TRUE;
     103        return FALSE;
     104    }
     105  }
     106
     107  if (!TGROUP_ZEROPT && !MOSAIC_ZEROPT) {
     108    switch (mode) {
     109      case ZPT_TGROUP:
     110      case ZPT_MOSAIC:
     111      case ZPT_IMAGES:
     112      default:
     113        if (nloop < 3) return TRUE;
     114        return FALSE;
     115    }
     116  }
     117  return FALSE;
     118}
  • trunk/Ohana/src/relphot/src/extra.c

    r41462 r41467  
    1414int whichGPC1filter (int photcode) {
    1515
    16   if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return PS1_g; // g-band
    17   if (((photcode > 10100) && (photcode < 10177)) || (photcode == 4200)) return PS1_r; // r-band
    18   if (((photcode > 10200) && (photcode < 10277)) || (photcode == 4300)) return PS1_i; // i-band
    19   if (((photcode > 10300) && (photcode < 10377)) || (photcode == 4400)) return PS1_z; // z-band
    20   if (((photcode > 10400) && (photcode < 10477)) || (photcode == 4500)) return PS1_y; // y-band
    21   if (((photcode > 10500) && (photcode < 10577)) || (photcode == 4600)) return PS1_w; // w-band
    22 
     16# if (1)
     17  // disable the corner chips:
     18  if (((photcode >  10000) && (photcode <  10077)) || (photcode == 4100)) return PS1_g; // g-band
     19  if (((photcode >  10100) && (photcode <  10177)) || (photcode == 4200)) return PS1_r; // r-band
     20  if (((photcode >  10200) && (photcode <  10277)) || (photcode == 4300)) return PS1_i; // i-band
     21  if (((photcode >  10300) && (photcode <  10377)) || (photcode == 4400)) return PS1_z; // z-band
     22  if (((photcode >  10400) && (photcode <  10477)) || (photcode == 4500)) return PS1_y; // y-band
     23  if (((photcode >  10500) && (photcode <  10577)) || (photcode == 4600)) return PS1_w; // w-band
     24# else
     25  // for testing, enable the corner chips:
     26  if (((photcode >= 10000) && (photcode <= 10077)) || (photcode == 4100)) return PS1_g; // g-band
     27  if (((photcode >= 10100) && (photcode <= 10177)) || (photcode == 4200)) return PS1_r; // r-band
     28  if (((photcode >= 10200) && (photcode <= 10277)) || (photcode == 4300)) return PS1_i; // i-band
     29  if (((photcode >= 10300) && (photcode <= 10377)) || (photcode == 4400)) return PS1_z; // z-band
     30  if (((photcode >= 10400) && (photcode <= 10477)) || (photcode == 4500)) return PS1_y; // y-band
     31  if (((photcode >= 10500) && (photcode <= 10577)) || (photcode == 4600)) return PS1_w; // w-band
     32# endif
    2333  return PS1_none;
    2434}
     
    2737int isGPC1chip (int photcode) {
    2838
    29   if (((photcode > 10000) && (photcode < 10077)) || (photcode == 4100)) return TRUE; // g-band
    30   if (((photcode > 10100) && (photcode < 10177)) || (photcode == 4200)) return TRUE; // r-band
    31   if (((photcode > 10200) && (photcode < 10277)) || (photcode == 4300)) return TRUE; // i-band
    32   if (((photcode > 10300) && (photcode < 10377)) || (photcode == 4400)) return TRUE; // z-band
    33   if (((photcode > 10400) && (photcode < 10477)) || (photcode == 4500)) return TRUE; // y-band
    34   if (((photcode > 10500) && (photcode < 10577)) || (photcode == 4600)) return TRUE; // w-band
     39# if (1)
     40  if (((photcode >  10000) && (photcode <  10077)) || (photcode == 4100)) return TRUE; // g-band
     41  if (((photcode >  10100) && (photcode <  10177)) || (photcode == 4200)) return TRUE; // r-band
     42  if (((photcode >  10200) && (photcode <  10277)) || (photcode == 4300)) return TRUE; // i-band
     43  if (((photcode >  10300) && (photcode <  10377)) || (photcode == 4400)) return TRUE; // z-band
     44  if (((photcode >  10400) && (photcode <  10477)) || (photcode == 4500)) return TRUE; // y-band
     45  if (((photcode >  10500) && (photcode <  10577)) || (photcode == 4600)) return TRUE; // w-band
     46# else
     47  if (((photcode >= 10000) && (photcode <= 10077)) || (photcode == 4100)) return TRUE; // g-band
     48  if (((photcode >= 10100) && (photcode <= 10177)) || (photcode == 4200)) return TRUE; // r-band
     49  if (((photcode >= 10200) && (photcode <= 10277)) || (photcode == 4300)) return TRUE; // i-band
     50  if (((photcode >= 10300) && (photcode <= 10377)) || (photcode == 4400)) return TRUE; // z-band
     51  if (((photcode >= 10400) && (photcode <= 10477)) || (photcode == 4500)) return TRUE; // y-band
     52  if (((photcode >= 10500) && (photcode <= 10577)) || (photcode == 4600)) return TRUE; // w-band
     53# endif
    3554
    3655  return FALSE;
  • trunk/Ohana/src/relphot/src/relphot_images.c

    r41462 r41467  
    279279
    280280  freeImages (db.ftable.buffer);
     281  freeMosaics ();
    281282  gfits_db_free (&db);
    282283
  • trunk/Ohana/src/relphot/test/relphot.tgroups.dvo

    r41462 r41467  
    484484  end
    485485end
     486
     487macro plot.tcat.data
     488  if ($0 != 2)
     489    echo "USAGE: plot.tcat.data (Nlast)"
     490    break
     491  end
     492
     493  $BSTYLE = -tickpad 0.2 +xpad 0.2 +ypad 0.2 -ypad 5
     494
     495  for i 0 $1
     496    sprintf name tcat.%02d.dat $i
     497    data $name
     498    dev -n $i
     499    resize 900 500
     500    clear;
     501    box $BSTYLE
     502    read Msys 4 Mrel 5 Mcal 7 Mmos 8 Mgrp 9 airmass 11 dMag 12;
     503    lim Msys dMag; plot Msys dMag -pt cir -op 0.2 -c blue
     504    echo $name
     505  end
     506end
Note: See TracChangeset for help on using the changeset viewer.