[SciPy-User] sequence verification

eat e.antero.tammi at gmail.com
Tue Apr 12 15:34:26 EDT 2011


Hi Mike,

On Tue, Apr 12, 2011 at 9:35 PM, Michael T Tate <mttate at usgs.gov> wrote:

>
>
> I am working a QC method that checks to make sure a sequence is complete.
>
> The sequence is 12 - 0s followed by 3 - 1s, 4 - 2s, 3 - 3s and finally 3 -
> 1s. The sequence looks something like this:
>
> [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  1.  2.  2.  2. 2.
>  3.  3.  3.  1.  1. 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.
>  1.  2.  2.  2. 2.  3.  3.  3.  1.  1.]
>
> Generally, this sequence is followed except if the instrument is stopped
> for service or there is a power failure.
>
> I need the program to check if there are 12 zeros preceding the sequence
> beginning with 3 - 1s. Then need to check to make sure there are 3 - 3s
> followed by 4 - 2s, 3 - 3s and 2 - 1s. If this series breaks down, I want to
> delete the incomplete series.
>
> Any guidance on how to do this would be greatly appreciated.

Here is a slightly simplified example (using integers) to demonstrate how to
find out if your sequence is following some (strict) pattern.
In []: seq
Out[]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1])
In []: pat
Out[]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 1,
1])
In []: n= len(seq)/ len(pat) # obviously len(pat) must integer multiple of
len(seq)
In []: not any(seq- pat[None, :].repeat(n, axis= 0).ravel())
Out[]: True

Regards,
eat

>
>
> Thanks in advance,
>
> Mike
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110412/facba47b/attachment.html>


More information about the SciPy-User mailing list