Changeset 15562 for trunk/psastro
- Timestamp:
- Nov 9, 2007, 3:09:20 PM (19 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 1 added
- 1 deleted
- 11 edited
-
Makefile.am (modified) (1 diff)
-
psastro.h (modified) (2 diffs)
-
psastroAnalysis.c (modified) (1 diff)
-
psastroArguments.c (modified) (1 diff)
-
psastroDefineFiles.c (modified) (3 diffs)
-
psastroDemoDump.c (modified) (1 diff)
-
psastroEnforceChip.c (deleted)
-
psastroEnforceChips.c (added)
-
psastroLoadRefstars.c (modified) (7 diffs)
-
psastroMosaicAstrom.c (modified) (1 diff)
-
psastroMosaicGradients.c (modified) (2 diffs)
-
psastroMosaicOneChip.c (modified) (1 diff)
-
psastroMosaicSetMatch.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/Makefile.am
r12806 r15562 33 33 psastroLuminosityFunction.c \ 34 34 psastroRefstarSubset.c \ 35 psastroEnforceChips.c \ 35 36 psastroMosaicAstrom.c \ 36 37 psastroMosaicGradients.c \ -
trunk/psastro/src/psastro.h
r15195 r15562 27 27 bool psastroDataSave (pmConfig *config); 28 28 bool psastroDefineFiles (pmConfig *config, pmFPAfile *input); 29 bool psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType); 29 30 bool psastroAnalysis (pmConfig *config); 30 31 … … 74 75 bool psastroDumpStars (psArray *stars, char *filename); 75 76 bool psastroDumpMatchedStars (char *filename, psArray *rawstars, psArray *refstars, psArray *match); 77 bool psastroDumpGradients (psArray *gradients, char *filename); 76 78 77 79 bool psastroMosaicSetAstrom_tmp (pmFPA *fpa); 78 80 int psastroSortByMag (const void *a, const void *b); 79 81 82 bool psastroEnforceChips (pmConfig *config, pmFPA *fpa, psMetadata *recipe); 83 84 psArray *psastroReadGetstarCatalog (psFits *fits); 85 psArray *psastroReadGetstar_PS1_DEV_0 (psFits *fits); 86 80 87 # endif /* PSASTRO_H */ -
trunk/psastro/src/psastroAnalysis.c
r15245 r15562 16 16 return true; 17 17 } 18 19 // XXX test retrun20 // return true;21 18 22 19 // load the reference stars overlapping the data stars -
trunk/psastro/src/psastroArguments.c
r12992 r15562 36 36 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_META_REPLACE, "", argv[N]); 37 37 psArgumentRemove (N, &argc, argv); 38 } 39 40 // apply the chip correction based on the reference astrometry? 41 if ((N = psArgumentGet (argc, argv, "-fixchips"))) { 42 psArgumentRemove (N, &argc, argv); 43 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true); 44 } 45 // define the reference astrometry file 46 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "REF.ASTROM", "-refastrom", "-refastromlist"); 47 if (status) { 48 // if supplied, assume -fixchips is desired 49 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true); 38 50 } 39 51 -
trunk/psastro/src/psastroDefineFiles.c
r14212 r15562 4 4 5 5 // these calls bind the I/O handle to the specified fpa 6 pmFPAfile *output = NULL;6 bool status; 7 7 8 output = pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT"); 8 // select the current recipe 9 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 10 if (!recipe) { 11 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n"); 12 return false; 13 } 14 15 pmFPAfile *output = pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT"); 9 16 if (!output) { 10 17 psError(PSASTRO_ERR_CONFIG, false, "Failed to build FPA from PSASTRO.INPUT"); … … 12 19 } 13 20 output->save = true; 21 22 bool fixChips = psMetadataLookupBool (&status, recipe, "PSASTRO.FIX.CHIPS"); 23 24 if (fixChips) { 25 if (!psastroDefineFile (config, input->fpa, "PSASTRO.REF.ASTROM", "REF.ASTROM", PM_FPA_FILE_ASTROM, PM_DETREND_TYPE_ASTROM)) { 26 psError (PS_ERR_IO, false, "Can't find a reference astrometry file"); 27 return NULL; 28 } 29 } 14 30 15 31 # if (0) … … 25 41 return true; 26 42 } 43 44 bool psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType) { 45 46 bool status; 47 pmFPAfile *file; 48 49 // look for the file on the argument list 50 file = pmFPAfileDefineFromArgs (&status, config, filerule, argname); 51 if (!status) { 52 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 53 return false; 54 } 55 if (file) { 56 if (file->type != fileType) { 57 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 58 return false; 59 } 60 return true; 61 } 62 63 // look for the file in the camera config table 64 file = pmFPAfileDefineFromConf (&status, config, filerule); 65 if (!status) { 66 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 67 return false; 68 } 69 if (file) { 70 if (file->type != fileType) { 71 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 72 return false; 73 } 74 return true; 75 } 76 77 // look for the file to be loaded from the detrend database 78 file = pmFPAfileDefineFromDetDB (&status, config, filerule, input, detrendType); 79 if (!status) { 80 psError (PS_ERR_UNKNOWN, false, "failed to load file definition"); 81 return false; 82 } 83 if (file) { 84 if (file->type != fileType) { 85 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 86 return false; 87 } 88 return true; 89 } 90 return false; 91 } 92 -
trunk/psastro/src/psastroDemoDump.c
r15199 r15562 173 173 return true; 174 174 } 175 176 // this function is used for test purposes (-trace psastro.dump 1) 177 bool psastroDumpGradients (psArray *gradients, char *filename) { 178 179 FILE *f = fopen (filename, "w"); 180 181 for (int i = 0; i < gradients->n; i++) { 182 pmAstromGradient *gradient = gradients->data[i]; 183 184 // write out the refstar data 185 fprintf (f, "%d %f %f %f %f %f %f\n", i, 186 gradient->FP.x, gradient->FP.y, 187 gradient->dTPdL.x, gradient->dTPdL.y, 188 gradient->dTPdM.x, gradient->dTPdM.y); 189 } 190 191 fclose (f); 192 return true; 193 } 194 -
trunk/psastro/src/psastroLoadRefstars.c
r15538 r15562 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 = psStringCopy(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 } -
trunk/psastro/src/psastroMosaicAstrom.c
r15260 r15562 21 21 pmFPA *fpa = input->fpa; 22 22 23 // XXX before we do object matches, we need to fix failed chips 24 // compare chips with supplied mosaic model 25 // adjust significant outliers to match model 23 // before we do object matches, we need to (optionally) fix failed chips. We compare chips with 24 // the supplied mosaic model. Adjust significant outliers to match model. 25 if (!psastroEnforceChips (config, fpa, recipe)) { 26 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips"); 27 return false; 28 } 26 29 27 30 // given the existing per-chip astrometry, determine matches between raw and ref stars -
trunk/psastro/src/psastroMosaicGradients.c
r15258 r15562 1 1 # include "psastroInternal.h" 2 static int nPass = 0; 2 3 3 4 bool psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe) { … … 50 51 } 51 52 53 // if desired, dump the gradients to a file 54 if (psTraceGetLevel("psastro.dump") > 0) { 55 char name[80]; 56 sprintf (name, "gradients.%d.dat", nPass); 57 psastroDumpGradients (gradients, name); 58 nPass ++; 59 } 60 52 61 // allocate mosaic-level polynomial transformation and set masks needed by DVO 53 62 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER"); -
trunk/psastro/src/psastroMosaicOneChip.c
r15259 r15562 55 55 return false; 56 56 } 57 58 psLogMsg ("psastro", PS_LOG_DETAIL, "mosaic fit chip order %d", order); 57 59 58 60 // create output toFPA; set masks appropriate to the Elixir DVO astrometry format if we are -
trunk/psastro/src/psastroMosaicSetMatch.c
r12806 r15562 15 15 if (!status) { 16 16 psError(PS_ERR_IO, false, "Failed to lookup matching radius: %s", radiusWord); 17 return NULL;17 return false; 18 18 } 19 20 if (RADIUS <= 0.0) { 21 if (iteration == 0) { 22 psError(PS_ERR_IO, false, "Invalid match radius for first iteration: %s", radiusWord); 23 return false; 24 } 25 psWarning ("skipping match for iteration %d\n", iteration); 26 return true; 27 } 19 28 20 29 // this loop selects the matched stars for all chips
Note:
See TracChangeset
for help on using the changeset viewer.
