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