0

I'll be honest, not sure that the title covers the complete topic.

I'm not a python programmer but we received a library that returns a 3D numpy array.

The values are temperatures in a wall. But sometimes some sensors are out of order or malfunctioning, this library build for us handles these problems. We provide the routine sets of data. The first one is a table with x,y coordinates and the inside temperature, the second one just the same x,y and outside temperatures.

The function returns a 3D numpy array.

The most outer array has a size of 3. with the indexs 0 = internal temperature, 1 = corrected internal temperature, 2 = outside temperature.

Inside we find a array that holds the x array of the y array values.

So getting lists out of that array works with (where insidetemp=0, outsidetemp=2)

insideTemperatureList = temperatureData[INSIDETEMP, 0,:]
outsideTemperatureList = temperatureData[OUTSIDETEMP, 0,:]

Final question .. I would like to get this in a array like this (° sign just to clarify)

[type-temp, x-coord, y-coord, temp]

[[0,0,0,15°],[0,0,1,16°],[0,0,2,90°] .... [1,0,2,16°] ... [2,10,10,-3°]]

Anybody could help me out ?

1 Answer 1

1

To create the test array, of shape 3 layers by (4, 4), I started with individual "layers":

inside  = np.arange(41, 57, dtype=int).reshape(4,4)
corr    = np.arange(21, 37, dtype=int).reshape(4,4)
outside = np.arange( 1, 17, dtype=int).reshape(4,4)
# Layer indices
INSIDETEMP = 0; CORRTEMP = 1; OUTSIDETEMP = 2

and created temperatureData as:

temperatureData = np.stack([inside, corr, outside])

To print the "outside" layer alone, you can run:

temperatureData[OUTSIDETEMP]

And to get your expected result, run the following one-liner:

result = np.array([ idx + (x,) for idx, x in np.ndenumerate(temperatureData) ])

The initial part of the result (the whole inside layer and the first row of corrected layer is:

array([[ 0,  0,  0, 41],
       [ 0,  0,  1, 42],
       [ 0,  0,  2, 43],
       [ 0,  0,  3, 44],
       [ 0,  1,  0, 45],
       [ 0,  1,  1, 46],
       [ 0,  1,  2, 47],
       [ 0,  1,  3, 48],
       [ 0,  2,  0, 49],
       [ 0,  2,  1, 50],
       [ 0,  2,  2, 51],
       [ 0,  2,  3, 52],
       [ 0,  3,  0, 53],
       [ 0,  3,  1, 54],
       [ 0,  3,  2, 55],
       [ 0,  3,  3, 56],
       [ 1,  0,  0, 21],
       [ 1,  0,  1, 22],
       [ 1,  0,  2, 23],
       [ 1,  0,  3, 24],
Sign up to request clarification or add additional context in comments.

1 Comment

Much appreciated !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.