Changeset 2650
- Timestamp:
- Dec 7, 2004, 12:28:29 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 6 edited
-
astro/psCoord.c (modified) (6 diffs)
-
astro/psCoord.h (modified) (4 diffs)
-
astronomy/psCoord.c (modified) (6 diffs)
-
astronomy/psCoord.h (modified) (4 diffs)
-
dataManip/psMinimize.c (modified) (2 diffs)
-
math/psMinimize.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r2635 r2650 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 6 19:49:36$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-07 22:28:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 189 189 190 190 /****************************************************************************** 191 XXX: It's not clear if this code correctly implements what the equations in192 the ADD imply. Bug 243 will, hopefully, decide that.193 194 XXX: Once this code is verified, delete Gene's code.195 191 *****************************************************************************/ 196 192 psSphere* psSphereTransformApply(psSphere* out, … … 224 220 225 221 return(out); 226 227 /* 228 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 229 (r,d) in the sphere coordinates. 230 231 XXX: In Gene's email, there are different variables with similar names (y 232 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 233 are no typo's. 234 235 psF64 sinY = 0.0; 236 psF64 cosY = 0.0; 237 psF64 sinX = 0.0; 238 psF64 cosX = 0.0; 239 psF64 x = 0.0; 240 psF64 y = 0.0; 241 psF64 dx = 0.0; 242 243 x = coord->r; 244 y = coord->d; 245 dx = x - transform->phiP; 246 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 247 sin(y) * transform->cosDeltaP; 248 cosY = sqrt(1.0 - sinY * sinY); 249 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 250 sin(y) * transform->sinDeltaP) / cos(y); 251 cosX = cos(y) * cos(dx) / cos(y); 252 253 out->r = atan2(sinX, cosX) + transform->alphaP; 254 out->d = atan2(sinY, cosY); 255 */ 256 } 257 258 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 259 // there is no algorithm for this in the ADD. 260 // XXX: This is bug 244 261 psSphereTransform* psSphereTransformICRSToEcliptic(psTime time) 262 { 263 PS_PTR_CHECK_NULL(&time, NULL); 264 265 struct tm *tmTime = psTimeToTM(&time); 266 psF64 year = (psF64)(1900 + tmTime->tm_year); 267 psF64 T = year / 100.0; 268 psF64 phi = DEG_TO_RAD(-23.452294) + 269 (DEG_TO_RAD(0.013013) * T) + 270 (DEG_TO_RAD(0.000001639) * T * T) - 271 (DEG_TO_RAD(0.000000503) * T * T * T); 272 psF64 alphaP = 0.0; 273 psF64 phiP = 0.0; 274 275 psFree(tmTime); 276 return (psSphereTransformAlloc(phi, alphaP, phiP)); 277 } 278 279 // XXX: the ADD changed. This code no longer conforms to the old ADD. 280 // XXX: Waiting for IfA to sepcify if T should include days/months/etc. 281 psSphereTransform* psSphereTransformEclipticToICRS(psTime time) 282 { 283 PS_PTR_CHECK_NULL(&time, NULL); 284 285 struct tm *tmTime = psTimeToTM(&time); 286 psF64 year = (psF64)(1900 + tmTime->tm_year); 222 } 223 224 psSphereTransform* psSphereTransformICRSToEcliptic(psTime *time) 225 { 226 PS_PTR_CHECK_NULL(time, NULL); 227 psF64 MJD = psTimeToMJD(time); 228 struct tm *tmTime = psTimeToTM(time); 229 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 287 230 psF64 T = year / 100.0; 288 231 psF64 alphaP = 0.0; … … 296 239 297 240 psFree(tmTime); 241 242 // Don't neglect the minus sign on deltaP (bug 244): 243 return (psSphereTransformAlloc(alphaP, -deltaP, phiP)); 244 } 245 246 247 psSphereTransform* psSphereTransformEclipticToICRS(psTime *time) 248 { 249 PS_PTR_CHECK_NULL(time, NULL); 250 psF64 MJD = psTimeToMJD(time); 251 struct tm *tmTime = psTimeToTM(time); 252 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 253 psF64 T = year / 100.0; 254 psF64 alphaP = 0.0; 255 psF64 deltaP = DEG_TO_RAD(23.0) + 256 SEC_TO_RAD(27.0) + 257 MIN_TO_RAD(8.0) - 258 (SEC_TO_RAD(46.845) * T) - 259 (SEC_TO_RAD(0.0059) * T * T) + 260 (SEC_TO_RAD(0.00181) * T * T * T); 261 psF64 phiP = 0.0; 262 263 psFree(tmTime); 298 264 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 299 265 } 300 266 301 // XXX: Should these be in radians, not degrees? 302 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 303 // there is no algorithm for this in the ADD. 304 // XXX: This is bug 245 267 // XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalaticToICRS() 305 268 psSphereTransform* psSphereTransformICRSToGalatic(void) 306 269 { 307 psF64 alphaP = DEG_TO_RAD( -62.6);308 psF64 deltaP = DEG_TO_RAD( 33.0);309 psF64 phiP = DEG_TO_RAD(282. 25);270 psF64 alphaP = DEG_TO_RAD(32.93192); 271 psF64 deltaP = DEG_TO_RAD(-62.87175); 272 psF64 phiP = DEG_TO_RAD(282.85948); 310 273 311 274 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 312 275 } 313 276 314 // XXX: Should these be in radians, not degrees?315 // XXX: the ADD changed. This code no longer conforms to the old ADD.316 277 psSphereTransform* psSphereTransformGalaticToICRS(void) 317 278 { … … 588 549 589 550 551 590 552 /****************************************************************************** 591 553 psSpherePrecess(coords, fromTime, toTime): … … 599 561 const psTime *toTime) 600 562 { 601 psF64 fromMJD = fromTime->sec/86400.0 + 602 fromTime->usec/86400000000.0 + 603 40587.0; 604 psF64 toMJD = toTime->sec/86400.0 + 605 toTime->usec/86400000000.0 + 606 40587.0; 563 psF64 fromMJD = psTimeToMJD(fromTime); 564 psF64 toMJD = psTimeToMJD(toTime); 607 565 psF64 T = (toMJD - fromMJD) / 36525.0; 608 566 -
trunk/psLib/src/astro/psCoord.h
r2635 r2650 1 /** @file psCoord.h1 a/** @file psCoord.h 2 2 * 3 3 * @brief Contains basic coordinate transformation definitions and operations … … 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 6 19:49:36$12 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-07 22:28:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 239 239 */ 240 240 psSphereTransform* psSphereTransformICRSToEcliptic( 241 psTime time ///< the time for which the resulting transform will be valid241 psTime *time ///< the time for which the resulting transform will be valid 242 242 ); 243 243 … … 248 248 */ 249 249 psSphereTransform* psSphereTransformEclipticToICRS( 250 psTime time ///< the time for which the resulting transform will be valid250 psTime *time ///< the time for which the resulting transform will be valid 251 251 ); 252 252 -
trunk/psLib/src/astronomy/psCoord.c
r2635 r2650 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 6 19:49:36$12 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-07 22:28:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 189 189 190 190 /****************************************************************************** 191 XXX: It's not clear if this code correctly implements what the equations in192 the ADD imply. Bug 243 will, hopefully, decide that.193 194 XXX: Once this code is verified, delete Gene's code.195 191 *****************************************************************************/ 196 192 psSphere* psSphereTransformApply(psSphere* out, … … 224 220 225 221 return(out); 226 227 /* 228 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 229 (r,d) in the sphere coordinates. 230 231 XXX: In Gene's email, there are different variables with similar names (y 232 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 233 are no typo's. 234 235 psF64 sinY = 0.0; 236 psF64 cosY = 0.0; 237 psF64 sinX = 0.0; 238 psF64 cosX = 0.0; 239 psF64 x = 0.0; 240 psF64 y = 0.0; 241 psF64 dx = 0.0; 242 243 x = coord->r; 244 y = coord->d; 245 dx = x - transform->phiP; 246 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 247 sin(y) * transform->cosDeltaP; 248 cosY = sqrt(1.0 - sinY * sinY); 249 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 250 sin(y) * transform->sinDeltaP) / cos(y); 251 cosX = cos(y) * cos(dx) / cos(y); 252 253 out->r = atan2(sinX, cosX) + transform->alphaP; 254 out->d = atan2(sinY, cosY); 255 */ 256 } 257 258 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 259 // there is no algorithm for this in the ADD. 260 // XXX: This is bug 244 261 psSphereTransform* psSphereTransformICRSToEcliptic(psTime time) 262 { 263 PS_PTR_CHECK_NULL(&time, NULL); 264 265 struct tm *tmTime = psTimeToTM(&time); 266 psF64 year = (psF64)(1900 + tmTime->tm_year); 267 psF64 T = year / 100.0; 268 psF64 phi = DEG_TO_RAD(-23.452294) + 269 (DEG_TO_RAD(0.013013) * T) + 270 (DEG_TO_RAD(0.000001639) * T * T) - 271 (DEG_TO_RAD(0.000000503) * T * T * T); 272 psF64 alphaP = 0.0; 273 psF64 phiP = 0.0; 274 275 psFree(tmTime); 276 return (psSphereTransformAlloc(phi, alphaP, phiP)); 277 } 278 279 // XXX: the ADD changed. This code no longer conforms to the old ADD. 280 // XXX: Waiting for IfA to sepcify if T should include days/months/etc. 281 psSphereTransform* psSphereTransformEclipticToICRS(psTime time) 282 { 283 PS_PTR_CHECK_NULL(&time, NULL); 284 285 struct tm *tmTime = psTimeToTM(&time); 286 psF64 year = (psF64)(1900 + tmTime->tm_year); 222 } 223 224 psSphereTransform* psSphereTransformICRSToEcliptic(psTime *time) 225 { 226 PS_PTR_CHECK_NULL(time, NULL); 227 psF64 MJD = psTimeToMJD(time); 228 struct tm *tmTime = psTimeToTM(time); 229 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 287 230 psF64 T = year / 100.0; 288 231 psF64 alphaP = 0.0; … … 296 239 297 240 psFree(tmTime); 241 242 // Don't neglect the minus sign on deltaP (bug 244): 243 return (psSphereTransformAlloc(alphaP, -deltaP, phiP)); 244 } 245 246 247 psSphereTransform* psSphereTransformEclipticToICRS(psTime *time) 248 { 249 PS_PTR_CHECK_NULL(time, NULL); 250 psF64 MJD = psTimeToMJD(time); 251 struct tm *tmTime = psTimeToTM(time); 252 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 253 psF64 T = year / 100.0; 254 psF64 alphaP = 0.0; 255 psF64 deltaP = DEG_TO_RAD(23.0) + 256 SEC_TO_RAD(27.0) + 257 MIN_TO_RAD(8.0) - 258 (SEC_TO_RAD(46.845) * T) - 259 (SEC_TO_RAD(0.0059) * T * T) + 260 (SEC_TO_RAD(0.00181) * T * T * T); 261 psF64 phiP = 0.0; 262 263 psFree(tmTime); 298 264 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 299 265 } 300 266 301 // XXX: Should these be in radians, not degrees? 302 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 303 // there is no algorithm for this in the ADD. 304 // XXX: This is bug 245 267 // XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalaticToICRS() 305 268 psSphereTransform* psSphereTransformICRSToGalatic(void) 306 269 { 307 psF64 alphaP = DEG_TO_RAD( -62.6);308 psF64 deltaP = DEG_TO_RAD( 33.0);309 psF64 phiP = DEG_TO_RAD(282. 25);270 psF64 alphaP = DEG_TO_RAD(32.93192); 271 psF64 deltaP = DEG_TO_RAD(-62.87175); 272 psF64 phiP = DEG_TO_RAD(282.85948); 310 273 311 274 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 312 275 } 313 276 314 // XXX: Should these be in radians, not degrees?315 // XXX: the ADD changed. This code no longer conforms to the old ADD.316 277 psSphereTransform* psSphereTransformGalaticToICRS(void) 317 278 { … … 588 549 589 550 551 590 552 /****************************************************************************** 591 553 psSpherePrecess(coords, fromTime, toTime): … … 599 561 const psTime *toTime) 600 562 { 601 psF64 fromMJD = fromTime->sec/86400.0 + 602 fromTime->usec/86400000000.0 + 603 40587.0; 604 psF64 toMJD = toTime->sec/86400.0 + 605 toTime->usec/86400000000.0 + 606 40587.0; 563 psF64 fromMJD = psTimeToMJD(fromTime); 564 psF64 toMJD = psTimeToMJD(toTime); 607 565 psF64 T = (toMJD - fromMJD) / 36525.0; 608 566 -
trunk/psLib/src/astronomy/psCoord.h
r2635 r2650 1 /** @file psCoord.h1 a/** @file psCoord.h 2 2 * 3 3 * @brief Contains basic coordinate transformation definitions and operations … … 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 6 19:49:36$12 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-07 22:28:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 239 239 */ 240 240 psSphereTransform* psSphereTransformICRSToEcliptic( 241 psTime time ///< the time for which the resulting transform will be valid241 psTime *time ///< the time for which the resulting transform will be valid 242 242 ); 243 243 … … 248 248 */ 249 249 psSphereTransform* psSphereTransformEclipticToICRS( 250 psTime time ///< the time for which the resulting transform will be valid250 psTime *time ///< the time for which the resulting transform will be valid 251 251 ); 252 252 -
trunk/psLib/src/dataManip/psMinimize.c
r2583 r2650 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-12-0 1 19:56:06$11 * @version $Revision: 1.93 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-12-07 22:28:29 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 455 455 } 456 456 457 /* 458 XXX: from bug 230: 459 460 We first perform a rotation: 461 u = - (x-x0)*cos(theta) + (y-y0)*sin(theta) 462 v = (x-x0)*cos(theta) + (y-y0)*sin(theta) 463 464 Here u is the major axis, and v is the minor axis, x0,y0 is the centre, and 465 theta is the position angle. 466 467 Then the flux is 468 469 flux = norm * exp(-( u*u/2.0/sigmau/sigmau + v*v/2.0/sigmav/sigmav) 470 )/2.0/pi/sigmau/sigmav 471 472 Here sigmau and sigmav are the widths of the major and minor axes. 473 474 The "norm" parameter in the equation above corresponds to the normalisation. 475 476 Suggest order: 477 478 norm 479 x0 480 y0 481 sigma_u 482 sigma_v 483 theta 484 */ 457 485 458 486 psVector *psMinimizeLMChi2Gauss2D(psImage *deriv, -
trunk/psLib/src/math/psMinimize.c
r2583 r2650 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-12-0 1 19:56:06$11 * @version $Revision: 1.93 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-12-07 22:28:29 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 455 455 } 456 456 457 /* 458 XXX: from bug 230: 459 460 We first perform a rotation: 461 u = - (x-x0)*cos(theta) + (y-y0)*sin(theta) 462 v = (x-x0)*cos(theta) + (y-y0)*sin(theta) 463 464 Here u is the major axis, and v is the minor axis, x0,y0 is the centre, and 465 theta is the position angle. 466 467 Then the flux is 468 469 flux = norm * exp(-( u*u/2.0/sigmau/sigmau + v*v/2.0/sigmav/sigmav) 470 )/2.0/pi/sigmau/sigmav 471 472 Here sigmau and sigmav are the widths of the major and minor axes. 473 474 The "norm" parameter in the equation above corresponds to the normalisation. 475 476 Suggest order: 477 478 norm 479 x0 480 y0 481 sigma_u 482 sigma_v 483 theta 484 */ 457 485 458 486 psVector *psMinimizeLMChi2Gauss2D(psImage *deriv,
Note:
See TracChangeset
for help on using the changeset viewer.
