IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2010, 10:39:57 AM (16 years ago)
Author:
eugene
Message:

adding checks for bad fit and repairs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/relastro.20100326/src/FixProblemImages.c

    r27488 r27489  
    44// original coordinates and recalculate the positions
    55
    6 int FixProblemImages () {
     6int FixProblemImages (SkyList *skylist) {
    77
    8   off_t im, Nimage;
     8  off_t i, Nimage;
    99  Image *image;
     10  SkyList sublist;
     11
     12  // allocate so we can reallocate below
     13  ALLOCATE (sublist.regions, SkyRegion *, 1);
     14  ALLOCATE (sublist.filename, char *, 1);
    1015
    1116  image = getimages (&Nimage);
    1217
     18  // first check on the dPos reported for each image
    1319  for (i = 0; i < Nimage; i++) {
    14    
     20    double dPosSum, dPos;
     21    off_t nPos;
     22    getOffsets (&dPosSum, &nPos, i);
     23    dPos = sqrt(dPosSum / nPos);
     24    if (dPos > 4.0) {
     25      setBadCoords (i);
     26    }
     27  }
     28
     29  for (i = 0; i < Nimage; i++) {
     30    int j, cat, Ncat, *catlist, Ncatlist;
     31    Catalog *catalog;
     32
    1533    // check if this image should be fixed
    1634    if (!badCoords(i)) continue;
    1735
    18     // get list of catalogs containing measurements for the bad images:
    19     catlist = getCatList(im, &Ncat);
    20     measlist = getMeasList(im, &Nmeas);
     36    // I need a list of the catalogs for this image
     37    catlist = getCatlist(&Ncatlist, i);
    2138
    22     for (i = 0; i < Nlist[im]; i++) {
    23       m = mlist[im][i];
    24       c = clist[im][i];
    25      
     39    // allocate Ncatlist skylist regions
     40    REALLOCATE (sublist.regions, SkyRegion *, Ncatlist);
     41    REALLOCATE (sublist.filename, char *, Ncatlist);
     42    sublist.Nregions = Ncatlist;
     43    sublist.ownElements = FALSE; // this list is only holding a view to the elements
    2644
    27 
    28     // set up the basic catalog info
    29     catalog.filename  = skylist[0].filename[i];
    30     catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
    31     catalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
    32     catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    33     catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
    34 
    35     if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
    36       fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename);
    37       exit (1);
    38     }
    39     if (!catalog.Naves_disk) {
    40       if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    41       dvo_catalog_unlock (&catalog);
    42       dvo_catalog_free (&catalog);
    43       continue;
     45    // copy the desired catalogs from skylist to skylistSubset
     46    for (j = 0; j < Ncatlist; j++) {
     47      cat = catlist[j];
     48      sublist.filename[j] = skylist[0].filename[cat];
     49      sublist.regions[j] = skylist[0].regions[cat];
    4450    }
    4551
     52    catalog = load_catalogs (&sublist, &Ncat, FALSE);
     53    assert (Ncat == Ncatlist);
     54
    4655    // match measurements with images
    47     initImageBins (&catalog, 1);
    48     findImages (&catalog, 1);
     56    initImageBins (catalog, Ncat, FALSE);
     57    findImages (catalog, Ncat, FALSE);
    4958
    5059    // update the detection coordinates using the new image parameters
    51     UpdateMeasures (&catalog, 1);
     60    resetImageRaw (catalog, Ncat, i);
    5261
    53     freeImageBins (1);
     62    freeImageBins (Ncat);
    5463
    5564    // write the updated detections to disk
    56     save_catalogs (&catalog, 1);
     65    save_catalogs (catalog, Ncat);
    5766  }
    5867 
Note: See TracChangeset for help on using the changeset viewer.