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