Changeset 36615 for trunk/ppBackground/src/ppBackgroundStackCamera.c
- Timestamp:
- Mar 27, 2014, 4:21:00 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ppBackground/src/ppBackgroundStackCamera.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppBackground/src/ppBackgroundStackCamera.c
r36582 r36615 33 33 pmConfig *config = data->config; // Because I'm reusing code. 34 34 int u,v; 35 size_t A,P; 36 double RR = -9999.0 ,DD = -99999.0,rr = 9999.0,dd = 99999.0; 35 37 // FIX Figure out what stacks we have to deal with. 36 38 psString stackName = data->stacks->data[0]; … … 49 51 } 50 52 psArrayAdd(data->stack_data,data->stack_data->n,psMemIncrRefCounter(stack)); 53 pmFPAfileActivate(config->files, false, NULL); 54 55 // You know what? Let's just fucking lie to config->files. 56 psMetadata *config_files = config->files; 57 config->files = NULL; 58 config->files = psMetadataAlloc(); 51 59 52 60 // Read over the input background models. … … 62 70 return(false); 63 71 } 64 72 73 // Pull out the information for this exposure 65 74 psMetadata *input = item->data.md; // the input metadata of interest 66 67 75 psString smfFileName = psMetadataLookupStr(NULL, input, "astrom"); 68 76 psMetadata *modelContent = psMetadataLookupMetadata(NULL, input, "models"); 77 78 // Allocate the model metadata object 79 psMetadata *Bmodel = psMetadataAlloc(); 80 69 81 // Read the smf file from this item 70 82 fileArguments("astrom",smfFileName,"",config); 71 83 pmFPAfile *smfFile = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM","astrom"); 72 84 85 // taking from pswarpLoadAstrometry.c 86 smfFile->type = PM_FPA_FILE_WCS; 73 87 // Read the SMF data 74 88 pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy 89 75 90 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 76 91 return NULL; 77 92 } 93 if (!pmFPAfileRead(smfFile,view,config)) { 94 psError(PS_ERR_IO, false, "failed READ at FPA %s", smfFile->name); 95 psFree(view); 96 return false; 97 } 98 78 99 printf("CZW: Item %d\n",i); 79 100 // find the FPA phu … … 93 114 } 94 115 } 116 117 psMemStats(0,&A,&P); 118 fprintf(stderr,"fpa %ld %ld\n",A,P); 119 95 120 pmChip *chip; // Chip from FPA 96 121 while ((chip = pmFPAviewNextChip(view, smfFile->fpa, 1))) { … … 106 131 psWarning("More than one cell present for chip %d", view->chip); 107 132 } 133 134 psMemStats(0,&A,&P); 135 fprintf(stderr,"chip %ld %ld\n",A,P); 108 136 109 137 // read WCS data from the corresponding header … … 128 156 } 129 157 130 // FIXLoad model data for this chip158 // Load model data for this chip 131 159 psString modelFileName = pmConfigConvertFilename(psMetadataLookupStr(NULL, modelContent, chipName), 132 160 config, PM_FPA_MODE_READ, false); … … 175 203 if (tp->y < data->dec_min) { data->dec_min = tp->y; } 176 204 else if (tp->y > data->dec_max) { data->dec_max = tp->y; } 177 } 178 } 179 205 206 if (sky->r < rr) { rr = sky->r; } 207 else if (sky->r > RR) { RR = sky->r; } 208 if (sky->r < dd) { dd = sky->d; } 209 else if (sky->d > DD) { DD = sky->d; } 210 211 } 212 } 213 214 // Allocate the model data for this chip 215 psMetadata *this_model = psMetadataAlloc(); 216 180 217 // Attach vectors to teh structure of the chip 181 psMetadataAddImage( chip->analysis,PS_LIST_TAIL,218 psMetadataAddImage(this_model,PS_LIST_TAIL, 182 219 "bkg image", 0, 183 220 "ota space X vector", image); 184 psMetadataAddImage( chip->analysis,PS_LIST_TAIL,221 psMetadataAddImage(this_model,PS_LIST_TAIL, 185 222 "bkg ra", 0, 186 223 "ota space ra vector", raim); 187 psMetadataAddImage( chip->analysis,PS_LIST_TAIL,224 psMetadataAddImage(this_model,PS_LIST_TAIL, 188 225 "bkg dec", 0, 189 226 "ota space dec vector", decim); 190 psMetadataAddImage( chip->analysis,PS_LIST_TAIL,227 psMetadataAddImage(this_model,PS_LIST_TAIL, 191 228 "bkg calibrated data", 0, 192 229 "ota space corrected data", model); … … 194 231 // Define default background model parameters, using the assumption: 195 232 // observed = camera + offset + scale * astrophysical 196 psMetadataAddF32( chip->analysis,PS_LIST_TAIL,233 psMetadataAddF32(this_model,PS_LIST_TAIL, 197 234 "bkg offset", PS_META_REPLACE, 198 235 "background offset for this exposure/ota pair", 0.0); 199 psMetadataAddF32( chip->analysis,PS_LIST_TAIL,236 psMetadataAddF32(this_model,PS_LIST_TAIL, 200 237 "bkg scale", PS_META_REPLACE, 201 238 "background scale parameter for this exposure/ota pair", 1.0); 202 // FIX Free model data for this chip 239 // Add this model to the current model 240 psMetadataAddMetadata(Bmodel,PS_LIST_TAIL, 241 chipName, PS_META_REPLACE, 242 "model data for this exposure/ota", this_model); 243 // Free model data for this chip 203 244 psFree(modelFileName); 204 245 psFree(modelFits); … … 212 253 psFree(decim); 213 254 psFree(model); 214 255 psFree(this_model); 256 215 257 // Check to see if we've loaded or allocated an OTA solution container for this chip 216 258 if (!psMetadataLookupPtr(NULL,data->OTA_solutions,chipName)) { // No solution metadata entry exists for this chipName … … 235 277 } 236 278 } 237 238 // FIX Hopefully this isn't going to destroy everything. 239 // Chip 279 280 281 psMemStats(0,&A,&P); 282 fprintf(stderr,"chip2 %ld %ld\n",A,P); 283 240 284 /* if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { */ 241 285 /* psError(psErrorCodeLast(), false, "Error saving data to files."); */ 242 286 /* return false; */ 243 287 /* } */ 244 } 245 // FPA 246 /* if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { */ 247 /* psError(psErrorCodeLast(), false, "Error saving data to files."); */ 248 /* return false; */ 249 /* } */ 250 251 // Add this smf to the smf array. 252 psArrayAdd(data->smfs,data->smfs->n,psMemIncrRefCounter(smfFile)); 253 psFree(smfFile); 254 } 255 288 } // end chip loop 289 290 // Add the set of models to the datastructure 291 psMetadataAddMetadata(data->models, PS_LIST_TAIL, 292 smfFile->origname, PS_META_REPLACE, 293 "model data for this exposure", Bmodel); 294 psMetadataAddS16(data->models,PS_LIST_TAIL, 295 "N", PS_META_REPLACE, 296 "counter", i); 297 // data->models->name->XY__->{image/ra/dec/calibrated/offset/scale} 298 // data->models->counter->XY__->{image/ra/dec/calibrated/offset/scale} 299 300 301 302 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 303 psError(psErrorCodeLast(), false, "Error saving data to files."); 304 return false; 305 } 306 pmFPAfileActivate(config->files, false, NULL); 307 psFree(modelContent); 308 // psFree(smfFile); 309 psFree(smfFileName); 310 psFree(view); 311 312 psFree(config->files); 313 config->files = psMetadataAlloc(); 314 // 315 316 // 317 } // end smf loop 318 319 // Unlie now. 320 psFree(config->files); 321 config->files = config_files; 322 256 323 // Allocate the modelMap for the region we're covering. 257 324 258 325 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 259 326 psImageBinning *binning = psImageBinningAlloc(); 260 binning->nXruff = 100; // Number of samples261 binning->nYruff = 100;327 binning->nXruff = 33; // Number of samples 328 binning->nYruff = 33; 262 329 binning->nXfine = ceil(data->ra_max - data->ra_min) + 1; // This is the range we're looking at 263 330 binning->nYfine = ceil(data->dec_max - data->dec_min) + 1; 264 331 binning->nXskip = floor(data->ra_min); 332 binning->nYskip = floor(data->dec_min); 333 psImageBinningSetScale(binning,PS_IMAGE_BINNING_CENTER); 334 printf("Sizes: sky: %f %f -> %f %f :: tp: %f %f -> %f %f :: map: %d %d\n", 335 rr,dd,RR,DD,data->ra_min,data->dec_min,data->ra_max,data->dec_max,binning->nXfine,binning->nYfine); 265 336 data->modelMap = psImageMapNoImageAlloc( binning,stats); 266 337
Note:
See TracChangeset
for help on using the changeset viewer.
