annotate psymap_simple.py @ 2:e6d1e9d6b399 draft

planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
author climate
date Thu, 26 Sep 2024 10:32:08 +0000
parents 706666d912d5
children
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]
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
7 # [-l]
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
8 # [-v]
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
9 # input varname
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
10 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
11 # positional arguments:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
12 # 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
13 # format)
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
14 # 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
15 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
16 # optional arguments:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
17 # -h, --help show this help message and exit
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
18 # -l, --logscale log scale the data
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
19 # --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
20 # --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
21 # --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
22 # --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
23 # --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
24 # --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
25 # --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
26 # --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
27 # -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
28 #
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
29
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
30 import argparse
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
31 import math
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
32 import warnings
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
33 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
34
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
35 import matplotlib as mpl
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
36 import psyplot.project as psy # noqa: I202,E402
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
37 import xarray
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
38
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
39 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
40 from matplotlib import pyplot # 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
41 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
42
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
43
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
44 class PsyPlot ():
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
45 def __init__(self, input, varname, output=None, logscale=False, cmap=None,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
46 proj=None, verbose=False, time=None, nrow=None, ncol=None,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
47 format=None, title=None):
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
48 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
49 self.varname = varname
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
50 if proj is None or proj == "":
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
51 self.proj = "cyl"
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
52 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
53 self.proj = proj
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
54 self.cmap = cmap if cmap is not None else "jet"
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
55 self.time = time if time is not None else []
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
56 self.ncol = int(ncol) if ncol is not None else int(1)
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
57 self.nrow = int(nrow) if nrow is not None else int(1)
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
58
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
59 # Open dataset
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
60 ds = xarray.open_dataset(input)[varname]
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
61 minv = math.log2(ds.data.min())
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
62 maxv = math.log2(ds.data.max())
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
63 if title is not None:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
64 self.title = title
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
65 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
66 self.title = ds.long_name
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
67 if len(self.title) > 60:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
68 self.title = ds.standard_name
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
69 del ds
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
70
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
71 if logscale:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
72 # Check that data range is sufficient for log scaling
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
73 if maxv < (minv * (10.0 ** 2.0)):
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
74 print("Not possible to log scale, switching to linear scale")
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
75 self.bounds = None
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
76 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
77 self.bounds = ['log', 2]
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
78 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
79 self.bounds = None
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
80 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
81 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
82 else:
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
83 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
84 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
85 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
86 else:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
87 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
88 if verbose:
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 print("date format: ", self.format)
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
98 print("logscale: ", self.bounds)
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
99 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
100
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
101 def plot(self):
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
102 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
103 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
104 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
105 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
106 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
107 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
108 title = self.title
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
109 clabel = self.title
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
110
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
111 # Plot with chosen options
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
112 if self.bounds is None:
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
113 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
114 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
115 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
116 title=title,
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
117 clabel=clabel)
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
118 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
119 psy.plot.mapplot(self.input, name=self.varname,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
120 cmap=self.cmap, bounds=self.bounds,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
121 projection=self.proj,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
122 title=title,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
123 clabel=clabel)
0
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
124
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
125 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
126
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
127 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
128 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
129 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
130
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
131 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
132 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
133 else:
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 = self.title + "\n" + self.format
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
135
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
136 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
137 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
138 rcParams.update({'plotter.maps.grid_labelsize': 8.0})
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
139
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
140 # Plot using options
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
141 if self.bounds is None:
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
142 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
143 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
144 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
145 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
146 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
147 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
148 clabel='{desc}')
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
149 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
150 m = psy.plot.mapplot(self.input, name=self.varname,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
151 cmap=self.cmap, bounds=self.bounds,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
152 projection=self.proj,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
153 ax=(self.nrow, self.ncol),
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
154 time=self.time, sort=['time'],
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
155 title=title,
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
156 clabel='{desc}')
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
157
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
158 m.share(keys='bounds')
1
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 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
161
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
162
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
163 def psymap_plot(input, proj, varname, logscale, cmap, output, verbose, time,
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 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
165 """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
166
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
167 p = PsyPlot(input, varname, output, logscale, cmap, proj, verbose, time,
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
168 nrow, ncol, format, title)
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
169
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
170 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
171 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
172 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
173 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
174
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
175
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
176 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
177 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
178 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
179 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
180 'input',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
181 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
182 )
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 '--proj',
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 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
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 'varname',
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 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
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(
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
193 "--logscale",
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
194 help='Plot the log scaled data'
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
195 )
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
196 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
197 '--cmap',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
198 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
199 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
200 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
201 '--output',
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
202 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
203 )
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
204 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
205 '--time',
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='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
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 '--format',
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='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
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 '--title',
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='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
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(
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
217 '--ncol',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
218 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
219 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
220 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
221 '--nrow',
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
222 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
223 )
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
224 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
225 "-v", "--verbose",
db8d76da4174 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
226 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
227 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
228 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
229
1
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
230 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
231 time = []
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
232 else:
706666d912d5 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
233 time = list(map(int, args.time.split(",")))
2
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
234
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
235 if args.logscale == 'no':
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
236 logscale = False
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
237 else:
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
238 logscale = True
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
239
e6d1e9d6b399 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
240 psymap_plot(args.input, args.proj, args.varname, logscale, 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
241 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
242 args.nrow, args.ncol, args.format, args.title)