netcdf4-python icon indicating copy to clipboard operation
netcdf4-python copied to clipboard

NAN

Open wangshuaicumt opened this issue 2 years ago • 6 comments

ps_point = d1.sel(lon='117.17638888845157', lat='35.47979166666699') print(ps_point.values)

When I run the codes, but the terminal shows NAN. How to solve it?

nan

wangshuaicumt avatar Mar 07 '23 08:03 wangshuaicumt

are you using xarray?

jswhit avatar Mar 07 '23 17:03 jswhit

are you using xarray?

Yeah.

wangshuaicumt avatar Mar 08 '23 01:03 wangshuaicumt

are you using xarray?

Is there a better way to achieve?

wangshuaicumt avatar Mar 08 '23 01:03 wangshuaicumt

this is really not a netcdf4-python issue. I suspect you are select a point with missing or undefined data, but you would have to ask an xarray expert (maybe here).

jswhit avatar Mar 08 '23 01:03 jswhit

this is really not a netcdf4-python issue. I suspect you are select a point with missing or undefined data, but you would have to ask an xarray expert (maybe here).

Yeah, thanks. The data I read out using xray is like this, and the graph drawn is as follows.

<xarray.DataArray 'z' (lat: 1180, lon: 1910)> [2253800 values with dtype=float32] Coordinates:

  • lon (lon) float64 116.2 116.2 116.2 116.2 ... 117.2 117.2 117.2 117.2
  • lat (lat) float64 35.48 35.48 35.48 35.48 ... 35.97 35.97 35.97 35.97 Attributes: long_name: z actual_range: [-153.15245056 136.86753845]

Figure_1

wangshuaicumt avatar Mar 08 '23 01:03 wangshuaicumt

You should specify

ds.sel(lat=.., lon=..., method='nearest' )

without that, it is trying to find that exact value.

mgrover1 avatar Mar 30 '23 01:03 mgrover1