IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7944


Ignore:
Timestamp:
Jul 20, 2006, 3:02:19 AM (20 years ago)
Author:
rhl
Message:

Wrote macro MAKE_ASTROM_RADIUS to generate pmAstromRadiusMatch(); added pmAstromRadiusMatch{chip,TP} using MAKE_ASTROM_RADIUS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryObjects.c

    r7927 r7944  
    88*  @author EAM, IfA
    99*
    10 *  @version $Revision: 1.10 $ $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 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    114114    return (matches);
    115115}
    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) \
     120psArray *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    } \
    137138    /*
    138      * sort both lists by Focal Plane X coord; st1 first
    139      */
     139     * sort both lists by X coord;
     140    st1 first
     141    */ \
    140142    psVector *x1 = psVectorAlloc(st1->n, PS_TYPE_F64);
     143    \
    141144    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    } \
    145152    const psVector *sorted1 = psVectorSortIndex(NULL, x1);
     153    \
    146154    assert (sorted1->type.type == PS_TYPE_S32);
    147 
     155    \
     156    \
    148157    psVector *y1 = psVectorAlloc(st1->n, PS_TYPE_F64);
     158    \
    149159    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 */ \
    156171    psVector *x2 = psVectorAlloc(st2->n, PS_TYPE_F64);
     172    \
    157173    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    } \
    161181    const psVector *sorted2 = psVectorSortIndex(NULL, x2);
    162 
     182    \
     183    \
    163184    psVector *y2 = psVectorAlloc(st2->n, PS_TYPE_F64);
     185    \
    164186    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    } \
    169196    /*
    170197     * Do the work
    171      */
     198     */ \
    172199    psArray *matches = match_lists(x1, y1, x2, y2, sorted1, sorted2, RADIUS);
    173 
     200    \
     201    \
    174202    psFree(sorted1);
     203    \
    175204    psFree(sorted2);
     205    \
    176206    psFree(x1);
     207    \
    177208    psFree(y1);
     209    \
    178210    psFree(x2);
     211    \
    179212    psFree(y2);
    180 
     213    \
     214    \
    181215    psLogMsg (__func__, 3, "radius match: %d pairs (radius: %f)\n", matches->n, RADIUS);
     216    \
    182217    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 */
     225MAKE_ASTROM_RADIUS(pmAstromRadiusMatch, FP)
     226MAKE_ASTROM_RADIUS(pmAstromRadiusMatchTP, TP)
     227MAKE_ASTROM_RADIUS(pmAstromRadiusMatchChip, chip)
    253228
    254229/******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.