Changeset 42182
- Timestamp:
- Apr 27, 2022, 4:30:04 PM (4 years ago)
- Location:
- branches/eam_branches/ipp-20220316/fpcamera/src
- Files:
-
- 7 edited
-
fpcamera.c (modified) (2 diffs)
-
fpcameraArguments.c (modified) (1 diff)
-
fpcameraDataLoad.c (modified) (1 diff)
-
fpcameraDataSave.c (modified) (2 diffs)
-
fpcameraLoadRefstars.c (modified) (6 diffs)
-
fpcameraParseCamera.c (modified) (1 diff)
-
fpcameraReadAstrometry.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/fpcamera/src/fpcamera.c
r42176 r42182 16 16 17 17 void usage(void) { 18 fprintf (stderr, "USAGE: one of the following \n");19 fprintf (stderr, " fpcamera -file filename[,filename,...] -mask maskfile[,maskfile,...] -variance varfile[,varfile,...] -astrom-file (smffile) -ref (dvopath) -OutFileBaseName\n\n");20 fprintf (stderr, " fpcamera -list filelist -masklist masklist -varlist varlist -astrom-file (smffile) -ref (dvopath) -OutFileBaseName\n\n");18 fprintf (stderr, "USAGE: one of the following:\n\n"); 19 fprintf (stderr, " fpcamera -file filename[,filename,...] -mask maskfile[,maskfile,...] -variance varfile[,varfile,...] -astrom-file (smffile) OutFileBaseName\n"); 20 fprintf (stderr, " fpcamera -list filelist -masklist masklist -varlist varlist -astrom-file (smffile) -ref (dvopath) -OutFileBaseName\n\n"); 21 21 fprintf (stderr, "where:\n"); 22 22 fprintf (stderr, " FileNameList is a text file containing filenames, one per line\n"); … … 25 25 fprintf (stderr, " OutFileBaseName is the 'root name' for output files\n\n"); 26 26 fprintf(stderr, "Optional arguments:\n"); 27 fprintf(stderr, "\t-stats STATS.mdc: Output statistics into STATS.mdc\n"); 28 fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n\n"); 27 fprintf(stderr, " -stats STATS.mdc: Output statistics into STATS.mdc\n"); 28 fprintf(stderr, " -chip CHIPNUM: Only process this chip number.\n\n"); 29 fprintf(stderr, " -D FPCAMERA.CATDIR (catdir): specify the reference catalog.\n\n"); 29 30 exit (PS_EXIT_CONFIG_ERROR); 30 31 } -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraArguments.c
r42175 r42182 63 63 64 64 // specify the reference data source (DVO format or ??) 65 N = psArgumentGet (argc, argv, "-ref");66 if (!N) ESCAPE (FPCAMERA_ERR_ARGUMENTS, "Missing -ref (database)");67 psArgumentRemove (N, &argc, argv);68 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "FPCAMERA.CATDIR", PS_META_REPLACE, "", argv[N]);69 psArgumentRemove (N, &argc, argv);65 // N = psArgumentGet (argc, argv, "-ref"); 66 // if (!N) ESCAPE (FPCAMERA_ERR_ARGUMENTS, "Missing -ref (database)"); 67 // psArgumentRemove (N, &argc, argv); 68 // psMetadataAddStr (config->arguments, PS_LIST_TAIL, "FPCAMERA.CATDIR", PS_META_REPLACE, "", argv[N]); 69 // psArgumentRemove (N, &argc, argv); 70 70 71 71 // specify the astrometry calibration -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraDataLoad.c
r42178 r42182 10 10 11 11 // select the input data sources 12 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "FPCAMERA.INPUT. SMF");13 if (!input) ESCAPE (PS_ERR_UNKNOWN, "FPCAMERA.INPUT. SMFnot listed in config->files");12 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "FPCAMERA.INPUT.ASTROM"); 13 if (!input) ESCAPE (PS_ERR_UNKNOWN, "FPCAMERA.INPUT.ASTROM not listed in config->files"); 14 14 15 // XXX pass input to fpcameraReadAstrometry? 16 // XXX change name of function? 15 // read the astrometry calibration information (from cmf/smf) 17 16 if (!fpcameraReadAstrometry (input, config)) ESCAPE (PS_ERR_UNKNOWN, "Failure to read astrometry calibration"); 18 17 -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraDataSave.c
r42178 r42182 23 23 pmFPAfileActivate (config->files, false, NULL); 24 24 pmFPAfileActivate (config->files, true, "FPCAMERA.OUTPUT"); 25 pmFPAfileActivate (config->files, true, "FPCAMERA.INPUT.ASTROM"); 25 26 26 27 view = pmFPAviewAlloc (0); … … 74 75 75 76 // activate all files except FPCAMERA.OUTPUT, and PSPHOT.OUTPUT.CFF 76 pmFPAfileActivate (config->files, true, NULL);77 pmFPAfileActivate (config->files, false, "FPCAMERA.OUTPUT");77 // pmFPAfileActivate (config->files, true, NULL); 78 // pmFPAfileActivate (config->files, false, "FPCAMERA.OUTPUT"); 78 79 79 80 psFree (view); -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraLoadRefstars.c
r42178 r42182 13 13 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, FPCAMERA_RECIPE); 14 14 15 // DVO APIs expect decimal degrees16 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"); 20 20 21 21 // extra field fraction to add … … 37 37 DECmax += dDEC * fieldPadding; 38 38 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 39 42 // grab the FPCAMERA.CATDIR name from the FPCAMERA recipe 40 43 char *catdir_recipe = psMetadataLookupStr(&status, recipe, "FPCAMERA.CATDIR"); … … 43 46 // substitute abstract name with concrete name, if present in FPCAMERA.CATDIRS 44 47 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"); 46 51 47 52 // the name in the recipe may be one of: … … 49 54 // (B) a reference to the name in the FPCAMERA.CATDIRS folder in site.config 50 55 // (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; 54 62 if (catdir_folder) { 55 63 // randomly choose one of the entries … … 69 77 } 70 78 79 // if catdir_virtual is NULL, catdir_recipe must be a file name 71 80 char *catdir = (catdir_virtual == NULL) ? catdir_recipe : catdir_virtual; 72 81 73 82 // convert the uri to a real filename (ie, path://foobar) 74 83 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); 76 85 77 86 psLogMsg ("fpcamera", 3, "looking up reference objects in %s\n", CATDIR); 78 87 79 88 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"); 81 90 82 91 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"); 84 93 85 94 // issue the following command: … … 166 175 167 176 psMetadataAdd (input->fpa->analysis, PS_LIST_TAIL, "FPCAMERA.REFSTARS", PS_DATA_ARRAY, "reference sources", refstars); 177 psFree (refstars); 178 168 179 return true; 169 180 } -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraParseCamera.c
r42178 r42182 23 23 // the input smf file is a required argument 24 24 pmFPAfileDefineFromArgs (&status, config, "FPCAMERA.INPUT.ASTROM", "INPUT.ASTROM"); 25 if (!status) ESCAPE(FPCAMERA_ERR_CONFIG, "Failed to build FPA from FPCAMERA.INPUT. SMF");25 if (!status) ESCAPE(FPCAMERA_ERR_CONFIG, "Failed to build FPA from FPCAMERA.INPUT.ASTROM"); 26 26 27 27 // select the current recipe -
branches/eam_branches/ipp-20220316/fpcamera/src/fpcameraReadAstrometry.c
r42178 r42182 1 1 # include "fpcamera.h" 2 3 # define ESCAPE(ERROR, MSG) { psError(ERROR, false, MSG); psFree(view); return false; } 2 4 3 5 /* \brief this function loads the astrometry calibration from the input smf file */ … … 5 7 6 8 bool status; 9 pmChip *chip = NULL; 10 pmFPAview *view = NULL; 7 11 8 12 // select the current recipe (just needed for pixel scale) 13 // XXX this is defined in psastro.config : use that value instead of one defined in fpcamera.config? 9 14 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, FPCAMERA_RECIPE); 10 if (!recipe) { 11 psError(FPCAMERA_ERR_CONFIG, true, "Can't find FPCAMERA recipe!\n"); 12 return false; 13 } 15 if (!recipe) ESCAPE(FPCAMERA_ERR_CONFIG, "Can't find FPCAMERA recipe!"); 14 16 15 17 // physical pixel scale in microns per pixel (used in case of non-bilevel astrometry) 16 18 double pixelScale = psMetadataLookupF32 (&status, recipe, "FPCAMERA.PIXEL.SCALE"); 17 if (!status) { 18 psError(PS_ERR_IO, true, "Failed to lookup pixel scale"); 19 return false; 20 } 19 if (!status) ESCAPE(PS_ERR_IO, "Failed to lookup pixel scale"); 21 20 22 pmFPAview *view = pmFPAviewAlloc (0); 21 // de-activate all files except FPCAMERA.INPUT.ASTROM (where we get the astrometric calibration) 22 pmFPAfileActivate (config->files, false, NULL); 23 pmFPAfileActivate (config->files, true, "FPCAMERA.INPUT.ASTROM"); 24 25 view = pmFPAviewAlloc (0); 26 27 // load headers for astrometry calibration 28 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE(FPCAMERA_ERR_DATA, "failed to load header at FPA level"); 29 30 // add in chip headers 31 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 32 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 33 if (!chip->process) { continue; } 34 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE(FPCAMERA_ERR_DATA, "failed to load header at Chip level"); 35 } 36 psLogMsg ("psastro", 3, "load headers : %f sec\n", psTimerMark ("psastro")); 37 38 // reset to loop over all chips: 39 pmFPAviewReset (view); 23 40 24 41 // check PHU header to see if we are using mosaic-level or per-chip astrometry … … 33 50 } 34 51 35 pmChip *chip; 52 // we need the min/max RA & DEC for each of the chips and for the entire FOV 53 double rMinFPA = +FLT_MAX; 54 double rMaxFPA = -FLT_MAX; 55 double dMinFPA = +FLT_MAX; 56 double dMaxFPA = -FLT_MAX; 57 36 58 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 37 59 psTrace ("fpcamera", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); … … 55 77 } 56 78 } 79 80 // we need the min/max RA & DEC for each of the chips and for the entire FOV 81 double rMinChip = +FLT_MAX; 82 double rMaxChip = -FLT_MAX; 83 double dMinChip = +FLT_MAX; 84 double dMaxChip = -FLT_MAX; 85 86 // this region defines the data area of the chip 87 psRegion *region = pmChipPixels (chip); 88 psPlane ptCH[4]; 89 90 // save the 4 corners 91 ptCH[0].x = region->x0; ptCH[0].y = region->y0; 92 ptCH[1].x = region->x1; ptCH[1].y = region->y0; 93 ptCH[2].x = region->x1; ptCH[2].y = region->y1; 94 ptCH[3].x = region->x0; ptCH[3].y = region->y1; 95 psFree (region); 96 97 // report and save the current best guess for the chip 0,0 pixel coordinates 98 for (int i = 0; i < 4; i++) { 99 psPlane ptFP, ptTP; 100 psSphere ptSky; 101 102 // 4 corners 103 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH[i]); 104 psPlaneTransformApply (&ptTP, input->fpa->toTPA, &ptFP); 105 psDeproject (&ptSky, &ptTP, input->fpa->toSky); 106 rMinChip = PS_MIN(rMinChip, DEG_RAD*ptSky.r); 107 rMaxChip = PS_MAX(rMaxChip, DEG_RAD*ptSky.r); 108 dMinChip = PS_MIN(dMinChip, DEG_RAD*ptSky.d); 109 dMaxChip = PS_MAX(dMaxChip, DEG_RAD*ptSky.d); 110 } 111 psMetadataAddF32 (chip->analysis, PS_LIST_TAIL, "RA_MIN", PS_META_REPLACE, "", rMinChip); 112 psMetadataAddF32 (chip->analysis, PS_LIST_TAIL, "RA_MAX", PS_META_REPLACE, "", rMaxChip); 113 psMetadataAddF32 (chip->analysis, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", dMinChip); 114 psMetadataAddF32 (chip->analysis, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", dMaxChip); 115 psLogMsg ("fpcamera", 3, "chip %3d = (%f,%f) - (%f,%f)\n", view->chip, rMinChip, dMinChip, rMaxChip, dMaxChip); 116 117 rMinFPA = PS_MIN(rMinFPA, rMinChip); 118 rMaxFPA = PS_MAX(rMaxFPA, rMaxChip); 119 dMinFPA = PS_MIN(dMinFPA, dMinChip); 120 dMaxFPA = PS_MAX(dMaxFPA, dMaxChip); 57 121 } 122 psMetadataAddF32 (input->fpa->analysis, PS_LIST_TAIL, "RA_MIN", PS_META_REPLACE, "", rMinFPA); 123 psMetadataAddF32 (input->fpa->analysis, PS_LIST_TAIL, "RA_MAX", PS_META_REPLACE, "", rMaxFPA); 124 psMetadataAddF32 (input->fpa->analysis, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", dMinFPA); 125 psMetadataAddF32 (input->fpa->analysis, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", dMaxFPA); 126 127 psLogMsg ("fpcamera", 3, "FPA FOV = (%f,%f) - (%f,%f)\n", rMinFPA, dMinFPA, rMaxFPA, dMaxFPA); 58 128 psLogMsg ("fpcamera", 3, "convert wcs terms to internal format : %f sec\n", psTimerMark ("fpcamera")); 59 129
Note:
See TracChangeset
for help on using the changeset viewer.
