Changeset 26879
- Timestamp:
- Feb 10, 2010, 4:24:46 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/psModules/src
- Files:
-
- 9 edited
-
astrom/pmAstrometryWCS.c (modified) (7 diffs)
-
camera/pmFPA.c (modified) (1 diff)
-
camera/pmReadoutFake.c (modified) (3 diffs)
-
camera/pmReadoutFake.h (modified) (1 diff)
-
config/pmConfig.c (modified) (3 diffs)
-
config/pmConfigCamera.c (modified) (7 diffs)
-
config/pmConfigRun.c (modified) (1 diff)
-
objects/pmSourceGroups.c (modified) (1 diff)
-
objects/pmSourceIO.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psModules/src/astrom/pmAstrometryWCS.c
r25876 r26879 378 378 // XXX make it optional to write out CDi_j terms, or other versions 379 379 // apply CDELT1,2 (degrees / pixel) to yield PCi,j terms of order unity 380 if (! (wcs->wcsCDkeys)) {380 if (!wcs->wcsCDkeys) { 381 381 382 382 double cdelt1 = wcs->cdelt1; … … 419 419 psMetadataRemoveKey(header, "CD2_2"); 420 420 } 421 } 422 if (wcs->wcsCDkeys) { 421 } else { 423 422 424 423 psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_1", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0]); … … 845 844 int k=0; 846 845 for (int j=0; j<nSamples; j++) { 847 double y = j * deltaY / nSamples;846 double y = bounds->y0 + (j * deltaY / nSamples); 848 847 for (int i=0; i<nSamples; i++) { 849 848 psPlane *s = psPlaneAlloc(); 850 s->x = i * deltaX / nSamples;849 s->x = bounds->x0 + (i * deltaX / nSamples); 851 850 s->y = y; 852 851 psArraySet(src, k, s); 853 852 psPlane *d = psPlaneTransformApply(NULL, trans, s); 854 853 psArraySet(dst, k, d); 855 psFree(s); 854 psFree(s); // drop our refs to s and d 856 855 psFree(d); 857 856 ++k; … … 869 868 // compare the computed coordintes from this transform with the original 870 869 psPlane *new = psPlaneAlloc(); 870 printf(" i chip_x fpa_x fpa_x_fit dx chip_y fpa_y fpa_y_fit dy dx > 0.5 || dy > 0.5\n"); 871 871 for (int i=0; i<psArrayLength(dst); i++) { 872 872 psPlane *d = (psPlane *) psArrayGet(dst, i); … … 875 875 new = psPlaneTransformApply(new, newTrans, s); 876 876 877 printf("%4d %f %f\n", i, 100.*(new->x - d->x)/d->x, 100.*(new->y - d->y)/d->y); 877 double xerr = new->x - d->x; 878 double yerr = new->y - d->y; 879 bool bigerr = (fabs(xerr) > .5) || (fabs(yerr) > .5); 880 printf("%4d %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %s\n" 881 , i, s->x, new->x, d->x, xerr, s->y, new->y, d->y, yerr, bigerr ? "BIGERR" : ""); 878 882 } 879 883 psFree(new); … … 891 895 psRegion *chipBounds = pmChipPixels(chip); 892 896 893 psPlaneTransform *newToFPA = linearFitToTransform(chip->toFPA, chipBounds); 897 #ifdef TESTING_CAMRUN_14728 898 chipBounds->y0 = 1874.; 899 chipBounds->x1 = 2387.; 900 #endif 901 902 // First combine the chip to FPA and FPA to TPA into a single transformation 903 psPlaneTransform *chipToTPA = psPlaneTransformCombine(NULL, chip->toFPA, fpa->toTPA, *chipBounds, 50); 904 if (!chipToTPA) { 905 psFree(chipBounds); 906 psError(PS_ERR_UNKNOWN, false, "failed to create chipToTPA"); 907 return false; 908 } 909 910 // Next do a linear fit 911 psPlaneTransform *newToFPA = linearFitToTransform(chipToTPA, chipBounds); 912 psFree(chipToTPA); 894 913 if (!newToFPA) { 895 914 psFree(chipBounds); 896 psError(PS_ERR_UNKNOWN, false, "linear fit for toFPA failed"); 897 return false; 898 } 915 psError(PS_ERR_UNKNOWN, false, "linear fit of chip to TPA transform failed"); 916 return false; 917 } 918 919 psPlaneTransform *newFromFPA = psPlaneTransformInvert(NULL, newToFPA, *chipBounds, 50); 920 psFree(chipBounds); 921 if (!newFromFPA) { 922 psFree(newToFPA); 923 psError(PS_ERR_UNKNOWN, false, "inversion of fit of chip to TPA transform failed"); 924 return false; 925 } 926 927 // Success. Now set the fpa's toTPA and fromTPA to identity and replace the chip's transforms. 928 929 psPlaneTransform *newToTPA = psPlaneTransformIdentity(1); 930 psFree(fpa->toTPA); 931 fpa->toTPA = newToTPA; 932 933 psPlaneTransform *newFromTPA = psPlaneTransformIdentity(1); 934 psFree(fpa->fromTPA); 935 fpa->fromTPA = newFromTPA; 899 936 900 937 psFree(chip->toFPA); … … 902 939 903 940 psFree(chip->fromFPA); 904 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *chipBounds, 50); 905 if (!chip->fromFPA) { 906 psError(PS_ERR_UNKNOWN, false, "failed to invert linear fit for toFPA"); 907 return false; 908 } 909 910 psPlane *chip0 = psPlaneAlloc(); 911 chip0->x = 0; 912 chip0->y = 0; 913 psPlane *chip1 = psPlaneAlloc(); 914 chip1->x = chipBounds->x1; 915 chip1->y = chipBounds->y1; 916 917 // compute bounding region for fpa 918 psPlane *fpa0 = psPlaneTransformApply(NULL, newToFPA, chip0); 919 psPlane *fpa1 = psPlaneTransformApply(NULL, newToFPA, chip1); 920 921 psRegion *fpaBounds = psRegionAlloc(fpa0->x, fpa1->x, fpa0->y, fpa1->y); 922 psFree(chip0); 923 psFree(chip1); 924 psFree(fpa0); 925 psFree(fpa1); 926 927 psPlaneTransform *newToTPA = linearFitToTransform(fpa->toTPA, fpaBounds); 928 if (!newToTPA) { 929 psError(PS_ERR_UNKNOWN, false, "failed to perform linear fit to toTPA"); 930 psFree(fpaBounds); 931 return false; 932 } 933 psFree(fpa->toTPA); 934 fpa->toTPA = newToTPA; 935 936 // XXX: is this region ok? 937 psFree(fpa->fromTPA); 938 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *fpaBounds, 50); 939 if (!fpa->fromTPA) { 940 psError(PS_ERR_UNKNOWN, false, "failed to invert linear fit to toTPA"); 941 return false; 942 } 943 941 chip->fromFPA = newFromFPA; 942 943 // Finally change the type for the projection. 944 944 fpa->toSky->type = PS_PROJ_TAN; 945 946 psFree(chipBounds);947 psFree(fpaBounds);948 945 949 946 return true; -
branches/eam_branches/20091201/psModules/src/camera/pmFPA.c
r26533 r26879 378 378 tmpFPA->toTPA = NULL; 379 379 tmpFPA->toSky = NULL; 380 tmpFPA->wcsCDkeys = false; 380 381 381 382 tmpFPA->analysis = psMetadataAlloc(); -
branches/eam_branches/20091201/psModules/src/camera/pmReadoutFake.c
r26260 r26879 23 23 #include "pmSourceUtils.h" 24 24 #include "pmModelUtils.h" 25 #include "pmSourceGroups.h" 25 26 26 27 #include "pmReadoutFake.h" 27 28 28 #define MODEL_TYPE "PS_MODEL_RGAUSS" // Type of model to use29 29 #define MAX_AXIS_RATIO 20.0 // Maximum axis ratio for PSF model 30 30 #define MODEL_MASK (PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE | \ 31 31 PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_LIMITS) // Mask to apply to models 32 33 34 static bool threaded = false; // Running threaded? 35 36 32 37 33 38 … … 47 52 } 48 53 return pmPSF_AxesToModel(params, axes); 54 } 55 56 /// Generate fake sources on a readout 57 static bool readoutFake(pmReadout *readout, // Readout of interest 58 const pmSourceGroups *groups, // Source groups 59 const psVector *x, // x coordinates 60 const psVector *y, // y coordinates 61 const psVector *mag, // Magnitudes 62 const psVector *xOffset, // Offsets in x 63 const psVector *yOffset, // Offsets in y 64 const pmPSF *psf, // PSF 65 float minFlux, // Minimum flux 66 float radius, // Minimum radius 67 bool circularise, // Circularise PSF? 68 bool normalisePeak, // Normalise sources for peak? 69 int groupIndex, // Group index 70 int cellIndex // Cell index 71 ) 72 { 73 psArray *cells = groups->groups->data[groupIndex]; // Cells in group 74 psVector *cellSources = cells->data[cellIndex]; // Sources in cell 75 76 for (int i = 0; i < cellSources->n; i++) { 77 int index = cellSources->data.S32[i]; // Index for source of interest 78 float flux = powf(10.0, -0.4 * mag->data.F32[index]); // Flux of source 79 float xSrc = x->data.F32[index], ySrc = y->data.F32[index]; // Coordinates of source 80 81 if (normalisePeak) { 82 // Normalise flux 83 pmModel *normModel = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation 84 if (!normModel || (normModel->flags & MODEL_MASK)) { 85 psFree(normModel); 86 continue; 87 } 88 // check that all params are valid: 89 bool validParams = true; 90 for (int j = 0; validParams && (j < normModel->params->n); j++) { 91 switch (j) { 92 case PM_PAR_SKY: 93 case PM_PAR_I0: 94 case PM_PAR_XPOS: 95 case PM_PAR_YPOS: 96 continue; 97 default: 98 if (!isfinite(normModel->params->data.F32[j])) { 99 validParams = false; 100 } 101 } 102 } 103 if (!validParams) { 104 psFree(normModel); 105 continue; 106 } 107 if (circularise && !circulariseModel(normModel)) { 108 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 109 psFree(normModel); 110 return false; 111 } 112 113 flux /= normModel->modelFlux(normModel->params); 114 psFree(normModel); 115 } 116 117 pmModel *fakeModel = pmModelFromPSFforXY(psf, xSrc, ySrc, flux); 118 if (!fakeModel || (fakeModel->flags & MODEL_MASK)) { 119 psFree(fakeModel); 120 continue; 121 } 122 // check that all params are valid: 123 bool validParams = true; 124 for (int j = 0; validParams && (j < fakeModel->params->n); j++) { 125 switch (j) { 126 case PM_PAR_SKY: 127 case PM_PAR_I0: 128 case PM_PAR_XPOS: 129 case PM_PAR_YPOS: 130 continue; 131 default: 132 if (!isfinite(fakeModel->params->data.F32[j])) { 133 validParams = false; 134 } 135 } 136 } 137 if (!validParams) { 138 psFree(fakeModel); 139 continue; 140 } 141 if (circularise && !circulariseModel(fakeModel)) { 142 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 143 psFree(fakeModel); 144 return false; 145 } 146 147 psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n", 148 fakeModel->params->data.F32[PM_PAR_XPOS], fakeModel->params->data.F32[PM_PAR_YPOS], 149 fakeModel->params->data.F32[PM_PAR_I0]); 150 151 pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate 152 fakeSource->peak = pmPeakAlloc(xSrc, ySrc, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE); 153 float fakeRadius = 1.0; // Radius of fake source 154 if (isfinite(minFlux)) { 155 fakeRadius = PS_MAX(fakeRadius, fakeModel->modelRadius(fakeModel->params, minFlux)); 156 } 157 if (radius > 0) { 158 fakeRadius = PS_MAX(fakeRadius, radius); 159 } 160 161 if (xOffset) { 162 if (!pmSourceDefinePixels(fakeSource, readout, xSrc + xOffset->data.S32[index], 163 ySrc + yOffset->data.S32[index], fakeRadius)) { 164 psErrorClear(); 165 continue; 166 } 167 if (!pmModelAddWithOffset(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0, 168 xOffset->data.S32[index], yOffset->data.S32[index])) { 169 psErrorClear(); 170 continue; 171 } 172 } else { 173 if (!pmSourceDefinePixels(fakeSource, readout, xSrc, ySrc, fakeRadius)) { 174 psErrorClear(); 175 continue; 176 } 177 if (!pmModelAdd(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0)) { 178 psErrorClear(); 179 continue; 180 } 181 } 182 psFree(fakeSource); 183 psFree(fakeModel); 184 } 185 186 return true; 187 } 188 189 /// Thread job for readoutFake() 190 static bool readoutFakeThread(psThreadJob *job) 191 { 192 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 193 194 psArray *args = job->args; // Arguments 195 196 pmReadout *readout = args->data[0]; // Readout of interest 197 const pmSourceGroups *groups = args->data[1]; // Source groups 198 const psVector *x = args->data[2]; // x coordinates 199 const psVector *y = args->data[3]; // y coordinates 200 const psVector *mag = args->data[4]; // Magnitudes 201 const psVector *xOffset = args->data[5]; // Offsets in x 202 const psVector *yOffset = args->data[6]; // Offsets in y 203 const pmPSF *psf = args->data[7]; // PSF 204 float minFlux = PS_SCALAR_VALUE(args->data[8], F32); // Minimum flux 205 float radius = PS_SCALAR_VALUE(args->data[9], F32); // Minimum radius 206 bool circularise = PS_SCALAR_VALUE(args->data[10], U8); // Circularise PSF? 207 bool normalisePeak = PS_SCALAR_VALUE(args->data[11], U8); // Normalise for peak? 208 int groupIndex = PS_SCALAR_VALUE(args->data[12], S32); // Group index 209 int cellIndex = PS_SCALAR_VALUE(args->data[13], S32); // Cell index 210 211 return readoutFake(readout, groups, x, y, mag, xOffset, yOffset, psf, minFlux, radius, circularise, 212 normalisePeak, groupIndex, cellIndex); 213 } 214 215 216 bool pmReadoutFakeThreads(bool new) 217 { 218 bool old = threaded; // Old status, to return 219 220 if (!old && new) { 221 threaded = true; 222 223 { 224 psThreadTask *task = psThreadTaskAlloc("PSMODULES_READOUT_FAKE", 14); 225 task->function = &readoutFakeThread; 226 psThreadTaskAdd(task); 227 psFree(task); 228 } 229 230 } else if (old && !new) { 231 threaded = false; 232 psThreadTaskRemove("PSMODULES_READOUT_FAKE"); 233 } 234 235 return old; 49 236 } 50 237 … … 86 273 psImageInit(readout->image, 0); 87 274 88 for (long i = 0; i < numSources; i++) { 89 float flux = powf(10.0, -0.4 * mag->data.F32[i]); // Flux of source 90 float xSrc = x->data.F32[i], ySrc = y->data.F32[i]; // Coordinates of source 91 92 if (normalisePeak) { 93 // Normalise flux 94 pmModel *normModel = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation 95 if (!normModel || (normModel->flags & MODEL_MASK)) { 96 psFree(normModel); 97 continue; 98 } 99 // check that all params are valid: 100 bool validParams = true; 101 for (int n = 0; validParams && (n < normModel->params->n); n++) { 102 if (n == PM_PAR_SKY) continue; 103 if (n == PM_PAR_I0) continue; 104 if (n == PM_PAR_XPOS) continue; 105 if (n == PM_PAR_YPOS) continue; 106 if (!isfinite(normModel->params->data.F32[n])) validParams = false; 107 } 108 if (!validParams) { 109 psFree(normModel); 110 continue; 111 } 112 if (circularise && !circulariseModel(normModel)) { 113 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 114 psFree(normModel); 275 int numThreads = threaded ? psThreadPoolSize() : 0; // Number of threads 276 pmSourceGroups *groups = pmSourceGroupsFromVectors(readout, x, y, numThreads); // Groups of sources 277 if (!groups) { 278 psError(PS_ERR_UNKNOWN, false, "Unable to generate source groups"); 279 return false; 280 } 281 282 if (threaded) { 283 for (int i = 0; i < groups->groups->n; i++) { 284 psArray *cells = groups->groups->data[i]; // Cell with sources 285 for (int j = 0; j < cells->n; j++) { 286 psThreadJob *job = psThreadJobAlloc("PSMODULES_READOUT_FAKE"); 287 psArray *args = job->args; 288 psArrayAdd(args, 1, readout); 289 psArrayAdd(args, 1, groups); 290 // Casting away const to add to array 291 psArrayAdd(args, 1, (psVector*)x); 292 psArrayAdd(args, 1, (psVector*)y); 293 psArrayAdd(args, 1, (psVector*)mag); 294 psArrayAdd(args, 1, (psVector*)xOffset); 295 psArrayAdd(args, 1, (psVector*)yOffset); 296 psArrayAdd(args, 1, (pmPSF*)psf); 297 PS_ARRAY_ADD_SCALAR(args, minFlux, PS_TYPE_F32); 298 PS_ARRAY_ADD_SCALAR(args, radius, PS_TYPE_S32); 299 PS_ARRAY_ADD_SCALAR(args, circularise, PS_TYPE_U8); 300 PS_ARRAY_ADD_SCALAR(args, normalisePeak, PS_TYPE_U8); 301 PS_ARRAY_ADD_SCALAR(args, i, PS_TYPE_S32); 302 PS_ARRAY_ADD_SCALAR(args, j, PS_TYPE_S32); 303 304 if (!psThreadJobAddPending(job)) { 305 psFree(job); 306 psFree(groups); 307 return false; 308 } 309 psFree(job); 310 } 311 if (!psThreadPoolWait(true)) { 312 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 313 psFree(groups); 115 314 return false; 116 315 } 117 118 flux /= normModel->modelFlux(normModel->params); 119 psFree(normModel); 120 } 121 122 pmModel *fakeModel = pmModelFromPSFforXY(psf, xSrc, ySrc, flux); 123 if (!fakeModel || (fakeModel->flags & MODEL_MASK)) { 124 psFree(fakeModel); 125 continue; 126 } 127 // check that all params are valid: 128 bool validParams = true; 129 for (int n = 0; validParams && (n < fakeModel->params->n); n++) { 130 if (n == PM_PAR_SKY) continue; 131 if (n == PM_PAR_I0) continue; 132 if (n == PM_PAR_XPOS) continue; 133 if (n == PM_PAR_YPOS) continue; 134 if (!isfinite(fakeModel->params->data.F32[n])) validParams = false; 135 } 136 if (!validParams) { 137 psFree(fakeModel); 138 continue; 139 } 140 if (circularise && !circulariseModel(fakeModel)) { 141 psError(PS_ERR_UNKNOWN, false, "Unable to circularise PSF model."); 142 psFree(fakeModel); 143 return false; 144 } 145 146 psTrace("psModules.camera", 10, "Adding source at %f,%f with flux %f\n", 147 fakeModel->params->data.F32[PM_PAR_XPOS], fakeModel->params->data.F32[PM_PAR_YPOS], 148 fakeModel->params->data.F32[PM_PAR_I0]); 149 150 pmSource *fakeSource = pmSourceAlloc(); // Fake source to generate 151 fakeSource->peak = pmPeakAlloc(xSrc, ySrc, fakeModel->params->data.F32[PM_PAR_I0], PM_PEAK_LONE); 152 float fakeRadius = 1.0; // Radius of fake source 153 if (isfinite(minFlux)) { 154 fakeRadius = PS_MAX(fakeRadius, fakeModel->modelRadius(fakeModel->params, minFlux)); 155 } 156 if (radius > 0) { 157 fakeRadius = PS_MAX(fakeRadius, radius); 158 } 159 160 if (xOffset) { 161 if (!pmSourceDefinePixels(fakeSource, readout, xSrc + xOffset->data.S32[i], 162 ySrc + yOffset->data.S32[i], fakeRadius)) { 163 psErrorClear(); 164 continue; 165 } 166 if (!pmModelAddWithOffset(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0, 167 xOffset->data.S32[i], yOffset->data.S32[i])) { 168 psErrorClear(); 169 continue; 170 } 171 } else { 172 if (!pmSourceDefinePixels(fakeSource, readout, xSrc, ySrc, fakeRadius)) { 173 psErrorClear(); 174 continue; 175 } 176 if (!pmModelAdd(fakeSource->pixels, NULL, fakeModel, PM_MODEL_OP_FULL, 0)) { 177 psErrorClear(); 178 continue; 179 } 180 } 181 psFree(fakeSource); 182 psFree(fakeModel); 316 } 317 } else if (!readoutFake(readout, groups, x, y, mag, xOffset, yOffset, psf, minFlux, radius, circularise, 318 normalisePeak, 0, 0)) { 319 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake sources on readout"); 320 psFree(groups); 321 return false; 322 } 323 324 psFree(groups); 325 326 // Set a concept value 327 #define CONCEPT_SET_S32(CONCEPTS, NAME, OLD, NEW) { \ 328 psMetadataItem *item = psMetadataLookup(CONCEPTS, NAME); \ 329 psAssert(item->type == PS_TYPE_S32, "Incorrect type: %x", item->type); \ 330 if (item->data.S32 == OLD) { \ 331 item->data.S32 = NEW; \ 332 } \ 333 } 334 335 if (readout->parent) { 336 CONCEPT_SET_S32(readout->parent->concepts, "CELL.XPARITY", 0, 1); 337 CONCEPT_SET_S32(readout->parent->concepts, "CELL.YPARITY", 0, 1); 338 CONCEPT_SET_S32(readout->parent->concepts, "CELL.XBIN", 0, 1); 339 CONCEPT_SET_S32(readout->parent->concepts, "CELL.YBIN", 0, 1); 183 340 } 184 341 185 342 return true; 343 186 344 } 187 345 -
branches/eam_branches/20091201/psModules/src/camera/pmReadoutFake.h
r26216 r26879 12 12 #include <pmPSF.h> 13 13 #include <pmSourceMasks.h> 14 15 /// Set threading 16 /// 17 /// Returns old threading state 18 bool pmReadoutFakeThreads( 19 bool new // New threading state 20 ); 14 21 15 22 /// Generate a fake readout from vectors -
branches/eam_branches/20091201/psModules/src/config/pmConfig.c
r24496 r26879 47 47 48 48 static bool checkPath(const char *filename, bool create, bool trunc); 49 static psString resolveConfigFile(const char *name); 49 50 50 51 bool pmConfigReadParamsSet(bool newReadCameraConfig) … … 447 448 psWarning("-ipprc command-line switch provided without the required filename --- ignored.\n"); 448 449 } else { 449 configFile = psStringCopy(argv[argNum]);450 configFile = resolveConfigFile(argv[argNum]); 450 451 psArgumentRemove(argNum, argc, argv); 451 452 } … … 1834 1835 return false; 1835 1836 } 1837 1838 static psString resolveConfigFile(const char *nameArg) 1839 { 1840 // if config file name is nebulous path resolve it 1841 // otherwise just return a copy of the argument 1842 if (strncasecmp(nameArg, "neb://", strlen("neb://"))) { 1843 return psStringCopy(nameArg); 1844 } 1845 1846 #ifdef HAVE_NEBCLIENT 1847 char *neb_server = getenv("NEB_SERVER"); 1848 1849 // if env isn't set, check the config system 1850 if (!neb_server) { 1851 psError(PM_ERR_CONFIG, true, "NEB_SERVER environment variable must be set in order to resolve config file."); 1852 return NULL; 1853 } 1854 1855 nebServer *server = nebServerAlloc(neb_server); 1856 if (!server) { 1857 psError(PM_ERR_SYS, true, "failed to create a nebServer object."); 1858 return NULL; 1859 } 1860 1861 char *nebfile = nebFind(server, nameArg); 1862 nebServerFree(server); 1863 if (!nebfile) { 1864 // object does not exist 1865 psError(PM_ERR_SYS, true, "failed to resolve nebulous path: %s.", nameArg); 1866 return NULL; 1867 } 1868 // XXX: do I need to free nebfile? 1869 1870 return psStringCopy(nebfile); 1871 #else 1872 psError(PM_ERR_PROG, true, "psModules was compiled without nebulous support."); 1873 return NULL; 1874 #endif // ifdef HAVE_NEBCLIENT 1875 } -
branches/eam_branches/20091201/psModules/src/config/pmConfigCamera.c
r23452 r26879 149 149 camerasIter = psMetadataIteratorAlloc(new, PS_LIST_HEAD, NULL); // Iterator 150 150 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 151 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, 0);151 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, PS_META_REPLACE); 152 152 } 153 153 psFree(camerasIter); … … 210 210 211 211 // See if the new one is already there 212 psString newName = NULL; // Name of skycelled camera 213 psStringAppend(&newName, "_%s-SKYCELL", name); 214 if (psMetadataLookup(oldCameras, newName)) { 212 psString newName = pmConfigCameraSkycellName(name); // Name of skycelled camera 213 bool mdok; // Status of MD lookup 214 psMetadata *oldCam = psMetadataLookupMetadata(&mdok, oldCameras, newName); // Existing camera configuration 215 if (mdok && oldCam) { 216 // Ensure new camera goes to the head of the metadata, so that it will be recognised first 217 // The old camera doesn't contain the PSMOSAIC header, so it will match anything! 218 psTrace("psModules.config", 6, "Camera configuration for %s exists, so moving to the front.", newName); 219 psMetadataAddMetadata(newCameras, PS_LIST_HEAD, newName, PS_META_REPLACE, NULL, oldCam); 215 220 psFree(newName); 216 221 return true; … … 366 371 // New camera MUST go to the head of the metadata, so that it will be recognised first 367 372 // The old camera doesn't contain the PSCAMERA and PSFORMAT headers, so it will match anything! 373 psTrace("psModules.config", 6, "Generated new camera configuration for %s.", newName); 368 374 psMetadataAddMetadata(newCameras, PS_LIST_HEAD, newName, PS_META_REPLACE, 369 375 "Automatically generated", new); … … 436 442 camerasIter = psMetadataIteratorAlloc(new, PS_LIST_HEAD, NULL); // Iterator 437 443 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 438 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, 0);444 psMetadataAddItem(cameras, camerasItem, PS_LIST_HEAD, PS_META_REPLACE); 439 445 } 440 446 psFree(camerasIter); … … 469 475 470 476 // See if the new one is already there 471 psString newName = NULL; // Name of mosaicked camera 472 psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA"); 473 if (psMetadataLookup(oldCameras, newName)) { 477 psString newName = mosaicLevel == PM_FPA_LEVEL_CHIP ? pmConfigCameraChipName(name) : 478 pmConfigCameraFPAName(name); // Name of mosaicked camera 479 bool mdok; // Status of MD lookup 480 psMetadata *oldCam = psMetadataLookupMetadata(&mdok, oldCameras, newName); // Existing camera configuration 481 if (mdok && oldCam) { 482 // Ensure new camera goes to the head of the metadata, so that it will be recognised first 483 // The old camera doesn't contain the PSMOSAIC header, so it will match anything! 484 psTrace("psModules.config", 6, "Camera configuration for %s exists, so moving to the front.", newName); 485 psMetadataAddMetadata(newCameras, PS_LIST_HEAD, newName, PS_META_REPLACE, NULL, oldCam); 474 486 psFree(newName); 475 487 return true; … … 477 489 478 490 psMetadata *new = psMetadataCopy(NULL, camera); // Copy of the camera description 479 bool mdok; // Status of MD lookups480 491 481 492 // ** Fix up the contents of the FPA description to match the mosaicked camera ** … … 849 860 // New camera MUST go to the head of the metadata, so that it will be recognised first 850 861 // The old camera doesn't contain the PSMOSAIC header, so it will match anything! 862 psTrace("psModules.config", 6, "Generated new camera configuration for %s.", newName); 851 863 psMetadataAddMetadata(newCameras, PS_LIST_HEAD, newName, PS_META_REPLACE, 852 864 "Automatically generated", new); -
branches/eam_branches/20091201/psModules/src/config/pmConfigRun.c
r23748 r26879 160 160 psArray *files = configRunFileGet(config, name, "FILES.INPUT"); // Files from RUN metadata 161 161 if (!files) { 162 configRunFileGet(config, name, "FILES.OUTPUT");162 files = configRunFileGet(config, name, "FILES.OUTPUT"); 163 163 } 164 164 -
branches/eam_branches/20091201/psModules/src/objects/pmSourceGroups.c
r26190 r26879 186 186 cellSources->data.S32[i] = i; 187 187 } 188 cellSources->n = numSources; 188 189 } else { 189 190 for (int i = 0; i < numSources; i++) { -
branches/eam_branches/20091201/psModules/src/objects/pmSourceIO.c
r26787 r26879 960 960 if (hdu->header == NULL) { 961 961 // if the IMAGE header does not exist, we have no data for this view 962 if (!psFitsMoveExtName (file->fits, headname)) {962 if (!psFitsMoveExtNameClean (file->fits, headname)) { 963 963 readout->data_exists = false; 964 964 psFree (headname);
Note:
See TracChangeset
for help on using the changeset viewer.
