Note that there are some explanatory texts on larger screens.

plurals
  1. POcalculating mean of several numpy masked arrays (masked_all)
    primarykey
    data
    text
    <p>first of all I'm new to python and programming but you guys already helped me a lot, so thanks a lot! But I've come to a problem I haven't found an answer so far:</p> <p>I have the data of several plates where the data represents the pressure on each plate at a large number of different spots. The thing is, these plates aren't perfectly round because of the sensors measuring the pressure and sometimes these sensors even produce an error so I don't have any data at a spot within the plate.</p> <p>When I just have to plot one plate, I'll do it like that:</p> <pre><code>import numpy.ma as ma matrix=ma.masked_all((160,65),float) for x in range(len(plate.X)): matrix[(plate.Y[x],plate.X[x])]=data.index(plate.measurementname[x]) image.pcolormesh(matrix,min,max) </code></pre> <p>This works fine. Now that I have several plates I'd like to plot the mean pressure on each spot. Because I don't know any mean function, I thought of adding all plates together and divide by the number of plates...I tried following:</p> <pre><code>import numpy.ma as ma meanmatrix=ma.masked_all((160,65),float) for plate in plateslist: matrix=ma.masked_all((160,65),float) for x in range(len(plate.X)): matrix[(plate.Y[x],plate.X[x])]=data.index(plate.measurementname[x]) meanmatrix+=matrix meanmatrix=meanmatrix/len(plateslist) image.pcolormesh(meanmatrix,min,max) </code></pre> <p>This works pretty good but there's one problem I can't solve. As I said sometimes some plates didn't get all data, therefore there's a "hole" at some spots in the plot. Now my meanmatrix has a whole where ever one of the plates had a whole even if all others had data at that spot.</p> <p>How can I make sure I won't get these holes or is there even a smoother way of getting my "meanmatrix"?? (I hope my question is clear enough...)</p> <p>Edit:</p> <p>The problem is not that I don't get the mean of the data, this actually works (well I don't like how I did it but it works), the problem is that I get these "holes" I described before. That's what bothers me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload