- Timestamp:
- Aug 13, 2009, 4:08:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches/ppSim/src/ppSimSequenceDark.c
r19315 r25069 1 1 # include "ppSimSequence.h" 2 2 3 bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand ) {3 bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand, const char *camera) { 4 4 5 5 bool status, setRate; … … 9 9 min = psMetadataLookupF32 (&status, sequence, "DARK.MIN"); 10 10 if (status) { 11 max = psMetadataLookupF32 (&status, sequence, "DARK.MAX");12 setRate = true;11 max = psMetadataLookupF32 (&status, sequence, "DARK.MAX"); 12 setRate = true; 13 13 } 14 14 … … 22 22 for (int i = 0; i < nImages->n; i++) { 23 23 24 float exptime = exptimes->data.F32[i];25 float n = nImages->data.S32[i];24 float exptime = exptimes->data.F32[i]; 25 float n = nImages->data.S32[i]; 26 26 27 for (int j = 0; j < n; j++) {27 for (int j = 0; j < n; j++) { 28 28 29 // XXX need to add output filename30 psString filename = NULL;31 if (path) {32 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);33 } else {34 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);35 }29 // XXX need to add output filename 30 psString filename = NULL; 31 if (path) { 32 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage); 33 } else { 34 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage); 35 } 36 36 37 // define the ppSim command38 psString command = NULL;37 // define the ppSim command 38 psString command = NULL; 39 39 40 psStringAppend (&command, "%s -type DARK", ppSimCommand);41 42 if (setRate) {43 double frnd = psRandomUniform(rng);44 float rate = min + (max - min)*frnd;45 psStringAppend (&command, " -darkrate %f", rate);46 }40 psStringAppend (&command, "%s -type DARK", ppSimCommand); 41 42 if (setRate) { 43 double frnd = psRandomUniform(rng); 44 float rate = min + (max - min)*frnd; 45 psStringAppend (&command, " -darkrate %f", rate); 46 } 47 47 48 psStringAppend (&command, " -exptime %f", exptime);48 psStringAppend (&command, " -exptime %f", exptime); 49 49 50 psStringAppend (&command, " %s", filename);50 psStringAppend (&command, " %s", filename); 51 51 52 fprintf (simfile, "%s\n", command); 53 psFree (command); 54 55 // define the inject command 56 // path should be dirname/filename 57 command = psStringCopy (injectCommand); 58 psStringAppend (&command, " %s*.fits", filename); 59 fprintf (inject, "%s\n", command); 60 psFree (command); 61 psFree (filename); 52 fprintf (simfile, "%s\n", command); 53 psFree (command); 54 55 // define the inject command 56 // path should be dirname/filename 57 // for SIMTEST camera nebulous insertion append .fits 58 // SIMMOSAIC nebulous insertions are appended with ChipXX.fits 59 // non-nebulous insertions use *.fits 60 const char *neb = "neb"; 62 61 63 nImage ++; 64 } 62 if (strncmp (path, neb, 3) == 0) { 63 64 if (strcmp (camera, "SIMTEST") == 0) { 65 command = psStringCopy (injectCommand); 66 psStringAppend (&command, " %s.fits", filename); 67 fprintf (inject, "%s\n", command); 68 69 } else if (strcmp (camera, "SIMMOSAIC") == 0) { 70 for (int i = 0; i < 2; i++) { 71 for (int j = 0; j < 2; j++) { 72 command = psStringCopy (injectCommand); 73 psStringAppend (&command, " %s.Chip%d%d.fits", filename, i, j); 74 fprintf (inject, "%s\n", command); 75 command = NULL; 76 } 77 } 78 79 } else { 80 psLogMsg ("ppSimSequence", PS_LOG_WARN, "unsupported camera type for nebulous insertion"); 81 exit (1); 82 } 83 84 } else { 85 command = psStringCopy (injectCommand); 86 psStringAppend (&command, " %s*.fits", filename); 87 fprintf (inject, "%s\n", command); 88 } 89 90 psFree (command); 91 psFree (filename); 92 nImage ++; 93 } 65 94 } 66 95 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
