Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 30078)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 30595)
@@ -67,5 +67,8 @@
 }
 
-psKernel *psKernelAlloc(int xMin, int xMax, int yMin, int yMax)
+psKernel *p_psKernelAlloc(const char *file,
+			  unsigned int lineno,
+			  const char *func,
+			  int xMin, int xMax, int yMin, int yMax)
 {
     // Check the inputs to make sure max > min; if not, switch.
@@ -91,5 +94,5 @@
     int numCols = xMax - xMin + 1;      // Number of columns for kernel image
 
-    psKernel *kernel = psAlloc(sizeof(psKernel)); // The kernel, to be returned
+    psKernel *kernel = p_psAlloc(file, lineno, func, sizeof(psKernel)); // The kernel, to be returned
     psMemSetDeallocator(kernel,(psFreeFunc)kernelFree);
 
@@ -272,7 +275,9 @@
     float threshold = sumKernel * (1.0 - frac); // Threshold for truncation
 
+    int truncateRadius = maxSize;	// Truncation radius
+    bool truncate = false;
+
     // Find truncation size
-    int truncate = 0;                     // Truncation radius
-    for (int radius = 1; truncate == 0 && radius < maxSize; radius++) {
+    for (int radius = 1; !truncate && (radius < maxSize); radius++) {
         int uMin = PS_MAX(-radius, xMin);
         int uMax = PS_MIN(radius, xMax);
@@ -290,11 +295,13 @@
             }
         }
+	// This is the truncation radius
         if (sum > threshold) {
-            // This is the truncation radius
-            truncate = radius;
-        }
-    }
-    if (truncate == maxSize) {
-        // No truncation possible
+	    truncate = true;
+            truncateRadius = radius;
+        }
+    }
+
+    // Do nothing if no truncation is possible
+    if (!truncate) {
         return true;
     }
@@ -302,9 +309,9 @@
     // Truncate the kernel
     {
-        int uMin = PS_MAX(-truncate, xMin);
-        int uMax = PS_MIN(truncate, xMax);
-        int vMin = PS_MAX(-truncate, yMin);
-        int vMax = PS_MIN(truncate, yMax);
-        int r2 = PS_SQR(truncate);
+        int uMin = PS_MAX(-truncateRadius, xMin);
+        int uMax = PS_MIN(truncateRadius, xMax);
+        int vMin = PS_MAX(-truncateRadius, yMin);
+        int vMax = PS_MIN(truncateRadius, yMax);
+        int r2 = PS_SQR(truncateRadius);
         for (int v = vMin; v <= vMax; v++) {
             int v2 = PS_SQR(v);
@@ -317,8 +324,8 @@
         }
     }
-    kernel->xMin = PS_MAX(-truncate, kernel->xMin);
-    kernel->xMax = PS_MIN(truncate, kernel->xMax);
-    kernel->yMin = PS_MAX(-truncate, kernel->yMin);
-    kernel->yMax = PS_MIN(truncate, kernel->yMax);
+    kernel->xMin = PS_MAX(-truncateRadius, kernel->xMin);
+    kernel->xMax = PS_MIN(truncateRadius, kernel->xMax);
+    kernel->yMin = PS_MAX(-truncateRadius, kernel->yMin);
+    kernel->yMax = PS_MIN(truncateRadius, kernel->yMax);
 
     return true;
Index: trunk/psLib/src/imageops/psImageConvolve.h
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.h	(revision 30078)
+++ trunk/psLib/src/imageops/psImageConvolve.h	(revision 30595)
@@ -84,4 +84,5 @@
 /// @return psKernel*          A new kernel object
 ///
+#ifdef DOXYGEN
 psKernel *psKernelAlloc(
     int xMin,                          ///< Most negative x index
@@ -89,5 +90,18 @@
     int yMin,                          ///< Most negative y index
     int yMax                           ///< Most positive y index
+);
+#else // ifdef DOXYGEN
+psKernel *p_psKernelAlloc(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    int xMin,                          ///< Most negative x index
+    int xMax,                          ///< Most positive x index
+    int yMin,                          ///< Most negative y index
+    int yMax                           ///< Most positive y index
 ) PS_ATTR_MALLOC;
+#define psKernelAlloc(xMin, xMax, yMin, yMax)				\
+    p_psKernelAlloc(__FILE__, __LINE__, __func__, (xMin), (xMax), (yMin), (yMax))
+#endif // ifdef DOXYGEN
 
 /// Allocate a convolution kernel from a provided image
Index: trunk/psLib/src/imageops/psImageCovariance.c
===================================================================
--- trunk/psLib/src/imageops/psImageCovariance.c	(revision 30078)
+++ trunk/psLib/src/imageops/psImageCovariance.c	(revision 30595)
@@ -30,4 +30,15 @@
     return covar;
 }
+
+/** 
+
+ * changes from 28666
+ ** add scale to imageCovarianceCalculate (& multiply at return)
+ ** add scale to imageCovarianceCalculateThread
+
+ ** accumulate scale (sum kernel^2) in psImageCovarianceCalculate and pass to imageCovarianceCalculate
+ ** accumulate scale (sum kernel^2) in psImageCovarianceCalculateFactor and pass to imageCovarianceCalculate
+
+ **/
 
 /// Calculation of covariance matrix element when convolving
Index: trunk/psLib/src/sys/psLogMsg.c
===================================================================
--- trunk/psLib/src/sys/psLogMsg.c	(revision 30078)
+++ trunk/psLib/src/sys/psLogMsg.c	(revision 30595)
@@ -291,10 +291,11 @@
         head_ptr += strlen(head_ptr);
     }
-    // Hostname should be 20 characters.
+
+    // Hostname should be 10 characters.
     if (logHost) {
         if (head_ptr > head) {
             *head_ptr++ = '|';
         }
-        maxLength -= snprintf(head_ptr, maxLength, "%-20s", hostname);
+        maxLength -= snprintf(head_ptr, maxLength, " %s ", hostname);
         head_ptr += strlen(head_ptr);
     }
@@ -310,12 +311,15 @@
             *head_ptr++ = '|';
         }
-        maxLength -= snprintf(head_ptr, maxLength, "%s", name);
+        maxLength -= snprintf(head_ptr, maxLength, "%s|\n", name);
 
         head_ptr += strlen(head_ptr);
-    }
-
-    if (head_ptr > head) {
-        *head_ptr++ = '\n';
-    } else if (!logMsg) {                  // no output desired
+    } else {
+      if (head_ptr > head) {
+	*head_ptr++ = '|';
+      }
+    }
+
+    // rather than putting in a return for the message, let's only put in the return if we asked for the function name
+    if ((head_ptr == head) && !logMsg) { // no output desired
         return;
     }
@@ -332,5 +336,5 @@
         char *line = strtok_r(msg, "\n", &msgPtr);
         while (line) {
-            if(write(logFD, "    ", 4)) {;} // ignore return value
+            if(write(logFD, "          ", PS_MIN(2*level, 10))) {;} // ignore return value
             if(write(logFD, line, strlen(line))) {;} // ignore return value
             if(write(logFD, "\n", 1)) {;} // ignore return value
Index: trunk/psLib/src/sys/psMemory.c
===================================================================
--- trunk/psLib/src/sys/psMemory.c	(revision 30078)
+++ trunk/psLib/src/sys/psMemory.c	(revision 30595)
@@ -626,5 +626,6 @@
             nleak++;
 
-            if (fd != NULL) {
+	    // only print a max of 500 leaks (make this an argument)
+            if ((nleak < 500) && (fd != NULL)) {
                 if (nleak == 1) {
                     fprintf(fd, "# func at (file:line)  ID: X  Ref: X\n");
Index: trunk/psLib/test/imageops/Makefile.am
===================================================================
--- trunk/psLib/test/imageops/Makefile.am	(revision 30078)
+++ trunk/psLib/test/imageops/Makefile.am	(revision 30595)
@@ -26,5 +26,6 @@
 	tap_psImageMapFit \
 	tap_psImageMapFit2 \
-	tap_psImageMaskOps
+	tap_psImageMaskOps \
+	tap_psImageCovariance
 
 #	tap_psImageShiftKernel
Index: trunk/psLib/test/imageops/samples/conv.sample1.001.fits
===================================================================
--- trunk/psLib/test/imageops/samples/conv.sample1.001.fits	(revision 30595)
+++ trunk/psLib/test/imageops/samples/conv.sample1.001.fits	(revision 30595)
@@ -0,0 +1,140 @@
+SIMPLE  =                    T / file does conform to FITS standard             BITPIX  =                  -32 / number of bits per data pixel                  NAXIS   =                    2 / number of data axes                            NAXIS1  =                   37 / length of data axis 1                          NAXIS2  =                   37 / length of data axis 2                          EXTEND  =                    T / FITS dataset may contain extensions            COMMENT   FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H BZERO   =   0.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          BSCALE  =   1.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             .I­.ÍpÇ/:01/r0ÓÀÓ1m²1ú¬ô2xmŒ2çmR3J¶?3§î4uP4<çJ4ÃÑ4§êA4Ì¶Ç4ë6K4þÃ5ù4ú4ã4Âó³4}Q4oï4,P@3éH
+3ÌZ32Ïµ2ÊXä2W1Ø¬1KÄp0ŽŽD0§/l¯.­ÑB-ðk.Ëô/Ôð0Fqî0ûÉx1ü2'Ò¬2°ge3.<ð3¡ÄA4
+7ô4gëš4³3.5X52¬5fz
+5.¬5 ÆL5­æ÷5±r5ªÕ·52H5
+
+š5W95$<4ìjî4 rØ4MGü3÷xÂ3~Ó30Œ292 ó1~¶0Ôù?0'tª/wf.«§/.r0Dñ÷1­º1§Í/2G>2Þ)®3h¯3äû4SÌŸ4ž4B5²;5h	Q5š0æ5å¬X6È«63Pa6M9i6]¢6aìÒ6YmM6EG6)
+Á6	S­5Ò,5
+5NRû5n4 ;=46¡Ø3Äü3Eü2Œ!L2(10É0ÞÝ*0%: /fï0-8Ÿ0÷ë¢1ŠyÊ2QÒ2ø=ž3àQ4×.4û5Ý5`ñ5·B
+6
+N6Jä'6Ö6±6Ö$·6ô}7ÇT7-C7t6ê©$6Ék6£È6zÆ
+65¿5÷ù5ÉO5B"Ü4Þ>P4oà3ó©3h<2Ð82/Ü1+à0Ï(0Ãx0Í\1{£2D
+«2ö093Þ4 }É4Šžv5"®£5+T6 %6PÓ6&06äÅ7ô7Eõ7nšZ7Ú7"
+7
+7àè7îÊ7_
+75Æ
+7
+Ÿé6Ër6@µ64E­5Ü5}2¶5	*{4Þ­4(
+3qñ82Í32#)í1sà¢0«¥1d¢Š2"2ØŒô364Ò4¯>.553æ5¯ô¶6 œ6©m6Þ&7(è7qÿ7¢zÚ7Î7øK8
+À8É8SB8Y 8Ç7ç 7Œ\Î7Qð7T7!6Ÿ-,6iuì65*5çÉ44è¬3`Š2³¢³2Ö·1=÷
+1ï
+\2©cZ3a¢4
+*w4£É,53v5žŒ62o6¡â'7
+·7]T77§?7ígG888I98pvª8à8Zœ8Kÿ8xå8Ñ*8^c~85ëâ8
+ò7Î¯Ä7Fè7;/6çÊÈ6ö`6 B5µD5%"4
+®3ç539Í:2
+Ð1Æ=°2k .3%Þ
+3ÛzF4 Î5
+Tç5¬µŽ60ŒK6©ºU7
+è7¥\7Î8Â8Z|8nL8¶Ë{8Ù5*8ôO959šy8üº€8æT8ÇO>8£®_8~ð¶8<
+8C(7­ !7WyÙ6üÆ?6Ü6\5ž5ß4_Q3Ž€î3á2BÃ2ÙP3«­4I2o4øyX5Í66
+Z6Á
+7~7µ?7äJ84tŽ80
+8»óÐ8øH
+9å³96ÛÔ9L%9Y'9[	9RX9?©9&@9	+
+8Öø8¿ó8`Ìd87»©47]ûØ6÷$6Y·5þcB5jÒÎ4Ë_î4%0\3{ì2³º3< œ4&4­oe5U7N5õŽ6|Ÿ7ûU7~
+
+7áç-8<â8É8Ùß
+9:õ9F
+w9u09Æk9 9©<H9ª:9¢ýX9¯ý9Ne9VY9)ø8ýzw8Ž	o8qÒä8AJ7¶üì7MÊ6ØèØ6Væœ5ÇŒw5.
+4,€3Ù¡3
+
+Ô31i4W>þ5
+ª 5¬"u6E;6Ó7Tš7È3Œ80Š:8-?8ã9%Ë{9dŽ9m9¶M_9ÕLè9ítÐ9ûJ	9üq9ðÇP9Úì9œdÏ9Â9xö®9<'È9	·8·gþ8ká8
+Æ~7 Æž7++$6ªíÇ6ÿ75QN4æ
+41Rx3nÀ3íKà4¥5VÐ,6Öu6%À7m7Ú8w48ïÚ8Õ
+:9#ð
+9m9¡Â9Ñ :ÈÎ:3:/:<$Ž:=¶:3
+º:I±:æž9ÛåØ9­.Z9N¬9><®9¶=8©ô8NÖ7ìøš7~7 *R6qª5ÕI50-ß403Å©4+÷È4î[?5Ô6;g£6Ô7aw
+7ßŠ8O}J8Ž9Qº9^÷9ý·9ÚAX: ê:8Ø>:h4=:Y:t:Xü:Î:z$Q:GæG:÷T9é\¡9®M39}Ö9/ŠÈ8æ8[{8$Öó7²ÅD75r6¬GÒ6ü5~²4ÅTç4S4jÝÊ5"> 5Ñð6} Ò7Þ7·*8p8Õ8ëŠ9=¯9]h9ÍpÁ:Šp:E÷t:#É:ÀzC:ø;};êÖ;œM:ÛŸé:£-0:d £:
+²p9àÌ>9 yè9_£9i8¹aÌ8Xïê7ínV7rád6è(ì6OXŠ5­
+W5õB4DÄÈ45n5PL÷6'6¡Wè75Uß7ŸT8:48ª®9»×9hÓø9¯(î9ý:8gŸ:Î::Þr2;(r;dÒª;xÔ;td;|Çþ;GJ`;
+l:µuÎ:`¶:eo9Ä9Âæ95xž8åe8\Å8i7ðb7È6ãb5ÞÄ
+5.bB4%4·ŠT5|]F6"p6ÂH7Y17ãQA8]t8É9*òÇ9³ì9Ì;8:bg:lì:Éñê;/»x;0ò;ÑÐ<â<,ª;<
+ÎU;¶¯·;k;€:¢.::&F9êÓž9/$9S³Ô9ž|8 É82ž7¹r72ÞÒ6¡?}6¢ 5Tüê4(²4Ò|Þ5V68æø6Ý(²7vß8 .8yø8áÒ9>9û9ãš~:.6þ:Ú8;	;|ñÖ;ÝDe<aÃ<æ]={<Þ*'<Lº;»+ò;Pñ:ßØž:j» :qe9±pR9lt9F8µw`8Jåì7ÓIô7Lü66¹]Ô6
+S+5vq4Ž³ð4ã¿D5õ26Gxº6î&;7£ 8	ÄÚ8
+\w8ðú9J,9i
+9ò':>V&:©TÄ;&L©;~< I<á
+    œ1bz    <Öa8<
+F";)¯;
+1::»
+9¿EP9}Zn9"S8Ãµ8[Û7åL7^öT6Éþ6*Õ5i4Å©
+4è³65;z6K}c6ò·708
+8e8óÄ9L
+È9¡ö9ôð>:BHÐ:¯ÅA;.Å~;š ù<7G°=
+5œF
+£>6lPœDØ=	¿<($n; Ë;ÒG:ºQ:
+bV9Å839A9'88Éª8brß7ìª47fCá6Ðµ360Vv5÷
+4Ìf4àe5š6D[&6ê3t7KÂ8+â8ª8ëI»9Emò9Y]9ë]Þ:8>Î:¢Ÿ;
+î;¹v<1«<ÑH    œL[     <ÐóA<
+oi;ý;
+Ó°:c}:Ó\9Áø¯9|.9$Ò 8Æoå8^~7èOÚ7aÊV6ÌvŒ6,5ï 4ÇÑn4Ì²þ5',63<6Õú7n[7÷Ñ8oÄÖ8ØQ!95é9A;9×:#Ëð:jÒ:ú;a\Î;ÁAõ<Ey<ËµQ='<Î
+E<DS;¹Á;S}N:ä€:pj:
+â9¶B9sá9x8ºm$8PPÎ7ØÄ}7R Ú6œÛv6ú<5{4ž [4°=]5qŠh6Áº6¹7N¡7×9A8Q8œXF9êé9|¥v9œÖ:
+Ã:Vmb:³1â;Æz;mi;®dw;ý¯<í±;þù;­€_;hÄ;¯Y:Š€
+:@GJ9óFæ9€9f9\
+9
+«8Šì89y7ÀØ79tD6Šÿ%6
+O
+5\Ö4¡.w4K5DÛ«5ü¶6ò7)±7±j$8-
+ú8¡n9õ»9TÜ919äÄå:$ï:vóÃ:ŸzŸ;
+Ûõ;<ž÷;bÊk;rÖT;cô¥;=Qe;
+:žEP:g`-:Ð×9Ìÿß9x9>[±8ð
+¶8$b8
+Ñ7¡mÐ7É65èÀÎ55õ4ä»4[þJ5}r5Ã	>6j­ï7íõ78ù8y@8ÕrÔ9*öb99·9üzâ:-[:p
+:£¡:Ñâ1:õ§4;Å:ö :Ò:¡l:gÊÙ:#RÒ9é²b9šW9kk§9
+ŸH8Ä#f8e­³7ûYª7z6õ_Þ6Zâ}5¶lá5­4NÙ4` 4Ü%æ53u6+ÈÎ6Â	7Léš7ÊT#8:Ð¢8¡[œ9{_9Eñ9uõ9ÀB·9ü
+t:!n:J q:rÆL::êP:Í":pé:F	:Éd9ïÞb9µPp9Ð998ôŽ+8v8/ 7ŸN7A]ž6·x"6"Á~5þ4Ñbõ4Ü¡3ÙÖ~4õ95CÄ5íë6ÕŸ7:l7aV8~$8fðª8ŒŠ×9€E9P¬ 959žI9ä« :fé:
+Ê:*:.ð :)9¯:Mx:²E9Þ3j9±Ðn99GÝ`9
+]I8ŽgÐ8\çŒ7ý£ò7i67	_š6z>5äb5<u#4^3Ò83^ø4CB¬4þEI5ýP60æ*6œ7=@Ò7±8
+Þ8Íe8Ç°l9ªÉ9Hxz9u9¡ç9Ÿum9Ö`P9æ4]9ëv9å.89Ôi¬9»Ëö9³9_9C\9
+ÛÛ8ÂEd8z}8ÄÜ7¬è78š6žÄ6,G5
+j4÷÷
+4>Ÿ3Ÿ3*|\3îŸ4­5>¶V5ÚÞr6k]6í>ð7`C67Æíj8%¹8Îß8¿x9929/,89ZKô90ë99)º9¿q9Éo9ÑÕ9F÷9XOP9-I$9þ8ŒûÊ8
+8#g67Äâ7]^6éã^6hr5×Úú5<#"4A3êÿ3(WÍ2Ã3¶[434Ýü5! 6
+6%7dï7nF7È*8
+y8lA 8Šþ8Üz9
+?9%7~9;9Ip¡9Nl 9IZ89:ê9%H9
+[n8Ü
+ 8¥Š8k®®8
+-
+7È7mñx7¥6­ì6	£Á5~o4ÜÎ43
+3[š2ÂÜ2R
+Ê3Ó3Ã
+s4qMX5
+ùú5X6ø6>P7}p7cìÁ7µÇô8Ð8A°ß8·ó8€]m8ÅHZ8àÜ8ò±8ùž8òõ-8á8Åæ8¥/8Vs8Bœ48	j
+7¶îq7eoI7h6H&6
+³µ5jä5
+õ
+4rúh3Äd3ÓB2SpÕ1ÔÛÚ2g<3GQÉ3÷Â84x~5
+ ¢5¢ê6
+áS6\J6ó	7CO7ço7ÓP*8¡85Õ8[Ò8zþ:8Ä8Ôû8U
+8|8\çð87U¥8÷7ÕŽ
+7À97EîÇ6ö{6t6?§5€þô5 k4µ$3ûÚ3J_$2®w1Ø
+81JáH2éÐ2¿3o+æ4
+("49œ5f
+5Ðq6
+`â6ró@6Ä 7Ø
+7W|17C7»7ã 898
+àŸ88O+8[
+7åÃ7œ¿7G7Zåð7{6ÈL6wÞ6^Š52*5"õ
+4·<4YÂ3t¡02Ãã 2*1Ol
+0µÊ1qš2,ú92Øô03wþ4
+B;4Ä5Uô5¥ž5ãp69/q6 š6ÍZ7
+
+T74o7[×©7}7Ãß7å7D	7~äA7^,c77
+¹7t06ÑP¬6'6=5éCj5
+5BÀ4åó4OD3pù2ßIó22	1
+8-0»(0@0ÚÍ.1ÃŽ28×2Ú3râx3ý84xæD4åÈf5G¡]5£M¥5û·66áñ6z«¿6¢#Ð6Æò6äÂ6ùA¥7 sÂ6úD×6æi
+6ÈlV6€š66f×6:ã]6 óÈ5§³'5Mf§4ìÍÐ4k%4÷Ã3{²2â
+¶2??x1á 0âoÌ0
+ià/r4g0-²00éá¬1ÛT2/@2Ãë§3Mu3ÊÁ4;äJ4£þM5Ã5P£ô57<5Ñm6èì6&zF6@76R7
+6XÈ§6S"
+6B.6(Z6
+1.5Õ·"5Øô5V@5
+À
+4©9·4BAô3ÑÈ#3UU2ËY%26cF1ª&0ó'à04d/{Þï.³òü/zO0.óL0Þ1T2<23°3ë¶3üC×4P"Ÿ4¡Œ}4ìÖÊ5#t®5TÀ(5Í5I>5¥a
+5ªK5Š#5©Ú5]-5XD5&þª4òÔø4Š]Ë4V¶ª4s	3,N3 xÊ2¢T²2\ô1ðF0ç062/0.»ìŠ-û.µ5/uŠõ0
+eØ0» 1RX²1ÞLõ2\êj2Î<35¥«3fð3ê.4,@Ï4nmV44¿UÑ4Ýö4òÝ
+4úŠä4ôž4à
+š4Ây4d/4sÉ40Ê¥3ñr3b,3</y2ÖvÀ2eèÂ1çÃµ1[ è0Ã0#§Û/ô.œÜ&.š                                                                                                                                                                                                                                                                                            
Index: trunk/psLib/test/imageops/samples/conv.sample1.002.fits
===================================================================
--- trunk/psLib/test/imageops/samples/conv.sample1.002.fits	(revision 30595)
+++ trunk/psLib/test/imageops/samples/conv.sample1.002.fits	(revision 30595)
@@ -0,0 +1,19 @@
+SIMPLE  =                    T / file does conform to FITS standard             BITPIX  =                  -32 / number of bits per data pixel                  NAXIS   =                    2 / number of data axes                            NAXIS1  =                   17 / length of data axis 1                          NAXIS2  =                   17 / length of data axis 2                          EXTEND  =                    T / FITS dataset may contain extensions            COMMENT   FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H BZERO   =   0.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          BSCALE  =   1.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             8ªï8ÿCé92åÇ9kïÛ9ÙÁ9¬óŽ9À9ÉðÈ9Æd9¶Z9u9œG9HÅr9È8ÕO8(R8;`8ûßØ9;) 9ú{9­ß9ÜÇ::
+F:)J:("B:9þr9ÇQ9¿9Zx9ãè8Ó^78¬9.!90±9¶z9úÒ:):`î:§B:¢	:€çª:¬m:g9:'.í9æF9Ñ9WêR97i8¿9bf9©!ù9ö:6µ:7ü:Î»
+;#,;*³t;/"w;H¿:ç¥:Âh:?wË9éöf9Qr9By8ýø
+9.9ÓÎ.:$+@:ì:êS";?Íx;:;©Yu;®ð;§;^/î;n:¥_:4Æ9ÍŽ9{ä9!jO9¡ø9þªò:VV:Ç_U;;ÍÇ; žË;ö2"<,ð<Aòr<1Æ;ÅŠ;pÜ;:Å:
+ª9Ãt9E²M9²U:êg:
+)4;tå;>%;ð=
+<r¬B<òŠk=]i<ÝÍ<J¢;¹÷ô;GJ::ÆÔS:=Ù9Ä€è9iBf9¹ø,:
+É®:ø;OÂ;¹<$1<èHF=FìDœé~=1FS<Ìæ<	e;Ïý:ÿh4:iá9åîð9È9¶R"::ø;#4T;€²<6¹Z=
+âœ0p>"œ@þ`=Z<'Ú;J};%Z:¯9ùöT9jX9š4Ÿ:Ì:Y;Û$;ô#<èÞ<Ó
+
+=*êMœ<¿"=+M<ÔŒd<âU;8ç;
+üo:~Öó9ùÁ9Oâ9±9ðgÆ:]GS:àò®;^	;Ì,Ê<S]*<×&Ó=5U<ß|ì<cX;à¿à;qôä:í
+@:]ï9æ0¬9'Î9s®9À5:$;?:Ñ;NÛ;2m;ÒÏ²<
+2'<@n<(;í x;:³;*ÿ+:­
+±:/sr9Ç
+9xè9AûÇ9.9é~R:G^":²s;Éf;ižà;%;°Vš;ŠëŒ;{&;2I:ÐÅ*:ehç:9€œ
+9VÛ±9O9^?j9€­©9ûÎÐ:Hùé:ÆÂ:ëþW;æ@;,Â;$8~;œØ:¹ÛÒ:m:èo9ÂÞ9Í$90QG8ÙMÈ9"'9hÖ9€³>9ê+8:&z:b$Š:ï«:jX:s:|Y±:@žò:
+°9ÈŒ9¥9Jô[9ü²8Û8ãÕc9"p59^YÜ9²9¿%9îEï:
+¹ú:°:Ú2:ÙÏ9ß$9³0N9+9PVh9²¶8È8IŸ8m8ÚŸ99AÚ:9qp¹9²9¢[59¬ªH9¬U9 ö9>+9nŸÜ9>q]9ôú8Í`¥8É¡                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Index: trunk/psLib/test/imageops/samples/incovar.sample1.001.fits
===================================================================
--- trunk/psLib/test/imageops/samples/incovar.sample1.001.fits	(revision 30595)
+++ trunk/psLib/test/imageops/samples/incovar.sample1.001.fits	(revision 30595)
@@ -0,0 +1,19 @@
+SIMPLE  =                    T / file does conform to FITS standard             BITPIX  =                  -32 / number of bits per data pixel                  NAXIS   =                    2 / number of data axes                            NAXIS1  =                   11 / length of data axis 1                          NAXIS2  =                   11 / length of data axis 2                          EXTEND  =                    T / FITS dataset may contain extensions            COMMENT   FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H BZERO   =   0.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          BSCALE  =   1.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             4¶×&7=ò¶µÛQž­æ9ºvÌÂž­æ:µÛ7=òŠ¶×4¶Õ©9.má¹±ç81¯ ;
+Ä?<ÇÐ;
+Ä?81¯ ¹±Û9.mÙ¶Õ©ó7<-G¹ :]$ž}L»wõ­œ/üg»wõ­ž}L:]¹ 7<.µÙ·81» ž75Ù:n;Ë
+:n75žp81ºðµÙžžªØ;
+Á|»t:
+YN<àA
+>@A<àA:
+YW»t
+;
+Áwžªºp`<ÃÇ,œ,~ø;Çph>KÂ?  >KÂ;Çphœ,~ê<ÃÇ$ºpdžªØ;
+Á|»t:
+YW<àA>@A<àA
+:
+YN»t
+;
+ÁwžªµÙ·81» žq75:n;Ë
+:n75Ùžx81ºðµÙž7<-8¹ú:]ž}@»wõœ/üY»wõž}@:]¹ô7<.¶Õ©9.mÙ¹±á81®ù;
+Ä9<ÇÏù;
+Ä981®ù¹±Õ9.mÒ¶Õ©ï4¢¶×7=óµÛž­æöºvÍËž­æôµÛ>7=ór¶×4&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Index: trunk/psLib/test/imageops/samples/incovar.sample1.002.fits
===================================================================
--- trunk/psLib/test/imageops/samples/incovar.sample1.002.fits	(revision 30595)
+++ trunk/psLib/test/imageops/samples/incovar.sample1.002.fits	(revision 30595)
@@ -0,0 +1,8 @@
+SIMPLE  =                    T / file does conform to FITS standard             BITPIX  =                  -32 / number of bits per data pixel                  NAXIS   =                    2 / number of data axes                            NAXIS1  =                   11 / length of data axis 1                          NAXIS2  =                   11 / length of data axis 2                          EXTEND  =                    T / FITS dataset may contain extensions            COMMENT   FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H BZERO   =   0.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          BSCALE  =   1.000000000000E+00 / Scaling: TRUE = BZERO + BSCALE * DISK          END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             4«¶ì7P-Ñµëå8žŒO³º}$žŒO²µëä'7P-Ñ¶ì§4««¶ì'94ù¹ì^84â;Ì<ÈÖ2;Ì84
+¹ì^94û¶ì(r7O×ê¹é:
+ßBž»}.œ0ÃÊ»}0žû:
+ßB¹é
+7OØ¿µë+84ïžj73¥a:p!;ÈU£:p!73€Xžl84ìµëXž»Qä;6n»|î:Ù<ä>à>nv<ä>à:Øø»|î;6qž»R¥º><Ç¬Dœ/À	;Ç+ >'c?  >'c;Ç*0œ/À	<Ç¬IºÄž»Qç;6m»|î:Ù<ä>à>nv<ä>à:Øõ»|î;6qž»R€µë84&žÈ73€:o;ÈTÔ:o73£ÆžÆ849µë$7O×ê¹é:
+ßBž»}0œ0ÃÊ»}.žä:
+ßB¹é
+7OØ¿¶ì'94ü¹ìa84ç;Ì	<ÈÖ6;Ì	84"¹ìa94ÿ¶ì(w4« ¶ì7P.€µëååžŒPqº}©žŒPrµëåZ7P.€¶ì4¬H                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Index: trunk/psLib/test/imageops/tap_psImageCovariance.c
===================================================================
--- trunk/psLib/test/imageops/tap_psImageCovariance.c	(revision 30595)
+++ trunk/psLib/test/imageops/tap_psImageCovariance.c	(revision 30595)
@@ -0,0 +1,70 @@
+/** @file  tap_psImageCovariance.c
+ *
+ *  @brief Contains the tests for psImageCovariance.[ch]
+ *
+ *  @version $Revision: 1.2 $
+ *  @date $Date: 2007-05-02 04:14:33 $
+ *
+ *  Copyright 2011 Institute for Astronomy, University of Hawaii
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <pslib.h>
+#include "tap.h"
+#include "pstap.h"
+
+psKernel *psKernelReadSimple(char *filename) {
+
+    psRegion region = {0, 0, 0, 0};
+
+    psFits *fits = psFitsOpen(filename, "r");
+    psFitsDumpErrors(0, "foo");
+    ok(fits, "opened FITS file");
+
+    psImage *image = psFitsReadImage(fits, region, 0);
+    psFitsDumpErrors(0, "foo");
+    ok(image, "read image from FITS file");
+
+    psFitsClose(fits);
+
+    int x0 = image->numCols / 2;
+    int y0 = image->numRows / 2;
+    psKernel *kernel = psKernelAllocFromImage(image, x0, y0);
+    ok(kernel, "allocated kernel from image");
+
+    psFree(image);
+
+    return kernel;
+}
+
+int main(int argc, char **argv) {
+
+    plan_tests(4);
+
+    // return null for null input image
+    {
+        psMemId id = psMemGetId();
+
+	// read in the kernel and the covariance matrix
+	psKernel *kernel = psKernelReadSimple("kernel.fits");
+        ok(kernel, "read kernel");
+
+	psKernel *inputCov = psKernelReadSimple("cov.input.fits");
+        ok(inputCov, "read input covariance");
+
+	psKernel *outputCov = psImageCovarianceCalculate(kernel, inputCov);
+        ok(outputCov, "calculated covariance");
+
+	psFits *fits = psFitsOpen("cov.output.fits", "w");
+	psFitsWriteImage(fits, NULL, outputCov->image, 0, NULL);
+	psFitsClose(fits);
+
+	psFree(kernel);
+        psFree(inputCov);
+        psFree(outputCov);
+        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
+    }
+}
+
+    
