Mercurial > repos > ecology > xarray_metadata_info
annotate xarray_mapplot.py @ 4:9bbaab36a5d4 draft
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
author | ecology |
---|---|
date | Thu, 20 Jan 2022 17:09:40 +0000 |
parents | 663268794710 |
children |
rev | line source |
---|---|
4
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
1 #!/usr/bin/env python3 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
2 # |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
3 # |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
4 # usage: xarray_mapplot.py [-h] [--proj PROJ] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
5 # [--cmap CMAP] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
6 # [--output OUTPUT] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
7 # [--time TIMES] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
8 # [--nrow NROW] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
9 # [--ncol NCOL] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
10 # [--title title] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
11 # [--latitude LATITUDE] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
12 # [--longitude LONGITUDE] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
13 # [--land ALPHA-LAND] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
14 # [--ocean ALPHA-OCEAN] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
15 # [--coastline ALPHA-COASTLINE] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
16 # [--borders ALPHA-BORDERS] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
17 # [--xlim "x1,x2"] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
18 # [--ylim "y1,y2"] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
19 # [--range "valmin,valmax"] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
20 # [--threshold VAL] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
21 # [--label label-colorbar] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
22 # [--config config-file] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
23 # [--shift] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
24 # [-v] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
25 # input varname |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
26 # |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
27 # positional arguments: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
28 # input input filename with geographical coordinates (netCDF |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
29 # format) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
30 # varname Specify which variable to plot (case sensitive) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
31 # |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
32 # optional arguments: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
33 # -h, --help show this help message and exit |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
34 # --proj PROJ Specify the projection on which we draw |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
35 # --cmap CMAP Specify which colormap to use for plotting |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
36 # --output OUTPUT output filename to store resulting image (png format) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
37 # --time TIMES time index from the file for multiple plots ("0 1 2 3") |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
38 # --title plot or subplot title |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
39 # --latitude variable name for latitude |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
40 # --longitude variable name for longitude |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
41 # --land add land on plot with alpha value [0-1] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
42 # --ocean add oceans on plot with alpha value [0-1] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
43 # --coastline add coastline with alpha value [0-1] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
44 # --borders add country borders with alpha value [0-1] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
45 # --xlim limited geographical area longitudes "x1,x2" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
46 # --ylim limited geographical area latitudes "y1,y2" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
47 # --range "valmin,valmax" for plotting |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
48 # --threshold do not plot values below threshold |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
49 # --label set a label for colormap |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
50 # --config plotting parameters are passed via a config file |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
51 # (overwrite other plotting options) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
52 # --shift shift longitudes if specified |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
53 # -v, --verbose switch on verbose mode |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
54 # |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
55 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
56 import argparse |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
57 import ast |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
58 import warnings |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
59 from pathlib import Path |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
60 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
61 import cartopy.crs as ccrs |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
62 import cartopy.feature as feature |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
63 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
64 from cmcrameri import cm |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
65 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
66 import matplotlib as mpl |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
67 mpl.use('Agg') |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
68 from matplotlib import pyplot # noqa: I202,E402 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
69 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
70 import xarray as xr # noqa: E402 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
71 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
72 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
73 class MapPlotXr (): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
74 def __init__(self, input, varname, output, verbose=False, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
75 config_file="", proj="", shift=False): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
76 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
77 li = list(input.split(",")) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
78 if len(li) > 1: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
79 self.input = li |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
80 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
81 self.input = input |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
82 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
83 if proj != "" and proj is not None and Path(proj).exists(): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
84 f = open(proj) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
85 sdict = ''.join( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
86 f.read().replace("\n", "").split('{')[1].split('}')[0] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
87 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
88 self.proj = '{' + sdict.strip() + '}' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
89 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
90 self.proj = None |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
91 self.varname = varname |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
92 self.shift = shift |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
93 self.xylim_supported = False |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
94 self.colorbar = True |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
95 if output is None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
96 if type(self.input) is list: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
97 self.output = Path(self.input[0]).stem + '.png' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
98 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
99 self.output = Path(self.input).stem + '.png' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
100 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
101 self.output = output |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
102 self.verbose = verbose |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
103 self.label = {} |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
104 self.time = [] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
105 self.xlim = [] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
106 self.ylim = [] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
107 self.range = [] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
108 self.latitude = "latitude" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
109 self.longitude = "longitude" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
110 self.land = 0 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
111 self.ocean = 0 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
112 self.coastline = 0 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
113 self.borders = 0 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
114 self.cmap = "coolwarm" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
115 self.threshold = "" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
116 self.title = "" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
117 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
118 if config_file != "" and config_file is not None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
119 with open(config_file) as f: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
120 sdict = ''.join( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
121 f.read().replace("\n", "").split('{')[1].split('}')[0] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
122 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
123 tmp = ast.literal_eval('{' + sdict.strip() + '}') |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
124 for key in tmp: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
125 if key == 'time': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
126 time = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
127 self.time = list(map(int, time.split(","))) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
128 if key == 'cmap': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
129 self.get_cmap(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
130 if key == 'latitude': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
131 self.latitude = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
132 if key == 'longitude': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
133 self.longitude = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
134 if key == 'land': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
135 self.land = float(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
136 if key == 'ocean': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
137 self.ocean = float(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
138 if key == 'coastline': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
139 self.coastline = float(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
140 if key == 'borders': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
141 self.borders = float(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
142 if key == 'xlim': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
143 xlim = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
144 self.xlim = list(map(float, xlim.split(","))) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
145 if key == 'ylim': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
146 ylim = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
147 self.ylim = list(map(float, ylim.split(","))) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
148 if key == 'range': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
149 range_values = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
150 self.range = list(map(float, range_values.split(","))) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
151 if key == 'threshold': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
152 self.threshold = float(tmp[key]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
153 if key == 'label': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
154 self.label['label'] = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
155 if key == 'title': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
156 self.title = tmp[key] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
157 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
158 if type(self.input) is list: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
159 self.dset = xr.open_mfdataset(self.input, use_cftime=True) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
160 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
161 self.dset = xr.open_dataset(self.input, use_cftime=True) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
162 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
163 if verbose: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
164 print("input: ", self.input) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
165 print("proj: ", self.proj) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
166 print("varname: ", self.varname) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
167 print("time: ", self.time) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
168 print("minval, maxval: ", self.range) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
169 print("title: ", self.title) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
170 print("output: ", self.output) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
171 print("label: ", self.label) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
172 print("shift: ", self.shift) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
173 print("ocean: ", self.ocean) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
174 print("land: ", self.land) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
175 print("coastline: ", self.coastline) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
176 print("borders: ", self.borders) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
177 print("latitude: ", self.latitude) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
178 print("longitude: ", self.longitude) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
179 print("xlim: ", self.xlim) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
180 print("ylim: ", self.ylim) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
181 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
182 def get_cmap(self, cmap): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
183 if cmap[0:3] == 'cm.': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
184 self.cmap = cm.__dict__[cmap[3:]] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
185 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
186 self.cmap = cmap |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
187 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
188 def projection(self): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
189 if self.proj is None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
190 return ccrs.PlateCarree() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
191 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
192 proj_dict = ast.literal_eval(self.proj) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
193 user_proj = proj_dict.pop("proj") |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
194 if user_proj == 'PlateCarree': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
195 self.xylim_supported = True |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
196 return ccrs.PlateCarree(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
197 elif user_proj == 'AlbersEqualArea': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
198 return ccrs.AlbersEqualArea(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
199 elif user_proj == 'AzimuthalEquidistant': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
200 return ccrs.AzimuthalEquidistant(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
201 elif user_proj == 'EquidistantConic': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
202 return ccrs.EquidistantConic(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
203 elif user_proj == 'LambertConformal': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
204 return ccrs.LambertConformal(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
205 elif user_proj == 'LambertCylindrical': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
206 return ccrs.LambertCylindrical(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
207 elif user_proj == 'Mercator': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
208 return ccrs.Mercator(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
209 elif user_proj == 'Miller': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
210 return ccrs.Miller(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
211 elif user_proj == 'Mollweide': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
212 return ccrs.Mollweide(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
213 elif user_proj == 'Orthographic': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
214 return ccrs.Orthographic(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
215 elif user_proj == 'Robinson': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
216 return ccrs.Robinson(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
217 elif user_proj == 'Sinusoidal': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
218 return ccrs.Sinusoidal(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
219 elif user_proj == 'Stereographic': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
220 return ccrs.Stereographic(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
221 elif user_proj == 'TransverseMercator': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
222 return ccrs.TransverseMercator(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
223 elif user_proj == 'UTM': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
224 return ccrs.UTM(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
225 elif user_proj == 'InterruptedGoodeHomolosine': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
226 return ccrs.InterruptedGoodeHomolosine(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
227 elif user_proj == 'RotatedPole': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
228 return ccrs.RotatedPole(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
229 elif user_proj == 'OSGB': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
230 self.xylim_supported = False |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
231 return ccrs.OSGB(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
232 elif user_proj == 'EuroPP': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
233 self.xylim_supported = False |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
234 return ccrs.EuroPP(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
235 elif user_proj == 'Geostationary': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
236 return ccrs.Geostationary(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
237 elif user_proj == 'NearsidePerspective': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
238 return ccrs.NearsidePerspective(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
239 elif user_proj == 'EckertI': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
240 return ccrs.EckertI(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
241 elif user_proj == 'EckertII': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
242 return ccrs.EckertII(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
243 elif user_proj == 'EckertIII': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
244 return ccrs.EckertIII(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
245 elif user_proj == 'EckertIV': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
246 return ccrs.EckertIV(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
247 elif user_proj == 'EckertV': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
248 return ccrs.EckertV(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
249 elif user_proj == 'EckertVI': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
250 return ccrs.EckertVI(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
251 elif user_proj == 'EqualEarth': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
252 return ccrs.EqualEarth(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
253 elif user_proj == 'Gnomonic': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
254 return ccrs.Gnomonic(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
255 elif user_proj == 'LambertAzimuthalEqualArea': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
256 return ccrs.LambertAzimuthalEqualArea(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
257 elif user_proj == 'NorthPolarStereo': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
258 return ccrs.NorthPolarStereo(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
259 elif user_proj == 'OSNI': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
260 return ccrs.OSNI(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
261 elif user_proj == 'SouthPolarStereo': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
262 return ccrs.SouthPolarStereo(**proj_dict) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
263 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
264 def plot(self, ts=None): |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
265 if self.shift: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
266 if self.longitude == 'longitude': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
267 self.dset = self.dset.assign_coords( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
268 longitude=((( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
269 self.dset[self.longitude] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
270 + 180) % 360) - 180)) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
271 elif self.longitude == 'lon': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
272 self.dset = self.dset.assign_coords( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
273 lon=(((self.dset[self.longitude] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
274 + 180) % 360) - 180)) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
275 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
276 pyplot.figure(1, figsize=[20, 10]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
277 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
278 # Set the projection to use for plotting |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
279 ax = pyplot.subplot(1, 1, 1, projection=self.projection()) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
280 if self.land: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
281 ax.add_feature(feature.LAND, alpha=self.land) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
282 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
283 if self.ocean: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
284 ax.add_feature(feature.OCEAN, alpha=self.ocean) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
285 if self.coastline: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
286 ax.coastlines(resolution='10m', alpha=self.coastline) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
287 if self.borders: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
288 ax.add_feature(feature.BORDERS, linestyle=':', alpha=self.borders) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
289 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
290 if self.xlim: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
291 min_lon = min(self.xlim[0], self.xlim[1]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
292 max_lon = max(self.xlim[0], self.xlim[1]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
293 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
294 min_lon = self.dset[self.longitude].min() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
295 max_lon = self.dset[self.longitude].max() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
296 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
297 if self.ylim: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
298 min_lat = min(self.ylim[0], self.ylim[1]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
299 max_lat = max(self.ylim[0], self.ylim[1]) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
300 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
301 min_lat = self.dset[self.latitude].min() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
302 max_lat = self.dset[self.latitude].max() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
303 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
304 if self.xylim_supported: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
305 pyplot.xlim(min_lon, max_lon) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
306 pyplot.ylim(min_lat, max_lat) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
307 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
308 # Fix extent |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
309 if self.threshold == "" or self.threshold is None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
310 threshold = self.dset[self.varname].min() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
311 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
312 threshold = float(self.threshold) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
313 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
314 if self.range == []: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
315 minval = self.dset[self.varname].min() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
316 maxval = self.dset[self.varname].max() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
317 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
318 minval = self.range[0] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
319 maxval = self.range[1] |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
320 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
321 if self.verbose: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
322 print("minval: ", minval) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
323 print("maxval: ", maxval) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
324 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
325 # pass extent with vmin and vmax parameters |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
326 proj_t = ccrs.PlateCarree() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
327 if ts is None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
328 self.dset.where( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
329 self.dset[self.varname] > threshold |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
330 )[self.varname].plot(ax=ax, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
331 vmin=minval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
332 vmax=maxval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
333 transform=proj_t, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
334 cmap=self.cmap, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
335 cbar_kwargs=self.label |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
336 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
337 if self.title != "" and self.title is not None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
338 pyplot.title(self.title) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
339 pyplot.savefig(self.output) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
340 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
341 if self.colorbar: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
342 self.dset.where( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
343 self.dset[self.varname] > threshold |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
344 )[self.varname].isel(time=ts).plot(ax=ax, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
345 vmin=minval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
346 vmax=maxval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
347 transform=proj_t, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
348 cmap=self.cmap, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
349 cbar_kwargs=self.label |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
350 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
351 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
352 self.dset.where( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
353 self.dset[self.varname] > minval |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
354 )[self.varname].isel(time=ts).plot(ax=ax, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
355 vmin=minval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
356 vmax=maxval, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
357 transform=proj_t, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
358 cmap=self.cmap, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
359 add_colorbar=False) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
360 if self.title != "" and self.title is not None: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
361 pyplot.title(self.title + "(time = " + str(ts) + ')') |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
362 pyplot.savefig(self.output[:-4] + "_time" + str(ts) + |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
363 self.output[-4:]) # assume png format |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
364 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
365 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
366 if __name__ == '__main__': |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
367 warnings.filterwarnings("ignore") |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
368 parser = argparse.ArgumentParser() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
369 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
370 'input', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
371 help='input filename with geographical coordinates (netCDF format)' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
372 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
373 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
374 '--proj', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
375 help='Config file with the projection on which we draw' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
376 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
377 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
378 'varname', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
379 help='Specify which variable to plot (case sensitive)' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
380 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
381 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
382 '--output', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
383 help='output filename to store resulting image (png format)' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
384 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
385 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
386 '--config', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
387 help='pass plotting parameters via a config file' |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
388 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
389 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
390 '--shift', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
391 help='shift longitudes if specified', |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
392 action="store_true" |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
393 ) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
394 parser.add_argument( |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
395 "-v", "--verbose", |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
396 help="switch on verbose mode", |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
397 action="store_true") |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
398 args = parser.parse_args() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
399 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
400 dset = MapPlotXr(input=args.input, varname=args.varname, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
401 output=args.output, verbose=args.verbose, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
402 config_file=args.config, proj=args.proj, |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
403 shift=args.shift) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
404 |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
405 if dset.time == []: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
406 dset.plot() |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
407 else: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
408 for t in dset.time: |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
409 dset.plot(t) |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
410 dset.shift = False # only shift once |
9bbaab36a5d4
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents:
3
diff
changeset
|
411 dset.colorbar = True |