简体   繁体   中英

Xarray Dataarray finding line of max Value

That's my first question here, I appreciate any help!

I've got global data in a xarray Dataarray with latitude and longitude as coordinates (.25° resolution) and I would like to find the latitude for each .25° longitude element, where the value is the highest.

I've tried data.max('lat') but that's giving me the maximum value of the data for each longitude element, and not the latitude.

Maybe there is a solution with data.where() , but I haven't figured it out yet. So perhaps someone did something similar and could help me?

Many thanks in advance V

Ok, found a solution:

def findlineofmaxes(data):
    latmaxes = data.max('lat')
    lineofmaxes = data.where(data == latmaxes, drop=True)
    return lineofmaxes

It's a workaround, but works for me!

I hope it's ok, to answer my own question, instead of just deleting it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM