IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 27, 2021, 8:39:17 AM (5 years ago)
Author:
eugene
Message:

updates to the good/bad night logic; save image stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/src/relphot_images.c

    r41555 r41556  
    4141  load_images (&db, skylist, &UserPatch, FALSE, USE_ALL_IMAGES);
    4242  MARKTIME("-- load images: %f sec\n", dtime);
    43 
    44   // checkImages("load images");
    4543
    4644  /* unlock, if we can (else, unlocked below) */
     
    6361    /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
    6462
    65     // checkImages("load catalog");
    66 
    6763    /* match measurements with images, mosaics */
    6864    initImageBins  (catalog, Ncatalog, TRUE);
     
    8783
    8884    setExclusions (catalog, Ncatalog, TRUE);
    89     // checkImages("set Exclu");
    9085
    9186    global_stats (catalog, Ncatalog, flatcorr, 0);
     
    118113      SetZptIteration (i);
    119114
    120       dump_tgroups (catalog, i);
    121       dump_catalog (catalog, 0, i); // for a test, just dump a specific catalog
    122       dump_tgroup_imstats (i);
    123 
    124115      setMrel  (catalog, Ncatalog, flatcorr); // threaded
    125       setMcalTest (catalog, flatcorr);
    126 
    127       dump_tgroups (catalog, i + 20);
    128       dump_catalog (catalog, 0, i + 20); // for a test, just dump a specific catalog
    129       dump_tgroup_imstats (i + 20);
    130 
    131       setMcal  (catalog, FALSE, flatcorr);
    132       setMmos  (catalog, FALSE, flatcorr);
    133       setMgrp  (catalog, FALSE, flatcorr);
    134       dump_tgroups (catalog, i + 40);
    135       dump_catalog (catalog, 0, i + 40); // for a test, just dump a specific catalog
    136       dump_tgroup_imstats (i + 40);
     116
     117      setMcal  (catalog, flatcorr);
     118      setMmos  (catalog, flatcorr);
     119      setMgrp  (catalog, flatcorr);
    137120
    138121      setMgrid (catalog, flatcorr);
     
    166149    if (USE_GRID) dump_grid ();
    167150
    168     /* set Mcal & Mmos for bad images */
    169     int onlyPoorImages = !CALIBRATE_STACKS_AND_WARPS;
    170     onlyPoorImages = FALSE; // XXX deactivate for now
    171     setMcal  (catalog, onlyPoorImages, flatcorr); // max loop since this is a final pass
    172     setMmos  (catalog, onlyPoorImages, flatcorr); // max loop since this is a final pass
    173     setMgrp  (catalog, onlyPoorImages, flatcorr); // max loop since this is a final pass
    174151    MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
    175152
     
    177154    setMcalFromTGroups (); // copy per-tgroup calibrations to the images
    178155
    179     if (SAVE_IMAGE_UPDATES) {
    180 
    181       FITS_DB dbX;
    182       off_t *LineNumber;
    183       Image *image, *subset;
    184       off_t Nimage, Nsubset, i, Nx;
    185       char filename[1024];
    186 
    187       gfits_db_init (&dbX);
    188       dbX.lockstate = LCK_XCLD;
    189       dbX.timeout   = 60.0;
    190       dbX.mode      = db.mode;
    191       dbX.format    = db.format;
    192 
    193       snprintf (filename, 1024, "%s.bck", ImageCat);
    194       if (!gfits_db_lock (&dbX, filename)) {
    195         fprintf (stderr, "can't lock backup image image catalog\n");
    196         return (FALSE);
    197       }
    198    
    199       // apply the changes from the image subset to the full table:
    200 
    201       // convert database table to internal structure (binary to Image)
    202       // 'image' points to the same memory as db->ftable->buffer
    203       image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder);
    204       if (!image) {
    205         fprintf (stderr, "ERROR: failed to read images\n");
    206         exit (2);
    207       }
    208       gfits_scan (db.ftable.header, "NAXIS1", OFF_T_FMT, 1,  &Nx);
    209 
    210       subset = getimages (&Nsubset, &LineNumber);
    211       for (i = 0; i < Nsubset; i++) {
    212         if (LineNumber[i] == -1) continue;
    213         memcpy (&image[LineNumber[i]], &subset[i], Nx);
    214       }
    215 
    216       // copy Images.dat data (all or only the subset / vtable elements?)  I think I need to dump
    217       // the entire Image table, but with the updates in place I think this says: re-work the
    218       // ftable/vtable usage in this program to be more sensible...
    219       gfits_copy_header (&db.header,  &dbX.header);
    220       gfits_copy_matrix (&db.matrix,  &dbX.matrix);
    221       gfits_copy_header (&db.theader, &dbX.theader);
    222       gfits_copy_ftable (&db.ftable,  &dbX.ftable);
    223 
    224       dbX.ftable.header = &dbX.theader;
    225       dbX.virtual = FALSE;
    226 
    227       // save Images.dat using the copied structure
    228       if (UPDATE_CATFORMAT) {
    229         // ensure the db format is updated
    230         dbX.format = dvo_catalog_catformat (UPDATE_CATFORMAT);
    231         gfits_modify (&dbX.header, "FORMAT", "%s", 1, UPDATE_CATFORMAT);
    232 
    233         char photcodeFile[1024];
    234         sprintf (photcodeFile, "%s/Photcodes.dat", CATDIR);
    235         SavePhotcodesFITS (photcodeFile);
    236       }
    237       dvo_image_save (&dbX, VERBOSE);
    238       dvo_image_unlock (&dbX);
    239       gfits_db_free (&dbX);
    240       MARKTIME("-- save Image.dat.bck: %f sec\n", dtime);
    241     }
     156    // calculate and save per-chip residuals here:
     157    MagResidSave ("mag.resid.fits", catalog);
     158
     159    save_images_updates (&db);
    242160
    243161    /* at this point, we have correct cal coeffs in the image/mosaic structures */
Note: See TracChangeset for help on using the changeset viewer.