home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 332624901

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/1596#issuecomment-332624901 https://api.github.com/repos/pydata/xarray/issues/1596 332624901 MDEyOklzc3VlQ29tbWVudDMzMjYyNDkwMQ== 5700886 2017-09-27T19:08:59Z 2017-09-27T19:08:59Z CONTRIBUTOR

Not really minimal but shows a real use:

```python from pathlib import Path import matplotlib.pyplot as plt import xarray as xr

create data path

daily_data_path = Path("/obs_data/") / "ASCAT" / "v1.x.x" / "data/Daily/Netcdf"

get data files and open mf dataset

data_files_2016 = daily_data_path.glob("2016/??/??/*.nc") raw_data_set = xr.open_mfdataset(data_files_2016).isel(latitude=300, longitude=0)

Resample with filling gaps by NaN's and shift to match original time axis

infilled_data_set = raw_data_set.resample(time="1D").asfreq() infilled_data_set.time.data += (raw_data_set.time.data[0] - infilled_data_set.time.data[0])

extract wind speeds

rws = raw_data_set.wind_speed iws = infilled_data_set.wind_speed.rename("resampled_wind_speed")

and plot (with a slight offset to be able to distinguish the lines)

fig, ax = plt.subplots(2, 1)

(iws+1).plot(ax=ax[0]); rws.plot(ax=ax[0]); ax[0].legend(["resampled", "original"], loc=0, ncol=2);

(iws+1).sel(time=slice("2016-08-01", "2016-10-01")).plot(ax=ax[1]); rws.sel(time=slice("2016-08-01", "2016-10-01")).plot(ax=ax[1]); ```

Note the gaps that are more clearly visible in the lower panel.

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