Created
July 13, 2011 09:28
-
-
Save jfburkhart/1079991 to your computer and use it in GitHub Desktop.
concatenation to fill a dict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_dups(x, y, z): | |
""" | |
## for regridding need to remove any duplicates | |
## First make sure there is enough data | |
""" | |
if len(z) > 10: | |
vals = zip(x, y, z) | |
vals.sort() | |
z0 = zip(x, y) | |
dummy = {} | |
for i, a in enumerate(vals): | |
if z0[i] not in dummy: | |
dummy.setdefault((a[0], a[1], a[2])) | |
#pdb.set_trace() | |
x = [] | |
y = [] | |
z = [] | |
for tmp in dummy: | |
x.append(tmp[0]) | |
y.append(tmp[1]) | |
z.append(dummy[tmp]) | |
x = np.array(x) | |
y = np.array(y) | |
z = np.array(z) | |
else: | |
raise Warning, "Not enough data to remove dups" | |
return x, y, z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
improved per bignose suggestions:
def remove_dups(original_sequence):
"""
## for regridding need to remove any duplicates