home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 514619297

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/3160#issuecomment-514619297 https://api.github.com/repos/pydata/xarray/issues/3160 514619297 MDEyOklzc3VlQ29tbWVudDUxNDYxOTI5Nw== 35968931 2019-07-24T12:52:58Z 2019-07-24T12:52:58Z MEMBER

There might be a better way, but I think this is one way:

First mask out all the data that isn't in your lat/long box. If your latitude and longitude are 1D then you could use .sel(), otherwise use .where(). You have two conditions (one for latitude and one for longitude), so combine them with np.logical_and():

python condition = np.logical_and(data.lat > 10.0, data.lon < 50.0) box = data.where(condition)

Then use DataArray.argmax() across all the dimensions of the result to find the indices of the maximum values.

python inds_of_max = box.argmax(dims=['lat', 'lon'])

Pass those indices to your latitude/longitude coordinate arrays to get the (lat, lon) pair you want.

python lat, lon = data.lat[inds_of_max], data.lon[inds_of_max]

(This would probably be better placed on stackoverflow than here but doesn't matter)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  472247188
Powered by Datasette · Queries took 0.818ms · About: xarray-datasette