IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15257


Ignore:
Timestamp:
Oct 9, 2007, 9:57:03 AM (19 years ago)
Author:
eugene
Message:

change the DVO fits table load to operate row-by-row (better memory footprint)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroLoadRefstars.c

    r15200 r15257  
    5454    // psStringAppend (&getstarCommand, " -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile);
    5555    // XXX TEST : no magnitude limit
     56    // XXX need to specify the desired photometry system
    5657    psStringAppend (&getstarCommand, " -D CATMODE mef -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
    5758    psTrace ("psastro", 3, "%s\n", getstarCommand);
     
    7778
    7879    psTimerStart ("psastro");
    79     psMetadata *header = psFitsReadHeader (NULL, fits);
    80     psArray *table = psFitsReadTable (fits);
    81     psFitsClose (fits);
    82 
    83     unlink (tempFile);
    84 
    85     if (table == NULL) {
    86         psError(PSASTRO_ERR_REFSTARS, true, "failure to load astrometric reference\n");
    87         return NULL;
    88     }
    89 
    90     psLogMsg ("psastro", 3, "read getstar output table : %f sec\n", psTimerMark ("psastro"));
     80    long numSources = psFitsTableSize(fits); // Number of sources in table
    9181
    9282    // convert the Average table to the pmAstromObj entries
    93     psTimerStart ("psastro");
    94 
    95     psArray *refstars = psArrayAllocEmpty (table->n);
    96     for (int i = 0; i < table->n; i++) {
     83    psArray *refstars = psArrayAllocEmpty (numSources);
     84    for (int i = 0; i < numSources; i++) {
    9785        pmAstromObj *ref = pmAstromObjAlloc ();
    9886
    99         psMetadata *row = table->data[i];
     87        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
    10088
    10189        // DVO tables are stored in degrees
     
    112100        psArrayAdd (refstars, 100, ref);
    113101        psFree (ref);
     102        psFree (row);
    114103    }
    115     psFree (header);
    116     psFree (table);
    117     psLogMsg ("psastro", 3, "converted table to pmAstromObj : %f sec\n", psTimerMark ("psastro"));
     104    psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
    118105
    119106    psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
    120107             refstars->n, RAmin, DECmin, RAmax, DECmax);
     108
     109    psFitsClose (fits);
     110    unlink (tempFile);
    121111
    122112    // dump or plot the available refstars
Note: See TracChangeset for help on using the changeset viewer.