-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from csiro-coasts/transect
Add `emsarray.transect` module
- Loading branch information
Showing
17 changed files
with
940 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ channels: | |
|
||
dependencies: | ||
- geos ~=3.10.2 | ||
- udunits2 >=2.2.25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,6 @@ API reference | |
utils.rst | ||
tutorial.rst | ||
plot.rst | ||
transect.rst | ||
types.rst | ||
exceptions.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. module:: emsarray.transect | ||
|
||
================= | ||
emsarray.transect | ||
================= | ||
|
||
.. currentmodule:: emsarray.transect | ||
|
||
Plot transects through your dataset. | ||
Transects are vertical slices along some path through your dataset. | ||
|
||
Examples | ||
-------- | ||
|
||
.. list-table:: | ||
|
||
* - :ref:`example-kgari-transect` | ||
|
||
.. image:: /_static/images/kgari-transect.png | ||
:width: 200 | ||
:class: no-scaled-link | ||
|
||
.. autofunction:: plot | ||
|
||
.. autoclass:: Transect | ||
:members: | ||
|
||
.. autoclass:: TransectPoint | ||
|
||
.. autoclass:: TransectSegment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import emsarray | ||
import shapely | ||
from emsarray import plot, transect | ||
from matplotlib import pyplot | ||
|
||
dataset_url = 'https://dapds00.nci.org.au/thredds/dodsC/fx3/model_data/gbr4_bgc_GBR4_H2p0_B2p0_Chyd_Dcrt.ncml' | ||
dataset = emsarray.open_dataset(dataset_url).isel(time=-1) | ||
dataset = dataset.ems.select_variables(['botz', 'temp']) | ||
|
||
line = shapely.LineString([ | ||
[152.9768944, -25.4827962], | ||
[152.9701996, -25.4420345], | ||
[152.9727745, -25.3967620], | ||
[152.9623032, -25.3517828], | ||
[152.9401588, -25.3103560], | ||
[152.9173279, -25.2538563], | ||
[152.8962135, -25.1942238], | ||
[152.8692627, -25.0706729], | ||
[152.8623962, -24.9698750], | ||
[152.8472900, -24.8415806], | ||
[152.8308105, -24.6470172], | ||
[152.7607727, -24.3521012], | ||
[152.6392365, -24.1906056], | ||
[152.4792480, -24.0615124], | ||
]) | ||
landmarks = [ | ||
('Round Island', shapely.Point(152.9262543, -25.2878719)), | ||
('Lady Elliot Island', shapely.Point(152.7145958, -24.1129146)), | ||
] | ||
|
||
# Plot the transect | ||
figure = transect.plot( | ||
dataset, line, dataset['temp'], | ||
figsize=(7.9, 3), | ||
bathymetry=dataset['botz'], | ||
landmarks=landmarks) | ||
figure.savefig('kgari-transect.png') | ||
|
||
# Plot the path of the transect | ||
figure = pyplot.figure(figsize=(5, 5), dpi=100) | ||
axes = figure.add_subplot(projection=dataset.ems.data_crs) | ||
axes.set_aspect(aspect='equal', adjustable='datalim') | ||
axes.set_title('Transect path') | ||
axes.add_collection(dataset.ems.make_poly_collection( | ||
dataset['botz'], cmap='Blues_r', edgecolor='face', | ||
linewidth=0.5, zorder=0)) | ||
plot.add_coast(axes, zorder=1) | ||
plot.add_gridlines(axes) | ||
plot.add_landmarks(axes, landmarks) | ||
axes = figure.axes[0] | ||
axes.set_extent(plot.bounds_to_extent(line.envelope.buffer(0.2).bounds)) | ||
axes.plot(*line.coords.xy, zorder=2) | ||
figure.savefig('kgari-path.png') | ||
|
||
pyplot.show(block=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _example-kgari-transect: | ||
|
||
==================== | ||
K'gari transect plot | ||
==================== | ||
|
||
The following is a :mod:`transect <emsarray.transect>` path | ||
starting in the Great Sandy Strait near K'gari, | ||
heading roughly North out to deeper waters: | ||
|
||
.. image:: /_static/images/kgari-path.png | ||
:alt: Transect of GBR1 dataset along Great Sandy Strait and past K'gari | ||
showing the water temperature. | ||
:align: center | ||
|
||
The temperature along this transect can be plotted: | ||
|
||
.. image:: /_static/images/kgari-transect.png | ||
:alt: Transect of GBR1 dataset along Great Sandy Strait and past K'gari | ||
showing the water temperature. | ||
|
||
Code | ||
==== | ||
|
||
:download:`Download kgari-transect.py example <kgari-transect.py>`. | ||
|
||
.. literalinclude:: kgari-transect.py | ||
:language: python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.