We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Use .dev versioning, pre-releases
With the 1.0 release coming and likely a few PRs with breaking changes, it would be helpful to start doing dev releases so we can maximize the number of eyes.

**Proposal**: Change version to `1.0.dev1` now, as we make changes, cut pre-release wheels and distribute them via on pypi.

We'll also likely want to do a legit `alpha`, `beta`, `rc`, `final` cycle for the 1.0 release.

@sgillies @geowurster @brendan-ward sound good?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rasterio/__init__.py`
Content:
```
1 """Rasterio"""
2 
3 from __future__ import absolute_import
4 
5 from collections import namedtuple
6 import logging
7 try:
8     from logging import NullHandler
9 except ImportError:  # pragma: no cover
10     class NullHandler(logging.Handler):
11         def emit(self, record):
12             pass
13 import warnings
14 
15 from rasterio._base import (
16     eval_window, window_shape, window_index, gdal_version)
17 from rasterio.dtypes import (
18     bool_, ubyte, uint8, uint16, int16, uint32, int32, float32, float64,
19     complex_, check_dtype)
20 from rasterio.env import ensure_env, Env
21 from rasterio.compat import string_types
22 from rasterio.profiles import default_gtiff_profile
23 from rasterio.transform import Affine, guard_transform
24 from rasterio.vfs import parse_path
25 from rasterio import windows
26 
27 # These modules are imported from the Cython extensions, but are also import
28 # here to help tools like cx_Freeze find them automatically
29 from rasterio import _err, coords, enums, vfs
30 
31 # Classes in rasterio._io are imported below just before we need them.
32 
33 __all__ = [
34     'band', 'open', 'copy', 'pad']
35 __version__ = "0.36.0"
36 __gdal_version__ = gdal_version()
37 
38 # Rasterio attaches NullHandler to the 'rasterio' logger and its
39 # descendents. See
40 # https://docs.python.org/2/howto/logging.html#configuring-logging-for-a-library
41 # Applications must attach their own handlers in order to see messages.
42 # See rasterio/rio/main.py for an example.
43 log = logging.getLogger(__name__)
44 log.addHandler(NullHandler())
45 
46 
47 @ensure_env
48 def open(path, mode='r', driver=None, width=None, height=None,
49          count=None, crs=None, transform=None, dtype=None, nodata=None,
50          **kwargs):
51     """Open file at ``path`` in ``mode`` 'r' (read), 'r+' (read and
52     write), or 'w' (write) and return a dataset Reader or Updater
53     object.
54 
55     In write mode, a driver name such as "GTiff" or "JPEG" (see GDAL
56     docs or ``gdal_translate --help`` on the command line),
57     ``width`` (number of pixels per line) and ``height`` (number of
58     lines), the ``count`` number of bands in the new file must be
59     specified.  Additionally, the data type for bands such as
60     ``rasterio.ubyte`` for 8-bit bands or ``rasterio.uint16`` for
61     16-bit bands must be specified using the ``dtype`` argument.
62 
63     Parameters
64     ----------
65     mode: string
66         "r" (read), "r+" (read/write), or "w" (write)
67     driver: string
68         driver code specifying the format name (e.g. "GTiff" or
69         "JPEG"). See GDAL docs at
70         http://www.gdal.org/formats_list.html (optional, required
71         for writing).
72     width: int
73         number of pixels per line
74         (optional, required for write)
75     height: int
76         number of lines
77         (optional, required for write)
78     count: int > 0
79         number of bands
80         (optional, required for write)
81     dtype: rasterio.dtype
82         the data type for bands such as ``rasterio.ubyte`` for
83         8-bit bands or ``rasterio.uint16`` for 16-bit bands
84         (optional, required for write)
85     crs: dict or string
86         Coordinate reference system
87         (optional, recommended for write)
88     transform: Affine instance
89         Affine transformation mapping the pixel space to geographic
90         space (optional, recommended for writing).
91     nodata: number
92         Defines pixel value to be interpreted as null/nodata
93         (optional, recommended for write)
94 
95     Returns
96     -------
97     A ``DatasetReader`` or ``DatasetUpdater`` object.
98 
99     Notes
100     -----
101     In write mode, you must specify at least ``width``, ``height``,
102     ``count`` and ``dtype``.
103 
104     A coordinate reference system for raster datasets in write mode
105     can be defined by the ``crs`` argument. It takes Proj4 style
106     mappings like
107 
108     .. code::
109 
110       {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84',
111        'no_defs': True}
112 
113     An affine transformation that maps ``col,row`` pixel coordinates
114     to ``x,y`` coordinates in the coordinate reference system can be
115     specified using the ``transform`` argument. The value should be
116     an instance of ``affine.Affine``
117 
118     .. code:: python
119 
120         >>> from affine import Affine
121         >>> transform = Affine(0.5, 0.0, -180.0, 0.0, -0.5, 90.0)
122 
123     These coefficients are shown in the figure below.
124 
125     .. code::
126 
127       | x |   | a  b  c | | c |
128       | y | = | d  e  f | | r |
129       | 1 |   | 0  0  1 | | 1 |
130 
131       a: rate of change of X with respect to increasing column,
132          i.e. pixel width
133       b: rotation, 0 if the raster is oriented "north up"
134       c: X coordinate of the top left corner of the top left pixel
135       d: rotation, 0 if the raster is oriented "north up"
136       e: rate of change of Y with respect to increasing row,
137          usually a negative number (i.e. -1 * pixel height) if
138          north-up.
139       f: Y coordinate of the top left corner of the top left pixel
140 
141     A 6-element sequence of the affine transformation matrix
142     coefficients in ``c, a, b, f, d, e`` order, (i.e. GDAL
143     geotransform order) will be accepted until 1.0 (deprecated).
144 
145     A virtual filesystem can be specified. The ``vfs`` parameter may
146     be an Apache Commons VFS style string beginning with "zip://" or
147     "tar://"". In this case, the ``path`` must be an absolute path
148     within that container.
149 
150     """
151     if not isinstance(path, string_types):
152         raise TypeError("invalid path: {0!r}".format(path))
153     if mode and not isinstance(mode, string_types):
154         raise TypeError("invalid mode: {0!r}".format(mode))
155     if driver and not isinstance(driver, string_types):
156         raise TypeError("invalid driver: {0!r}".format(driver))
157     if dtype and not check_dtype(dtype):
158         raise TypeError("invalid dtype: {0!r}".format(dtype))
159     if transform:
160         transform = guard_transform(transform)
161     elif 'affine' in kwargs:
162         affine = kwargs.pop('affine')
163         transform = guard_transform(affine)
164 
165     # Get AWS credentials if we're attempting to access a raster
166     # on S3.
167     pth, archive, scheme = parse_path(path)
168     if scheme == 's3':
169         Env().get_aws_credentials()
170         log.debug("AWS credentials have been obtained")
171 
172     # Create dataset instances and pass the given env, which will
173     # be taken over by the dataset's context manager if it is not
174     # None.
175     if mode == 'r':
176         from rasterio._io import RasterReader
177         s = RasterReader(path)
178     elif mode == 'r+':
179         from rasterio._io import writer
180         s = writer(path, mode)
181     elif mode == 'r-':
182         from rasterio._base import DatasetReader
183         s = DatasetReader(path)
184     elif mode == 'w':
185         from rasterio._io import writer
186         s = writer(path, mode, driver=driver,
187                    width=width, height=height, count=count,
188                    crs=crs, transform=transform, dtype=dtype,
189                    nodata=nodata, **kwargs)
190     else:
191         raise ValueError(
192             "mode string must be one of 'r', 'r+', or 'w', not %s" % mode)
193     s.start()
194     return s
195 
196 
197 @ensure_env
198 def copy(src, dst, **kw):
199     """Copy a source raster to a new destination with driver specific
200     creation options.
201 
202     Parameters
203     ----------
204     src: string
205         an existing raster file
206     dst: string
207         valid path to output file.
208 
209     Returns
210     -------
211     None
212 
213     Raises
214     ------
215     ValueError:
216         If source path is not a valid Dataset
217 
218     Notes
219     -----
220     A ``driver`` keyword argument with value like 'GTiff' or 'JPEG' is
221     used to control the output format.
222 
223     This is the one way to create write-once files like JPEGs.
224     """
225     from rasterio._copy import RasterCopier
226     return RasterCopier()(src, dst, **kw)
227 
228 
229 def drivers(**kwargs):
230     """Create a gdal environment with registered drivers and creation
231     options.
232 
233     This function is deprecated; please use ``env.Env`` instead.
234 
235     Parameters
236     ----------
237     **kwargs:: keyword arguments
238         Configuration options that define GDAL driver behavior
239 
240         See https://trac.osgeo.org/gdal/wiki/ConfigOptions
241 
242     Returns
243     -------
244     GDALEnv responsible for managing the environment.
245 
246     Notes
247     -----
248     Use as a context manager, ``with rasterio.drivers(): ...``
249     """
250     warnings.warn("Deprecated; Use env.Env instead", DeprecationWarning)
251     return Env(**kwargs)
252 
253 
254 Band = namedtuple('Band', ['ds', 'bidx', 'dtype', 'shape'])
255 
256 def band(ds, bidx):
257     """Wraps a dataset and a band index up as a 'Band'
258 
259     Parameters
260     ----------
261     ds: rasterio.RasterReader
262         Open rasterio dataset
263     bidx: int
264         Band number, index starting at 1
265 
266     Returns
267     -------
268     a rasterio.Band
269     """
270     return Band(
271         ds,
272         bidx,
273         set(ds.dtypes).pop(),
274         ds.shape)
275 
276 
277 def pad(array, transform, pad_width, mode=None, **kwargs):
278     """pad array and adjust affine transform matrix.
279 
280     Parameters
281     ----------
282     array: ndarray
283         Numpy ndarray, for best results a 2D array
284     transform: Affine transform
285         transform object mapping pixel space to coordinates
286     pad_width: int
287         number of pixels to pad array on all four
288     mode: str or function
289         define the method for determining padded values
290 
291     Returns
292     -------
293     (array, transform): tuple
294         Tuple of new array and affine transform
295 
296     Notes
297     -----
298     See numpy docs for details on mode and other kwargs:
299     http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.pad.html
300     """
301     import numpy as np
302     transform = guard_transform(transform)
303     padded_array = np.pad(array, pad_width, mode, **kwargs)
304     padded_trans = list(transform)
305     padded_trans[2] -= pad_width * padded_trans[0]
306     padded_trans[5] -= pad_width * padded_trans[4]
307     return padded_array, Affine(*padded_trans[:6])
308 
309 
310 def get_data_window(arr, nodata=None):
311     warnings.warn("Deprecated; Use rasterio.windows instead", DeprecationWarning)
312     return windows.get_data_window(arr, nodata)
313 
314 
315 def window_union(data):
316     warnings.warn("Deprecated; Use rasterio.windows instead", DeprecationWarning)
317     return windows.union(data)
318 
319 
320 def window_intersection(data):
321     warnings.warn("Deprecated; Use rasterio.windows instead", DeprecationWarning)
322     return windows.intersection(data)
323 
324 def windows_intersect(data):
325     warnings.warn("Deprecated; Use rasterio.windows instead", DeprecationWarning)
326     return windows.intersect(data)
327
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rasterio/__init__.py b/rasterio/__init__.py
--- a/rasterio/__init__.py
+++ b/rasterio/__init__.py
@@ -32,7 +32,7 @@
 
 __all__ = [
     'band', 'open', 'copy', 'pad']
-__version__ = "0.36.0"
+__version__ = "1.0.dev1"
 __gdal_version__ = gdal_version()
 
 # Rasterio attaches NullHandler to the 'rasterio' logger and its

{"golden_diff": "diff --git a/rasterio/__init__.py b/rasterio/__init__.py\n--- a/rasterio/__init__.py\n+++ b/rasterio/__init__.py\n@@ -32,7 +32,7 @@\n \n __all__ = [\n     'band', 'open', 'copy', 'pad']\n-__version__ = \"0.36.0\"\n+__version__ = \"1.0.dev1\"\n __gdal_version__ = gdal_version()\n \n # Rasterio attaches NullHandler to the 'rasterio' logger and its\n", "issue": "Use .dev versioning, pre-releases\nWith the 1.0 release coming and likely a few PRs with breaking changes, it would be helpful to start doing dev releases so we can maximize the number of eyes.\n\n**Proposal**: Change version to `1.0.dev1` now, as we make changes, cut pre-release wheels and distribute them via on pypi.\n\nWe'll also likely want to do a legit `alpha`, `beta`, `rc`, `final` cycle for the 1.0 release.\n\n@sgillies @geowurster @brendan-ward sound good?\n\n", "before_files": [{"content": "\"\"\"Rasterio\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom collections import namedtuple\nimport logging\ntry:\n    from logging import NullHandler\nexcept ImportError:  # pragma: no cover\n    class NullHandler(logging.Handler):\n        def emit(self, record):\n            pass\nimport warnings\n\nfrom rasterio._base import (\n    eval_window, window_shape, window_index, gdal_version)\nfrom rasterio.dtypes import (\n    bool_, ubyte, uint8, uint16, int16, uint32, int32, float32, float64,\n    complex_, check_dtype)\nfrom rasterio.env import ensure_env, Env\nfrom rasterio.compat import string_types\nfrom rasterio.profiles import default_gtiff_profile\nfrom rasterio.transform import Affine, guard_transform\nfrom rasterio.vfs import parse_path\nfrom rasterio import windows\n\n# These modules are imported from the Cython extensions, but are also import\n# here to help tools like cx_Freeze find them automatically\nfrom rasterio import _err, coords, enums, vfs\n\n# Classes in rasterio._io are imported below just before we need them.\n\n__all__ = [\n    'band', 'open', 'copy', 'pad']\n__version__ = \"0.36.0\"\n__gdal_version__ = gdal_version()\n\n# Rasterio attaches NullHandler to the 'rasterio' logger and its\n# descendents. See\n# https://docs.python.org/2/howto/logging.html#configuring-logging-for-a-library\n# Applications must attach their own handlers in order to see messages.\n# See rasterio/rio/main.py for an example.\nlog = logging.getLogger(__name__)\nlog.addHandler(NullHandler())\n\n\n@ensure_env\ndef open(path, mode='r', driver=None, width=None, height=None,\n         count=None, crs=None, transform=None, dtype=None, nodata=None,\n         **kwargs):\n    \"\"\"Open file at ``path`` in ``mode`` 'r' (read), 'r+' (read and\n    write), or 'w' (write) and return a dataset Reader or Updater\n    object.\n\n    In write mode, a driver name such as \"GTiff\" or \"JPEG\" (see GDAL\n    docs or ``gdal_translate --help`` on the command line),\n    ``width`` (number of pixels per line) and ``height`` (number of\n    lines), the ``count`` number of bands in the new file must be\n    specified.  Additionally, the data type for bands such as\n    ``rasterio.ubyte`` for 8-bit bands or ``rasterio.uint16`` for\n    16-bit bands must be specified using the ``dtype`` argument.\n\n    Parameters\n    ----------\n    mode: string\n        \"r\" (read), \"r+\" (read/write), or \"w\" (write)\n    driver: string\n        driver code specifying the format name (e.g. \"GTiff\" or\n        \"JPEG\"). See GDAL docs at\n        http://www.gdal.org/formats_list.html (optional, required\n        for writing).\n    width: int\n        number of pixels per line\n        (optional, required for write)\n    height: int\n        number of lines\n        (optional, required for write)\n    count: int > 0\n        number of bands\n        (optional, required for write)\n    dtype: rasterio.dtype\n        the data type for bands such as ``rasterio.ubyte`` for\n        8-bit bands or ``rasterio.uint16`` for 16-bit bands\n        (optional, required for write)\n    crs: dict or string\n        Coordinate reference system\n        (optional, recommended for write)\n    transform: Affine instance\n        Affine transformation mapping the pixel space to geographic\n        space (optional, recommended for writing).\n    nodata: number\n        Defines pixel value to be interpreted as null/nodata\n        (optional, recommended for write)\n\n    Returns\n    -------\n    A ``DatasetReader`` or ``DatasetUpdater`` object.\n\n    Notes\n    -----\n    In write mode, you must specify at least ``width``, ``height``,\n    ``count`` and ``dtype``.\n\n    A coordinate reference system for raster datasets in write mode\n    can be defined by the ``crs`` argument. It takes Proj4 style\n    mappings like\n\n    .. code::\n\n      {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84',\n       'no_defs': True}\n\n    An affine transformation that maps ``col,row`` pixel coordinates\n    to ``x,y`` coordinates in the coordinate reference system can be\n    specified using the ``transform`` argument. The value should be\n    an instance of ``affine.Affine``\n\n    .. code:: python\n\n        >>> from affine import Affine\n        >>> transform = Affine(0.5, 0.0, -180.0, 0.0, -0.5, 90.0)\n\n    These coefficients are shown in the figure below.\n\n    .. code::\n\n      | x |   | a  b  c | | c |\n      | y | = | d  e  f | | r |\n      | 1 |   | 0  0  1 | | 1 |\n\n      a: rate of change of X with respect to increasing column,\n         i.e. pixel width\n      b: rotation, 0 if the raster is oriented \"north up\"\n      c: X coordinate of the top left corner of the top left pixel\n      d: rotation, 0 if the raster is oriented \"north up\"\n      e: rate of change of Y with respect to increasing row,\n         usually a negative number (i.e. -1 * pixel height) if\n         north-up.\n      f: Y coordinate of the top left corner of the top left pixel\n\n    A 6-element sequence of the affine transformation matrix\n    coefficients in ``c, a, b, f, d, e`` order, (i.e. GDAL\n    geotransform order) will be accepted until 1.0 (deprecated).\n\n    A virtual filesystem can be specified. The ``vfs`` parameter may\n    be an Apache Commons VFS style string beginning with \"zip://\" or\n    \"tar://\"\". In this case, the ``path`` must be an absolute path\n    within that container.\n\n    \"\"\"\n    if not isinstance(path, string_types):\n        raise TypeError(\"invalid path: {0!r}\".format(path))\n    if mode and not isinstance(mode, string_types):\n        raise TypeError(\"invalid mode: {0!r}\".format(mode))\n    if driver and not isinstance(driver, string_types):\n        raise TypeError(\"invalid driver: {0!r}\".format(driver))\n    if dtype and not check_dtype(dtype):\n        raise TypeError(\"invalid dtype: {0!r}\".format(dtype))\n    if transform:\n        transform = guard_transform(transform)\n    elif 'affine' in kwargs:\n        affine = kwargs.pop('affine')\n        transform = guard_transform(affine)\n\n    # Get AWS credentials if we're attempting to access a raster\n    # on S3.\n    pth, archive, scheme = parse_path(path)\n    if scheme == 's3':\n        Env().get_aws_credentials()\n        log.debug(\"AWS credentials have been obtained\")\n\n    # Create dataset instances and pass the given env, which will\n    # be taken over by the dataset's context manager if it is not\n    # None.\n    if mode == 'r':\n        from rasterio._io import RasterReader\n        s = RasterReader(path)\n    elif mode == 'r+':\n        from rasterio._io import writer\n        s = writer(path, mode)\n    elif mode == 'r-':\n        from rasterio._base import DatasetReader\n        s = DatasetReader(path)\n    elif mode == 'w':\n        from rasterio._io import writer\n        s = writer(path, mode, driver=driver,\n                   width=width, height=height, count=count,\n                   crs=crs, transform=transform, dtype=dtype,\n                   nodata=nodata, **kwargs)\n    else:\n        raise ValueError(\n            \"mode string must be one of 'r', 'r+', or 'w', not %s\" % mode)\n    s.start()\n    return s\n\n\n@ensure_env\ndef copy(src, dst, **kw):\n    \"\"\"Copy a source raster to a new destination with driver specific\n    creation options.\n\n    Parameters\n    ----------\n    src: string\n        an existing raster file\n    dst: string\n        valid path to output file.\n\n    Returns\n    -------\n    None\n\n    Raises\n    ------\n    ValueError:\n        If source path is not a valid Dataset\n\n    Notes\n    -----\n    A ``driver`` keyword argument with value like 'GTiff' or 'JPEG' is\n    used to control the output format.\n\n    This is the one way to create write-once files like JPEGs.\n    \"\"\"\n    from rasterio._copy import RasterCopier\n    return RasterCopier()(src, dst, **kw)\n\n\ndef drivers(**kwargs):\n    \"\"\"Create a gdal environment with registered drivers and creation\n    options.\n\n    This function is deprecated; please use ``env.Env`` instead.\n\n    Parameters\n    ----------\n    **kwargs:: keyword arguments\n        Configuration options that define GDAL driver behavior\n\n        See https://trac.osgeo.org/gdal/wiki/ConfigOptions\n\n    Returns\n    -------\n    GDALEnv responsible for managing the environment.\n\n    Notes\n    -----\n    Use as a context manager, ``with rasterio.drivers(): ...``\n    \"\"\"\n    warnings.warn(\"Deprecated; Use env.Env instead\", DeprecationWarning)\n    return Env(**kwargs)\n\n\nBand = namedtuple('Band', ['ds', 'bidx', 'dtype', 'shape'])\n\ndef band(ds, bidx):\n    \"\"\"Wraps a dataset and a band index up as a 'Band'\n\n    Parameters\n    ----------\n    ds: rasterio.RasterReader\n        Open rasterio dataset\n    bidx: int\n        Band number, index starting at 1\n\n    Returns\n    -------\n    a rasterio.Band\n    \"\"\"\n    return Band(\n        ds,\n        bidx,\n        set(ds.dtypes).pop(),\n        ds.shape)\n\n\ndef pad(array, transform, pad_width, mode=None, **kwargs):\n    \"\"\"pad array and adjust affine transform matrix.\n\n    Parameters\n    ----------\n    array: ndarray\n        Numpy ndarray, for best results a 2D array\n    transform: Affine transform\n        transform object mapping pixel space to coordinates\n    pad_width: int\n        number of pixels to pad array on all four\n    mode: str or function\n        define the method for determining padded values\n\n    Returns\n    -------\n    (array, transform): tuple\n        Tuple of new array and affine transform\n\n    Notes\n    -----\n    See numpy docs for details on mode and other kwargs:\n    http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.pad.html\n    \"\"\"\n    import numpy as np\n    transform = guard_transform(transform)\n    padded_array = np.pad(array, pad_width, mode, **kwargs)\n    padded_trans = list(transform)\n    padded_trans[2] -= pad_width * padded_trans[0]\n    padded_trans[5] -= pad_width * padded_trans[4]\n    return padded_array, Affine(*padded_trans[:6])\n\n\ndef get_data_window(arr, nodata=None):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.get_data_window(arr, nodata)\n\n\ndef window_union(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.union(data)\n\n\ndef window_intersection(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.intersection(data)\n\ndef windows_intersect(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.intersect(data)\n", "path": "rasterio/__init__.py"}], "after_files": [{"content": "\"\"\"Rasterio\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom collections import namedtuple\nimport logging\ntry:\n    from logging import NullHandler\nexcept ImportError:  # pragma: no cover\n    class NullHandler(logging.Handler):\n        def emit(self, record):\n            pass\nimport warnings\n\nfrom rasterio._base import (\n    eval_window, window_shape, window_index, gdal_version)\nfrom rasterio.dtypes import (\n    bool_, ubyte, uint8, uint16, int16, uint32, int32, float32, float64,\n    complex_, check_dtype)\nfrom rasterio.env import ensure_env, Env\nfrom rasterio.compat import string_types\nfrom rasterio.profiles import default_gtiff_profile\nfrom rasterio.transform import Affine, guard_transform\nfrom rasterio.vfs import parse_path\nfrom rasterio import windows\n\n# These modules are imported from the Cython extensions, but are also import\n# here to help tools like cx_Freeze find them automatically\nfrom rasterio import _err, coords, enums, vfs\n\n# Classes in rasterio._io are imported below just before we need them.\n\n__all__ = [\n    'band', 'open', 'copy', 'pad']\n__version__ = \"1.0.dev1\"\n__gdal_version__ = gdal_version()\n\n# Rasterio attaches NullHandler to the 'rasterio' logger and its\n# descendents. See\n# https://docs.python.org/2/howto/logging.html#configuring-logging-for-a-library\n# Applications must attach their own handlers in order to see messages.\n# See rasterio/rio/main.py for an example.\nlog = logging.getLogger(__name__)\nlog.addHandler(NullHandler())\n\n\n@ensure_env\ndef open(path, mode='r', driver=None, width=None, height=None,\n         count=None, crs=None, transform=None, dtype=None, nodata=None,\n         **kwargs):\n    \"\"\"Open file at ``path`` in ``mode`` 'r' (read), 'r+' (read and\n    write), or 'w' (write) and return a dataset Reader or Updater\n    object.\n\n    In write mode, a driver name such as \"GTiff\" or \"JPEG\" (see GDAL\n    docs or ``gdal_translate --help`` on the command line),\n    ``width`` (number of pixels per line) and ``height`` (number of\n    lines), the ``count`` number of bands in the new file must be\n    specified.  Additionally, the data type for bands such as\n    ``rasterio.ubyte`` for 8-bit bands or ``rasterio.uint16`` for\n    16-bit bands must be specified using the ``dtype`` argument.\n\n    Parameters\n    ----------\n    mode: string\n        \"r\" (read), \"r+\" (read/write), or \"w\" (write)\n    driver: string\n        driver code specifying the format name (e.g. \"GTiff\" or\n        \"JPEG\"). See GDAL docs at\n        http://www.gdal.org/formats_list.html (optional, required\n        for writing).\n    width: int\n        number of pixels per line\n        (optional, required for write)\n    height: int\n        number of lines\n        (optional, required for write)\n    count: int > 0\n        number of bands\n        (optional, required for write)\n    dtype: rasterio.dtype\n        the data type for bands such as ``rasterio.ubyte`` for\n        8-bit bands or ``rasterio.uint16`` for 16-bit bands\n        (optional, required for write)\n    crs: dict or string\n        Coordinate reference system\n        (optional, recommended for write)\n    transform: Affine instance\n        Affine transformation mapping the pixel space to geographic\n        space (optional, recommended for writing).\n    nodata: number\n        Defines pixel value to be interpreted as null/nodata\n        (optional, recommended for write)\n\n    Returns\n    -------\n    A ``DatasetReader`` or ``DatasetUpdater`` object.\n\n    Notes\n    -----\n    In write mode, you must specify at least ``width``, ``height``,\n    ``count`` and ``dtype``.\n\n    A coordinate reference system for raster datasets in write mode\n    can be defined by the ``crs`` argument. It takes Proj4 style\n    mappings like\n\n    .. code::\n\n      {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84',\n       'no_defs': True}\n\n    An affine transformation that maps ``col,row`` pixel coordinates\n    to ``x,y`` coordinates in the coordinate reference system can be\n    specified using the ``transform`` argument. The value should be\n    an instance of ``affine.Affine``\n\n    .. code:: python\n\n        >>> from affine import Affine\n        >>> transform = Affine(0.5, 0.0, -180.0, 0.0, -0.5, 90.0)\n\n    These coefficients are shown in the figure below.\n\n    .. code::\n\n      | x |   | a  b  c | | c |\n      | y | = | d  e  f | | r |\n      | 1 |   | 0  0  1 | | 1 |\n\n      a: rate of change of X with respect to increasing column,\n         i.e. pixel width\n      b: rotation, 0 if the raster is oriented \"north up\"\n      c: X coordinate of the top left corner of the top left pixel\n      d: rotation, 0 if the raster is oriented \"north up\"\n      e: rate of change of Y with respect to increasing row,\n         usually a negative number (i.e. -1 * pixel height) if\n         north-up.\n      f: Y coordinate of the top left corner of the top left pixel\n\n    A 6-element sequence of the affine transformation matrix\n    coefficients in ``c, a, b, f, d, e`` order, (i.e. GDAL\n    geotransform order) will be accepted until 1.0 (deprecated).\n\n    A virtual filesystem can be specified. The ``vfs`` parameter may\n    be an Apache Commons VFS style string beginning with \"zip://\" or\n    \"tar://\"\". In this case, the ``path`` must be an absolute path\n    within that container.\n\n    \"\"\"\n    if not isinstance(path, string_types):\n        raise TypeError(\"invalid path: {0!r}\".format(path))\n    if mode and not isinstance(mode, string_types):\n        raise TypeError(\"invalid mode: {0!r}\".format(mode))\n    if driver and not isinstance(driver, string_types):\n        raise TypeError(\"invalid driver: {0!r}\".format(driver))\n    if dtype and not check_dtype(dtype):\n        raise TypeError(\"invalid dtype: {0!r}\".format(dtype))\n    if transform:\n        transform = guard_transform(transform)\n    elif 'affine' in kwargs:\n        affine = kwargs.pop('affine')\n        transform = guard_transform(affine)\n\n    # Get AWS credentials if we're attempting to access a raster\n    # on S3.\n    pth, archive, scheme = parse_path(path)\n    if scheme == 's3':\n        Env().get_aws_credentials()\n        log.debug(\"AWS credentials have been obtained\")\n\n    # Create dataset instances and pass the given env, which will\n    # be taken over by the dataset's context manager if it is not\n    # None.\n    if mode == 'r':\n        from rasterio._io import RasterReader\n        s = RasterReader(path)\n    elif mode == 'r+':\n        from rasterio._io import writer\n        s = writer(path, mode)\n    elif mode == 'r-':\n        from rasterio._base import DatasetReader\n        s = DatasetReader(path)\n    elif mode == 'w':\n        from rasterio._io import writer\n        s = writer(path, mode, driver=driver,\n                   width=width, height=height, count=count,\n                   crs=crs, transform=transform, dtype=dtype,\n                   nodata=nodata, **kwargs)\n    else:\n        raise ValueError(\n            \"mode string must be one of 'r', 'r+', or 'w', not %s\" % mode)\n    s.start()\n    return s\n\n\n@ensure_env\ndef copy(src, dst, **kw):\n    \"\"\"Copy a source raster to a new destination with driver specific\n    creation options.\n\n    Parameters\n    ----------\n    src: string\n        an existing raster file\n    dst: string\n        valid path to output file.\n\n    Returns\n    -------\n    None\n\n    Raises\n    ------\n    ValueError:\n        If source path is not a valid Dataset\n\n    Notes\n    -----\n    A ``driver`` keyword argument with value like 'GTiff' or 'JPEG' is\n    used to control the output format.\n\n    This is the one way to create write-once files like JPEGs.\n    \"\"\"\n    from rasterio._copy import RasterCopier\n    return RasterCopier()(src, dst, **kw)\n\n\ndef drivers(**kwargs):\n    \"\"\"Create a gdal environment with registered drivers and creation\n    options.\n\n    This function is deprecated; please use ``env.Env`` instead.\n\n    Parameters\n    ----------\n    **kwargs:: keyword arguments\n        Configuration options that define GDAL driver behavior\n\n        See https://trac.osgeo.org/gdal/wiki/ConfigOptions\n\n    Returns\n    -------\n    GDALEnv responsible for managing the environment.\n\n    Notes\n    -----\n    Use as a context manager, ``with rasterio.drivers(): ...``\n    \"\"\"\n    warnings.warn(\"Deprecated; Use env.Env instead\", DeprecationWarning)\n    return Env(**kwargs)\n\n\nBand = namedtuple('Band', ['ds', 'bidx', 'dtype', 'shape'])\n\ndef band(ds, bidx):\n    \"\"\"Wraps a dataset and a band index up as a 'Band'\n\n    Parameters\n    ----------\n    ds: rasterio.RasterReader\n        Open rasterio dataset\n    bidx: int\n        Band number, index starting at 1\n\n    Returns\n    -------\n    a rasterio.Band\n    \"\"\"\n    return Band(\n        ds,\n        bidx,\n        set(ds.dtypes).pop(),\n        ds.shape)\n\n\ndef pad(array, transform, pad_width, mode=None, **kwargs):\n    \"\"\"pad array and adjust affine transform matrix.\n\n    Parameters\n    ----------\n    array: ndarray\n        Numpy ndarray, for best results a 2D array\n    transform: Affine transform\n        transform object mapping pixel space to coordinates\n    pad_width: int\n        number of pixels to pad array on all four\n    mode: str or function\n        define the method for determining padded values\n\n    Returns\n    -------\n    (array, transform): tuple\n        Tuple of new array and affine transform\n\n    Notes\n    -----\n    See numpy docs for details on mode and other kwargs:\n    http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.pad.html\n    \"\"\"\n    import numpy as np\n    transform = guard_transform(transform)\n    padded_array = np.pad(array, pad_width, mode, **kwargs)\n    padded_trans = list(transform)\n    padded_trans[2] -= pad_width * padded_trans[0]\n    padded_trans[5] -= pad_width * padded_trans[4]\n    return padded_array, Affine(*padded_trans[:6])\n\n\ndef get_data_window(arr, nodata=None):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.get_data_window(arr, nodata)\n\n\ndef window_union(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.union(data)\n\n\ndef window_intersection(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.intersection(data)\n\ndef windows_intersect(data):\n    warnings.warn(\"Deprecated; Use rasterio.windows instead\", DeprecationWarning)\n    return windows.intersect(data)\n", "path": "rasterio/__init__.py"}]}