IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 27, 2022, 4:30:04 PM (4 years ago)
Author:
eugene
Message:

fpcamera now reads the astrometry and loads the refstars

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraLoadRefstars.c

    r42178 r42182  
    1313    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, FPCAMERA_RECIPE);
    1414
    15     // DVO APIs expect decimal degrees
    16     float RAmin  = DEG_RAD*psMetadataLookupF32(NULL, recipe, "RA_MIN");
    17     float RAmax  = DEG_RAD*psMetadataLookupF32(NULL, recipe, "RA_MAX");
    18     float DECmin = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MIN");
    19     float DECmax = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MAX");
     15    // FPA FOV is determined by fpcameraReadAstrometry & save on fpa->analysis
     16    float RAmin  = psMetadataLookupF32(NULL, input->fpa->analysis, "RA_MIN");
     17    float RAmax  = psMetadataLookupF32(NULL, input->fpa->analysis, "RA_MAX");
     18    float DECmin = psMetadataLookupF32(NULL, input->fpa->analysis, "DEC_MIN");
     19    float DECmax = psMetadataLookupF32(NULL, input->fpa->analysis, "DEC_MAX");
    2020
    2121    // extra field fraction to add
     
    3737    DECmax += dDEC * fieldPadding;
    3838
     39    // XXX: fpcameraArguments.c looks for this explicitly on the command line, but stores it in arguments.
     40    // this could be a recipe value which can also be defined as a command-line option
     41
    3942    // grab the FPCAMERA.CATDIR name from the FPCAMERA recipe
    4043    char *catdir_recipe = psMetadataLookupStr(&status, recipe, "FPCAMERA.CATDIR");
     
    4346    // substitute abstract name with concrete name, if present in FPCAMERA.CATDIRS
    4447    psMetadata *catdirs = psMetadataLookupMetadata(&status, config->site, "FPCAMERA.CATDIRS"); // List of cameras
    45     if (!catdirs) ESCAPE(FPCAMERA_ERR_CONFIG, "Unable to find FPCAMERA.CATDIRS in the system configuration.\n");
     48
     49    // XXX it is allowed that FPCAMERA.CATDIRS is not defined in site.config: the value must be a real path
     50    // if (!catdirs) ESCAPE(FPCAMERA_ERR_CONFIG, "Unable to find FPCAMERA.CATDIRS in the system configuration.\n");
    4651
    4752    // the name in the recipe may be one of:
     
    4954    // (B) a reference to the name in the FPCAMERA.CATDIRS folder in site.config
    5055    // (C) a reference to a folder in the FPCAMERA.CATDIRS folder in site.config, containing multiple copy locations
    51     char *catdir_virtual = psMetadataLookupStr(&status, catdirs, catdir_recipe);
    52 
    53     psMetadata *catdir_folder = psMetadataLookupMetadata(&status, catdirs, catdir_recipe);
     56
     57    // can we find a plain string matching catdir_recipe in the catdirs folder?
     58    char *catdir_virtual = catdirs ? psMetadataLookupStr(&status, catdirs, catdir_recipe) : NULL;
     59
     60    // OR, can we find a subfolder in the catdirs folder?
     61    psMetadata *catdir_folder = catdirs ? psMetadataLookupMetadata(&status, catdirs, catdir_recipe) : NULL;
    5462    if (catdir_folder) {
    5563        // randomly choose one of the entries
     
    6977    }
    7078
     79    // if catdir_virtual is NULL, catdir_recipe must be a file name
    7180    char *catdir = (catdir_virtual == NULL) ? catdir_recipe : catdir_virtual;
    7281
    7382    // convert the uri to a real filename (ie, path://foobar)
    7483    psString CATDIR = pmConfigConvertFilename(catdir, config, false, false); // Resolved filename
    75     ESCAPE(FPCAMERA_ERR_CONFIG, "unable to determine filename for CATDIR %s", catdir);
     84    if (!CATDIR) ESCAPE(FPCAMERA_ERR_CONFIG, "unable to determine filename for CATDIR %s", catdir);
    7685
    7786    psLogMsg ("fpcamera", 3, "looking up reference objects in %s\n", CATDIR);
    7887
    7988    char *getstarCommand = psStringCopy(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR"));
    80     ESCAPE(FPCAMERA_ERR_CONFIG, "unable to find DVO.GETSTAR in recipe");
     89    if (!getstarCommand) ESCAPE(FPCAMERA_ERR_CONFIG, "unable to find DVO.GETSTAR in recipe");
    8190
    8291    char *outformat = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.OUTFORMAT");
    83     ESCAPE(FPCAMERA_ERR_CONFIG, "unable to find DVO.GETSTAR.OUTFORMAT in recipe");
     92    if (!outformat) ESCAPE(FPCAMERA_ERR_CONFIG, "unable to find DVO.GETSTAR.OUTFORMAT in recipe");
    8493
    8594    // issue the following command:
     
    166175   
    167176    psMetadataAdd (input->fpa->analysis, PS_LIST_TAIL, "FPCAMERA.REFSTARS", PS_DATA_ARRAY, "reference sources", refstars);
     177    psFree (refstars);
     178
    168179    return true;
    169180}
Note: See TracChangeset for help on using the changeset viewer.