Changeset 23259
- Timestamp:
- Mar 10, 2009, 4:53:42 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 56 edited
-
archive/conv_variance/fake.c (modified) (1 diff)
-
archive/conv_variance/phot.c (modified) (1 diff)
-
ippTools/src/dettool.c (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (2 diffs)
-
ppMerge/src/ppMergeMask.c (modified) (1 diff)
-
ppMerge/src/ppMergeScaleZero.c (modified) (1 diff)
-
ppSim/src/ppSimBadPixels.c (modified) (1 diff)
-
ppSim/src/ppSimLoop.c (modified) (1 diff)
-
ppSim/src/ppSimSequence.c (modified) (2 diffs)
-
ppStack/src/ppStackLoop.c (modified) (1 diff)
-
ppStack/src/ppStackPhotometry.c (modified) (1 diff)
-
ppSub/src/ppSubVarianceFactors.c (modified) (1 diff)
-
ppSub/test/fake.c (modified) (1 diff)
-
psLib/src/fits/psFitsScale.c (modified) (2 diffs)
-
psLib/src/math/psRandom.c (modified) (3 diffs)
-
psLib/src/math/psRandom.h (modified) (5 diffs)
-
psLib/test/fits/tap_psFitsImage.c (modified) (1 diff)
-
psLib/test/imageops/convolutionBench.c (modified) (1 diff)
-
psLib/test/imageops/tap_psImageInterpolate2.c (modified) (1 diff)
-
psLib/test/math/tap_psMinimizeLMM.c (modified) (2 diffs)
-
psLib/test/math/tap_psPolyFit1D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit2D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit3D.c (modified) (1 diff)
-
psLib/test/math/tap_psPolyFit4D.c (modified) (1 diff)
-
psLib/test/math/tap_psRandom.c (modified) (11 diffs)
-
psLib/test/math/tap_psStats07.c (modified) (1 diff)
-
psLib/test/math/tap_psStats09.c (modified) (1 diff)
-
psLib/test/math/tap_psStatsTiming.c (modified) (1 diff)
-
psLib/test/math/tst_psMinimizeLMM.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit1D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit2D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit3D.c (modified) (1 diff)
-
psLib/test/math/tst_psPolyFit4D.c (modified) (1 diff)
-
psLib/test/math/tst_psRandom.c (modified) (13 diffs)
-
psLib/test/math/tst_psStats09.c (modified) (1 diff)
-
psLib/test/mathtypes/tap_psVectorSelect.c (modified) (2 diffs)
-
psLib/test/types/tap_psTree.c (modified) (1 diff)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (3 diffs)
-
psModules/src/camera/pmFPA_JPEG.c (modified) (1 diff)
-
psModules/src/config/pmConfig.c (modified) (8 diffs)
-
psModules/src/config/pmConfigCamera.c (modified) (2 diffs)
-
psModules/src/config/pmConfigRecipes.h (modified) (3 diffs)
-
psModules/src/config/pmConfigRun.c (modified) (3 diffs)
-
psModules/src/config/pmConfigRun.h (modified) (2 diffs)
-
psModules/src/detrend/pmFringeStats.c (modified) (1 diff)
-
psModules/src/detrend/pmRemnance.c (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionMatch.c (modified) (1 diff)
-
psModules/test/detrend/tap_pmMaskBadPixels.c (modified) (12 diffs)
-
psModules/test/imcombine/tap_pmImageCombine.c (modified) (1 diff)
-
psModules/test/objects/tap_pmFringe.c (modified) (1 diff)
-
psModules/test/objects/tap_pmSourceFitModel.c (modified) (1 diff)
-
psModules/test/objects/tap_pmSourceFitModel_Delta.c (modified) (2 diffs)
-
psphot/src/psphotModelBackground.c (modified) (1 diff)
-
psphot/src/psphotVisual.c (modified) (2 diffs)
-
pstest/src/tst_psPolynomial.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/conv_variance/fake.c
r20210 r23259 47 47 psFree(weight); 48 48 49 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);49 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 50 50 51 51 psImage *bright = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); -
trunk/archive/conv_variance/phot.c
r20210 r23259 52 52 53 53 psStats *bgStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 54 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);54 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 55 55 psImageBackground(bgStats, NULL, image, mask, maskVal, rng); 56 56 double bg = bgStats->robustMedian; -
trunk/ippTools/src/dettool.c
r21402 r23259 578 578 // generate a random-valued vector, return an index sorted by the random values 579 579 psVector *randomVector = psVectorAlloc(detrendExps->n, PS_TYPE_F32); // random values 580 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);580 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 581 581 for (int i = 0; i < randomVector->n; i++) { 582 582 randomVector->data.F32[i] = psRandomUniform(rng); -
trunk/ppImage/src/ppImageLoop.c
r23174 r23259 25 25 } 26 26 27 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 28 if (dump_file) { 29 pmConfigCamerasCull(config, NULL); 30 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG"); 31 32 pmConfigDump(config, input->fpa, dump_file); 33 } 27 pmConfigCamerasCull(config, NULL); 28 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG"); 34 29 35 30 pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest … … 220 215 psFree(view); 221 216 217 // Dump configuration 218 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 219 if (dump_file) { 220 pmConfigDump(config, input->fpa, dump_file); 221 } 222 222 223 // Write out summary statistics 223 224 if (options->doStats) { -
trunk/ppMerge/src/ppMergeMask.c
r23166 r23259 369 369 370 370 pmFPAview *view = pmFPAviewAlloc(0); ///< View to component of interest 371 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); ///< Random number generator371 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); ///< Random number generator 372 372 373 373 psMetadata *stats = NULL; ///< Statistics for output -
trunk/ppMerge/src/ppMergeScaleZero.c
r21365 r23259 51 51 break; 52 52 } 53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); ///< Random number generator53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); ///< Random number generator 54 54 pmFPAview *view = NULL; ///< View into FPA 55 55 -
trunk/ppSim/src/ppSimBadPixels.c
r20910 r23259 74 74 } 75 75 76 psRandom *pseudoRNG = psRandomAlloc (PS_RANDOM_TAUS, seed); // Pseudo-random number generator76 psRandom *pseudoRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, seed); // Pseudo-random number generator 77 77 78 78 psImage *image = readout->image; // Image of interest -
trunk/ppSim/src/ppSimLoop.c
r21365 r23259 25 25 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe 26 26 27 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator27 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 28 28 29 29 char *typeStr = psMetadataLookupStr(NULL, recipe, "IMAGE.TYPE"); // Type of image to simulate -
trunk/ppSim/src/ppSimSequence.c
r19315 r23259 133 133 if (ppsim_recipe) psStringAppend (&ppSimCommand, " -recipe PPSIM %s", ppsim_recipe); 134 134 135 unsigned long seed = psMetadataLookupS32 (&status, config, "RND_SEED"); 136 if (!status) seed = 0; 137 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 135 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 138 136 139 137 psMetadataItem *item = psMetadataLookup (config, "SEQUENCE"); 140 138 if (item == NULL) { 141 139 psLogMsg ("ppSimSequence", PS_LOG_WARN, "missing SEQUENCE description"); 142 exit ( 1);140 exit (PS_EXIT_CONFIG_ERROR); 143 141 } 144 142 … … 170 168 } 171 169 172 // determine the camera for the sequence and define the ppSim command173 if (camera == NULL) {174 camera = psMetadataLookupStr (&status, sequence, "CAMERA");175 }176 177 psString injectCommandReal = NULL;178 psString ppSimCommandReal = NULL;179 180 psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera);181 psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera);170 // determine the camera for the sequence and define the ppSim command 171 if (camera == NULL) { 172 camera = psMetadataLookupStr (&status, sequence, "CAMERA"); 173 } 174 175 psString injectCommandReal = NULL; 176 psString ppSimCommandReal = NULL; 177 178 psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera); 179 psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera); 182 180 183 181 if (!strcasecmp (type, "BIAS")) { -
trunk/ppStack/src/ppStackLoop.c
r23242 r23259 415 415 psArray *subKernels = psArrayAlloc(num); // Subtraction kernels --- required in the stacking 416 416 psArray *subRegions = psArrayAlloc(num); // Subtraction regions --- required in the stacking 417 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator417 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 418 418 int numGood = 0; // Number of good frames 419 419 int numCols = 0, numRows = 0; // Size of image -
trunk/ppStack/src/ppStackPhotometry.c
r23242 r23259 50 50 51 51 // Measure background 52 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator52 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 53 53 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics 54 54 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { -
trunk/ppSub/src/ppSubVarianceFactors.c
r21524 r23259 65 65 66 66 psStats *vfStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics 67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 68 68 69 69 // mask these values when examining the background -
trunk/ppSub/test/fake.c
r18591 r23259 89 89 int main(int argc, char *argv[]) 90 90 { 91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 92 92 93 93 // Images to generate -
trunk/psLib/src/fits/psFitsScale.c
r21183 r23259 112 112 // psImageBackground automatically excludes pixels that are non-finite, so we don't need to bother about a 113 113 // mask. 114 psU64 seed = p_psRandomGetSystemSeed(false); 115 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 114 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 116 115 psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object 117 116 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { … … 290 289 if (!psMemIncrRefCounter(rng) && options->fuzz) { 291 290 // Don't blab about which seed we're going to get --- it's not necessary for this purpose 292 psU64 seed = p_psRandomGetSystemSeed(false); 293 rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 291 rng = psRandomAlloc(PS_RANDOM_TAUS); 294 292 } 295 293 -
trunk/psLib/src/math/psRandom.c
r20547 r23259 29 29 #include <inttypes.h> 30 30 31 #include "psAbort.h" 31 32 #include "psMemory.h" 32 33 #include "psRandom.h" … … 38 39 39 40 41 unsigned long seed = 0; // Seed for RNG 42 43 40 44 psU64 p_psRandomGetSystemSeed(bool log) 41 45 { 42 FILE* fd; 43 psU64 seedVal = 0; 44 time_t timeVal; 46 psU64 seedVal = 0; // Seed value to return 45 47 46 fd = fopen("/dev/urandom","r"); 47 if(fd == NULL) { 48 // Read system clock to get seed 49 seedVal = (psU64)time(&timeVal); 50 } else { 51 // Read urandom to get seed 52 if (fread(&seedVal, sizeof(psU64),1,fd)) {;} // ignore return value 53 // Close file 54 fclose(fd); 48 // Since zero is a special value in our context, don't allow the final value chosen to be zero 49 while (seedVal == 0) { 50 FILE *fd = fopen("/dev/urandom", "r"); 51 if (fd) { 52 // Read urandom to get seed 53 if (fread(&seedVal, sizeof(psU64), 1, fd)) {;} // ignore return value 54 // Close file 55 fclose(fd); 56 } else { 57 // Read system clock to get seed 58 time_t timeVal; // Time value 59 seedVal = (psU64)time(&timeVal); 60 } 55 61 } 56 62 … … 63 69 } 64 70 65 psRandom *psRandomAlloc(psRandomType type, 66 unsigned long seed) 71 psU64 psRandomSeed(psU64 value) 67 72 { 68 gsl_rng *r = NULL; 69 psRandom *myRNG = NULL; 73 while (value == 0) { 74 value = p_psRandomGetSystemSeed(true); 75 } 76 seed = value; 77 return seed; 78 } 70 79 80 // Destructor for psRandom 81 static void randomFree(psRandom *rng) 82 { 83 if (rng->gsl) { 84 gsl_rng_free(rng->gsl); 85 } 86 return; 87 } 88 89 // Constructor for psRandom 90 static psRandom *randomAlloc(psRandomType type) 91 { 92 psRandom *rng = psAlloc(sizeof(psRandom)); // Random number generator to return 93 psMemSetDeallocator(rng, (psFreeFunc)randomFree); 94 95 rng->type = type; 96 97 const gsl_rng_type *gslType; // Type of RNG according to GSL 71 98 switch (type) { 72 case PS_RANDOM_TAUS: 73 myRNG = (psRandom*)psAlloc(sizeof(psRandom)); 74 r = gsl_rng_alloc(gsl_rng_taus); 75 myRNG->gsl = r; 76 if(seed == 0) { 77 gsl_rng_set(myRNG->gsl, p_psRandomGetSystemSeed(true)); 78 } else { 79 gsl_rng_set(myRNG->gsl, seed); 80 } 81 myRNG->type = type; 99 case PS_RANDOM_TAUS: 100 gslType = gsl_rng_taus; 82 101 break; 83 84 default: 85 psError(PS_ERR_UNEXPECTED_NULL, true, _("Unknown Random Number Generator Type")); 102 default: 103 psAbort("Unknown Random Number Generator Type: %x", type); 86 104 break; 87 105 } 88 106 89 return(myRNG); 107 rng->gsl = gsl_rng_alloc(gslType); 108 return rng; 90 109 } 91 110 92 void psRandomReset(psRandom *rand, 93 unsigned long seed) 111 psRandom *psRandomAlloc(psRandomType type) 94 112 { 95 // Check null psRandom 96 if(rand==NULL) { 97 psError(PS_ERR_UNEXPECTED_NULL, 98 true, 99 _("Random variable is NULL.")); 100 } else { 101 // Check seed value to see if system seed should be used 102 if(seed == 0) { 103 gsl_rng_set(rand->gsl,p_psRandomGetSystemSeed(true)); 104 } else { 105 gsl_rng_set(rand->gsl, seed); 106 } 113 psRandom *rng = randomAlloc(type); 114 psRandomReset(rng); 115 116 return rng; 117 } 118 119 psRandom *psRandomAllocSpecific(psRandomType type, psU64 specificSeed) 120 { 121 psRandom *rng = randomAlloc(type); 122 if (specificSeed == 0) { 123 specificSeed = p_psRandomGetSystemSeed(true); 107 124 } 125 gsl_rng_set(rng->gsl, specificSeed); 126 return rng; 127 } 128 129 bool psRandomReset(psRandom *rand) 130 { 131 PS_ASSERT_RANDOM_NON_NULL(rand, false); 132 if (seed == 0) { 133 seed = p_psRandomGetSystemSeed(true); 134 } 135 gsl_rng_set(rand->gsl, seed); 136 return true; 108 137 } 109 138 110 139 double psRandomUniform(const psRandom *r) 111 140 { 112 // Check null psRandom variable 113 if(r == NULL) { 114 psError(PS_ERR_UNEXPECTED_NULL, 115 true, 116 _("Random variable is NULL.")); 117 return(0); 118 } else { 119 return(gsl_rng_uniform(r->gsl)); 120 } 141 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 142 return gsl_rng_uniform(r->gsl); 121 143 } 122 144 123 145 double psRandomGaussian(const psRandom *r) 124 146 { 125 // Check null psRandom variable 126 if(r == NULL) { 127 psError(PS_ERR_UNEXPECTED_NULL, 128 true, 129 _("Random variable is NULL.")); 130 return(0); 131 } else { 132 // XXX: What should sigma be? 133 return(gsl_ran_gaussian(r->gsl, 1.0)); 134 } 147 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 148 return gsl_ran_gaussian(r->gsl, 1.0); 135 149 } 136 150 137 151 double p_psRandomGaussian(const psRandom *r, double sigma) 138 152 { 139 // Check null psRandom variable 140 if(r == NULL) { 141 psError(PS_ERR_UNEXPECTED_NULL, 142 true, 143 _("Random variable is NULL.")); 144 return(0); 145 } else { 146 return(gsl_ran_gaussian(r->gsl, sigma)); 147 } 153 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 154 return gsl_ran_gaussian(r->gsl, sigma); 148 155 } 149 156 150 157 double psRandomPoisson(const psRandom *r, double mean) 151 158 { 152 // Check null psRandom variable 153 if(r == NULL) { 154 psError(PS_ERR_UNEXPECTED_NULL, 155 true, 156 _("Random variable is NULL.")); 157 return(0); 158 } else { 159 return((psF64) gsl_ran_poisson(r->gsl, mean)); 160 } 159 PS_ASSERT_RANDOM_NON_NULL(r, NAN); 160 return gsl_ran_poisson(r->gsl, mean); 161 161 } 162 162 -
trunk/psLib/src/math/psRandom.h
r15627 r23259 29 29 #include <gsl/gsl_randist.h> 30 30 31 / ** Enumeration containing a flag for psRandom types. */31 /// Random number generator types 32 32 typedef enum { 33 33 PS_RANDOM_TAUS ///< A maximally equidistributed combined Tausworthe generator. 34 34 } psRandomType; 35 35 36 /** Data structure for psRandom. 37 * Contains information on the psRandom type and GNU Scientific Library random number generator. 38 */ 36 /// Random number generator 39 37 typedef struct { 40 38 psRandomType type; ///< The type of RNG … … 48 46 ); 49 47 50 /** Allocates a psRandom struct. 51 * 52 * @return psRandom*: A new psRandom structure. 53 */ 48 /// Set the seed to use for random number generators. 49 /// 50 /// A seed value of zero indicates that the seed is to be generated from the system. 51 /// The new seed value is returned 52 psU64 psRandomSeed(psU64 seed ///< Seed for RNG 53 ); 54 55 /// Allocate a random number generator 56 /// 57 /// The currently defined seed (via psRandomSeed) is used 54 58 psRandom *psRandomAlloc( 55 psRandomType type, ///< The type of RNG 56 unsigned long seed ///< Known value with which to seed the RNG 59 psRandomType type ///< The type of RNG 57 60 ) PS_ATTR_MALLOC; 58 61 59 /** Resets an existing psRandom struct. 60 * 61 * @return void 62 */ 63 void psRandomReset( 64 psRandom *rand, ///< Existing psRandom struct to reset 65 unsigned long seed ///< Known value with which to seed the RNG 62 /// Allocate a random number generator with a specific seed 63 /// 64 /// A seed value of zero indicates that the seed is to be generated from the system. 65 psRandom *psRandomAllocSpecific(psRandomType type, ///< The type of RNG 66 psU64 specificSeed ///< The specific seed to use 67 ); 68 69 /// Resets an existing random number generator 70 bool psRandomReset( 71 psRandom *rand ///< Random number generator to reset 66 72 ); 67 73 … … 72 78 */ 73 79 double psRandomUniform( 74 const psRandom *r ///< psRandom struct for RNG80 const psRandom *r ///< Random number generator 75 81 ); 76 82 … … 81 87 */ 82 88 double psRandomGaussian( 83 const psRandom *r ///< psRandom struct for RNG89 const psRandom *r ///< Random number generator 84 90 ); 85 91 86 /** Random number generator based on a Gaussian deviate , N(0,1).92 /** Random number generator based on a Gaussian deviate with specified standard deviation. 87 93 * Uses gsl_ran_gaussian. 88 *89 * XXX: I created this since the above psLib spec for p_psRandomGaussian90 * had no argument for sigma. Verify that with IfA.91 94 * 92 95 * @return double: Random number. 93 96 */ 94 97 double p_psRandomGaussian( 95 const psRandom *r, ///< psRandom struct for RNG98 const psRandom *r, ///< Random number generator 96 99 double sigma 97 100 ); … … 103 106 */ 104 107 double psRandomPoisson( 105 const psRandom *r, ///< psRandom struct for RNG108 const psRandom *r, ///< Random number generator 106 109 double mean ///< Mean value 107 110 ); -
trunk/psLib/test/fits/tap_psFitsImage.c
r19382 r23259 12 12 static psImage *generateImage(void) 13 13 { 14 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345); // Random number generator14 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); // Random number generator 15 15 psImage *image = psImageAlloc(NUMCOLS, NUMROWS, PS_TYPE_F32); // Generated image 16 16 for (int y = 0; y < NUMROWS; y++) { -
trunk/psLib/test/imageops/convolutionBench.c
r17320 r23259 68 68 int main(int argc, char *argv[]) 69 69 { 70 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0); // Random number generator70 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); // Random number generator 71 71 72 72 printf("#%14s%16s %8s %8s\n", "Image", "Kernel", "Direct", "FFT"); -
trunk/psLib/test/imageops/tap_psImageInterpolate2.c
r21465 r23259 77 77 psImage *variance = NULL; // generateVariance(xSize, ySize, type); 78 78 psImage *mask = NULL; // generateMask(xSize, ySize); 79 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);79 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 80 80 81 81 psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, mask, 0, NAN, NAN, -
trunk/psLib/test/math/tap_psMinimizeLMM.c
r13124 r23259 95 95 { 96 96 psMemId id = psMemGetId(); 97 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed97 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 98 98 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 99 99 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); … … 203 203 { 204 204 psMemId id = psMemGetId(); 205 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed205 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 206 206 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 207 207 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
trunk/psLib/test/math/tap_psPolyFit1D.c
r13337 r23259 109 109 psVector *xTruth = psVectorAlloc(numData, PS_TYPE_F64); 110 110 psVector *fTruth = psVectorAlloc(numData, PS_TYPE_F64); 111 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed111 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 112 112 for (int i = 0; i < numData; i++) { 113 113 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit2D.c
r17567 r23259 108 108 yTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit3D.c
r17567 r23259 108 108 zTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit4D.c
r17567 r23259 132 132 tTruth->n = numData; 133 133 fTruth->n = numData; 134 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed134 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 135 135 for (int i = 0; i < numData; i++) { 136 136 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psRandom.c
r13123 r23259 3 3 work properly. 4 4 5 ensure that psRandom structs are properly allocated by psRandomAlloc ().5 ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 47 47 plan_tests(34); 48 48 49 // ensure that psRandom structs are properly allocated by psRandomAlloc ()49 // ensure that psRandom structs are properly allocated by psRandomAllocSpecific() 50 50 { 51 51 psMemId id = psMemGetId(); 52 52 // Valid type allocation 53 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAlloc () set type properly");53 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAllocSpecific() set type properly"); 57 57 psFree(myRNG); 58 58 skip_end(); … … 63 63 { 64 64 psMemId id = psMemGetId(); 65 psRandom *myRNG = psRandomAlloc (100,SEED);66 ok(myRNG == NULL, "psRandomAlloc () refused to generate psRandom with unallowed type");65 psRandom *myRNG = psRandomAllocSpecific(100,SEED); 66 ok(myRNG == NULL, "psRandomAllocSpecific() refused to generate psRandom with unallowed type"); 67 67 psFree(myRNG); 68 68 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 72 72 { 73 73 psMemId id = psMemGetId(); 74 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);75 ok(myRNG != NULL, "psRandomAlloc () allows negative seed");74 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 75 ok(myRNG != NULL, "psRandomAllocSpecific() allows negative seed"); 76 76 psFree(myRNG); 77 77 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 85 85 rans->n = rans->nalloc; 86 86 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 87 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");87 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 90 90 91 91 // Initialize vector data with random number … … 125 125 rans->n = rans->nalloc; 126 126 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 127 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");127 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 130 130 131 131 // Initialize vector with random data … … 167 167 rans->n = rans->nalloc; 168 168 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 169 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");169 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 172 172 173 173 // Initialize vector with random data … … 210 210 rans02->n = rans02->nalloc; 211 211 212 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");212 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 215 215 216 216 … … 252 252 if (0) { 253 253 psRandom *myRNG1 = NULL; 254 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);254 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 255 255 // psLogSetDestination("dest:stderr"); 256 256 psLogSetDestination(0); … … 275 275 rans02->n = rans02->nalloc; 276 276 277 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");277 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 280 280 281 281 … … 325 325 rans02->n = rans02->nalloc; 326 326 327 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");327 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 330 330 331 331 // Initialize vectors with random data -
trunk/psLib/test/math/tap_psStats07.c
r12247 r23259 58 58 PS_ASSERT_INT_NONNEGATIVE(Npts, NULL); 59 59 60 // psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, p_psRandomGetSystemSeed());61 psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);60 // psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, p_psRandomGetSystemSeed()); 61 psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED); 62 62 psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32); 63 63 for (unsigned int i = 0; i < Npts; i++) { -
trunk/psLib/test/math/tap_psStats09.c
r12783 r23259 52 52 srand(SEED); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 for (long i = 0; i < numData; i++) { -
trunk/psLib/test/math/tap_psStatsTiming.c
r12513 r23259 20 20 21 21 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) for tests 22 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);22 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 23 23 psVector *rnd = psVectorAlloc (1000, PS_TYPE_F32); 24 24 for (int i = 0; i < rnd->n; i++) { -
trunk/psLib/test/math/tst_psMinimizeLMM.c
r11686 r23259 66 66 psBool testStatus = true; 67 67 68 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed68 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 69 69 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 70 70 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
trunk/psLib/test/math/tst_psPolyFit1D.c
r11686 r23259 101 101 xTruth->n = numData; 102 102 fTruth->n = numData; 103 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed103 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 104 104 for (int i = 0; i < numData; i++) { 105 105 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit2D.c
r11686 r23259 100 100 yTruth->n = numData; 101 101 fTruth->n = numData; 102 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed102 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 103 103 for (int i = 0; i < numData; i++) { 104 104 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit3D.c
r11686 r23259 103 103 zTruth->n = numData; 104 104 fTruth->n = numData; 105 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed105 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 106 106 for (int i = 0; i < numData; i++) { 107 107 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit4D.c
r11686 r23259 124 124 tTruth->n = numData; 125 125 fTruth->n = numData; 126 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed126 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 127 127 for (int i = 0; i < numData; i++) { 128 128 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psRandom.c
r6484 r23259 3 3 work properly. 4 4 5 t00(): ensure that psRandom structs are properly allocated by psRandomAlloc ().5 t00(): ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 t01(): ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 45 45 46 46 testDescription tests[] = { 47 {testRandomAlloc,000,"psRandomAlloc ",0,false},47 {testRandomAlloc,000,"psRandomAllocSpecific",0,false}, 48 48 {testRandomUniform,000,"psRandomUniform",0,false}, 49 49 {testRandomGaussian,000,"psRandomGaussian",0,false}, … … 70 70 71 71 // Valid type allocation 72 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);72 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 73 73 if (myRNG == NULL) { 74 74 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 85 85 // psLogSetDestination("file:seed_msglog1.txt"); 86 86 psLogSetDestination(fd1); 87 myRNG = psRandomAlloc (PS_RANDOM_TAUS, 0);87 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 88 88 // psLogSetDestination("dest:stderr"); 89 89 psLogSetDestination(2); … … 100 100 // Invalid type allocation 101 101 psLogMsg(__func__,PS_LOG_INFO,"Invalid type, should generate error message"); 102 myRNG = psRandomAlloc (100,SEED);102 myRNG = psRandomAllocSpecific(100,SEED); 103 103 if (myRNG != NULL) { 104 104 psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid type"); … … 107 107 108 108 // Negative seed value 109 myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);109 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 110 110 if(myRNG == NULL) { 111 111 psError(PS_ERR_UNKNOWN,true,"Did not return allocated psRandom"); … … 125 125 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 126 126 127 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);127 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 128 if (myRNG == NULL) { 129 129 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 171 171 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 172 172 173 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);173 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 174 174 if (myRNG == NULL) { 175 175 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 219 219 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 220 220 221 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);221 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 222 222 if (myRNG == NULL) { 223 223 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 268 268 rans02->n = rans02->nalloc; 269 269 270 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);270 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 271 271 if (myRNG == NULL) { 272 272 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 302 302 303 303 psRandom *myRNG1 = NULL; 304 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);304 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 305 305 // psLogSetDestination("dest:stderr"); 306 306 psLogSetDestination(0); … … 326 326 rans02->n = rans02->nalloc; 327 327 328 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 329 329 if (myRNG == NULL) { 330 330 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 372 372 rans02->n = rans02->nalloc; 373 373 374 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);374 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 375 375 if (myRNG == NULL) { 376 376 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); -
trunk/psLib/test/math/tst_psStats09.c
r11686 r23259 52 52 printPositiveTestHeader(stdout, "psMathUtils functions", "psVectorStats Clipped Stats Routine"); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 truth->n = numData; -
trunk/psLib/test/mathtypes/tap_psVectorSelect.c
r18333 r23259 17 17 psVector *vector = psVectorAlloc(size, PS_TYPE_F32); 18 18 psVectorInit(vector, 0.0); 19 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);19 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 20 20 for (long i = 0; i < numNonzero; i++) { 21 21 long index = psRandomUniform(rng) * size; … … 52 52 psVector *vector = psVectorAlloc(size, PS_TYPE_F32); 53 53 psVectorInit(vector, 0.0); 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345);54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); 55 55 for (long i = 0; i < numNonzero; i++) { 56 56 long index = psRandomUniform(rng) * size; -
trunk/psLib/test/types/tap_psTree.c
r18145 r23259 16 16 psVector *y = psVectorAlloc(NUM, PS_TYPE_F64); 17 17 18 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);18 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 19 19 for (int i = 0; i < NUM; i++) { 20 20 x->data.F64[i] = 2.0 * psRandomUniform(rng) - 1.0; -
trunk/psModules/src/camera/pmFPAMaskWeight.c
r21363 r23259 331 331 332 332 if (!psMemIncrRefCounter(rng)) { 333 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);333 rng = psRandomAlloc(PS_RANDOM_TAUS); 334 334 } 335 335 … … 371 371 372 372 if (!psMemIncrRefCounter(rng)) { 373 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);373 rng = psRandomAlloc(PS_RANDOM_TAUS); 374 374 } 375 375 … … 532 532 533 533 if (!psMemIncrRefCounter(rng)) { 534 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);534 rng = psRandomAlloc(PS_RANDOM_TAUS); 535 535 } 536 536 -
trunk/psModules/src/camera/pmFPA_JPEG.c
r21183 r23259 154 154 155 155 // measure the image statistics for scaling 156 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);156 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 157 157 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 158 158 stats->nSubsample = 10000; -
trunk/psModules/src/config/pmConfig.c
r23215 r23259 13 13 14 14 #include <stdio.h> 15 #include <stdlib.h> 15 16 #include <string.h> 16 17 #include <strings.h> /* for strn?casecmp */ … … 24 25 #include <pslib.h> 25 26 26 #include "pmConfig.h"27 27 #include "pmErrorCodes.h" 28 28 #include "pmFPALevel.h" 29 29 #include "pmConfigRecipes.h" 30 30 #include "pmConfigCamera.h" 31 #include "pmConfigRun.h" 32 33 #include "pmConfig.h" 31 34 32 35 #ifdef HAVE_NEBCLIENT … … 432 435 // variable will contain the name of the configuration file. 433 436 434 char *configFile = NULL; 435 // 437 char *configFile = NULL; // Name of configuration file 438 436 439 // First, try command line 437 //438 440 psS32 argNum = psArgumentGet(*argc, argv, "-ipprc"); 439 441 if (argNum != 0) { … … 447 449 } 448 450 } 449 // 451 450 452 // Next, try environment variable 451 //452 453 if (!configFile) { 453 454 configFile = getenv(IPPRC_ENV); 454 455 if (configFile) { 455 configFile = psStringCopy (configFile); 456 } 457 } 458 459 // 456 configFile = psStringCopy(configFile); 457 } 458 } 459 460 460 // Last chance is ~/.ipprc 461 //462 461 if (!configFile) { 463 462 char *home = getenv("HOME"); … … 466 465 } 467 466 468 // We have the configuration filename; now we read and parse the config 469 // file and store in psMetadata struct user. 467 // Read and parse the config file and store in struct user. 470 468 // XXX move this section to pmConfigReadUser.c ? 471 472 469 if (!pmConfigFileRead(&config->user, configFile, "user")) { 473 470 psFree(config); … … 477 474 psFree(configFile); 478 475 479 // XXX why was this being called here? Is someone calling pmConfigRead multiple times? 480 // pmConfigDone(); 481 assert (configPath == NULL); 476 pmConfigRunCommand(config, *argc, argv); 482 477 483 478 // define the config-file search path (configPath). 479 psAssert(configPath == NULL, "Configuration path is already defined."); 484 480 psString path = psMetadataLookupStr(NULL, config->user, "PATH"); 485 pmConfigSet (path);481 pmConfigSet(path); 486 482 487 483 // read the SITE file … … 525 521 psLogSetLevel(logLevel); 526 522 } 527 528 523 529 524 // Set logging format … … 646 641 psTimeInit(timeName); 647 642 } 643 } 644 645 // Set the random number generator seed 646 { 647 psU64 seed = 0; // RNG seed 648 int argNum = psArgumentGet(*argc, argv, "-seed"); // Argument number 649 if (argNum > 0) { 650 psArgumentRemove(argNum, argc, argv); 651 if (argNum >= *argc) { 652 psWarning("-seed command-line switch provided without the required seed value --- ignored."); 653 } else { 654 char *end = NULL; // Pointer to end of consumed string 655 seed = strtoll(argv[argNum], &end, 0); 656 if (strlen(end) > 0) { 657 psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]); 658 psFree(config); 659 return NULL; 660 } 661 psArgumentRemove(argNum, argc, argv); 662 } 663 } 664 pmConfigRunSeed(config, seed); 648 665 } 649 666 -
trunk/psModules/src/config/pmConfigCamera.c
r22700 r23259 213 213 psStringAppend(&newName, "_%s-SKYCELL", name); 214 214 if (psMetadataLookup(oldCameras, newName)) { 215 psFree(newName); 215 216 return true; 216 217 } … … 469 470 psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA"); 470 471 if (psMetadataLookup(oldCameras, newName)) { 472 psFree(newName); 471 473 return true; 472 474 } -
trunk/psModules/src/config/pmConfigRecipes.h
r12916 r23259 1 1 /* @file pmConfigRecipes.h 2 2 * @brief Configuration Recipe functions 3 * 3 * 4 4 * @author ?, MHPCC 5 5 * @author Paul Price, IfA 6 6 * @author Eugene Magnier, IfA 7 * 7 * 8 8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 9 * @date $Date: 2007-04-19 02:10:12 $ … … 13 13 #ifndef PM_CONFIG_RECIPES_H 14 14 #define PM_CONFIG_RECIPES_H 15 16 #include <pmConfig.h> 15 17 16 18 /// @addtogroup Config Configuration System … … 26 28 27 29 28 bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config);29 bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag);30 psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe);30 bool pmConfigLoadRecipeArguments(int *argc, char **argv, pmConfig *config); 31 bool pmConfigLoadRecipeOptions(int *argc, char **argv, pmConfig *config, char *flag); 32 psMetadata *pmConfigRecipeOptions(pmConfig *config, char *recipe); 31 33 32 34 /// @} -
trunk/psModules/src/config/pmConfigRun.c
r23244 r23259 72 72 73 73 74 bool pmConfigRunCommand(pmConfig *config, int argc, c onst char **argv)74 bool pmConfigRunCommand(pmConfig *config, int argc, char **argv) 75 75 { 76 76 PS_ASSERT_PTR_NON_NULL(config, false); … … 81 81 psString command = NULL; 82 82 for (int i = 0; i < argc; i++) { 83 psStringAppend(&command, "%s ", argv[i]);83 psStringAppend(&command, "%s ", argv[i]); 84 84 } 85 85 … … 89 89 return true; 90 90 } 91 92 93 bool pmConfigRunSeed(pmConfig *config, psU64 seed) 94 { 95 PS_ASSERT_PTR_NON_NULL(config, false); 96 97 psMetadata *run = configRun(config);// Run-time information 98 psAssert(run, "Require run-time information"); 99 100 if (!seed) { 101 bool mdok; // Status of MD lookup 102 seed = psMetadataLookupU64(&mdok, run, "SEED"); 103 } 104 if (!seed) { 105 bool mdok; // Status of MD lookup 106 seed = psMetadataLookupU64(&mdok, config->user, "SEED"); 107 } 108 109 // seed may still be zero by this point 110 seed = psRandomSeed(seed); 111 return psMetadataAddU64(run, PS_LIST_TAIL, "SEED", PS_META_REPLACE, "Random number generator seed", seed); 112 } 113 -
trunk/psModules/src/config/pmConfigRun.h
r23243 r23259 4 4 #include <pslib.h> 5 5 #include <pmConfig.h> 6 #include <pmFPAfile.h> 6 7 7 8 /// Add a file to the list of files used in the run-time information … … 12 13 13 14 /// Add the command line to the run-time information 14 bool pmConfigRunCommand(pmConfig *config, ///< Configuration 15 int argc, const char **argv ///< Command line arguments 15 bool pmConfigRunCommand( 16 pmConfig *config, ///< Configuration 17 int argc, char **argv ///< Command line arguments 18 ); 19 20 /// Record the random number generator seed in the run-time information 21 bool pmConfigRunSeed( 22 pmConfig *config, ///< Configuration 23 psU64 seed ///< RNG seed 16 24 ); 17 25 -
trunk/psModules/src/detrend/pmFringeStats.c
r21183 r23259 65 65 rng = psMemIncrRefCounter(random); 66 66 } else { 67 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);67 rng = psRandomAlloc(PS_RANDOM_TAUS); 68 68 } 69 69 -
trunk/psModules/src/detrend/pmRemnance.c
r21183 r23259 28 28 int numCols = image->numCols, numRows = image->numRows; // Size of image 29 29 30 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator30 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 31 31 32 32 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics -
trunk/psModules/src/detrend/pmShutterCorrection.c
r21457 r23259 911 911 psStats *stats = psStatsAlloc(meanStat | stdevStat); // Statistics to apply 912 912 if (!rng) { 913 rng = psRandomAlloc(PS_RANDOM_TAUS , 0);913 rng = psRandomAlloc(PS_RANDOM_TAUS); 914 914 } else { 915 915 psMemIncrRefCounter(rng); -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r21422 r23259 214 214 int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Image dimensions 215 215 216 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator216 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 217 217 218 218 memCheck("start"); -
trunk/psModules/test/detrend/tap_pmMaskBadPixels.c
r15160 r23259 282 282 pmCell *cell = generateSimpleCell(NULL); 283 283 pmReadout *in = generateSimpleReadout(cell); 284 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);284 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 285 285 286 286 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with NULL input pmReadout"); … … 301 301 psFree(in->image); 302 302 in->image = NULL; 303 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);303 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 304 304 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with NULL input pmReadout->image"); 305 305 psFree(rng); … … 319 319 psFree(in->image); 320 320 in->image = psImageAlloc(0, 0, PS_TYPE_F32); 321 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);321 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 322 322 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with empty input pmReadout->image"); 323 323 psFree(rng); … … 337 337 psFree(in->image); 338 338 in->image = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_S32); 339 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);339 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 340 340 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for pmReadout->image"); 341 341 psFree(rng); … … 355 355 psFree(in->mask); 356 356 in->mask = psImageAlloc(0, 0, PS_TYPE_MASK); 357 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);357 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 358 358 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for pmReadout->image"); 359 359 psFree(rng); … … 373 373 psFree(in->mask); 374 374 in->mask = psImageAlloc(TEST_NUM_COLS/2, TEST_NUM_ROWS/2, PS_TYPE_MASK); 375 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);375 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 376 376 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with bad size for in->mask"); 377 377 psFree(rng); … … 391 391 psFree(in->mask); 392 392 in->mask = psImageAlloc(TEST_NUM_COLS, TEST_NUM_ROWS, PS_TYPE_S32); 393 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);393 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 394 394 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with bad type for in->mask"); 395 395 psFree(rng); … … 407 407 pmCell *cell = generateSimpleCell(NULL); 408 408 pmReadout *in = generateSimpleReadout(cell); 409 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);409 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 410 410 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with empty out image"); 411 411 psFree(rng); … … 423 423 pmCell *cell = generateSimpleCell(NULL); 424 424 pmReadout *in = generateSimpleReadout(cell); 425 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);425 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 426 426 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect type for out image"); 427 427 psFree(rng); … … 439 439 pmCell *cell = generateSimpleCell(NULL); 440 440 pmReadout *in = generateSimpleReadout(cell); 441 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);441 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 442 442 ok(!pmMaskFlagSuspectPixels(out, NULL, 1.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with incorrect size for out image"); 443 443 psFree(rng); … … 455 455 pmCell *cell = generateSimpleCell(NULL); 456 456 pmReadout *in = generateSimpleReadout(cell); 457 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);457 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 458 458 459 459 ok(!pmMaskFlagSuspectPixels(out, in, 0.0, 1, 1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with rej input <= 0.0"); … … 472 472 pmCell *cell = generateSimpleCell(NULL); 473 473 pmReadout *in = generateSimpleReadout(cell); 474 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 0);474 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 475 475 476 476 ok(!pmMaskFlagSuspectPixels(out, in, 1.0, 1, -1.0, rng), "pmMaskFlagSuspectPixels() returned NULL with frac input < 0.0"); -
trunk/psModules/test/imcombine/tap_pmImageCombine.c
r11118 r23259 9 9 psArray *generate_images(void) 10 10 { 11 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 12345); // Random Number Generator11 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 12345); // Random Number Generator 12 12 13 13 // Generate images -
trunk/psModules/test/objects/tap_pmFringe.c
r15726 r23259 89 89 ok(fringe != NULL, "pmFringeRegionsAlloc() returned non-NULL"); 90 90 psImage *img = psImageAlloc(NUM_COLS, NUM_ROWS, PS_TYPE_F32); 91 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 10);91 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 10); 92 92 fringe->x = psVectorAlloc(NUM_FRINGE_PNTS/2, PS_TYPE_F32); 93 93 fringe->y = psVectorAlloc(NUM_FRINGE_PNTS/2, PS_TYPE_F32); -
trunk/psModules/test/objects/tap_pmSourceFitModel.c
r14654 r23259 27 27 28 28 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 29 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);29 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 30 30 31 31 static float radius[] = {3.0, 5.0, 7.0, 10.0, 15.0, 25.0}; -
trunk/psModules/test/objects/tap_pmSourceFitModel_Delta.c
r14654 r23259 23 23 24 24 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 25 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);25 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 26 26 27 27 // noise vector to noise up the image … … 167 167 168 168 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) 169 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);169 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 170 170 171 171 static float radius[] = {3.0, 5.0, 7.0, 10.0, 15.0, 25.0}; -
trunk/psphot/src/psphotModelBackground.c
r21183 r23259 49 49 assert (maskVal); 50 50 51 // user supplied seed, if available 52 unsigned long seed = psMetadataLookupS32 (&status, recipe, "IMSTATS_SEED"); 53 if (!status) { 54 seed = 0; 55 } 56 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 51 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 57 52 58 53 // subtract this amount extra from the sky -
trunk/psphot/src/psphotVisual.c
r23242 r23259 32 32 33 33 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 34 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);34 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 35 35 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 36 36 fprintf (stderr, "failed to get background values\n"); … … 78 78 79 79 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 80 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);80 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 81 81 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 82 82 fprintf (stderr, "failed to get background values\n"); -
trunk/pstest/src/tst_psPolynomial.c
r5873 r23259 289 289 fillVectors(x, f, NORD, NPTS, type[k]); 290 290 psTime *now = psTimeGetNow(PS_TIME_UTC); 291 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);291 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 292 292 for (int i = 0; i < NPTS; i++) { 293 293 double errgen = psRandomGaussian(r); … … 361 361 // add random errors to the vector 362 362 psTime *now = psTimeGetNow(PS_TIME_UTC); 363 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);363 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 364 364 for (int i = 0; i < NPTS; i++) { 365 365 double errgen = psRandomGaussian(r); … … 464 464 fillVectors(x, f, NORD, NPTS, type[k]); 465 465 psTime *now = psTimeGetNow(PS_TIME_UTC); 466 const psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, now->sec);466 const psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, now->sec); 467 467 for (int i = 0; i < NPTS; i++) { 468 468 double errgen = psRandomGaussian(r);
Note:
See TracChangeset
for help on using the changeset viewer.
