annotate psymap_simple.py @ 3:b7dcc1cb0871 draft default tip

planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 526396eeef506a7a8b868d9663b9cde0bcab83ab
author climate
date Tue, 01 Oct 2024 20:11:36 +0000
parents 533c276ae533
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
eb1f3666ce17 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
2 #
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
3 #
eb1f3666ce17 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]
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
5 # [--cmap CMAP]
eb1f3666ce17 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
533c276ae533 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
8 # [-v]
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
9 # input varname
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
10 #
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
11 # positional arguments:
eb1f3666ce17 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
13 # format)
eb1f3666ce17 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)
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
15 #
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
16 # optional arguments:
eb1f3666ce17 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
533c276ae533 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
eb1f3666ce17 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
eb1f3666ce17 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
eb1f3666ce17 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
322e000d8c48 "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")
322e000d8c48 "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
322e000d8c48 "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
322e000d8c48 "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.
322e000d8c48 "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
eb1f3666ce17 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
28 #
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
29
eb1f3666ce17 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
533c276ae533 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
32 import warnings
eb1f3666ce17 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
34
eb1f3666ce17 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
533c276ae533 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
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
38
0
eb1f3666ce17 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')
eb1f3666ce17 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
322e000d8c48 "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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
42
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
43
eb1f3666ce17 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
533c276ae533 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,
533c276ae533 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,
533c276ae533 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
eb1f3666ce17 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
eb1f3666ce17 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
533c276ae533 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 == "":
533c276ae533 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"
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
52 else:
533c276ae533 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
533c276ae533 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"
533c276ae533 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 []
533c276ae533 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)
533c276ae533 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)
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
58
533c276ae533 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
533c276ae533 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]
533c276ae533 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())
533c276ae533 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())
533c276ae533 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:
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
65 else:
533c276ae533 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
533c276ae533 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:
533c276ae533 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
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
70
533c276ae533 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:
533c276ae533 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
533c276ae533 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)):
533c276ae533 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")
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
76 else:
533c276ae533 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]
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
78 else:
533c276ae533 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
322e000d8c48 "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:
322e000d8c48 "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 = ""
322e000d8c48 "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
533c276ae533 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
eb1f3666ce17 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:
eb1f3666ce17 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'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
86 else:
eb1f3666ce17 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
88 if verbose:
eb1f3666ce17 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)
eb1f3666ce17 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)
eb1f3666ce17 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)
eb1f3666ce17 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
322e000d8c48 "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)
322e000d8c48 "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)
322e000d8c48 "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)
322e000d8c48 "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)
322e000d8c48 "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
533c276ae533 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
eb1f3666ce17 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)
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
100
eb1f3666ce17 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
533c276ae533 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
322e000d8c48 "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:
322e000d8c48 "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
322e000d8c48 "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:
322e000d8c48 "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
322e000d8c48 "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:
322e000d8c48 "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
533c276ae533 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
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
110
2
533c276ae533 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
533c276ae533 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
eb1f3666ce17 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,
eb1f3666ce17 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,
eb1f3666ce17 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
322e000d8c48 "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
533c276ae533 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)
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
118 else:
533c276ae533 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,
533c276ae533 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,
533c276ae533 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,
533c276ae533 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,
533c276ae533 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
124
eb1f3666ce17 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)
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
126
1
322e000d8c48 "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):
322e000d8c48 "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:
322e000d8c48 "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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
130
1
322e000d8c48 "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:
322e000d8c48 "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
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
133 else:
322e000d8c48 "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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
135
1
322e000d8c48 "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]
322e000d8c48 "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})
322e000d8c48 "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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
139
533c276ae533 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
533c276ae533 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
322e000d8c48 "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,
322e000d8c48 "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,
322e000d8c48 "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,
322e000d8c48 "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),
322e000d8c48 "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'],
322e000d8c48 "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,
322e000d8c48 "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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
149 else:
533c276ae533 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,
533c276ae533 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,
533c276ae533 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,
533c276ae533 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),
533c276ae533 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'],
533c276ae533 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,
533c276ae533 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}')
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
157
533c276ae533 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
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
159
322e000d8c48 "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)
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
161
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
162
2
533c276ae533 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
322e000d8c48 "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
eb1f3666ce17 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"""
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
166
2
533c276ae533 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
322e000d8c48 "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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
169
1
322e000d8c48 "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:
322e000d8c48 "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()
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
172 else:
322e000d8c48 "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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
174
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
175
eb1f3666ce17 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__':
eb1f3666ce17 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")
eb1f3666ce17 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()
eb1f3666ce17 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(
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
180 'input',
eb1f3666ce17 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)'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
182 )
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
183
eb1f3666ce17 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(
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
185 '--proj',
eb1f3666ce17 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'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
187 )
eb1f3666ce17 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(
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
189 'varname',
eb1f3666ce17 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)'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
191 )
eb1f3666ce17 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
193 "--logscale",
533c276ae533 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'
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
195 )
533c276ae533 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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
197 '--cmap',
eb1f3666ce17 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'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
199 )
eb1f3666ce17 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(
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
201 '--output',
eb1f3666ce17 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)'
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
203 )
eb1f3666ce17 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
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
205 '--time',
322e000d8c48 "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'
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
207 )
322e000d8c48 "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(
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
209 '--format',
322e000d8c48 "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)'
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
211 )
322e000d8c48 "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(
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
213 '--title',
322e000d8c48 "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'
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
215 )
322e000d8c48 "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(
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
217 '--ncol',
322e000d8c48 "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'
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
219 )
322e000d8c48 "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(
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
221 '--nrow',
322e000d8c48 "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'
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
223 )
322e000d8c48 "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
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
225 "-v", "--verbose",
eb1f3666ce17 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",
eb1f3666ce17 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")
eb1f3666ce17 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()
eb1f3666ce17 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit c1362af034361b6fb869411f1ea928388f230d72
climate
parents:
diff changeset
229
1
322e000d8c48 "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:
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
231 time = []
322e000d8c48 "planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit 4803d769c7b0b37fa80c69bd7327f6789cd3c6bf"
climate
parents: 0
diff changeset
232 else:
322e000d8c48 "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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
234
533c276ae533 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':
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
237 else:
533c276ae533 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
533c276ae533 planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/psy-maps commit d330adb8ea0000ffb2e1dcc2346fd34409f6618e
climate
parents: 1
diff changeset
239
533c276ae533 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
322e000d8c48 "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,
322e000d8c48 "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)