Example on using `preprocess` with `mfdataset`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
I wrote this little notebook today while trying to get some satellite data in form that was nice to work with: https://gist.github.com/dcherian/66269bc2b36c2bc427897590d08472d7
I think it would make a useful example for the docs.
A few questions:
- Do you think it'd be a good addition to the examples?
- Is this the recommended way of adding meaningful co-ordinates, expanding dims etc.? The main bit is this function:
def preprocess(ds):
dsnew = ds.copy()
dsnew['latitude'] = xr.DataArray(np.linspace(90, -90, 180),
dims=['phony_dim_0'])
dsnew['longitude'] = xr.DataArray(np.linspace(-180, 180, 360),
dims=['phony_dim_1'])
dsnew = (dsnew.rename({'l3m_data': 'sss',
'phony_dim_0': 'latitude',
'phony_dim_1': 'longitude'})
.set_coords(['latitude', 'longitude'])
.drop('palette'))
dsnew['time'] = (pd.to_datetime(dsnew.attrs['time_coverage_start'])
+ np.timedelta64(3, 'D') + np.timedelta64(12, 'h'))
dsnew = dsnew.expand_dims('time').set_coords('time')
return dsnew
Also open to other feedback...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the notebook in the linked gist, especially the preprocess function and its use with mfdataset. Determine how it should be adapted into the xarray documentation examples, and consider the questions about coordinates, expanded dimensions, and recommended usage. Done means an accepted, maintainable documentation example with the relevant workflow explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100