IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28946


Ignore:
Timestamp:
Aug 17, 2010, 3:34:04 PM (16 years ago)
Author:
eugene
Message:

test of MD using dark-specific data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/psLib/test/math/tap_psPolynomialMD_sampleDark.c

    r28919 r28946  
    44#include "pstap.h"
    55
    6 #define TOL 1.0e-8
     6#define TOL 1.0e-4
    77
    88int main(int argc, char *argv[])
    99{
    10     plan_tests(2);
     10    plan_tests(13);
    1111    {
    1212        psMemId id = psMemGetId();
     
    1616        skip_start (!f, 10, "skipping tests using polyMD.dat");
    1717
    18         psVector *exptime = psVectorAlloc (100, PS_TYPE_F32);
    19         psVector *temp    = psVectorAlloc (100, PS_TYPE_F32);
    20         psVector *ord1    = psVectorAlloc (100, PS_TYPE_F32);
    21         psVector *ord2    = psVectorAlloc (100, PS_TYPE_F32);
    22         psVector *ord3    = psVectorAlloc (100, PS_TYPE_F32);
    23         psVector *flux    = psVectorAlloc (100, PS_TYPE_F32);
     18        psVector *exptime = psVectorAllocEmpty (100, PS_TYPE_F32);
     19        psVector *temp    = psVectorAllocEmpty (100, PS_TYPE_F32);
     20        psVector *ord1    = psVectorAllocEmpty (100, PS_TYPE_F32);
     21        psVector *ord2    = psVectorAllocEmpty (100, PS_TYPE_F32);
     22        psVector *ord3    = psVectorAllocEmpty (100, PS_TYPE_F32);
     23        psVector *flux    = psVectorAllocEmpty (100, PS_TYPE_F32);
    2424
    2525        float Exptime, Temp, Ord1, Ord2, Ord3, Flux;
     
    3737            psAssert (i < exptime->nalloc, "error reading data");
    3838        }
    39         ok (exptime->n == 100, "read data");
     39        ok (exptime->n == 5000, "read %d elements", exptime->n);
    4040
    4141        // fit f to ord1, ord2, ord3 (1st order only)
     
    7878
    7979        // fit f to exptime (1st order) and temp (2nd order)
     80        // f = D0 + D1*exptime + D2*exptime*temp + D3*exptime*temp^2
    8081        {
    8182            psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 2);
    82 
     83            poly->coeffMask[0][1] = 1; // x^0 y^1
     84            poly->coeffMask[0][2] = 1; // x^0 y^2
     85           
    8386            bool polyOK = psVectorFitPolynomial2D(poly, NULL, 0, flux, NULL, exptime, temp);
    8487            ok(polyOK, "Fit polynomial");
    8588
    8689            skip_start(!polyOK, 4, "Skipping coefficient checks since fit failed.");
    87             // is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d", index);
    88             // is_double_tol(poly->coeff[1][0], 5.0,    TOL, "Coefficient %d", index);
    89             // is_double_tol(poly->coeff[0][1], 0.025,  TOL, "Coefficient %d", index);
    90             for (int ix = 0; ix < 2; ix++) {
    91                 for (int iy = 0; iy < 3; iy++) {
    92                     fprintf (stderr, "poly %d %d : %f\n", ix, iy, poly->coeff[ix][iy]);
    93                 }
    94             }
     90            is_double_tol(poly->coeff[0][0], 1000.0, TOL, "Coefficient %d %d", 0, 0);
     91            is_double_tol(poly->coeff[1][0], 5.0,    TOL, "Coefficient %d %d", 1, 0);
     92            is_double_tol(poly->coeff[1][1], 0.025,  TOL, "Coefficient %d %d", 1, 1);
     93            is_double_tol(poly->coeff[1][2], 0.005,  TOL, "Coefficient %d %d", 1, 2);
    9594            skip_end();
    9695            psFree(poly);
    9796        }
     97        psFree(exptime);
     98        psFree(temp);
     99        psFree(ord1);
     100        psFree(ord2);
     101        psFree(ord3);
     102        psFree(flux);
    98103        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    99104        skip_end();
Note: See TracChangeset for help on using the changeset viewer.