- Timestamp:
- Aug 13, 2009, 4:08:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches/ppSim/src/ppSimSequenceObject.c
r24099 r25069 1 1 # include "ppSimSequence.h" 2 2 3 bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand ) {3 bool ppSimSequenceObject (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; … … 25 25 26 26 if (filters->n != exptimes->n) { 27 psLogMsg ("ppSimSequence", PS_LOG_WARN, "mis-match in filter and exptime lists");28 exit (1);27 psLogMsg ("ppSimSequence", PS_LOG_WARN, "mis-match in filter and exptime lists"); 28 exit (1); 29 29 } 30 30 … … 34 34 // loop over the filters & exposure times 35 35 for (int i = 0; i < filters->n; i++) { 36 37 // offset parameters38 float dR = psMetadataLookupF32 (&status, sequence, "OFFSET.RA");39 float dD = psMetadataLookupF32 (&status, sequence, "OFFSET.DEC");40 41 int nR = psMetadataLookupS32 (&status, sequence, "OFFSET.NR");42 int nD = psMetadataLookupS32 (&status, sequence, "OFFSET.ND");43 44 // loop over the offset sequence45 for (int iR = 0; iR < nR; iR++) {46 for (int iD = 0; iD < nD; iD++) {36 37 // offset parameters 38 float dR = psMetadataLookupF32 (&status, sequence, "OFFSET.RA"); 39 float dD = psMetadataLookupF32 (&status, sequence, "OFFSET.DEC"); 40 41 int nR = psMetadataLookupS32 (&status, sequence, "OFFSET.NR"); 42 int nD = psMetadataLookupS32 (&status, sequence, "OFFSET.ND"); 43 44 // loop over the offset sequence 45 for (int iR = 0; iR < nR; iR++) { 46 for (int iD = 0; iD < nD; iD++) { 47 47 48 // RA & DEC in degrees XXX (should be radians...)49 // offsets are in arcseconds50 float R = Ro + dR*(iR - 0.5*nR + 0.5) / cos (RAD_DEG*Do) / 3600.0;51 float D = Do + dD*(iD - 0.5*nD + 0.5) / 3600.0;52 53 // dither parameters54 float dr = psMetadataLookupF32 (&status, sequence, "DITHER.RA");55 float dd = psMetadataLookupF32 (&status, sequence, "DITHER.DEC");56 57 int nr = psMetadataLookupS32 (&status, sequence, "DITHER.NR");58 int nd = psMetadataLookupS32 (&status, sequence, "DITHER.ND");59 60 // loop over the dither sequence61 for (int ir = 0; ir < nr; ir++) {62 for (int id = 0; id < nd; id++) {48 // RA & DEC in degrees XXX (should be radians...) 49 // offsets are in arcseconds 50 float R = Ro + dR*(iR - 0.5*nR + 0.5) / cos (RAD_DEG*Do) / 3600.0; 51 float D = Do + dD*(iD - 0.5*nD + 0.5) / 3600.0; 52 53 // dither parameters 54 float dr = psMetadataLookupF32 (&status, sequence, "DITHER.RA"); 55 float dd = psMetadataLookupF32 (&status, sequence, "DITHER.DEC"); 56 57 int nr = psMetadataLookupS32 (&status, sequence, "DITHER.NR"); 58 int nd = psMetadataLookupS32 (&status, sequence, "DITHER.ND"); 59 60 // loop over the dither sequence 61 for (int ir = 0; ir < nr; ir++) { 62 for (int id = 0; id < nd; id++) { 63 63 64 // ra, dec in degrees; offsets in arcsec65 float ra = R + dr*(ir - 0.5*nr + 0.5) / cos (RAD_DEG*D) / 3600.0;66 float dec = D + dd*(id - 0.5*nd + 0.5) / 3600.0;67 68 // rotation sequence parameters69 float pos_min = psMetadataLookupF32 (&status, sequence, "POS_MIN");70 float pos_max = psMetadataLookupF32 (&status, sequence, "POS_MAX");71 float pos_delta = psMetadataLookupF32 (&status, sequence, "POS_DELTA");72 assert (pos_delta > 0.0);73 assert (pos_max >= pos_min);74 75 // loop over rotation sequence76 for (float pos = pos_min; pos <= pos_max; pos += pos_delta) {77 78 // define the output filename79 psString filename = NULL;80 if (path) {81 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);82 } else {83 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);84 }64 // ra, dec in degrees; offsets in arcsec 65 float ra = R + dr*(ir - 0.5*nr + 0.5) / cos (RAD_DEG*D) / 3600.0; 66 float dec = D + dd*(id - 0.5*nd + 0.5) / 3600.0; 67 68 // rotation sequence parameters 69 float pos_min = psMetadataLookupF32 (&status, sequence, "POS_MIN"); 70 float pos_max = psMetadataLookupF32 (&status, sequence, "POS_MAX"); 71 float pos_delta = psMetadataLookupF32 (&status, sequence, "POS_DELTA"); 72 assert (pos_delta > 0.0); 73 assert (pos_max >= pos_min); 74 75 // loop over rotation sequence 76 for (float pos = pos_min; pos <= pos_max; pos += pos_delta) { 77 78 // define the output filename 79 psString filename = NULL; 80 if (path) { 81 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage); 82 } else { 83 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage); 84 } 85 85 86 // define the ppSim command87 psString command = NULL;86 // define the ppSim command 87 psString command = NULL; 88 88 89 psStringAppend (&command, "%s -type OBJECT", ppSimCommand);90 psStringAppend (&command, " -filter %s", (char *) filters->data[i]);91 psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);92 psStringAppend (&command, " -skymags %f", skymags->data.F32[i]);89 psStringAppend (&command, "%s -type OBJECT", ppSimCommand); 90 psStringAppend (&command, " -filter %s", (char *) filters->data[i]); 91 psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]); 92 psStringAppend (&command, " -skymags %f", skymags->data.F32[i]); 93 93 94 psStringAppend (&command, " -ra %f", ra);95 psStringAppend (&command, " -dec %f", dec);96 psStringAppend (&command, " -pa %f", pos);97 psStringAppend (&command, " -obs_mode OBJECT.%s", (char *) filters->data[i]);94 psStringAppend (&command, " -ra %f", ra); 95 psStringAppend (&command, " -dec %f", dec); 96 psStringAppend (&command, " -pa %f", pos); 97 psStringAppend (&command, " -obs_mode OBJECT.%s", (char *) filters->data[i]); 98 98 99 double frnd = psRandomUniform(rng);100 float seeing = IQmin + (IQmax - IQmin)*frnd;101 102 psStringAppend (&command, " -seeing %f", seeing);99 double frnd = psRandomUniform(rng); 100 float seeing = IQmin + (IQmax - IQmin)*frnd; 101 102 psStringAppend (&command, " -seeing %f", seeing); 103 103 104 psStringAppend (&command, " %s", filename);104 psStringAppend (&command, " %s", filename); 105 105 106 fprintf (simfile, "%s\n", command); 107 psFree (command); 108 109 // define the inject command 110 // path should be dirname/filename 111 command = psStringCopy (injectCommand); 112 psStringAppend (&command, " %s*.fits", filename); 113 fprintf (inject, "%s\n", command); 114 psFree (command); 115 psFree (filename); 106 fprintf (simfile, "%s\n", command); 107 psFree (command); 108 109 // define the inject command 110 // path should be dirname/filename 111 // for SIMTEST camera nebulous insertion append .fits 112 // SIMMOSAIC nebulous insertions are appended with ChipXX.fits 113 // non-nebulous insertions use *.fits 114 const char *neb = "neb"; 116 115 117 nImage ++; 118 } 119 } 120 } 116 if (strncmp (path, neb, 3) == 0) { 117 118 if (strcmp (camera, "SIMTEST") == 0) { 119 command = psStringCopy (injectCommand); 120 psStringAppend (&command, " %s.fits", filename); 121 fprintf (inject, "%s\n", command); 122 123 } else if (strcmp (camera, "SIMMOSAIC") == 0) { 124 for (int i = 0; i < 2; i++) { 125 for (int j = 0; j < 2; j++) { 126 command = psStringCopy (injectCommand); 127 psStringAppend (&command, " %s.Chip%d%d.fits", filename, i, j); 128 fprintf (inject, "%s\n", command); 129 command = NULL; 130 } 131 } 132 133 } else { 134 psLogMsg ("ppSimSequence", PS_LOG_WARN, "unsupported camera type for nebulous insertion"); 135 exit (1); 136 137 } 138 139 } else { 140 command = psStringCopy (injectCommand); 141 psStringAppend (&command, " %s*.fits", filename); 142 fprintf (inject, "%s\n", command); 143 } 144 145 psFree (command); 146 psFree (filename); 147 nImage ++; 148 } 149 } 150 } 151 } 121 152 } 122 }123 153 } 124 154 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
