home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 883232093

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/5620#issuecomment-883232093 https://api.github.com/repos/pydata/xarray/issues/5620 883232093 IC_kwDOAMm_X840pQ1d 14808389 2021-07-20T09:09:31Z 2021-07-20T09:44:42Z MEMBER

Actually, I can reproduce this with the example "rasm" dataset: python In [2]: import xarray as xr ...: ...: rasm = xr.tutorial.open_dataset("rasm").load() ...: ...: min_lat = 17 ...: max_lat = 18 ...: min_lon = 189 ...: max_lon = 190 ...: ...: mask = ( ...: (rasm.xc <= max_lon) & (rasm.xc > min_lon) ...: & (rasm.yc <= max_lat) & (rasm.yc > min_lat) ...: ) ...: ...: subset = rasm.xc.where(mask, drop=True) ...: display(subset.max(), subset.xc.max()) ...: display(subset, subset.xc) <xarray.DataArray 'xc' ()> array(189.89982737) <xarray.DataArray 'xc' ()> array(190.07286203) <xarray.DataArray 'xc' (y: 3, x: 4)> array([[189.55836619, 189.72833384, 189.89982737, nan], [189.30253733, 189.47184886, 189.64270151, 189.81509531], [189.04515208, 189.21383799, 189.38403452, nan]]) Coordinates: xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6 yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08 Dimensions without coordinates: y, x Attributes: long_name: longitude of grid cell center units: degrees_east <xarray.DataArray 'xc' (y: 3, x: 4)> array([[189.55836619, 189.72833384, 189.89982737, 190.07286203], [189.30253733, 189.47184886, 189.64270151, 189.81509531], [189.04515208, 189.21383799, 189.38403452, 189.55578745]]) Coordinates: xc (y, x) float64 189.6 189.7 189.9 190.1 ... 189.0 189.2 189.4 189.6 yc (y, x) float64 17.02 17.27 17.51 17.76 ... 17.34 17.59 17.84 18.08 Dimensions without coordinates: y, x Attributes: long_name: longitude of grid cell center units: degrees_east

which makes it pretty obvious why this fails: drop=True drops as much as possible, but to really drop everything we would have to collapse the result to 1D. To work around that, .where sets the data to nan where necessary, but only for data variables (as coordinates still need to label the masked values).

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