Changeset 15547
- Timestamp:
- Nov 9, 2007, 12:57:01 PM (19 years ago)
- Location:
- branches/eam_branch_20071023/psastro/src
- Files:
-
- 2 edited
-
psastro.h (modified) (1 diff)
-
psastroLoadRefstars.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071023/psastro/src/psastro.h
r15519 r15547 82 82 bool psastroEnforceChips (pmConfig *config, pmFPA *fpa, psMetadata *recipe); 83 83 84 psArray *psastroReadGetstarCatalog (psFits *fits); 85 psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits); 86 84 87 # endif /* PSASTRO_H */ -
branches/eam_branch_20071023/psastro/src/psastroLoadRefstars.c
r15257 r15547 15 15 float DECmin = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MIN"); 16 16 float DECmax = DEG_RAD*psMetadataLookupF32(NULL, recipe, "DEC_MAX"); 17 // float MAGmax = psMetadataLookupF32(NULL, recipe, "MAG_MAX");18 17 19 18 // XXX CATDIR needs to look up abstracted name from psastro.config … … 25 24 char *getstarCommand = psMemIncrRefCounter(psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR")); 26 25 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"); 27 34 28 35 // issue the following command: … … 39 46 psTimerStart ("psastro"); 40 47 41 // use fork to add timeout capability48 // supply a known output format (for CATALOG output) so the code below knows what to read 42 49 if (ELIXIR_MODE) { 43 psStringAppend (&getstarCommand, " -D CAT FORMAT elixir");50 psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT elixir"); 44 51 } else { 45 psStringAppend (&getstarCommand, " -D CAT FORMAT panstarrs");52 psStringAppend (&getstarCommand, " -D CATMODE mef -D CATFORMAT panstarrs"); 46 53 } 47 54 … … 52 59 psFree(CATDIR); 53 60 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); 58 66 psTrace ("psastro", 3, "%s\n", getstarCommand); 59 67 60 68 // XXX use psPipe: catch stderr, stdout, allow for Nsec timeout... 69 // use fork to add timeout capability 61 70 status = system (getstarCommand); 62 71 if (status) { … … 71 80 psFits *fits = psFitsOpen (tempFile, "r"); 72 81 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 115 psArray *psastroReadGetstarCatalog (psFits *fits) { 116 117 bool status; 118 73 119 if (ELIXIR_MODE) { 74 120 psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR"); … … 77 123 } 78 124 79 psTimerStart ("psastro");80 125 long numSources = psFitsTableSize(fits); // Number of sources in table 81 126 … … 102 147 psFree (row); 103 148 } 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 refstars113 if (psTraceGetLevel("psastro.dump") > 0) {114 psastroDumpRefstars (refstars, "refstars.dat");115 }116 117 if (psTraceGetLevel("psastro.plot") > 0) {118 psastroPlotRefstars (refstars, recipe);119 }120 121 149 return refstars; 122 150 } 151 152 psArray *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.
