IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15547


Ignore:
Timestamp:
Nov 9, 2007, 12:57:01 PM (19 years ago)
Author:
eugene
Message:

allow getstar to write new output formats (with mag, proper-motion, etc)

Location:
branches/eam_branch_20071023/psastro/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071023/psastro/src/psastro.h

    r15519 r15547  
    8282bool              psastroEnforceChips (pmConfig *config, pmFPA *fpa, psMetadata *recipe);
    8383
     84psArray *psastroReadGetstarCatalog (psFits *fits);
     85psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits);
     86
    8487# endif /* PSASTRO_H */
  • branches/eam_branch_20071023/psastro/src/psastroLoadRefstars.c

    r15257 r15547  
    1515    float DECmin = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MIN");
    1616    float DECmax = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MAX");
    17     // float MAGmax = psMetadataLookupF32(NULL, recipe, "MAG_MAX");
    1817
    1918    // XXX CATDIR needs to look up abstracted name from psastro.config
     
    2524    char *getstarCommand = psMemIncrRefCounter(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR"));
    2625    PS_ASSERT (getstarCommand, NULL);
     26
     27    char *outformat = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.OUTFORMAT");
     28    PS_ASSERT (outformat, NULL);
     29
     30    char *photcode = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.PHOTCODE");
     31    PS_ASSERT (photcode, NULL);
     32
     33    float MAGmax = psMetadataLookupF32(NULL, recipe, "DVO.GETSTAR.MAG.MAX");
    2734
    2835    // issue the following command:
     
    3946    psTimerStart ("psastro");
    4047
    41     // use fork to add timeout capability
     48    // supply a known output format (for CATALOG output) so the code below knows what to read
    4249    if (ELIXIR_MODE) {
    43         psStringAppend (&getstarCommand, " -D CATFORMAT elixir");
     50        psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT elixir");
    4451    } else {
    45         psStringAppend (&getstarCommand, " -D CATFORMAT panstarrs");
     52        psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT panstarrs");
    4653    }
    4754
     
    5259    psFree(CATDIR);
    5360
    54     // psStringAppend (&getstarCommand, " -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile);
    55     // XXX TEST : no magnitude limit
    56     // XXX need to specify the desired photometry system
    57     psStringAppend (&getstarCommand, " -D CATMODE mef -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
     61    // supply the max magnitude, the output format, and the photcode
     62    psStringAppend (&getstarCommand, " -maglim %f -format %s -photcode %s", MAGmax, outformat, photcode);
     63
     64    // add region and output filename
     65    psStringAppend (&getstarCommand, " -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
    5866    psTrace ("psastro", 3, "%s\n", getstarCommand);
    5967
    6068    // XXX use psPipe: catch stderr, stdout, allow for Nsec timeout...
     69    // use fork to add timeout capability
    6170    status = system (getstarCommand);
    6271    if (status) {
     
    7180    psFits *fits = psFitsOpen (tempFile, "r");
    7281
     82    psTimerStart ("psastro");
     83
     84    psArray *refstars = NULL;
     85    if (!strcmp (outformat, "CATALOG")) {
     86      refstars = psastroReadGetstarCatalog (fits);
     87    }
     88    if (!strcmp (outformat, "PS1_DEV_0")) {
     89      refstars = psastroReadGetstar_PS1_DEV_0 (fits);
     90    }
     91    if (refstars == NULL) {
     92        psError(PSASTRO_ERR_REFSTARS, true, "error reading reference data\n");
     93        return NULL;
     94    }
     95    psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
     96
     97    psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
     98             refstars->n, RAmin, DECmin, RAmax, DECmax);
     99
     100    psFitsClose (fits);
     101    unlink (tempFile);
     102
     103    // dump or plot the available refstars
     104    if (psTraceGetLevel("psastro.dump") > 0) {
     105        psastroDumpRefstars (refstars, "refstars.dat");
     106    }
     107
     108    if (psTraceGetLevel("psastro.plot") > 0) {
     109        psastroPlotRefstars (refstars, recipe);
     110    }
     111
     112    return refstars;
     113}
     114
     115psArray *psastroReadGetstarCatalog (psFits *fits) {
     116
     117    bool status;
     118
    73119    if (ELIXIR_MODE) {
    74120        psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR");
     
    77123    }
    78124
    79     psTimerStart ("psastro");
    80125    long numSources = psFitsTableSize(fits); // Number of sources in table
    81126
     
    102147        psFree (row);
    103148    }
    104     psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
    105 
    106     psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
    107              refstars->n, RAmin, DECmin, RAmax, DECmax);
    108 
    109     psFitsClose (fits);
    110     unlink (tempFile);
    111 
    112     // dump or plot the available refstars
    113     if (psTraceGetLevel("psastro.dump") > 0) {
    114         psastroDumpRefstars (refstars, "refstars.dat");
    115     }
    116 
    117     if (psTraceGetLevel("psastro.plot") > 0) {
    118         psastroPlotRefstars (refstars, recipe);
    119     }
    120 
    121149    return refstars;
    122150}
     151
     152psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits) {
     153
     154    bool status;
     155
     156    psFitsMoveExtName (fits, "GETSTAR_PS1_DEV_0");
     157
     158    long numSources = psFitsTableSize(fits); // Number of sources in table
     159
     160    // convert the Average table to the pmAstromObj entries
     161    psArray *refstars = psArrayAllocEmpty (numSources);
     162    for (int i = 0; i < numSources; i++) {
     163        pmAstromObj *ref = pmAstromObjAlloc ();
     164
     165        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
     166
     167        ref->sky->r   = RAD_DEG*psMetadataLookupF32 (&status, row, "RA");
     168        ref->sky->d   = RAD_DEG*psMetadataLookupF32 (&status, row, "DEC");
     169        ref->Mag      = psMetadataLookupS32 (&status, row, "MAG");
     170
     171        psArrayAdd (refstars, 100, ref);
     172        psFree (ref);
     173        psFree (row);
     174    }
     175    return refstars;
     176}
Note: See TracChangeset for help on using the changeset viewer.