Skip to content

Commit

Permalink
updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
perrette committed Jun 2, 2016
1 parent f64f70a commit f442bcd
Show file tree
Hide file tree
Showing 30 changed files with 2,570 additions and 3,795 deletions.
2 changes: 1 addition & 1 deletion docs/_notebooks_rst/geoarray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ In contrast to cartopy/PROJ.4, dimarray.geo functions perform both coordinate tr

.. note :: Why cartopy and not just pyproj? Pyproj would be just fine, and is more minimalistic, but cartopy also implements vector transformas and offers other useful features related to plotting, reading shapefiles, download online data and so on, which come in handy. Moreover it feels more `"pythonic" <http://legacy.python.org/dev/peps/pep-0008>`_, is actively developed with support from the Met' Office, and is related to another interesting project, iris. It builds on other powerful packages such as shapely and it feels like in the long (or not so long) run it might grow toward something even more useful.
.. seealso:: :ref:`projection`
.. seealso:: :ref:`projection`
17 changes: 7 additions & 10 deletions docs/_notebooks_rst/netcdf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ DimArrayOnDisk: 'myvar' (6)
1 / scenario (3): u'a' to u'c'

>>> ds2['myvar'].values # doctest: +SKIP
<type 'netCDF4.Variable'>
<type 'netCDF4._netCDF4.Variable'>
int64 myvar(time, scenario)
units: myunits
bla: bla
Expand Down Expand Up @@ -234,23 +234,20 @@ Create a variable with unlimited dimension
>>>
>>> ds = da.open_nc('/tmp/test.nc', 'w')
>>> ds.axes.append('time', None)
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4.Dimension'> (unlimited): name = 'time', size = 0
<BLANKLINE>
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4._netCDF4.Dimension'> (unlimited): name = 'time', size = 0

Fill-up the variable:

>>> ds['bla'] = da.DimArray([1,2,3,4,5], dims=['time'], axes=[list('abcde')])
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4.Dimension'> (unlimited): name = 'time', size = 5
<BLANKLINE>
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4._netCDF4.Dimension'> (unlimited): name = 'time', size = 5

Append some new slices:

>>> ds['bla'].ix[5] = da.DimArray([66], dims=['time'], axes=[['f']])
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4.Dimension'> (unlimited): name = 'time', size = 6
<BLANKLINE>
>>> ds.nc.dimensions['time'] # underlying netCDF4 object # doctest: +SKIP
<type 'netCDF4._netCDF4.Dimension'> (unlimited): name = 'time', size = 6

>>> ds['bla'].read()
dimarray: 6 non-null elements (0 null)
Expand Down
Binary file modified docs/_notebooks_rst/netcdf_files/figure_4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 29 additions & 15 deletions docs/_notebooks_rst/projection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,25 @@ They are obviously projection coordinates. 2-dimensional longitude and latitude
Examining closer the attributes of 'surfvelmag' variable, a "grid_mapping" attribute is present:

>>> ds['surfvelmag'].attrs # doctest: +SKIP
OrderedDict([(u'grid_mapping', u'mapping'), (u'reference', u'Joughin I., Smith B.E., Howat I.M., Scambos T., Moon T., "Greenland flow variability from ice-sheet wide velocity mapping", JGlac 56(197), 2010.'), (u'note', u'Ian Joughin notes that "Having any papers that use the data we provided to searise cite this paper [the reference provided] gives us something we can track through ISI and report to NASA to satisfy their metrics requirements, which is a necessary evil to ensure continued production of such data sets. So ... any publication of results based on this data should cite the above paper."'), (u'long_name', u'Surface Velocity Magnitude'), (u'units', u'meters/year')])
OrderedDict([(u'grid_mapping', u'mapping'),
(u'reference',
u'Joughin I., Smith B.E., Howat I.M., Scambos T., Moon T., "Greenland flow variability from ice-sheet wide velocity mapping", JGlac 56(197), 2010.'),
(u'note',
u'Ian Joughin notes that "Having any papers that use the data we provided to searise cite this paper [the reference provided] gives us something we can track through ISI and report to NASA to satisfy their metrics requirements, which is a necessary evil to ensure continued production of such data sets. So ... any publication of results based on this data should cite the above paper."'),
(u'long_name', u'Surface Velocity Magnitude'),
(u'units', u'meters/year')])

"grid_mapping" is a string which points to another variable in the dataset, here "mapping". This is according to CF-conventions. *mapping* is a dummy variable whose attributes contain the information needed to define a coordinate reference system.

>>> grid_mapping = ds['mapping'].attrs
>>> grid_mapping # doctest: +SKIP
OrderedDict([(u'ellipsoid', u'WGS84'), (u'latitude_of_projection_origin', 90.0), (u'straight_vertical_longitude_from_pole', -39.0), (u'standard_parallel', 71.0), (u'false_northing', 0.0), (u'grid_mapping_name', u'polar_stereographic'), (u'false_easting', 0.0)])
OrderedDict([(u'ellipsoid', u'WGS84'),
(u'latitude_of_projection_origin', 90.0),
(u'straight_vertical_longitude_from_pole', -39.0),
(u'standard_parallel', 71.0),
(u'false_northing', 0.0),
(u'grid_mapping_name', u'polar_stereographic'),
(u'false_easting', 0.0)])

We can use matplotlib's contourf to get a feeling for what that all mean. Below using regular x1, y1 grid, in the projection plane.

Expand All @@ -127,18 +139,20 @@ We can use matplotlib's contourf to get a feeling for what that all mean. Below
>>> ax = gca() # get plot axis
>>> ax.set_aspect('equal') # equal aspect ratio
>>> ax.set_xticks([-500e3,0,500e3]) # ticks every 500 km # doctest: +SKIP
[<matplotlib.axis.XTick at 0x7f2e17660a50>,
<matplotlib.axis.XTick at 0x7f2e176a9650>,
<matplotlib.axis.XTick at 0x7f2e174d58d0>]
[<matplotlib.axis.XTick at 0x7f31cd8654d0>,
<matplotlib.axis.XTick at 0x7f31cd89c8d0>,
<matplotlib.axis.XTick at 0x7f31cd6e4350>]/home/perrette/glacierenv/local/lib/python2.7/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if self._edgecolors == str('face'):

.. image:: projection_files/figure_16-1.png

.. image:: projection_files/figure_16-2.png



And now plotting versus lon and lat (irregular, 2-D grid in this case):

>>> contourf(ds['lon'], ds['lat'], log(clip(v, 1e-3,inf))); colorbar() # doctest: +SKIP
<matplotlib.colorbar.Colorbar instance at 0x7f2e2043e680>
<matplotlib.colorbar.Colorbar instance at 0x7f31cd52a950>

.. image:: projection_files/figure_18-1.png

Expand All @@ -158,7 +172,7 @@ The :func:`dimarray.geo.crs.get_crs` function returns the most adequate projecti

>>> stere = get_crs(grid_mapping)
>>> stere # doctest: +SKIP
<dimarray.geo.crs.PolarStereographic at 0x7f2e142f1350>
<dimarray.geo.crs.PolarStereographic at 0x7f31cc56e1d0>

All projection classes defined in dimarray inherit from :class:cartopy.crs.CRS. A few common transformations have a Cartopy equivalent, and are defined as subclass, where possible.

Expand Down Expand Up @@ -216,7 +230,7 @@ Double-check against earlier figures, this looks all right:

>>> h = log(clip(vt,1e-3,inf)).contourf(levels=np.linspace(-7.5, 10, 8)) # doctest: +SKIP
>>> colorbar(h) # doctest: +SKIP
<matplotlib.colorbar.Colorbar instance at 0x7f2e20424e60>
<matplotlib.colorbar.Colorbar instance at 0x7f31cc4ed518>

.. image:: projection_files/figure_40-1.png

Expand All @@ -240,9 +254,9 @@ That is the original field on the projection plane.
>>> ax = gca()
>>> ax.set_aspect('equal') # equal aspect ratio
>>> ax.set_xticks([-500e3,0,500e3]) # ticks every 500 km # doctest: +SKIP
[<matplotlib.axis.XTick at 0x7f2e14168950>,
<matplotlib.axis.XTick at 0x7f2e14168110>,
<matplotlib.axis.XTick at 0x7f2e134d7650>]
[<matplotlib.axis.XTick at 0x7f31cd73dad0>,
<matplotlib.axis.XTick at 0x7f31cd865550>,
<matplotlib.axis.XTick at 0x7f31cb71a890>]

.. image:: projection_files/figure_45-1.png

Expand Down Expand Up @@ -273,10 +287,10 @@ Transforming vectors in longitude latitude coordinates does not make much sense
>>> ax = gca()
>>> ax.set_aspect('equal') # equal aspect ratio
>>> ax.set_xticks([-1000e3,0]) # ticks every 1000 km # doctest: +SKIP
/home/perrette/glacierenv/local/lib/python2.7/site-packages/numpy/ma/core.py:790: RuntimeWarning: invalid value encountered in greater_equal
/home/perrette/glacierenv/local/lib/python2.7/site-packages/numpy/ma/core.py:806: RuntimeWarning: invalid value encountered in greater_equal
return umath.absolute(a) * self.tolerance >= umath.absolute(b)
[<matplotlib.axis.XTick at 0x7f2e1402a650>,
<matplotlib.axis.XTick at 0x7f2e14011ed0>]
[<matplotlib.axis.XTick at 0x7f31cc233250>,
<matplotlib.axis.XTick at 0x7f31cc233790>]

.. image:: projection_files/figure_50-2.png

Expand Down
Binary file modified docs/_notebooks_rst/projection_files/figure_18-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_notebooks_rst/projection_files/figure_40-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_notebooks_rst/projection_files/figure_50-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/_notebooks_rst/reindexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ array([ nan, 3. , 3.5, 4. ])
>>> plt.plot(xl.time, xl.values, '*-',label='left') # doctest: +SKIP
>>> plt.plot(xr.time, xr.values, '+-',label='right') # doctest: +SKIP
>>> plt.legend(loc='upper left') # doctest: +SKIP
<matplotlib.legend.Legend at 0x7fe5a780f090>
<matplotlib.legend.Legend at 0x7fc6858ee850>

.. image:: reindexing_files/figure_18-1.png

Expand All @@ -117,4 +117,4 @@ dimarray: 2 non-null elements (2 null)
0 / x0 (4): 1 to 4
array([ nan, 3., nan, 4.])

See :func:`dimarray.align`
See :func:`dimarray.align`
Binary file modified docs/_notebooks_rst/reindexing_files/figure_18-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 40 additions & 40 deletions docs/_notebooks_rst/reshape_files/output_21-0.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,56 @@
<tr>
<th rowspan="2" valign="top">0</th>
<th>0</th>
<td> 0</td>
<td> 2</td>
<td> 4</td>
<td> 6</td>
<td> 8</td>
<td> 10</td>
<td> 12</td>
<td> 14</td>
<td> 16</td>
<td> 18</td>
<td>0</td>
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
<td>10</td>
<td>12</td>
<td>14</td>
<td>16</td>
<td>18</td>
</tr>
<tr>
<th>1</th>
<td> 1</td>
<td> 3</td>
<td> 5</td>
<td> 7</td>
<td> 9</td>
<td> 11</td>
<td> 13</td>
<td> 15</td>
<td> 17</td>
<td> 19</td>
<td>1</td>
<td>3</td>
<td>5</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
</tr>
<tr>
<th rowspan="2" valign="top">1</th>
<th>0</th>
<td> 20</td>
<td> 22</td>
<td> 24</td>
<td> 26</td>
<td> 28</td>
<td> 30</td>
<td> 32</td>
<td> 34</td>
<td> 36</td>
<td> 38</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>28</td>
<td>30</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>1</th>
<td> 21</td>
<td> 23</td>
<td> 25</td>
<td> 27</td>
<td> 29</td>
<td> 31</td>
<td> 33</td>
<td> 35</td>
<td> 37</td>
<td> 39</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
</tr>
</tbody>
</table>
Expand Down
16 changes: 10 additions & 6 deletions docs/_notebooks_rst/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ dimarray comes with basic plotting facility. For 1-D and 2-D data, it simplies i
>>> %matplotlib inline # doctest: +SKIP
>>> a = dataset['combined_data']
>>> a.plot() # doctest: +SKIP
Using matplotlib backend: Qt4Agg
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib
[<matplotlib.lines.Line2D at 0x7fb04ac30ed0>,
<matplotlib.lines.Line2D at 0x7fb04ac7e090>]
[<matplotlib.lines.Line2D at 0x7f729cffdd50>,
<matplotlib.lines.Line2D at 0x7f729cffded0>]

.. image:: tutorial_files/figure_80-2.png

Expand All @@ -380,15 +380,19 @@ In addition, it can also display 2-D data via its methods `contour`, `contourf`
>>> c = a.contourf()
>>> colorbar(c) # explicit colorbar creation # doctest: +SKIP
>>> a.contour(colors='k') # doctest: +SKIP
<matplotlib.contour.QuadContourSet instance at 0x7fb04aa83560>
/home/perrette/glacierenv/local/lib/python2.7/site-packages/matplotlib/collections.py:650: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if self._edgecolors_original != str('face'):
<matplotlib.contour.QuadContourSet instance at 0x7f729ce46b00>/home/perrette/glacierenv/local/lib/python2.7/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if self._edgecolors == str('face'):

.. image:: tutorial_files/figure_82-1.png

.. image:: tutorial_files/figure_82-3.png



>>> # plot the data
>>> a.pcolor(colorbar=True) # colorbar as keyword argument # doctest: +SKIP
<matplotlib.collections.QuadMesh at 0x7fb04a95d7d0>
<matplotlib.collections.QuadMesh at 0x7f729cd3aa10>

.. image:: tutorial_files/figure_83-1.png

Expand Down
Binary file modified docs/_notebooks_rst/tutorial_files/figure_80-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/_notebooks_rst/tutorial_files/figure_82-1.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_notebooks_rst/tutorial_files/figure_83-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 40 additions & 40 deletions docs/_notebooks_rst/tutorial_files/output_75-0.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,56 @@
<tr>
<th rowspan="2" valign="top">0</th>
<th>0</th>
<td> 0</td>
<td> 2</td>
<td> 4</td>
<td> 6</td>
<td> 8</td>
<td> 10</td>
<td> 12</td>
<td> 14</td>
<td> 16</td>
<td> 18</td>
<td>0</td>
<td>2</td>
<td>4</td>
<td>6</td>
<td>8</td>
<td>10</td>
<td>12</td>
<td>14</td>
<td>16</td>
<td>18</td>
</tr>
<tr>
<th>1</th>
<td> 1</td>
<td> 3</td>
<td> 5</td>
<td> 7</td>
<td> 9</td>
<td> 11</td>
<td> 13</td>
<td> 15</td>
<td> 17</td>
<td> 19</td>
<td>1</td>
<td>3</td>
<td>5</td>
<td>7</td>
<td>9</td>
<td>11</td>
<td>13</td>
<td>15</td>
<td>17</td>
<td>19</td>
</tr>
<tr>
<th rowspan="2" valign="top">1</th>
<th>0</th>
<td> 20</td>
<td> 22</td>
<td> 24</td>
<td> 26</td>
<td> 28</td>
<td> 30</td>
<td> 32</td>
<td> 34</td>
<td> 36</td>
<td> 38</td>
<td>20</td>
<td>22</td>
<td>24</td>
<td>26</td>
<td>28</td>
<td>30</td>
<td>32</td>
<td>34</td>
<td>36</td>
<td>38</td>
</tr>
<tr>
<th>1</th>
<td> 21</td>
<td> 23</td>
<td> 25</td>
<td> 27</td>
<td> 29</td>
<td> 31</td>
<td> 33</td>
<td> 35</td>
<td> 37</td>
<td> 39</td>
<td>21</td>
<td>23</td>
<td>25</td>
<td>27</td>
<td>29</td>
<td>31</td>
<td>33</td>
<td>35</td>
<td>37</td>
<td>39</td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit f442bcd

Please sign in to comment.