Skip to content

Commit

Permalink
Merge pull request #27 from jhamman/master
Browse files Browse the repository at this point in the history
cleanup and fix to anaconda builds
  • Loading branch information
Joe Hamman authored Feb 22, 2017
2 parents d2d70d5 + 99915b6 commit 4f2a05d
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 302 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"

before_install:
- sudo apt-get update
- sudo apt-get install libnetcdf-dev nco
# Get miniconda
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.3" ]]; then
wget http://repo.continuum.io/miniconda/Miniconda3-3.4.2-Linux-x86_64.sh -O miniconda.sh;
# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget http://repo.continuum.io/miniconda/Miniconda-3.4.2-Linux-x86_64.sh -O miniconda.sh;
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
Expand All @@ -23,7 +25,7 @@ before_install:
- conda info -a

# Make Conda test environment
- conda env create --file ci/requirements-${TRAVIS_PYTHON_VERSION}.yml
- conda env create --file ci/requirements-$TRAVIS_PYTHON_VERSION.yml
- source activate test_env
- python setup.py install

Expand Down
71 changes: 35 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ purposes too.

### Conda Installation:

conda install -c https://conda.anaconda.org/ioos pynco
conda install -c conda-forge pynco

### Requirements

Expand Down Expand Up @@ -89,7 +89,7 @@ Now any NCO command (i.e. ncks, ncra, ...) can be called as a method of `nco`.
temperatures = nco.ncra(input=ifile, returnCdf=True).variables['T'][:]
temperatures = nco.ncra(input=ifile, returnArray='T')

* Wrapper Objects
* Wrapper Objects

The Atted opject is a convienent wrapper object to the `-a` command-line switch in ncatted.
The Limit object is a wrapper to the `-d` command-line switch.
Expand All @@ -98,9 +98,9 @@ Now any NCO command (i.e. ncks, ncra, ...) can be called as a method of `nco`.
e.g the following are equivalent:
```
ncatted -a _FillValue,three_dmn,o,d,-9.91e+33 in.nc
nco.ncatted(input="in.nc" options=[ c.atted("overwrite","_FillValue","three_dmn",-9.91e+33,'d')])
```
see more examples below
nco.ncatted(input="in.nc",options=[c.atted("overwrite","_FillValue","three_dmn",-9.91e+33,'d')])
```
see more examples below

## Tempfile helpers

Expand All @@ -115,32 +115,31 @@ is equivalent to:
* Atted wrapper


It is sometimes more tidy to define the atted objects in a seperate list then add that list the options in the nco call
It is sometimes more tidy to define the atted objects in a separate list then add that list the options in the nco call

```
opt=[
c.Atted("o", "units", "temperature", "Kelvin"),
c.Atted("c", "min", "temperature", 0.16,'d' ),
c.Atted("m", "max", "temperature", 283.01,'float64'),
c.Atted("c", "bnds","time",[0.5,1.5],'f')
c.Atted("o", "units", "temperature", "Kelvin"),
c.Atted("c", "min", "temperature", 0.16,'d' ),
c.Atted("m", "max", "temperature", 283.01,'float64'),
c.Atted("c", "bnds","time",[0.5,1.5],'f')
]
nco.ncatted(input="in.nc",options=opt)
```

You can also use keyword arguments in the call so the above options become

```
opt=[
c.Atted(mode="o", attName="units", varName="temperature", Value="Kelvin",sType="c"),
c.Atted(mode="create", attName="min", varName="temperature", Value=0.16,sType='d' ),
c.Atted(mode="modify", attName="max", varName="temperature", Value=283.01,sType='float64'),
c.Atted(mode="create", attName="bnds", varName="time", Value=[0.5,1.5],sType='float32')
opt=[c.Atted(mode="o", attName="units", varName="temperature", Value="Kelvin",sType="c"),
c.Atted(mode="create", attName="min", varName="temperature", Value=0.16,sType='d' ),
c.Atted(mode="modify", attName="max", varName="temperature", Value=283.01,sType='float64'),
c.Atted(mode="create", attName="bnds", varName="time", Value=[0.5,1.5],sType='float32')
]
```

Value can be a single value or a list ( or any python iterable type or a numpy array).

If sType is NOT included then the type is inferred from the first value in the list<br/>
If sType is NOT included then the type is inferred from the first value in the list<br/>
if sType is included then any values in the list are NOT of sType are converted to sType<br/><br/>

For sType you can use the following:
Expand All @@ -150,23 +149,23 @@ is equivalent to:

For a netCDF3 character string use "c"or "char"<br/>
For netCDF4 string(s) use "sng" or "string"<br/>

For mode you can use the single character abbreviations as per ncatted or the following words:<br/>
(a)ppend, (c)reate, (d)elete, (m)odify, (n)append, (o)verwrite<br/>

* Limit and LimitSingle wrapper

the following are equivalent
```
ncks -d time,0,8,2 -d time,10 -d lat,-20.0,20.0 -d lon,50.0,350.0 -d lev,,,4
and
opt=[
c.Limit("time",0,8,2),
c.LimitSingle("time",10),
c.Limit("lat",-20.0,20.0),
ncks -d time,0,8,2 -d time,10 -d lat,-20.0,20.0 -d lon,50.0,350.0 -d lev,,,4
and
opt=[
c.Limit("time",0,8,2),
c.LimitSingle("time",10),
c.Limit("lat",-20.0,20.0),
c.Limit(dmn_name="lon",srt=50.0,end=350.0),
c.Limit(dmn_name="lev",srd=4)
]
c.Limit(dmn_name="lev",srd=4)
]

nco.ncks(input="in.nc", output="out.nc", options=opt)
```
Expand All @@ -177,18 +176,18 @@ is equivalent to:
```
ncrename -v p,pressure -v t,temperature in.nc

rDict={ 'p':'pressure', 't':'temperature' }
rDict={'p':'pressure', 't':'temperature'}
nco.ncrename(input="in.nc", options=[ c.Rename("variable",rDict)])
```
rename coordinate variables (dim & var)
```
ncrename -d lon,longitude -d lat,latitude -v lon,longitude -v lat,latitude in.nc
ncrename -d lon,longitude -d lat,latitude -v lon,longitude -v lat,latitude in.nc

rDict={ 'lon':'longitude', 'lat':'latitude' }
nco.ncrename(input="in.nc", options=[ c.Rename("d",rDict), c.Rename("v",rDict) ])
rDict={'lon':'longitude', 'lat':'latitude'}
nco.ncrename(input="in.nc", options=[c.Rename("d",rDict), c.Rename("v",rDict)])
```
## Support, Issues, Bugs, ...
Expand Down
10 changes: 0 additions & 10 deletions ci/requirements-2.7.txt

This file was deleted.

12 changes: 12 additions & 0 deletions ci/requirements-2.7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=2.7
- dateutil
- h5py
- netCDF4
- numpy
- pytest
- scipy
- setuptools
10 changes: 0 additions & 10 deletions ci/requirements-3.4.txt

This file was deleted.

12 changes: 12 additions & 0 deletions ci/requirements-3.4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.4
- dateutil
- h5py
- netCDF4
- numpy
- pytest
- scipy
- setuptools
10 changes: 0 additions & 10 deletions ci/requirements-3.5.txt

This file was deleted.

12 changes: 12 additions & 0 deletions ci/requirements-3.5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.5
- dateutil
- h5py
- netCDF4
- numpy
- pytest
- scipy
- setuptools
12 changes: 12 additions & 0 deletions ci/requirements-3.6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.6
- dateutil
- h5py
- netCDF4
- numpy
- pytest
- scipy
- setuptools
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ purposes too.

### Conda Installation:

conda install -c https://conda.anaconda.org/ioos pynco
conda install -c conda-forge pynco

### Requirements

Expand Down
Loading

0 comments on commit 4f2a05d

Please sign in to comment.