Changeset 7944 for trunk/psModules/src/astrom/pmAstrometryObjects.c
- Timestamp:
- Jul 20, 2006, 3:02:19 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryObjects.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryObjects.c
r7927 r7944 8 8 * @author EAM, IfA 9 9 * 10 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-07- 18 15:36:32$10 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-07-20 13:02:19 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 114 114 return (matches); 115 115 } 116 /****************************************************************************** 117 pmAstromRadiusMatch(st1, st2, config) 118 ******************************************************************************/ 119 psArray *pmAstromRadiusMatch( 120 const psArray *st1, 121 const psArray *st2, 122 const psMetadata *config) 123 { 124 PS_ASSERT_PTR_NON_NULL(st1, NULL); 125 PS_ASSERT_PTR_NON_NULL(st2, NULL); 126 PS_ASSERT_PTR_NON_NULL(config, NULL); 127 128 assert(st1->n == 0 || pmIsAstromObj(st1->data[0])); 129 assert(st2->n == 0 || pmIsAstromObj(st2->data[0])); 130 131 bool status = false; 132 double RADIUS = psMetadataLookupF32 (&status, config, "PSASTRO.MATCH.RADIUS"); 133 if (!status) { 134 psError(PS_ERR_IO, false, "Failed to lookup matching radius"); 135 return NULL; 136 } 116 117 /************************************************************************************************************/ 118 119 #define MAKE_ASTROM_RADIUS(FUNC, MEMBER) \ 120 psArray *FUNC( \ 121 const psArray *st1, \ 122 const psArray *st2, \ 123 const psMetadata *config) \ 124 { \ 125 PS_ASSERT_PTR_NON_NULL(st1, NULL); \ 126 PS_ASSERT_PTR_NON_NULL(st2, NULL); \ 127 PS_ASSERT_PTR_NON_NULL(config, NULL); \ 128 \ 129 assert(st1->n == 0 || pmIsAstromObj(st1->data[0])); \ 130 assert(st2->n == 0 || pmIsAstromObj(st2->data[0])); \ 131 \ 132 bool status = false; \ 133 double RADIUS = psMetadataLookupF32 (&status, config, "PSASTRO.MATCH.RADIUS"); \ 134 if (!status) { \ 135 psError(PS_ERR_IO, false, "Failed to lookup matching radius"); \ 136 return NULL; \ 137 } \ 137 138 /* 138 * sort both lists by Focal Plane X coord; st1 first 139 */ 139 * sort both lists by X coord; 140 st1 first 141 */ \ 140 142 psVector *x1 = psVectorAlloc(st1->n, PS_TYPE_F64); 143 \ 141 144 x1->n = x1->nalloc; 142 for (int i = 0; i < st1->n; i++) { 143 x1->data.F64[i] = ((pmAstromObj *)st1->data[i])->FP->x; 144 } 145 \ 146 for (int i = 0; i < st1->n; i++) 147 { 148 \ 149 x1->data.F64[i] = ((pmAstromObj *)st1->data[i])->MEMBER->x; 150 \ 151 } \ 145 152 const psVector *sorted1 = psVectorSortIndex(NULL, x1); 153 \ 146 154 assert (sorted1->type.type == PS_TYPE_S32); 147 155 \ 156 \ 148 157 psVector *y1 = psVectorAlloc(st1->n, PS_TYPE_F64); 158 \ 149 159 y1->n = y1->nalloc; 150 for (int i = 0; i < st1->n; i++) { 151 x1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->FP->x; 152 y1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->FP->y; 153 } 154 155 // now st2 160 \ 161 for (int i = 0; i < st1->n; i++) 162 { 163 \ 164 x1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->MEMBER->x; 165 \ 166 y1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->MEMBER->y; 167 \ 168 } \ 169 \ 170 /* now st2 */ \ 156 171 psVector *x2 = psVectorAlloc(st2->n, PS_TYPE_F64); 172 \ 157 173 x2->n = x2->nalloc; 158 for (int i = 0; i < st2->n; i++) { 159 x2->data.F64[i] = ((pmAstromObj *)st2->data[i])->FP->x; 160 } 174 \ 175 for (int i = 0; i < st2->n; i++) 176 { 177 \ 178 x2->data.F64[i] = ((pmAstromObj *)st2->data[i])->MEMBER->x; 179 \ 180 } \ 161 181 const psVector *sorted2 = psVectorSortIndex(NULL, x2); 162 182 \ 183 \ 163 184 psVector *y2 = psVectorAlloc(st2->n, PS_TYPE_F64); 185 \ 164 186 y2->n = y2->nalloc; 165 for (int i = 0; i < st2->n; i++) { 166 x2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->FP->x; 167 y2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->FP->y; 168 } 187 \ 188 for (int i = 0; i < st2->n; i++) 189 { 190 \ 191 x2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->MEMBER->x; 192 \ 193 y2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->MEMBER->y; 194 \ 195 } \ 169 196 /* 170 197 * Do the work 171 */ 198 */ \ 172 199 psArray *matches = match_lists(x1, y1, x2, y2, sorted1, sorted2, RADIUS); 173 200 \ 201 \ 174 202 psFree(sorted1); 203 \ 175 204 psFree(sorted2); 205 \ 176 206 psFree(x1); 207 \ 177 208 psFree(y1); 209 \ 178 210 psFree(x2); 211 \ 179 212 psFree(y2); 180 213 \ 214 \ 181 215 psLogMsg (__func__, 3, "radius match: %d pairs (radius: %f)\n", matches->n, RADIUS); 216 \ 182 217 return (matches); 183 } 184 185 /****************************************************************************** 186 pmAstromRadiusMatchChip(st1, st2, config) : match objects on the chip 187 ******************************************************************************/ 188 psArray *pmAstromRadiusMatchChip( 189 const psArray *st1, 190 const psArray *st2, 191 const psMetadata *config) 192 { 193 PS_ASSERT_PTR_NON_NULL(st1, NULL); 194 PS_ASSERT_PTR_NON_NULL(st2, NULL); 195 PS_ASSERT_PTR_NON_NULL(config, NULL); 196 197 assert(st1->n == 0 || pmIsAstromObj(st1->data[0])); 198 assert(st2->n == 0 || pmIsAstromObj(st2->data[0])); 199 200 bool status = false; 201 double RADIUS = psMetadataLookupF32 (&status, config, "PSASTRO.MATCH.RADIUS"); 202 if (!status) { 203 psError(PS_ERR_IO, false, "Failed to lookup matching radius"); 204 return NULL; 205 } 206 /* 207 * sort both lists by chip X coord; st1 first 208 */ 209 psVector *x1 = psVectorAlloc(st1->n, PS_TYPE_F64); 210 x1->n = x1->nalloc; 211 for (int i = 0; i < st1->n; i++) { 212 x1->data.F64[i] = ((pmAstromObj *)st1->data[i])->FP->x; 213 } 214 const psVector *sorted1 = psVectorSortIndex(NULL, x1); 215 assert (sorted1->type.type == PS_TYPE_S32); 216 217 psVector *y1 = psVectorAlloc(st1->n, PS_TYPE_F64); 218 y1->n = y1->nalloc; 219 for (int i = 0; i < st1->n; i++) { 220 x1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->chip->x; 221 y1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->chip->y; 222 } 223 224 // now st2 225 psVector *x2 = psVectorAlloc(st2->n, PS_TYPE_F64); 226 x2->n = x2->nalloc; 227 for (int i = 0; i < st2->n; i++) { 228 x2->data.F64[i] = ((pmAstromObj *)st2->data[i])->FP->x; 229 } 230 const psVector *sorted2 = psVectorSortIndex(NULL, x2); 231 232 psVector *y2 = psVectorAlloc(st2->n, PS_TYPE_F64); 233 y2->n = y2->nalloc; 234 for (int i = 0; i < st2->n; i++) { 235 x2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->chip->x; 236 y2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->chip->y; 237 } 238 /* 239 * Do the work 240 */ 241 psArray *matches = match_lists(x1, y1, x2, y2, sorted1, sorted2, RADIUS); 242 243 psFree(sorted1); 244 psFree(sorted2); 245 psFree(x1); 246 psFree(y1); 247 psFree(x2); 248 psFree(y2); 249 250 psLogMsg (__func__, 3, "radius match: %d pairs (radius: %f)\n", matches->n, RADIUS); 251 return (matches); 252 } 218 \ 219 } 220 221 /******************************************************************************/ 222 /* 223 * Match two lists of pmAstromObjs, based on the FP, TP, or chip coordinates 224 */ 225 MAKE_ASTROM_RADIUS(pmAstromRadiusMatch, FP) 226 MAKE_ASTROM_RADIUS(pmAstromRadiusMatchTP, TP) 227 MAKE_ASTROM_RADIUS(pmAstromRadiusMatchChip, chip) 253 228 254 229 /******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
