annotate psymap_simple.py @ 1:706666d912d5 draft

"planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
author climate
date Sat, 05 Oct 2019 17:11:18 -0400
parents db8d76da4174
children e6d1e9d6b399
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
1 #!/usr/bin/env python3
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
2 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
3 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
4 # usage: psymap_simple.py [-h] [--proj PROJ]
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
5 # [--cmap CMAP]
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
6 # [--output OUTPUT]
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
7 # [-v]
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
8 # input varname
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
9 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
10 # positional arguments:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
11 # input input filename with geographical coordinates (netCDF
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
12 # format)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
13 # varname Specify which variable to plot (case sensitive)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
14 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
15 # optional arguments:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
16 # -h, --help show this help message and exit
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
17 # --proj PROJ Specify the projection on which we draw
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
18 # --cmap CMAP Specify which colormap to use for plotting
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
19 # --output OUTPUT output filename to store resulting image (png format)
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
20 # --time TIMES time index from the file for multiple plots ("0 1 2 3")
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
21 # --nrow NROW number of rows for multiple plot grid
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
22 # --ncol NCOL number of columns for multiple plot grid
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
23 # --format date format such as %Y (for year) %B (for month), etc.
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
24 # --title plot or subplot title
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
25 # -v, --verbose switch on verbose mode
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
26 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
27
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
28 import argparse
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
29 import warnings
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
30 from pathlib import Path
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
31
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
32 import matplotlib as mpl
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
33 mpl.use('Agg')
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
34 from matplotlib import pyplot # noqa: I202,E402
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
35
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
36 import psyplot.project as psy # noqa: I202,E402
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
37 from psyplot import rcParams # noqa: I202,E402
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
38
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
39
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
40 class PsyPlot ():
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
41 def __init__(self, input, proj, varname, cmap, output, verbose=False,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
42 time=[], nrow=1, ncol=1, format="%B %e, %Y",
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
43 title=""):
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
44 self.input = input
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
45 self.proj = proj
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
46 self.varname = varname
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
47 self.cmap = cmap
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
48 self.time = time
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
49 if format is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
50 self.format = ""
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
51 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
52 self.format = format.replace('X', '%')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
53 if title is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
54 self.title = ""
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
55 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
56 self.title = title
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
57 if ncol is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
58 self.ncol = 1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
59 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
60 self.ncol = int(ncol)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
61 if nrow is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
62 self.nrow = 1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
63 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
64 self.nrow = int(nrow)
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
65 if output is None:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
66 self.output = Path(input).stem + '.png'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
67 else:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
68 self.output = output
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
69 self.verbose = verbose
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
70 if verbose:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
71 print("input: ", self.input)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
72 print("proj: ", self.proj)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
73 print("varname: ", self.varname)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
74 print("cmap: ", self.cmap)
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
75 print("time: ", self.time)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
76 print("ncol: ", self.ncol)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
77 print("nrow: ", self.nrow)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
78 print("title: ", self.title)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
79 print("date format: ", self.format)
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
80 print("output: ", self.output)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
81
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
82 def plot(self):
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
83 if self.title and self.format:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
84 title = self.title + "\n" + self.format
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
85 elif not self.title and self.format:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
86 title = self.format
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
87 elif self.title and not self.format:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
88 title = self.title
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
89 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
90 title = '%(long_name)s'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
91
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
92 if self.cmap is None and self.proj is None:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
93 psy.plot.mapplot(self.input, name=self.varname,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
94 title=title,
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
95 clabel='{desc}')
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
96 elif self.proj is None or not self.proj:
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
97 psy.plot.mapplot(self.input, name=self.varname,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
98 title=title,
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
99 cmap=self.cmap, clabel='{desc}')
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
100 elif self.cmap is None or not self.cmap:
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
101 psy.plot.mapplot(self.input, name=self.varname,
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
102 projection=self.proj,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
103 title=title,
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
104 clabel='{desc}')
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
105 else:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
106 psy.plot.mapplot(self.input, name=self.varname,
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
107 cmap=self.cmap,
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
108 projection=self.proj,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
109 title=title,
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
110 clabel='{desc}')
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
111
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
112 pyplot.savefig(self.output)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
113
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
114 def multiple_plot(self):
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
115 if not self.format:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
116 self.format = "%B %e, %Y"
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
117
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
118 if not self.title:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
119 title = self.format
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
120 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
121 title = self.title + "\n" + self.format
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
122 mpl.rcParams['figure.figsize'] = [20, 8]
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
123 mpl.rcParams.update({'font.size': 8})
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
124 rcParams.update({'plotter.maps.grid_labelsize': 8.0})
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
125 if self.cmap is None and self.proj is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
126 m = psy.plot.mapplot(self.input, name=self.varname,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
127 title=title,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
128 ax=(self.nrow, self.ncol),
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
129 time=self.time, sort=['time'],
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
130 clabel='{desc}')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
131 m.share(keys='bounds')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
132 elif self.proj is None or not self.proj:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
133 m = psy.plot.mapplot(self.input, name=self.varname,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
134 title=title,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
135 ax=(self.nrow, self.ncol),
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
136 time=self.time, sort=['time'],
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
137 cmap=self.cmap, clabel='{desc}')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
138 m.share(keys='bounds')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
139 elif self.cmap is None or not self.cmap:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
140 m = psy.plot.mapplot(self.input, name=self.varname,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
141 projection=self.proj,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
142 ax=(self.nrow, self.ncol),
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
143 time=self.time, sort=['time'],
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
144 title=title,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
145 clabel='{desc}')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
146 m.share(keys='bounds')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
147 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
148 m = psy.plot.mapplot(self.input, name=self.varname,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
149 cmap=self.cmap,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
150 projection=self.proj,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
151 ax=(self.nrow, self.ncol),
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
152 time=self.time, sort=['time'],
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
153 title=title,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
154 clabel='{desc}')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
155 m.share(keys='bounds')
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
156
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
157 pyplot.savefig(self.output)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
158
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
159
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
160 def psymap_plot(input, proj, varname, cmap, output, verbose, time,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
161 nrow, ncol, format, title):
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
162 """Generate plot from input filename"""
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
163
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
164 p = PsyPlot(input, proj, varname, cmap, output, verbose, time,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
165 nrow, ncol, format, title)
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
166 if len(time) == 0:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
167 p.plot()
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
168 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
169 p.multiple_plot()
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
170
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
171
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
172 if __name__ == '__main__':
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
173 warnings.filterwarnings("ignore")
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
174 parser = argparse.ArgumentParser()
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
175 parser.add_argument(
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
176 'input',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
177 help='input filename with geographical coordinates (netCDF format)'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
178 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
179
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
180 parser.add_argument(
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
181 '--proj',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
182 help='Specify the projection on which we draw'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
183 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
184 parser.add_argument(
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
185 'varname',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
186 help='Specify which variable to plot (case sensitive)'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
187 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
188 parser.add_argument(
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
189 '--cmap',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
190 help='Specify which colormap to use for plotting'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
191 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
192 parser.add_argument(
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
193 '--output',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
194 help='output filename to store resulting image (png format)'
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
195 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
196 parser.add_argument(
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
197 '--time',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
198 help='list of times to plot for multiple plots'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
199 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
200 parser.add_argument(
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
201 '--format',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
202 help='format for date/time (default is Month d, yyyy)'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
203 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
204 parser.add_argument(
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
205 '--title',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
206 help='plot title'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
207 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
208 parser.add_argument(
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
209 '--ncol',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
210 help='number of columns for multiple plots'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
211 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
212 parser.add_argument(
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
213 '--nrow',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
214 help='number of rows for multiple plots'
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
215 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
216 parser.add_argument(
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
217 "-v", "--verbose",
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
218 help="switch on verbose mode",
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
219 action="store_true")
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
220 args = parser.parse_args()
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
221
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
222 if args.time is None:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
223 time = []
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
224 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
225 time = list(map(int, args.time.split(",")))
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
226 psymap_plot(args.input, args.proj, args.varname, args.cmap,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
227 args.output, args.verbose, time,
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
228 args.nrow, args.ncol, args.format, args.title)