IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26220


Ignore:
Timestamp:
Nov 20, 2009, 3:21:14 PM (16 years ago)
Author:
eugene
Message:

add option to use multiple copies of the reference catalog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091113/psastro/src/psastroLoadRefstars.c

    r24805 r26220  
    5050        return false;
    5151    }
     52
     53    // the name in the recipe may be one of:
     54    // (A) the actual directory name
     55    // (B) a reference to the name in the PSASTRO.CATDIRS folder in site.config
     56    // (C) a reference to a folder in the PSASTRO.CATDIRS folder in site.config, containing multiple copy locations
    5257    char *catdir_virtual = psMetadataLookupStr(&status, catdirs, catdir_recipe);
     58
     59    psMetadata *catdir_folder = psMetadataLookupMetadata(&status, catdirs, catdir_recipe);
     60    if (catdir_folder) {
     61        // randomly choose one of the entries
     62        psLogMsg ("psastro", 3, "choosing catdir_folder\n");
     63        int nEntry = catdir_folder->list->n;
     64
     65        psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 
     66        double frnd = psRandomUniform(rng);
     67        int entry = PS_MIN(nEntry - 1, PS_MAX(0, nEntry * frnd));
     68        psFree(rng);
     69
     70        psMetadataItem *item = psListGet(catdir_folder->list, entry);
     71        if (item->type != PS_DATA_STRING) {
     72            psError(PSASTRO_ERR_CONFIG, true, "Invalid entry in PSASTRO.CATDIR folder: %s\n", item->name);
     73            return false;
     74        }
     75        catdir_virtual = item->data.str;
     76    }
     77
    5378    char *catdir = (catdir_virtual == NULL) ? catdir_recipe : catdir_virtual;
    5479
     
    5681    psString CATDIR = pmConfigConvertFilename(catdir, config, false, false); // Resolved filename
    5782    PS_ASSERT (CATDIR, NULL);
     83
     84    psLogMsg ("psastro", 3, "looking up reference objects in %s\n", CATDIR);
    5885
    5986    char *getstarCommand = psStringCopy(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR"));
Note: See TracChangeset for help on using the changeset viewer.