Permalink
Browse files

Fixed bug in XWrap

  • Loading branch information...
1 parent 5da3a29 commit 71532e06aa1092fa827627fda4e04b1cfa9ca2df @petigura committed Sep 25, 2012
Showing with 9 additions and 7 deletions.
  1. +5 −2 FFA.py
  2. +4 −5 FFA_cy.pyx
View
7 FFA.py
@@ -155,7 +155,7 @@ def FFAShiftAdd(XW0,stage):
return XW
-def XWrap(x,Pcad0,rem,fill_value=0,pow2=False):
+def XWrap(x,Pcad,fill_value=0,pow2=False):
"""
Extend and wrap array.
@@ -178,7 +178,10 @@ def XWrap(x,Pcad0,rem,fill_value=0,pow2=False):
ncad = x.size # Number of cadences
# for some reason np.ceil(ncad/Pcad0) doesn't work!
+ Pcad0 = np.floor(Pcad)
nrow = int( np.floor(ncad/Pcad0) +1 )
+ rem = np.round(nrow * (Pcad - Pcad0))
+
nExtend = nrow * Pcad0 - ncad # Pad out remainder of array with 0s.
if type(x) is np.ma.core.MaskedArray:
@@ -263,7 +266,7 @@ def remShuffle(shape,rem):
"""
nrow,ncol = shape
- assert (rem >= 0) & (rem<=ncol), 'rem must be >= 0 and <= ncol '
+ assert (rem >= 0) & (rem<=nrow), 'rem must be >= 0 and <= ncol '
irow,icol = np.mgrid[0:nrow,0:ncol]
colshift = np.linspace(0,rem,nrow)
View
@@ -175,7 +175,7 @@ def FFAShiftAdd(cnp.ndarray[cnp.float64_t, ndim=2] XW0,
return XW
-def XWrap(x,Pcad0,rem,fill_value=0,pow2=False):
+def XWrap(x,Pcad,fill_value=0):
"""
Extend and wrap array.
@@ -184,11 +184,8 @@ def XWrap(x,Pcad0,rem,fill_value=0,pow2=False):
Parameters
----------
-
x : input
- Pcad0 : Base period
- rem : The actual period can be longer by rem/nrow
- pow2 : If true, pad out nRows so that it's the next power of 2.
+ Pcad : Period to fold on. Can be non-integer, only accurate to 1./Pcad0
Return
------
@@ -198,7 +195,9 @@ def XWrap(x,Pcad0,rem,fill_value=0,pow2=False):
ncad = x.size # Number of cadences
# for some reason np.ceil(ncad/Pcad0) doesn't work!
+ Pcad0 = np.floor(Pcad)
nrow = int( np.floor(ncad/Pcad0) +1 )
+ rem = int(np.round(Pcad0 * (Pcad-Pcad0) ))
nExtend = nrow * Pcad0 - ncad # Pad out remainder of array with 0s.
if type(x) is np.ma.core.MaskedArray:

0 comments on commit 71532e0

Please sign in to comment.