0

I have a numpy.ndarray (data) that has 5 elements and each element has 2042 rows and two columns. The first column contains dates (on 15-minute intervals) and the second contains temperatures. I am working a script that will find the max temperature in a 24-hour period. I have a working script for that.

x1=0
y1=95
maxTblue=[] 

for i in range(int(len(data[0])/96)+1):
    #collect the max temp for 24-hr period
    maxTblue.append(max(data[0][x1:y1,1]))
    #add 96 to shift to the next 24-hr period
    x1+=96
    y1+=96

Now, I want to be able to collect the date where the max temperature occurs for each 24-hour period. I tried the following script but it's giving me the wrong dates. The dates should increase by 24-hour periods, but the current script is returning dates from the first 24-hour period.

maxdateBlue=[]
locblue=[]
x3=0
y3=95
for i in range(int(len(data[0])/96)+1):
    #index for the max temp 
    locblue.append(np.where(data[0][x3:y3,1]==maxTblue[i]))
    #date where the max temp occurs
    maxdateBlue.append(data[0][locblue[i],0])
    x3+=96
    y3+=96

How do I properly use np.where, or how do I use another indices command to find out when my max temperatures occur?

1 Answer 1

2

To find the index of the maximum value in a numpy array use np.argmax()

Sign up to request clarification or add additional context in comments.

Comments

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.