Changeset 12917
- Timestamp:
- Apr 18, 2007, 4:11:34 PM (19 years ago)
- Location:
- trunk/ppSim
- Files:
-
- 4 edited
-
configure.ac (modified) (1 diff)
-
src/Makefile.am (modified) (1 diff)
-
src/ppSimArguments.c (modified) (3 diffs)
-
src/ppSimLoop.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/configure.ac
r12833 r12917 19 19 PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0]) 20 20 PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0]) 21 PKG_CHECK_MODULES([PSASTRO], [psastro >= 0.9.0]) 21 22 22 23 IPP_STDOPTS -
trunk/ppSim/src/Makefile.am
r12833 r12917 1 1 bin_PROGRAMS = ppSim 2 2 3 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $( ppSim_CFLAGS)4 ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 3 ppSim_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) $(ppSim_CFLAGS) 4 ppSim_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSASTRO_LIBS) 5 5 ppSim_SOURCES = \ 6 6 ppSim.c \ -
trunk/ppSim/src/ppSimArguments.c
r12873 r12917 170 170 config->argv[1]); 171 171 172 173 // Values common for stars 174 float scale = psMetadataLookupF32(NULL, arguments, "-scale"); // Plate scale 175 float zp = psMetadataLookupF32(NULL, arguments, "-zp"); // Zero point 176 float seeing = psMetadataLookupF32(NULL, arguments, "-seeing"); // Zero point 177 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SCALE", 0, "Plate scale (arcsec/pix)", scale); 178 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp); 179 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SEEING", 0, "Seeing simga (pix)", 180 seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 181 182 const char *starName = psMetadataLookupStr(NULL, arguments, "-stars"); // Name of file with stars 183 if (starName) { 172 if (type == PPSIM_TYPE_OBJECT) { 173 // Load values required for adding stars 174 float scale = psMetadataLookupF32(NULL, arguments, "-scale"); // Plate scale 175 float zp = psMetadataLookupF32(NULL, arguments, "-zp"); // Zero point 176 float seeing = psMetadataLookupF32(NULL, arguments, "-seeing"); // Zero point 184 177 float ra0 = psMetadataLookupF32(NULL, arguments, "-ra"); // Right Ascension of boresight 185 178 float dec0 = psMetadataLookupF32(NULL, arguments, "-dec"); // Declination of boresight … … 188 181 if (isnan(ra0) || isnan(dec0) || isnan(pa) || isnan(scale) || isnan(zp) || isnan(seeing)) { 189 182 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 190 "-ra, -dec, -pa -scale, -zp, -seeing must be specified with -stars");183 "-ra, -dec, -pa, -scale, -zp, -seeing must be specified for OBJECT type"); 191 184 usage(arguments, config); 192 185 } 186 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SCALE", 0, "Plate scale (arcsec/pix)", scale); 187 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp); 188 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SEEING", 0, "Seeing simga (pix)", 189 seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 193 190 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "RA", 0, "Boresight RA (radians)", 194 191 ra0 * M_PI / 180.0); … … 197 194 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)", 198 195 pa * M_PI / 180.0); 199 200 psArray *raDecMag = psVectorsReadFromFile(starName, "%f %f %f"); // Vectors for RA Dec Mag 201 if (!raDecMag || raDecMag->n != 3) { 202 psError(PS_ERR_IO, false, "Unable to read RA Dec Mag from %s", starName); 203 psFree(raDecMag); 204 psFree(arguments); 205 psFree(config); 206 exit(PS_EXIT_CONFIG_ERROR); 207 } 208 209 psVector *ra = raDecMag->data[0]; // Star RAs 210 psVector *dec = raDecMag->data[1]; // Star Declinations 211 psVector *mag = raDecMag->data[2]; // Star magnitudes 212 for (long i = 0; i < ra->n; i++) { 213 ra->data.F32[i] *= M_PI / 180.0; 214 dec->data.F32[i] *= M_PI / 180.0; 215 } 216 217 psMetadataAddVector(config->arguments, PS_LIST_TAIL, "CATALOG.RA", 0, "Star RAs (radians)", ra); 218 psMetadataAddVector(config->arguments, PS_LIST_TAIL, "CATALOG.DEC", 0, "Star Decs (radians)", dec); 219 psMetadataAddVector(config->arguments, PS_LIST_TAIL, "CATALOG.MAG", 0, "Star magnitudes", mag); 220 psFree(raDecMag); 221 } 222 223 if (psMetadataLookupF32(NULL, config->arguments, "STARS.DENSITY") > 0 && 224 (isnan(scale) || isnan(zp) || isnan(seeing))) { 225 psWarning("-scale, -zp, -seeing must be specified if fake stars are to be generated --- turned off."); 226 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "STASR.NUM", PS_META_REPLACE, 227 "Fake stars turned off", 0); 228 } 229 196 } 230 197 231 198 psFree(arguments); -
trunk/ppSim/src/ppSimLoop.c
r12907 r12917 6 6 #include <pslib.h> 7 7 #include <psmodules.h> 8 #include <psastro.h> 8 9 9 10 #include "ppSim.h" … … 268 269 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator 269 270 270 psVector *ra = psMetadataLookupPtr(NULL, config->arguments, "CATALOG.RA");// Star RAs271 psVector *dec = psMetadataLookupPtr(NULL, config->arguments, "CATALOG.DEC");// Star Declinations272 psVector *mag = psMetadataLookupPtr(NULL, config->arguments, "CATALOG.MAG");// Star magnitudes271 psVector *ra = NULL; // Star RAs 272 psVector *dec = NULL; // Star Declinations 273 psVector *mag = NULL; // Star magnitudes 273 274 float seeing = psMetadataLookupF32(NULL, config->arguments, "SEEING"); // Seeing sigma (pix) 274 float scale = psMetadataLookupF32(NULL, config->arguments, "SCALE") ; // Plate scale (arcsec/pixel)275 scale *= M_PI / 3600.0 / 180.0; // Convert to radians/pixel275 float scale = psMetadataLookupF32(NULL, config->arguments, "SCALE") * 276 M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel) 276 277 float zp = psMetadataLookupF32(NULL, config->arguments, "ZEROPOINT"); // Photometric zero point 277 278 278 279 // Add catalogue stars 279 if (type == PPSIM_TYPE_OBJECT && ra && dec && mag) { 280 // Convert star ra,dec to pixels from FPA centre 280 if (type == PPSIM_TYPE_OBJECT) { 281 281 float ra0 = psMetadataLookupF32(NULL, config->arguments, "RA"); // Boresight RA (radians) 282 282 float dec0 = psMetadataLookupF32(NULL, config->arguments, "DEC"); // Boresight Dec (radians) 283 283 float pa = psMetadataLookupF32(NULL, config->arguments, "PA"); // Position angle (radians) 284 284 285 // Read catalogue stars using psastro 286 psMetadata *astroRecipe = psMetadataLookupPtr(NULL, config->recipes, PSASTRO_RECIPE); 287 if (!astroRecipe) { 288 psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE); 289 psFree(rng); 290 psFree(bounds); 291 return PS_EXIT_CONFIG_ERROR; 292 } 293 294 // Size of FPA 295 float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale; 296 297 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN", PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius); 298 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MAX", PS_DATA_F32 | PS_META_REPLACE, "", ra0 + radius); 299 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MIN", PS_DATA_F32 | PS_META_REPLACE, "", dec0 - radius); 300 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "DEC_MAX", PS_DATA_F32 | PS_META_REPLACE, "", dec0 + radius); 301 psArray *refStars = psastroLoadRefstars(config); 302 if (!refStars || refStars->n == 0) { 303 psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars."); 304 psFree(refStars); 305 psFree(rng); 306 psFree(bounds); 307 return PS_EXIT_CONFIG_ERROR; 308 } 309 psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", refStars->n); 310 311 ra = psVectorAlloc(refStars->n, PS_TYPE_F32); 312 dec = psVectorAlloc(refStars->n, PS_TYPE_F32); 313 mag = psVectorAlloc(refStars->n, PS_TYPE_F32); 314 285 315 // Conversion loop 286 for (long i = 0; i < ra->n; i++) { 287 float div = sin(dec->data.F32[i]) * sin(dec0) + 288 cos(dec->data.F32[i]) * cos(dec0) * cos(ra->data.F32[i] - ra0); // Divisor 316 for (long i = 0; i < refStars->n; i++) { 317 pmAstromObj *ref = refStars->data[i]; // Reference star 318 float raStar = ref->sky->r; // RA of star 319 float decStar = ref->sky->d; // Dec of star 320 float magStar = ref->Mag; // Magnitude of star 321 289 322 290 323 // Convert to x,y position on tangent plane, in pixels 291 float xi = cos(dec->data.F32[i]) * sin(ra->data.F32[i] - ra0) / div / scale; 292 float eta = (sin(dec->data.F32[i]) * cos(dec0) - 293 cos(dec->data.F32[i]) * sin(dec0) * cos(ra->data.F32[i] - ra0)) / div / scale; 324 float div = sin(decStar) * sin(dec0) + cos(decStar) * cos(dec0) * cos(raStar - ra0); // Divisor 325 float xi = cos(decStar) * sin(raStar - ra0) / div / scale; 326 float eta = (sin(decStar) * cos(dec0) - cos(decStar) * sin(dec0) * cos(raStar - ra0)) / 327 div / scale; 294 328 295 329 // Apply rotation … … 298 332 299 333 // Convert magnitude to peak flux 300 mag->data.F32[i] = powf(10.0, -0.4 * (mag->data.F32[i] - zp)) / sqrt(2.0*M_PI) / seeing * expTime; 301 } 334 mag->data.F32[i] = powf(10.0, -0.4 * (magStar - zp)) / sqrt(2.0*M_PI) / seeing * expTime; 335 } 336 psFree(refStars); 302 337 303 338 psMetadataAddF64(fpa->concepts, PS_LIST_TAIL, "FPA.RA", PS_META_REPLACE, "Right ascension", ra0);
Note:
See TracChangeset
for help on using the changeset viewer.
