Skip to content

Fix xr_linregress problem with dask #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2362b11
Updated ci envs
jbusecke Dec 12, 2019
3d4d690
Updated travis.yml
jbusecke Dec 12, 2019
8165636
Added upstream dependencies and py38
jbusecke Dec 12, 2019
a757d54
Added upstream dependencies and py38
jbusecke Dec 12, 2019
61d4ae0
Merge branch 'refactor_xr_linregress' of github.com:jbusecke/xarrayut…
jbusecke Dec 12, 2019
53e714d
Included test for xr_linregress
jbusecke Dec 12, 2019
4771691
Decrease numpy version
jbusecke Dec 12, 2019
cee9c13
Added ancient numpy and dask versions
jbusecke Dec 12, 2019
00406f3
Decrease dask version
jbusecke Dec 12, 2019
f3e5dd8
Added the ancient env to ci
jbusecke Dec 12, 2019
f0251b6
Narrow down version conflict
jbusecke Dec 12, 2019
63edeee
Remove the py27 env
jbusecke Dec 12, 2019
56d3d70
Remove the py27 env
jbusecke Dec 12, 2019
4040d79
Merge branch 'refactor_xr_linregress' of github.com:jbusecke/xarrayut…
jbusecke Dec 12, 2019
36a8aeb
Try dask 2.8
jbusecke Dec 12, 2019
80c7be7
Try multiple dask versions in each env
jbusecke Dec 12, 2019
ff44dca
Test all envs with dask < 2.0
jbusecke Dec 12, 2019
65d0ef3
Allow py38 env to fail for now...
jbusecke Dec 12, 2019
10d26a7
Vary xarray versions.
jbusecke Dec 12, 2019
9213cc8
Final commit for the day
jbusecke Dec 12, 2019
7da23b6
Merge branch 'refactor_xr_linregress' of github.com:jbusecke/xarrayut…
jbusecke Dec 12, 2019
5edb456
Forgot env
jbusecke Dec 12, 2019
cc0064b
Add temp notebook
jbusecke Dec 17, 2019
870c430
Added warning and comments
jbusecke Dec 17, 2019
73427b6
Increase coverage for xr_linregress
jbusecke Dec 17, 2019
fa2f657
Added nans to tests for xr_linregress
jbusecke Dec 17, 2019
6cfd69f
Fix nan indexing
jbusecke Dec 17, 2019
9e51ae7
Added explicit pip dependency to ci
jbusecke Dec 17, 2019
11d3d47
Fixed local nan test
jbusecke Dec 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ notifications:
matrix:
fast_finish: true
include:
- env: CONDA_ENV=py27
- env: CONDA_ENV=py35
- env: CONDA_ENV=py36
- env: CONDA_ENV=py36
- env: CONDA_ENV=py37
- env: CONDA_ENV=py37-upstream_master
- env: CONDA_ENV=py38
allow_failures:
- env: CONDA_ENV=py38

before_install:
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
Expand All @@ -22,7 +24,7 @@ before_install:

install:
- conda env create --file ci/environment-$CONDA_ENV.yml
- source activate test_env
- source activate test_env_xarrayutils
- conda list
- pip install --no-deps -e .

Expand Down
21 changes: 0 additions & 21 deletions ci/environment-py35.yml

This file was deleted.

9 changes: 5 additions & 4 deletions ci/environment-py36.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: test_env
name: test_env_xarrayutils
channels:
- conda-forge
dependencies:
- python=3.6
- xarray
- dask
- dask < 2 #remove this once upstream problem
# (https://github.com/pydata/xarray/issues/3574) is fixed
- numpy
- pytest
- future
- scipy
- flake8
- black
- astropy
- matplotlib
# Necesary additions for the plotting tools (might have to make thos optional)
- gsw
- cartopy
- xgcm
- pip
- pip:
- codecov
- pytest-cov
23 changes: 23 additions & 0 deletions ci/environment-py37-upstream_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test_env_xarrayutils
channels:
- conda-forge
dependencies:
- python=3.7
- dask < 2 #remove this once upstream problem
# (https://github.com/pydata/xarray/issues/3574) is fixed
- numpy
- pytest
- future
- scipy
- black
- astropy
- matplotlib
# Necesary additions for the plotting tools (might have to make thos optional)
- gsw
- cartopy
- pip
- pip:
- git+https://github.com/pydata/xarray.git
- git+https://github.com/xgcm/xgcm.git
- codecov
- pytest-cov
10 changes: 6 additions & 4 deletions ci/environment-py37.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: test_env
name: test_env_xarrayutils
channels:
- conda-forge
dependencies:
- python=3.7
- xarray
- dask
- xarray < 0.14
- dask < 2 #remove this once upstream problem
# (https://github.com/pydata/xarray/issues/3574) is fixed
- numpy
- pytest
- future
- scipy
- flake8
- black
- astropy
- matplotlib
# Necesary additions for the plotting tools (might have to make thos optional)
- gsw
- cartopy
- xgcm
- pip
- pip:
- codecov
- pytest-cov
10 changes: 6 additions & 4 deletions ci/environment-py27.yml → ci/environment-py38.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
name: test_env
name: test_env_xarrayutils
channels:
- conda-forge
dependencies:
- python=2.7
- python=3.8
- xarray
- dask
- dask < 2 #remove this once upstream problem
# (https://github.com/pydata/xarray/issues/3574) is fixed
- numpy
- pytest
- future
- scipy
- flake8
- black
- astropy
- matplotlib
# Necesary additions for the plotting tools (might have to make thos optional)
- gsw
- cartopy
- xgcm
- pip
- pip:
- codecov
- pytest-cov
178 changes: 178 additions & 0 deletions docs/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using xarrayutils to build a xgcm compatible grid for observational products\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Still gotta figure out how to do the download clean...store on figshare as unzipped file?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import xarray as xr\n",
"import xgcm\n",
"from xarrayutils.build_grids import grid_aggregate,rebuild_grid"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"path = '/Users/juliusbusecke/Work/CODE/PYTHON/xarrayutils/notebooks/MIMOC_ML_v2'\n",
"ds = xr.open_mfdataset(path+'/MIMOC_ML_v2.2_CT_SA_MLP_month*',concat_dim='month')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ds_new = xr.Dataset(data_vars=ds.drop(['LONGITUDE','LATITUDE']).data_vars,coords={'LONG':ds.LONGITUDE.mean('month'),'LAT':ds.LATITUDE.mean('month'),'month':ds.month})\n",
"ds_new.LAT.attrs = {'axis':'X',\n",
" 'standard_name': 'x_grid_index',\n",
" 'long_name': 'x-dimension of the grid'}\n",
"\n",
"ds_new.LONG.attrs = {'axis':'Y',\n",
" 'standard_name': 'y_grid_index',\n",
" 'long_name': 'y-dimension of the grid'}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# grid = xgcm.Grid(ds_new)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "KeyError",
"evalue": "'XC'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-5-18be2f814549>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mbins\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'LONG'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'LAT'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mgrid_coarse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgrid_aggregate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mds_new\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mbins\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Users/juliusbusecke/Work/CODE/PYTHON/xarrayutils/xarrayutils/build_grids.py\u001b[0m in \u001b[0;36mgrid_aggregate\u001b[0;34m(grid, bins)\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0mtemp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mff\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'XC'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'YC'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 75\u001b[0;31m temp[ff] = xr.DataArray(da.from_array(grid[ff].data,chunks=grid[ff].shape),\n\u001b[0m\u001b[1;32m 76\u001b[0m coords=grid[ff].coords,dims=grid[ff].dims)\n\u001b[1;32m 77\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/juliusbusecke/anaconda/lib/python2.7/site-packages/xarray/core/dataset.pyc\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 696\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 697\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mhashable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 698\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_construct_dataarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 699\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 700\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_copy_listed\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/juliusbusecke/anaconda/lib/python2.7/site-packages/xarray/core/dataset.pyc\u001b[0m in \u001b[0;36m_construct_dataarray\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 640\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 641\u001b[0m _, name, variable = _get_virtual_variable(\n\u001b[0;32m--> 642\u001b[0;31m self._variables, name, self._level_coords, self.dims)\n\u001b[0m\u001b[1;32m 643\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 644\u001b[0m \u001b[0mcoords\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mOrderedDict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/juliusbusecke/anaconda/lib/python2.7/site-packages/xarray/core/dataset.pyc\u001b[0m in \u001b[0;36m_get_virtual_variable\u001b[0;34m(variables, key, level_vars, dim_sizes)\u001b[0m\n\u001b[1;32m 69\u001b[0m \u001b[0mref_var\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdim_var\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_index_variable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_level_variable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mref_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 71\u001b[0;31m \u001b[0mref_var\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvariables\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mref_name\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 72\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mvar_name\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyError\u001b[0m: 'XC'"
]
}
],
"source": [
"bins = [('LONG',10),('LAT',10)]\n",
"grid_coarse = grid_aggregate(ds_new,bins)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"out = rebuild_grid(ds_new)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ds_new"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"grid = xgcm.Grid(ds)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"interp_test = grid.diff(ds.ABSOLUTE_SALINITY_MIXED_LAYER,'X')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading