IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11669


Ignore:
Timestamp:
Feb 6, 2007, 11:55:28 AM (19 years ago)
Author:
jhoblitt
Message:

move psPolynomial*metdata() functions from psMetdata.* into math/psPolynomialMetdata.* as is causes an unnessicary dep from psMetadata.c -> psPolynomial.h

Location:
trunk/psLib/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/Makefile.am

    r10547 r11669  
    1717        psMinimizePolyFit.c \
    1818        psPolynomial.c \
     19        psPolynomialMetadata.c \
    1920        psPolynomialUtils.c \
    2021        psRandom.c \
     
    4344        psMinimizePolyFit.h \
    4445        psPolynomial.h \
     46        psPolynomialMetadata.h \
    4547        psPolynomialUtils.h \
    4648        psRandom.h \
  • trunk/psLib/src/pslib_strict.h

    r10978 r11669  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2007-01-09 01:25:44 $
     11*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2007-02-06 21:55:28 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6868#include "psRegionForImage.h"
    6969#include "psPolynomial.h"
     70#include "psPolynomialMetadata.h"
    7071#include "psPolynomialUtils.h"
    7172#include "psSpline.h"
  • trunk/psLib/src/types/psMetadata.c

    r11668 r11669  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.149 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-02-06 21:36:09 $
     14 *  @version $Revision: 1.150 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2007-02-06 21:55:28 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    14161416    return noErrors;
    14171417}
    1418 
    1419 psPolynomial1D *psPolynomial1DfromMetadata(const psMetadata *folder)
    1420 {
    1421     PS_ASSERT_PTR_NON_NULL(folder, NULL);
    1422     bool status;
    1423     char keyword[80];
    1424 
    1425     // get polynomial orders
    1426     int nXorder = psMetadataLookupS32 (&status, folder, "NORDER_X");
    1427     if (!status) {
    1428         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial1D in metadata is missing NORDER_X");
    1429         return NULL;
    1430     }
    1431     // how many polynomial coeffs are expected?
    1432     int nElementsExpected = psMetadataLookupS32 (&status, folder, "NELEMENTS");
    1433     if (!status) {
    1434         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial1D in metadata is missing NELEMENTS");
    1435         return NULL;
    1436     }
    1437 
    1438     psPolynomial1D *poly = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, nXorder);
    1439 
    1440     int nElements = 0;
    1441     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1442         sprintf (keyword, "VAL_X%02d", nx);
    1443         poly->coeff[nx] = psMetadataLookupF64 (&status, folder, keyword);
    1444         if (!status) {
    1445             // an undefined component implies the component was masked
    1446             // this is symmetrical with the 1DtoMD function
    1447             poly->mask[nx] = 1;
    1448             poly->coeff[nx] = 0;
    1449             poly->coeffErr[nx] = 0;
    1450         } else {
    1451             poly->mask[nx] = 0;
    1452             nElements ++;
    1453         }
    1454         sprintf (keyword, "ERR_X%02d", nx);
    1455         poly->coeffErr[nx] = psMetadataLookupF64 (&status, folder, keyword);
    1456     }
    1457     if (nElements != nElementsExpected) {
    1458         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    1459                 "psPolynomial1D in metadata does not have the correct number of coefficients: "
    1460                 "%d found vs %d expected", nElements, nElementsExpected);
    1461         psFree(poly);
    1462         return NULL;
    1463     }
    1464     return (poly);
    1465 }
    1466 
    1467 // XXX : these may need F64, or %g format for output
    1468 bool psPolynomial1DtoMetadata(psMetadata *md,
    1469                               const psPolynomial1D *poly,
    1470                               const char *format,
    1471                               ...)
    1472 {
    1473     PS_ASSERT_PTR_NON_NULL(md, false);
    1474     PS_ASSERT_PTR_NON_NULL(poly, false);
    1475     //XXX:  Current implementation only supports ordinary polynomials.
    1476     if (poly->type != PS_POLYNOMIAL_ORD)
    1477         return false;
    1478 
    1479     int Nbyte;
    1480     char tmp;
    1481     char *root;
    1482     va_list argp;
    1483 
    1484     va_start (argp, format);
    1485     Nbyte = vsnprintf (&tmp, 0, format, argp);
    1486     va_end (argp);
    1487 
    1488     if (Nbyte <= 0)
    1489         return false;
    1490 
    1491     va_start (argp, format);
    1492     root = (char *) psAlloc (Nbyte + 1);
    1493     memset (root, 0, Nbyte + 1);
    1494     vsnprintf (root, Nbyte + 1, format, argp);
    1495     va_end (argp);
    1496 
    1497     psMetadata *folder = psMetadataAlloc ();
    1498 
    1499     // specify the polynomial orders
    1500     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_X", PS_DATA_S32, "number of x orders", poly->nX);
    1501 
    1502     char namespace[80];
    1503     char namespace_err[80];
    1504     int nElements = 0;   // count the number of unmasked elements
    1505 
    1506     // place polynomial entries on folder
    1507     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1508         if (poly->mask[nx] == 0) {
    1509             sprintf(namespace, "VAL_X%02d", nx);
    1510             sprintf(namespace_err, "ERR_X%02d", nx);
    1511             psMetadataAdd (folder, PS_LIST_TAIL, namespace, PS_DATA_F64,
    1512                            "polynomial coefficient", poly->coeff[nx]);
    1513             psMetadataAdd (folder, PS_LIST_TAIL, namespace_err, PS_DATA_F64,
    1514                            "polynomial coefficient error", poly->coeffErr[nx]);
    1515             nElements ++;
    1516         }
    1517     }
    1518     psMetadataAdd (folder, PS_LIST_TAIL, "NELEMENTS", PS_DATA_S32, "number of unmasked coeffs", nElements);
    1519     psMetadataAdd (md, PS_LIST_TAIL, root, PS_DATA_METADATA, "folder for 1D polynomial", folder);
    1520     psFree (root);
    1521     psFree(folder);
    1522     return true;
    1523 }
    1524 
    1525 psPolynomial2D *psPolynomial2DfromMetadata(const psMetadata *folder)
    1526 {
    1527     PS_ASSERT_PTR_NON_NULL(folder, NULL);
    1528     bool status;
    1529     char keyword[80];
    1530 
    1531     // get polynomial orders
    1532     int nXorder = psMetadataLookupS32 (&status, folder, "NORDER_X");
    1533     if (!status) {
    1534         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial2D in metadata is missing NORDER_X");
    1535         return NULL;
    1536     }
    1537     int nYorder = psMetadataLookupS32 (&status, folder, "NORDER_Y");
    1538     if (!status) {
    1539         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial2D in metadata is missing NORDER_Y");
    1540         return NULL;
    1541     }
    1542     // how many polynomial coeffs are expected?
    1543     int nElementsExpected = psMetadataLookupS32 (&status, folder, "NELEMENTS");
    1544     if (!status) {
    1545         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial2D in metadata is missing NELEMENTS");
    1546         return NULL;
    1547     }
    1548 
    1549     psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXorder, nYorder);
    1550 
    1551     int nElements = 0;
    1552     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1553         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1554             sprintf (keyword, "VAL_X%02d_Y%02d", nx, ny);
    1555             poly->coeff[nx][ny] = psMetadataLookupF64 (&status, folder, keyword);
    1556             if (!status) {
    1557                 // an undefined component implies the component was masked
    1558                 // this is symmetrical with the 2DtoMD function
    1559                 poly->mask[nx][ny] = 1;
    1560                 poly->coeff[nx][ny] = 0;
    1561                 poly->coeffErr[nx][ny] = 0;
    1562             } else {
    1563                 poly->mask[nx][ny] = 0;
    1564                 nElements ++;
    1565             }
    1566             sprintf (keyword, "ERR_X%02d_Y%02d", nx, ny);
    1567             poly->coeffErr[nx][ny] = psMetadataLookupF64 (&status, folder, keyword);
    1568         }
    1569     }
    1570     if (nElements != nElementsExpected) {
    1571         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    1572                 "psPolynomial2D in metadata does not have the correct number of coefficients: "
    1573                 "%d found vs %d expected", nElements, nElementsExpected);
    1574         psFree(poly);
    1575         return NULL;
    1576     }
    1577     return (poly);
    1578 }
    1579 
    1580 // XXX : these may need F64, or %g format for output
    1581 bool psPolynomial2DtoMetadata (psMetadata *md,
    1582                                const psPolynomial2D *poly,
    1583                                const char *format,
    1584                                ...)
    1585 {
    1586     PS_ASSERT_PTR_NON_NULL(md, false);
    1587     PS_ASSERT_PTR_NON_NULL(poly, false);
    1588     //XXX:  Current implementation only supports ordinary polynomials.
    1589     if (poly->type != PS_POLYNOMIAL_ORD)
    1590         return false;
    1591 
    1592     // XXX I'm puzzled by this test.  a polynomial of 0 order with a value of 0 is a
    1593     // perfectly valid polynomial and can be written out.  a polynomial with all elements
    1594     // masked still carries information.
    1595     //Make sure polynomial isn't 0, completely empty
    1596     //if (poly->nX == 0 && poly->nY == 0 && poly->coeff[0][0] == 0)
    1597     //return false;
    1598 
    1599     int Nbyte;
    1600     char tmp;
    1601     char *root;
    1602     va_list argp;
    1603 
    1604     va_start (argp, format);
    1605     Nbyte = vsnprintf (&tmp, 0, format, argp);
    1606     va_end (argp);
    1607 
    1608     if (Nbyte <= 0)
    1609         return false;
    1610 
    1611     va_start (argp, format);
    1612     root = (char *) psAlloc (Nbyte + 1);
    1613     memset (root, 0, Nbyte + 1);
    1614     vsnprintf (root, Nbyte + 1, format, argp);
    1615     va_end (argp);
    1616 
    1617     psMetadata *folder = psMetadataAlloc ();
    1618 
    1619     // specify the polynomial orders
    1620     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_X", PS_DATA_S32, "number of x orders", poly->nX);
    1621     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_Y", PS_DATA_S32, "number of y orders", poly->nY);
    1622 
    1623     char namespace[80];
    1624     char namespace_err[80];
    1625     int nElements = 0;   // count the number of unmasked elements
    1626 
    1627     // place polynomial entries on folder
    1628     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1629         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1630             if (poly->mask[nx][ny] == 0) {
    1631                 sprintf(namespace, "VAL_X%02d_Y%02d", nx, ny);
    1632                 sprintf(namespace_err, "ERR_X%02d_Y%02d", nx, ny);
    1633                 psMetadataAdd (folder, PS_LIST_TAIL, namespace, PS_DATA_F64,
    1634                                "polynomial coefficient", poly->coeff[nx][ny]);
    1635                 psMetadataAdd (folder, PS_LIST_TAIL, namespace_err, PS_DATA_F64,
    1636                                "polynomial coefficient error", poly->coeffErr[nx][ny]);
    1637                 nElements ++;
    1638             }
    1639         }
    1640     }
    1641     psMetadataAdd (folder, PS_LIST_TAIL, "NELEMENTS", PS_DATA_S32, "number of unmasked coeffs", nElements);
    1642     psMetadataAdd (md, PS_LIST_TAIL, root, PS_DATA_METADATA, "folder for 2D polynomial", folder);
    1643     psFree (root);
    1644     psFree(folder);
    1645     return true;
    1646 }
    1647 
    1648 psPolynomial3D *psPolynomial3DfromMetadata (const psMetadata *folder)
    1649 {
    1650     PS_ASSERT_PTR_NON_NULL(folder, NULL);
    1651 
    1652     bool status;
    1653     char keyword[80];
    1654 
    1655     // get polynomial orders
    1656     int nXorder = psMetadataLookupS32 (&status, folder, "NORDER_X");
    1657     if (!status) {
    1658         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial3D in metadata is missing NORDER_X");
    1659         return NULL;
    1660     }
    1661     int nYorder = psMetadataLookupS32 (&status, folder, "NORDER_Y");
    1662     if (!status) {
    1663         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial3D in metadata is missing NORDER_Y");
    1664         return NULL;
    1665     }
    1666     int nZorder = psMetadataLookupS32 (&status, folder, "NORDER_Z");
    1667     if (!status) {
    1668         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial3D in metadata is missing NORDER_Z");
    1669         return NULL;
    1670     }
    1671     // how many polynomial coeffs are expected?
    1672     int nElementsExpected = psMetadataLookupS32 (&status, folder, "NELEMENTS");
    1673     if (!status) {
    1674         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial3D in metadata is missing NELEMENTS");
    1675         return NULL;
    1676     }
    1677 
    1678     psPolynomial3D *poly = psPolynomial3DAlloc (PS_POLYNOMIAL_ORD, nXorder, nYorder, nZorder);
    1679 
    1680     int nElements = 0;
    1681     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1682         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1683             for (int nz = 0; nz < poly->nZ + 1; nz++) {
    1684                 sprintf (keyword, "VAL_X%02d_Y%02d_Z%02d", nx, ny, nz);
    1685                 poly->coeff[nx][ny][nz] = psMetadataLookupF64 (&status, folder, keyword);
    1686                 if (!status) {
    1687                     // an undefined component implies the component was masked
    1688                     // this is symmetrical with the 3DtoMD function
    1689                     poly->mask[nx][ny][nz] = 1;
    1690                     poly->coeff[nx][ny][nz] = 0;
    1691                     poly->coeffErr[nx][ny][nz] = 0;
    1692                 } else {
    1693                     poly->mask[nx][ny][nz] = 0;
    1694                     nElements ++;
    1695                 }
    1696                 sprintf (keyword, "ERR_X%02d_Y%02d_Z%02d", nx, ny, nz);
    1697                 poly->coeffErr[nx][ny][nz] = psMetadataLookupF64 (&status, folder, keyword);
    1698             }
    1699         }
    1700     }
    1701     if (nElements != nElementsExpected) {
    1702         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    1703                 "psPolynomial3D in metadata does not have the correct number of coefficients: "
    1704                 "%d found vs %d expected", nElements, nElementsExpected);
    1705         psFree(poly);
    1706         return NULL;
    1707     }
    1708     return (poly);
    1709 }
    1710 
    1711 bool psPolynomial3DtoMetadata (psMetadata *md,
    1712                                const psPolynomial3D *poly,
    1713                                const char *format,
    1714                                ...)
    1715 {
    1716     PS_ASSERT_PTR_NON_NULL(md, false);
    1717     PS_ASSERT_PTR_NON_NULL(poly, false);
    1718     //XXX:  Current implementation only supports ordinary polynomials.
    1719     if (poly->type != PS_POLYNOMIAL_ORD)
    1720         return false;
    1721 
    1722     int Nbyte;
    1723     char tmp;
    1724     char *root;
    1725     va_list argp;
    1726 
    1727     va_start (argp, format);
    1728     Nbyte = vsnprintf (&tmp, 0, format, argp);
    1729     va_end (argp);
    1730 
    1731     if (Nbyte <= 0)
    1732         return false;
    1733 
    1734     va_start (argp, format);
    1735     root = (char *) psAlloc (Nbyte + 1);
    1736     memset (root, 0, Nbyte + 1);
    1737     vsnprintf (root, Nbyte + 1, format, argp);
    1738     va_end (argp);
    1739 
    1740     psMetadata *folder = psMetadataAlloc ();
    1741 
    1742     // specify the polynomial orders
    1743     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_X", PS_DATA_S32, "number of x orders", poly->nX);
    1744     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_Y", PS_DATA_S32, "number of y orders", poly->nY);
    1745     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_Z", PS_DATA_S32, "number of z orders", poly->nZ);
    1746 
    1747     char namespace[80];
    1748     char namespace_err[80];
    1749     int nElements = 0;   // count the number of unmasked elements
    1750 
    1751     // place polynomial entries on folder
    1752     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1753         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1754             for (int nz = 0; nz < poly->nZ + 1; nz++) {
    1755                 if (poly->mask[nx][ny][nz] == 0) {
    1756                     sprintf(namespace, "VAL_X%02d_Y%02d_Z%02d", nx, ny, nz);
    1757                     sprintf(namespace_err, "ERR_X%02d_Y%02d_Z%02d", nx, ny, nz);
    1758                     psMetadataAdd (folder, PS_LIST_TAIL, namespace,
    1759                                    PS_DATA_F64, "polynomial coefficient",
    1760                                    poly->coeff[nx][ny][nz], nx, ny, nz);
    1761                     psMetadataAdd (folder, PS_LIST_TAIL, namespace_err,
    1762                                    PS_DATA_F64, "polynomial coeffficient error",
    1763                                    poly->coeffErr[nx][ny][nz], nx, ny, nz);
    1764                     nElements ++;
    1765                 }
    1766             }
    1767         }
    1768     }
    1769     psMetadataAdd (folder, PS_LIST_TAIL, "NELEMENTS", PS_DATA_S32, "number of unmasked coeffs", nElements);
    1770     psMetadataAdd (md, PS_LIST_TAIL, root, PS_DATA_METADATA, "folder for 3D polynomial", folder);
    1771     psFree(root);
    1772     psFree(folder);
    1773     return true;
    1774 }
    1775 
    1776 psPolynomial4D *psPolynomial4DfromMetadata(const psMetadata *folder)
    1777 {
    1778     PS_ASSERT_PTR_NON_NULL(folder, NULL);
    1779 
    1780     bool status;
    1781     char keyword[80];
    1782 
    1783     int nXorder = psMetadataLookupS32 (&status, folder, "NORDER_X");
    1784     if (!status) {
    1785         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial4D in metadata is missing NORDER_X");
    1786         return NULL;
    1787     }
    1788     int nYorder = psMetadataLookupS32 (&status, folder, "NORDER_Y");
    1789     if (!status) {
    1790         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial4D in metadata is missing NORDER_Y");
    1791         return NULL;
    1792     }
    1793     int nZorder = psMetadataLookupS32 (&status, folder, "NORDER_Z");
    1794     if (!status) {
    1795         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial4D in metadata is missing NORDER_Z");
    1796         return NULL;
    1797     }
    1798     int nTorder = psMetadataLookupS32 (&status, folder, "NORDER_T");
    1799     if (!status) {
    1800         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial4D in metadata is missing NORDER_T");
    1801         return NULL;
    1802     }
    1803     // how many polynomial coeffs are expected?
    1804     int nElementsExpected = psMetadataLookupS32 (&status, folder, "NELEMENTS");
    1805     if (!status) {
    1806         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "psPolynomial4D in metadata is missing NELEMENTS");
    1807         return NULL;
    1808     }
    1809 
    1810     psPolynomial4D *poly = psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, nXorder, nYorder, nZorder, nTorder);
    1811 
    1812     int nElements = 0;
    1813     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1814         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1815             for (int nz = 0; nz < poly->nZ + 1; nz++) {
    1816                 for (int nt = 0; nt < poly->nT + 1; nt++) {
    1817                     sprintf (keyword, "VAL_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
    1818                     poly->coeff[nx][ny][nz][nt] = psMetadataLookupF64 (&status, folder, keyword);
    1819                     if (!status) {
    1820                         // an undefined component implies the component was masked
    1821                         // this is symmetrical with the 4DtoMD function
    1822                         poly->mask[nx][ny][nz][nt] = 1;
    1823                         poly->coeff[nx][ny][nz][nt] = 0;
    1824                         poly->coeffErr[nx][ny][nz][nt] = 0;
    1825                     } else {
    1826                         poly->mask[nx][ny][nz][nt] = 0;
    1827                         nElements ++;
    1828                     }
    1829                     sprintf (keyword, "ERR_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
    1830                     poly->coeffErr[nx][ny][nz][nt] = psMetadataLookupF64 (&status, folder, keyword);
    1831                 }
    1832             }
    1833         }
    1834     }
    1835     if (nElements != nElementsExpected) {
    1836         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    1837                 "psPolynomial4D in metadata does not have the correct number of coefficients: "
    1838                 "%d found vs %d expected", nElements, nElementsExpected);
    1839         psFree(poly);
    1840         return NULL;
    1841     }
    1842     return (poly);
    1843 }
    1844 
    1845 bool psPolynomial4DtoMetadata (psMetadata *md,
    1846                                const psPolynomial4D *poly,
    1847                                const char *format,
    1848                                ...)
    1849 {
    1850     PS_ASSERT_PTR_NON_NULL(md, false);
    1851     PS_ASSERT_PTR_NON_NULL(poly, false);
    1852     //XXX:  Current implementation only supports ordinary polynomials.
    1853     if (poly->type != PS_POLYNOMIAL_ORD)
    1854         return false;
    1855 
    1856     int Nbyte;
    1857     char tmp;
    1858     char *root;
    1859     va_list argp;
    1860 
    1861     va_start (argp, format);
    1862     Nbyte = vsnprintf (&tmp, 0, format, argp);
    1863     va_end (argp);
    1864 
    1865     if (Nbyte <= 0)
    1866         return false;
    1867 
    1868     va_start (argp, format);
    1869     root = (char *) psAlloc (Nbyte + 1);
    1870     memset (root, 0, Nbyte + 1);
    1871     vsnprintf (root, Nbyte + 1, format, argp);
    1872     va_end (argp);
    1873 
    1874     psMetadata *folder = psMetadataAlloc ();
    1875 
    1876     // specify the polynomial orders
    1877     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_X", PS_DATA_S32, "number of x orders", poly->nX);
    1878     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_Y", PS_DATA_S32, "number of y orders", poly->nY);
    1879     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_Z", PS_DATA_S32, "number of z orders", poly->nZ);
    1880     psMetadataAdd (folder, PS_LIST_TAIL, "NORDER_T", PS_DATA_S32, "number of t orders", poly->nT);
    1881 
    1882     char namespace[80];
    1883     char namespace_err[80];
    1884     int nElements = 0;   // count the number of unmasked elements
    1885 
    1886     // place polynomial entries on folder
    1887     for (int nx = 0; nx < poly->nX + 1; nx++) {
    1888         for (int ny = 0; ny < poly->nY + 1; ny++) {
    1889             for (int nz = 0; nz < poly->nZ + 1; nz++) {
    1890                 for (int nt = 0; nt < poly->nT + 1; nt++) {
    1891                     if (poly->mask[nx][ny][nz][nt] == 0) {
    1892                         sprintf(namespace, "VAL_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
    1893                         sprintf(namespace_err, "ERR_X%02d_Y%02d_Z%02d_T%02d", nx, ny, nz, nt);
    1894                         psMetadataAdd (folder, PS_LIST_TAIL, namespace,
    1895                                        PS_DATA_F64, "polynomial coefficient",
    1896                                        poly->coeff[nx][ny][nz][nt], nx, ny, nz, nt);
    1897                         psMetadataAdd (folder, PS_LIST_TAIL, namespace_err,
    1898                                        PS_DATA_F64, "polynomial coeffficient error",
    1899                                        poly->coeffErr[nx][ny][nz][nt], nx, ny, nz, nt);
    1900                         nElements ++;
    1901                     }
    1902                 }
    1903             }
    1904         }
    1905     }
    1906     psMetadataAdd (folder, PS_LIST_TAIL, "NELEMENTS", PS_DATA_S32, "number of unmasked coeffs", nElements);
    1907     psMetadataAdd (md, PS_LIST_TAIL, root, PS_DATA_METADATA, "folder for 4D polynomial", folder);
    1908     psFree(root);
    1909     psFree(folder);
    1910     return true;
    1911 }
  • trunk/psLib/src/types/psMetadata.h

    r11668 r11669  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2007-02-06 21:36:09 $
     11*  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2007-02-06 21:55:28 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    10531053);
    10541054
    1055 /** Allocates a new psPolynomial1D structure with information from a psMetadata.
    1056  *
    1057  *  Parses a psMetadata container with psPolynomial1D information.  The first two
    1058  *  elements of the metadata folder specify the order of the x & y variables.  (ie,
    1059  *  NORDER_X, NORDER_Y).  The following elements are the values of the coefficients
    1060  *  and the coefficient errors.  (ie, VAL_X00_Y00, ERR_X00_Y00, etc.).  If the orders
    1061  *  or any coefficients are missing or have incorrect syntax, NULL is returned.
    1062  *
    1063  *  @return psPolynomial1D*:        Newly allocated psPolynomial1D from metadata.
    1064  */
    1065 psPolynomial1D *psPolynomial1DfromMetadata(
    1066     const psMetadata *folder                 ///< folder containing the polynomial info.
    1067 );
    1068 
    1069 /** Stores the information from a psPolynomial1D structure in a psMetadata container.
    1070  *
    1071  *  Creates a psMetadata folder with psPolynomial1D information.  The first two
    1072  *  elements of the metadata folder specify the order of the x & y variables.  (ie,
    1073  *  NORDER_X, NORDER_Y).  The following elements are the values of the coefficients
    1074  *  and the coefficient errors.  (ie, VAL_X00_Y00, ERR_X00_Y00, etc.).  The input
    1075  *  polynomial must be of ordinary type and have a valid name format.  False is also
    1076  *  returned if any inputs are NULL.  *If a particular mask element is non-zero, that
    1077  *  polynomial coefficient (and error) are skipped.
    1078  *
    1079  *  @return bool:       True if successful, otherwise false.
    1080  */
    1081 bool psPolynomial1DtoMetadata(
    1082     psMetadata *md,                    ///< Metadata container for polynomial storage.
    1083     const psPolynomial1D *poly,        ///< Polynomial information to be stored.
    1084     const char *format,                ///< Name of polynomial folder.
    1085     ...                                ///< Arguments for name formatting.
    1086 );
    1087 
    1088 /** Allocates a new psPolynomial2D structure with information from a psMetadata.
    1089  *
    1090  *  Parses a psMetadata container with psPolynomial2D information.  The first two
    1091  *  elements of the metadata folder specify the order of the x & y variables.  (ie,
    1092  *  NORDER_X, NORDER_Y).  The following elements are the values of the coefficients
    1093  *  and the coefficient errors.  (ie, VAL_X00_Y00, ERR_X00_Y00, etc.).  If the orders
    1094  *  or any coefficients are missing or have incorrect syntax, NULL is returned.
    1095  *
    1096  *  @return psPolynomial2D*:        Newly allocated psPolynomial2D from metadata.
    1097  */
    1098 psPolynomial2D *psPolynomial2DfromMetadata(
    1099     const psMetadata *folder                 ///< folder containing the polynomial info.
    1100 );
    1101 
    1102 /** Stores the information from a psPolynomial2D structure in a psMetadata container.
    1103  *
    1104  *  Creates a psMetadata folder with psPolynomial2D information.  The first two
    1105  *  elements of the metadata folder specify the order of the x & y variables.  (ie,
    1106  *  NORDER_X, NORDER_Y).  The following elements are the values of the coefficients
    1107  *  and the coefficient errors.  (ie, VAL_X00_Y00, ERR_X00_Y00, etc.).  The input
    1108  *  polynomial must be of ordinary type and have a valid name format.  False is also
    1109  *  returned if any inputs are NULL.  *If a particular mask element is non-zero, that
    1110  *  polynomial coefficient (and error) are skipped.
    1111  *
    1112  *  @return bool:       True if successful, otherwise false.
    1113  */
    1114 bool psPolynomial2DtoMetadata(
    1115     psMetadata *md,                    ///< Metadata container for polynomial storage.
    1116     const psPolynomial2D *poly,              ///< Polynomial information to be stored.
    1117     const char *format,                      ///< Name of polynomial folder.
    1118     ...                                ///< Arguments for name formatting.
    1119 );
    1120 
    1121 /** Allocates a new psPolynomial3D structure with information from a psMetadata.
    1122  *
    1123  *  Parses a psMetadata container with psPolynomial3D information.  The first three
    1124  *  elements of the metadata folder specify the order of the x, y, & z variables.  (ie,
    1125  *  NORDER_X, NORDER_Y, NORDER_Z).  The following elements are the values of the
    1126  *  coefficients and the coefficient errors.  (ie, VAL_X00_Y00_Z00, ERR_X00_Y00_Z00,
    1127  *  etc.).  If the orders or any coefficients are missing or have incorrect syntax,
    1128  *  NULL is returned.
    1129  *
    1130  *  @return psPolynomial3D*:        Newly allocated psPolynomial3D from metadata.
    1131  */
    1132 psPolynomial3D *psPolynomial3DfromMetadata(
    1133     const psMetadata *folder                 ///< folder containing the polynomial info.
    1134 );
    1135 
    1136 /** Stores the information from a psPolynomial3D structure in a psMetadata container.
    1137  *
    1138  *  Creates a psMetadata folder with psPolynomial3D information.  The first three
    1139  *  elements of the metadata folder specify the order of the x, y, & z variables.  (ie,
    1140  *  NORDER_X, NORDER_Y, NORDER_Z).  The following elements are the values of the
    1141  *  coefficients and the coefficient errors.  (ie, VAL_X00_Y00_Z00, ERR_X00_Y00_Z00,
    1142  *  etc.).  The input polynomial must be of ordinary type and have a valid name format.
    1143  *  False is also returned if any inputs are NULL.  *If a particular mask element is
    1144  *  non-zero, that polynomial coefficient (and error) are skipped.
    1145  *
    1146  *  @return bool:       True if successful, otherwise false.
    1147  */
    1148 bool psPolynomial3DtoMetadata(
    1149     psMetadata *md,                    ///< Metadata container for polynomial storage.
    1150     const psPolynomial3D *poly,              ///< Polynomial information to be stored.
    1151     const char *format,                      ///< Name of polynomial folder.
    1152     ...                                ///< Arguments for name formatting.
    1153 );
    1154 
    1155 /** Allocates a new psPolynomial4D structure with information from a psMetadata.
    1156  *
    1157  *  Parses a psMetadata container with psPolynomial4D information.  The first four
    1158  *  elements of the metadata folder specify the order of the x, y, z, & t variables.
    1159  *  (ie, NORDER_X, NORDER_Y, NORDER_Z, NORDER_T).  The following elements are the
    1160  *  values of the coefficients and the coefficient errors.  (ie, VAL_X00_Y00_Z00_T00,
    1161  *  ERR_X00_Y00_Z00_T00, etc.).  If the orders or any coefficients are missing or
    1162  *  have incorrect syntax, NULL is returned.
    1163  *
    1164  *  @return psPolynomial4D*:        Newly allocated psPolynomial4D from metadata.
    1165  */
    1166 psPolynomial4D *psPolynomial4DfromMetadata(
    1167     const psMetadata *folder                 ///< folder containing the polynomial info.
    1168 );
    1169 
    1170 /** Stores the information from a psPolynomial4D structure in a psMetadata container.
    1171  *
    1172  *  Creates a psMetadata folder with psPolynomial4D information.  The first four
    1173  *  elements of the metadata folder specify the order of the x, y, z, & t variables.
    1174  *  (ie, NORDER_X, NORDER_Y, NORDER_Z, NORDER_T).  The following elements are the values
    1175  *  of the coefficients and the coefficient errors.  (ie, VAL_X00_Y00_Z00_T00,
    1176  *  ERR_X00_Y00_Z00_T00, etc.).  The input polynomial must be of ordinary type and have
    1177  *  a valid name format.  False is also returned if any inputs are NULL.  *If a particular
    1178  *  mask element is non-zero, that polynomial coefficient (and error) are skipped.
    1179  *
    1180  *  @return bool:       True if successful, otherwise false.
    1181  */
    1182 bool psPolynomial4DtoMetadata(
    1183     psMetadata *md,                    ///< Metadata container for polynomial storage.
    1184     const psPolynomial4D *poly,              ///< Polynomial information to be stored.
    1185     const char *format,                      ///< Name of polynomial folder.
    1186     ...                                ///< Arguments for name formatting.
    1187 );
    11881055
    11891056
Note: See TracChangeset for help on using the changeset viewer.