[Numpy-discussion] Appending/combining masked arrays
Gökhan Sever
gokhansever at gmail.com
Wed Sep 29 17:01:57 EDT 2010
Hello,
Consider these two simple masked arrays:
I[188]: a = np.ma.masked_equal([1,2,3], value=2)
I[189]: b = np.ma.masked_equal([4,3,2], value=2)
An operation like this voids the mask:
I[190]: np.append(a,b)
O[190]:
masked_array(data = [1 2 3 4 3 2],
mask = False,
fill_value = 999999)
In my real use case I have two lists (shown simplified versions):
I[193]: all_measured[5::14][1:]
O[193]:
[masked_array(data = [425.82268 441.8043 432.69865 433.75158 420.42552
469.73359 483.80741
427.66887 466.7487 452.64255 438.14488 428.38871 416.38598 432.92884
440.74705 415.00694 430.1807 446.02079 428.1408 428.21708 461.37897
453.43518 433.90081 426.88591 451.15683 426.07399 410.7971 455.19179
389.01905 485.69204 505.35355 523.30598 502.00168 491.85421 485.75839
473.37061 459.24917 438.47531 424.09222 411.82773 409.27676 366.24813
362.0136 385.61986 350.38855 357.10589 390.84878 390.53565 332.60864
368.45913],
mask = [False False False False False False False False
False False False False
False False False False False False False False False False False False
False False False False False False False False False False False False
False False False False False False False False False False False False
False False],
fill_value = 1e+20)
,
masked_array(data = [762.00897 756.79155 773.59503 757.97867
746.20204 752.0657],
mask = [False False False False False False],
fill_value = 1e+20)
]
I[194]: all_predicted[5::14][1:]
O[194]:
[masked_array(data = [601.587925396 615.382975948 637.565961135
662.845855035 630.180285797
910.714363555 886.048093691 912.616380221 1087.38406572 789.0075947
777.900831884 733.319025182 750.579326854 752.627618389 696.521605131
633.362074267 722.437789869 730.89750503 692.179530427 703.786215707
808.592649936 1006.89797524 818.839286207 767.260255009 787.622382926
831.332970348 949.016807581 783.981396594 643.768619685 654.417348215
681.516301642 753.577103851 654.092465489 628.484105951 691.461588689
800.901347497 630.894132084 610.977386345 512.926749811 653.74866061
587.915074604 531.106658494 562.265237436 606.32672755 563.281067561
546.715211886 604.210379352 475.66452212 454.426293217 656.039874394],
mask = [False False False False False False False False
False False False False
False False False False False False False False False False False False
False False False False False False False False False False False False
False False False False False False False False False False False False
False False],
fill_value = 1e+20)
,
masked_array(data = [891.251806903 833.185882945 840.250000752
831.649215796 883.534378034
841.970022166],
mask = [False False False False False False],
fill_value = 1e+20)
]
These lists have 42 varying size masked arrays in each. I want to be
able to combine each list in one array --preferably in a masked array
for not losing the mask information so that I can perform some overall
statistics.
What is the way to solve this issue?
Thanks
--
Gökhan
More information about the NumPy-Discussion
mailing list