annotate xarray_tool.py @ 4:9bbaab36a5d4 draft

"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
author ecology
date Thu, 20 Jan 2022 17:09:40 +0000
parents 663268794710
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
1 # xarray tool for:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
2 # - getting metadata information
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
3 # - select data and save results in csv file for further post-processing
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
4
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
5 import argparse
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
6 import csv
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
7 import os
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
8 import warnings
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
9
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
10 import geopandas as gdp
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
11
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
12 import pandas as pd
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
13
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
14 from shapely.geometry import Point
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
15 from shapely.ops import nearest_points
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
16
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
17 import xarray as xr
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
18
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
19
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
20 class XarrayTool ():
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
21 def __init__(self, infile, outfile_info="", outfile_summary="",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
22 select="", outfile="", outputdir="", latname="",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
23 latvalN="", latvalS="", lonname="", lonvalE="",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
24 lonvalW="", filter_list="", coords="", time="",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
25 verbose=False, no_missing=False, coords_info=None,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
26 tolerance=None):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
27 self.infile = infile
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
28 self.outfile_info = outfile_info
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
29 self.outfile_summary = outfile_summary
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
30 self.select = select
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
31 self.outfile = outfile
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
32 self.outputdir = outputdir
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
33 self.latname = latname
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
34 if tolerance != "" and tolerance is not None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
35 self.tolerance = float(tolerance)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
36 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
37 self.tolerance = -1
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
38 if latvalN != "" and latvalN is not None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
39 self.latvalN = float(latvalN)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
40 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
41 self.latvalN = ""
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
42 if latvalS != "" and latvalS is not None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
43 self.latvalS = float(latvalS)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
44 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
45 self.latvalS = ""
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
46 self.lonname = lonname
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
47 if lonvalE != "" and lonvalE is not None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
48 self.lonvalE = float(lonvalE)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
49 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
50 self.lonvalE = ""
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
51 if lonvalW != "" and lonvalW is not None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
52 self.lonvalW = float(lonvalW)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
53 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
54 self.lonvalW = ""
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
55 self.filter = filter_list
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
56 self.time = time
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
57 self.coords = coords
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
58 self.verbose = verbose
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
59 self.no_missing = no_missing
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
60 # initialization
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
61 self.dset = None
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
62 self.gset = None
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
63 self.coords_info = coords_info
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
64 if self.verbose:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
65 print("infile: ", self.infile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
66 print("outfile_info: ", self.outfile_info)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
67 print("outfile_summary: ", self.outfile_summary)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
68 print("outfile: ", self.outfile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
69 print("select: ", self.select)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
70 print("outfile: ", self.outfile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
71 print("outputdir: ", self.outputdir)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
72 print("latname: ", self.latname)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
73 print("latvalN: ", self.latvalN)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
74 print("latvalS: ", self.latvalS)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
75 print("lonname: ", self.lonname)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
76 print("lonvalE: ", self.lonvalE)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
77 print("lonvalW: ", self.lonvalW)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
78 print("filter: ", self.filter)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
79 print("time: ", self.time)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
80 print("coords: ", self.coords)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
81 print("coords_info: ", self.coords_info)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
82
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
83 def info(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
84 f = open(self.outfile_info, 'w')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
85 ds = xr.open_dataset(self.infile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
86 ds.info(f)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
87 f.close()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
88
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
89 def summary(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
90 f = open(self.outfile_summary, 'w')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
91 ds = xr.open_dataset(self.infile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
92 writer = csv.writer(f, delimiter='\t')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
93 header = ['VariableName', 'NumberOfDimensions']
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
94 for idx, val in enumerate(ds.dims.items()):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
95 header.append('Dim' + str(idx) + 'Name')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
96 header.append('Dim' + str(idx) + 'Size')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
97 writer.writerow(header)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
98 for name, da in ds.data_vars.items():
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
99 line = [name]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
100 line.append(len(ds[name].shape))
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
101 for d, s in zip(da.shape, da.sizes):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
102 line.append(s)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
103 line.append(d)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
104 writer.writerow(line)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
105 for name, da in ds.coords.items():
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
106 line = [name]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
107 line.append(len(ds[name].shape))
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
108 for d, s in zip(da.shape, da.sizes):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
109 line.append(s)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
110 line.append(d)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
111 writer.writerow(line)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
112 f.close()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
113
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
114 def rowfilter(self, single_filter):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
115 split_filter = single_filter.split('#')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
116 filter_varname = split_filter[0]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
117 op = split_filter[1]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
118 ll = float(split_filter[2])
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
119 if (op == 'bi'):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
120 rl = float(split_filter[3])
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
121 if filter_varname == self.select:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
122 # filter on values of the selected variable
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
123 if op == 'bi':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
124 self.dset = self.dset.where(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
125 (self.dset <= rl) & (self.dset >= ll)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
126 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
127 elif op == 'le':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
128 self.dset = self.dset.where(self.dset <= ll)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
129 elif op == 'ge':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
130 self.dset = self.dset.where(self.dset >= ll)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
131 elif op == 'e':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
132 self.dset = self.dset.where(self.dset == ll)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
133 else: # filter on other dimensions of the selected variable
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
134 if op == 'bi':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
135 self.dset = self.dset.sel({filter_varname: slice(ll, rl)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
136 elif op == 'le':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
137 self.dset = self.dset.sel({filter_varname: slice(None, ll)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
138 elif op == 'ge':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
139 self.dset = self.dset.sel({filter_varname: slice(ll, None)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
140 elif op == 'e':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
141 self.dset = self.dset.sel({filter_varname: ll},
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
142 method='nearest')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
143
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
144 def selection(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
145 if self.dset is None:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
146 self.ds = xr.open_dataset(self.infile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
147 self.dset = self.ds[self.select] # select variable
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
148 if self.time:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
149 self.datetime_selection()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
150 if self.filter:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
151 self.filter_selection()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
152
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
153 self.area_selection()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
154 if self.gset.count() > 1:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
155 # convert to dataframe if several rows and cols
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
156 self.gset = self.gset.to_dataframe().dropna(how='all'). \
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
157 reset_index()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
158 self.gset.to_csv(self.outfile, header=True, sep='\t')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
159 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
160 data = {
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
161 self.latname: [self.gset[self.latname].values],
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
162 self.lonname: [self.gset[self.lonname].values],
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
163 self.select: [self.gset.values]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
164 }
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
165
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
166 df = pd.DataFrame(data, columns=[self.latname, self.lonname,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
167 self.select])
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
168 df.to_csv(self.outfile, header=True, sep='\t')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
169
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
170 def datetime_selection(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
171 split_filter = self.time.split('#')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
172 time_varname = split_filter[0]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
173 op = split_filter[1]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
174 ll = split_filter[2]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
175 if (op == 'sl'):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
176 rl = split_filter[3]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
177 self.dset = self.dset.sel({time_varname: slice(ll, rl)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
178 elif (op == 'to'):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
179 self.dset = self.dset.sel({time_varname: slice(None, ll)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
180 elif (op == 'from'):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
181 self.dset = self.dset.sel({time_varname: slice(ll, None)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
182 elif (op == 'is'):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
183 self.dset = self.dset.sel({time_varname: ll}, method='nearest')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
184
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
185 def filter_selection(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
186 for single_filter in self.filter:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
187 self.rowfilter(single_filter)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
188
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
189 def area_selection(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
190
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
191 if self.latvalS != "" and self.lonvalW != "":
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
192 # Select geographical area
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
193 self.gset = self.dset.sel({self.latname:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
194 slice(self.latvalS, self.latvalN),
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
195 self.lonname:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
196 slice(self.lonvalW, self.lonvalE)})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
197 elif self.latvalN != "" and self.lonvalE != "":
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
198 # select nearest location
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
199 if self.no_missing:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
200 self.nearest_latvalN = self.latvalN
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
201 self.nearest_lonvalE = self.lonvalE
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
202 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
203 # find nearest location without NaN values
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
204 self.nearest_location()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
205 if self.tolerance > 0:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
206 self.gset = self.dset.sel({self.latname: self.nearest_latvalN,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
207 self.lonname: self.nearest_lonvalE},
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
208 method='nearest',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
209 tolerance=self.tolerance)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
210 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
211 self.gset = self.dset.sel({self.latname: self.nearest_latvalN,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
212 self.lonname: self.nearest_lonvalE},
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
213 method='nearest')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
214 else:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
215 self.gset = self.dset
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
216
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
217 def nearest_location(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
218 # Build a geopandas dataframe with all first elements in each dimension
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
219 # so we assume null values correspond to a mask that is the same for
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
220 # all dimensions in the dataset.
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
221 dsel_frame = self.dset
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
222 for dim in self.dset.dims:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
223 if dim != self.latname and dim != self.lonname:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
224 dsel_frame = dsel_frame.isel({dim: 0})
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
225 # transform to pandas dataframe
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
226 dff = dsel_frame.to_dataframe().dropna().reset_index()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
227 # transform to geopandas to collocate
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
228 gdf = gdp.GeoDataFrame(dff,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
229 geometry=gdp.points_from_xy(dff[self.lonname],
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
230 dff[self.latname]))
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
231 # Find nearest location where values are not null
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
232 point = Point(self.lonvalE, self.latvalN)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
233 multipoint = gdf.geometry.unary_union
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
234 queried_geom, nearest_geom = nearest_points(point, multipoint)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
235 self.nearest_latvalN = nearest_geom.y
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
236 self.nearest_lonvalE = nearest_geom.x
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
237
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
238 def selection_from_coords(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
239 fcoords = pd.read_csv(self.coords, sep='\t')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
240 for row in fcoords.itertuples():
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
241 self.latvalN = row[0]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
242 self.lonvalE = row[1]
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
243 self.outfile = (os.path.join(self.outputdir,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
244 self.select + '_' +
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
245 str(row.Index) + '.tabular'))
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
246 self.selection()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
247
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
248 def get_coords_info(self):
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
249 ds = xr.open_dataset(self.infile)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
250 for c in ds.coords:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
251 filename = os.path.join(self.coords_info,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
252 c.strip() +
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
253 '.tabular')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
254 pd = ds.coords[c].to_pandas()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
255 pd.index = range(len(pd))
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
256 pd.to_csv(filename, header=False, sep='\t')
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
257
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
258
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
259 if __name__ == '__main__':
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
260 warnings.filterwarnings("ignore")
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
261 parser = argparse.ArgumentParser()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
262
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
263 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
264 'infile',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
265 help='netCDF input filename'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
266 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
267 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
268 '--info',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
269 help='Output filename where metadata information is stored'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
270 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
271 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
272 '--summary',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
273 help='Output filename where data summary information is stored'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
274 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
275 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
276 '--select',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
277 help='Variable name to select'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
278 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
279 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
280 '--latname',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
281 help='Latitude name'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
282 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
283 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
284 '--latvalN',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
285 help='North latitude value'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
286 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
287 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
288 '--latvalS',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
289 help='South latitude value'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
290 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
291 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
292 '--lonname',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
293 help='Longitude name'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
294 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
295 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
296 '--lonvalE',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
297 help='East longitude value'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
298 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
299 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
300 '--lonvalW',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
301 help='West longitude value'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
302 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
303 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
304 '--tolerance',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
305 help='Maximum distance between original and selected value for '
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
306 ' inexact matches e.g. abs(index[indexer] - target) <= tolerance'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
307 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
308 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
309 '--coords',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
310 help='Input file containing Latitude and Longitude'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
311 'for geographical selection'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
312 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
313 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
314 '--coords_info',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
315 help='output-folder where for each coordinate, coordinate values '
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
316 ' are being printed in the corresponding outputfile'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
317 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
318 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
319 '--filter',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
320 nargs="*",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
321 help='Filter list variable#operator#value_s#value_e'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
322 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
323 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
324 '--time',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
325 help='select timeseries variable#operator#value_s[#value_e]'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
326 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
327 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
328 '--outfile',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
329 help='csv outfile for storing results of the selection'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
330 '(valid only when --select)'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
331 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
332 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
333 '--outputdir',
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
334 help='folder name for storing results with multiple selections'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
335 '(valid only when --select)'
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
336 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
337 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
338 "-v", "--verbose",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
339 help="switch on verbose mode",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
340 action="store_true"
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
341 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
342 parser.add_argument(
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
343 "--no_missing",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
344 help="""Do not take into account possible null/missing values
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
345 (only valid for single location)""",
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
346 action="store_true"
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
347 )
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
348 args = parser.parse_args()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
349
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
350 p = XarrayTool(args.infile, args.info, args.summary, args.select,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
351 args.outfile, args.outputdir, args.latname,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
352 args.latvalN, args.latvalS, args.lonname,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
353 args.lonvalE, args.lonvalW, args.filter,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
354 args.coords, args.time, args.verbose,
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
355 args.no_missing, args.coords_info, args.tolerance)
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
356 if args.info:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
357 p.info()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
358 if args.summary:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
359 p.summary()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
360 if args.coords:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
361 p.selection_from_coords()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
362 elif args.select:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
363 p.selection()
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
364 elif args.coords_info:
9bbaab36a5d4 "planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
ecology
parents: 3
diff changeset
365 p.get_coords_info()