comparison xarray_select.xml @ 0:225d0d275a24 draft

"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit f1455c158011dc4aab0fd469cf794be6f4142992"
author ecology
date Fri, 22 May 2020 05:19:15 -0400
parents
children 6baac361495b
comparison
equal deleted inserted replaced
-1:000000000000 0:225d0d275a24
1 <tool id="xarray_select" name="NetCDF xarray Selection" version="0.15.1">
2 <description>extracts variable values with custom conditions on dimensions</description>
3 <requirements>
4 <requirement type="package" version="3">python</requirement>
5 <requirement type="package" version="1.5.3">netcdf4</requirement>
6 <requirement type="package" version="0.15.1">xarray</requirement>
7 <requirement type="package" version="0.7.0">geopandas</requirement>
8 <requirement type="package" version="1.7.0">shapely</requirement>
9 </requirements>
10 <command detect_errors="exit_code"><![CDATA[
11 mkdir output_dir &&
12 python '$__tool_directory__/xarray_tool.py' '$input' --select '$var'
13 --verbose
14 --filter
15 #for $i,$uc in enumerate($user_choice)
16 #if $uc.condi_between.comparator=="bi"
17 '${uc.dim}#${uc.condi_between.comparator}#${uc.condi_between.t1}#${uc.condi_between.t2}'
18 #else
19 '${uc.dim}#${uc.condi_between.comparator}#${uc.condi_between.value}'
20 #end if
21 #end for
22
23 #if $time.condi_datetime.datetime=="yes"
24 --time
25 #if $time.condi_datetime.condi_between.comparator=="sl"
26 '${time.condi_datetime.dim}#${time.condi_datetime.condi_between.comparator}#${time.condi_datetime.condi_between.t1}#${time.condi_datetime.condi_between.t2}'
27 #else
28 '${time.condi_datetime.dim}#${time.condi_datetime.condi_between.comparator}#${time.condi_datetime.condi_between.t1}'
29 #end if
30 #end if
31
32 #if $condi_source_coord.coord_source=="coord_from_file"
33 --coords '$coord_tabular'
34 --latname '$condi_source_coord.lat_dim' --lonname '$condi_source_coord.lon_dim'
35 --outputdir output_dir
36 #else
37 --outfile 'final.tabular'
38 #if $condi_source_coord.condi_coord.coord=='single'
39 --latname $condi_source_coord.condi_coord.lat_dim
40 --latvalN $condi_source_coord.condi_coord.lat_val
41 --lonname $condi_source_coord.condi_coord.lon_dim
42 --lonvalE $condi_source_coord.condi_coord.lon_val
43 #elif $condi_source_coord.condi_coord.coord=='subregion'
44 --latname $condi_source_coord.condi_coord.lat_dim
45 --latvalN $condi_source_coord.condi_coord.lat_valN
46 --latvalS $condi_source_coord.condi_coord.lat_valS
47 --lonname $condi_source_coord.condi_coord.lon_dim
48 --lonvalE $condi_source_coord.condi_coord.lon_valE
49 --lonvalW $condi_source_coord.condi_coord.lon_valW
50 #end if
51 #end if
52 ]]></command>
53 <inputs>
54 <param type="data" name="input" label="Input netcdf file" format="netcdf"/>
55 <param type="data" label="Tabular of variables" name="var_tab" format="tabular" help="Select the tabular file which summarize the available variables and dimensions."/>
56
57 <param name="var" type="select" label="Choose the variable to extract">
58 <options from_dataset="var_tab">
59 <column name="name" index="0"/>
60 <column name="value" index="0"/>
61 </options>
62 </param>
63
64 <conditional name="condi_source_coord">
65 <param name="coord_source" type="select" label="Source of coordinates">
66 <option value="coord_from_stdin">Manually enter coordinates</option>
67 <option value="coord_from_file">Use coordinates from input file</option>
68 </param>
69
70 <when value="coord_from_file">
71 <param type="data" label="Tabular of coord" name="coord_tabular" format="tabular" help="Format : Latitude Longitude"/>
72 <param name="lat_dim" type="select" label="Name of latitude coordinate" >
73 <options from_dataset="var_tab">
74 <column name="value" index="0"/>
75 </options>
76 </param>
77 <param name="lon_dim" type="select" label="Name of longitude coordinate" >
78 <options from_dataset="var_tab">
79 <column name="value" index="0"/>
80 </options>
81 </param>
82 </when>
83
84 <when value="coord_from_stdin">
85 <conditional name="condi_coord">
86 <param name="coord" type="select" label="Geographical area" help="Use this option to get valid values at your custom coordinates.">
87 <option value="global">Whole available region</option>
88 <option value="single">Single location</option>
89 <option value="subregion">Sub-region extraction</option>
90 </param>
91 <when value="single">
92 <param name="lat_dim" type="select" label="Name of latitude coordinate" >
93 <options from_dataset="var_tab">
94 <column name="value" index="0"/>
95 </options>
96 </param>
97 <param name="lat_val" type="float" value="0" label="Latitude"/>
98 <param name="lon_dim" type="select" label="Name of longitude coordinate" >
99 <options from_dataset="var_tab">
100 <column name="value" index="0"/>
101 </options>
102 </param>
103 <param name="lon_val" type="float" value="0" label="Longitude"/>
104 </when>
105 <when value="subregion">
106 <param name="lat_dim" type="select" label="Name of latitude coordinate" >
107 <options from_dataset="var_tab">
108 <column name="value" index="0"/>
109 </options>
110 </param>
111 <param name="lat_valN" type="float" value="0" label="Latitude North"/>
112 <param name="lat_valS" type="float" value="0" label="Latitude South"/>
113 <param name="lon_dim" type="select" label="Name of longitude coordinate" >
114 <options from_dataset="var_tab">
115 <column name="value" index="0"/>
116 </options>
117 </param>
118 <param name="lon_valE" type="float" value="0" label="Longitude East"/>
119 <param name="lon_valW" type="float" value="0" label="Longitude West"/>
120 </when>
121 <when value="global"></when>
122 </conditional>
123 </when>
124
125 </conditional>
126
127 <section name="time" title="Select Time series" expanded="false">
128 <conditional name="condi_datetime">
129 <param name="datetime" type="select" label="Datetime selection" help="Use this option to extract timeseries from your dataset">
130 <option value="no">No</option>
131 <option value="yes">Yes</option>
132 </param>
133 <when value="no"></when>
134 <when value="yes">
135 <param name="dim" type="select" label="Select datetime dimension" help="Use this option only if your dataset contains a date/time dimension">
136 <options from_dataset="var_tab">
137 <column name="value" index="0"/>
138 </options>
139 </param>
140 <conditional name="condi_between">
141 <param name="comparator" type="select" label="date/Time selection">
142 <option value="is">is</option>
143 <option value="sl">slice</option>
144 <option value="ne">nearest</option>
145 <option value="to">to</option>
146 <option value="from">from</option>
147 </param>
148 <when value="sl">
149 <param name="t1" type="text" value="" label="Start date/time"/>
150 <param name="t2" type="text" value="" label="End date/time"/>
151 </when>
152 <when value="is">
153 <param name="t1" type="text" value="" label="date/time"/>
154 </when>
155 <when value="ne">
156 <param name="t1" type="text" value="" label="date/time"/>
157 </when>
158 <when value="to">
159 <param name="t1" type="text" value="" label="date/time"/>
160 </when>
161 <when value="from">
162 <param name="t1" type="text" value="" label="date/time"/>
163 </when>
164 </conditional>
165 </when>
166 </conditional>
167 </section>
168 <repeat name="user_choice" title="additional filter" help="Use this option to filter on the selected dataset">
169 <param name="dim" type="select" label="Dimensions">
170 <options from_dataset="var_tab">
171 <column name="value" index="0"/>
172 </options>
173 </param>
174 <conditional name="condi_between">
175 <param name="comparator" type="select" label="Comparator">
176 <option value="e">Equal</option>
177 <option value="ge">Greater or equal</option>
178 <option value="le">Less or equal</option>
179 <option value="bi">Between-include [threshold1,threshold2]</option>
180 </param>
181 <when value="bi">
182 <param name="t1" type="text" value="0" label="Inferior threshold"/>
183 <param name="t2" type="text" value="0" label="Superior threshold"/>
184 </when>
185 <when value="e">
186 <param name="value" type="text" value="0" label="Value"/>
187 </when>
188 <when value="ge">
189 <param name="value" type="text" value="0" label="Value"/>
190 </when>
191 <when value="le">
192 <param name="value" type="text" value="0" label="Value"/>
193 </when>
194 </conditional>
195 </repeat>
196 </inputs>
197 <outputs>
198 <collection type="list" name="output">
199 <discover_datasets pattern="__designation_and_ext__" visible="false" format="tabular" directory="output_dir"/>
200 <filter>condi_source_coord['coord_source'] == 'coord_from_file'</filter>
201 </collection>
202 <data name="simpleoutput" from_work_dir="final.tabular" format="tabular">
203 <filter>condi_source_coord['coord_source'] == 'coord_from_stdin'</filter>
204 </data>
205 </outputs>
206 <tests>
207 <test>
208 <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>
209 <param name="var" value="phy"/>
210 <param name="var_tab" value="var_tab_dataset-ibi"/>
211 <conditional name="condi_source_coord">
212 <param name="coord_source" value="coord_from_stdin"/>
213 <conditional name="condi_coord">
214 <param name="coord" value="single"/>
215 <param name="lat_dim" value="latitude"/>
216 <param name="lat_val" value="44.0"/>
217 <param name="lon_dim" value="longitude"/>
218 <param name="lon_val" value="-2.0"/>
219 </conditional>
220 </conditional>
221 <output name="simpleoutput" value="Test1.tabular">
222 <assert_contents>
223 <has_text_matching expression="0\t2002-12-15\t0.5"/>
224 <has_text_matching expression="144\t2014-12-15\t0.5"/>
225 </assert_contents>
226 </output>
227 </test>
228 <test>
229 <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>
230 <param name="var_tab" value="var_tab_dataset-ibi"/>
231 <param name="var" value="nh4"/>
232
233 <conditional name="condi_source_coord">
234 <param name="coord_source" value="coord_from_stdin"/>
235 <conditional name="condi_coord">
236 <param name="coord" value="global"/>
237 </conditional>
238 </conditional>
239 <section name="time">
240 <conditional name="condi_datetime">
241 <param name="datetime" value="yes"/>
242 <conditional name="condi_between">
243 <param name="comparator" value="sl"/>
244 <param name="t1" value="2003-12-15" />
245 <param name="t2" value="2004-12-15" />
246 </conditional>
247 </conditional>
248 </section>
249 <repeat name="user_choice">
250 <param name="dim" value="nh4"/>
251 <conditional name="condi_between">
252 <param name="comparator" value="ge"/>
253 <param name="value" value="50."/>
254 </conditional>
255 </repeat>
256 <output name="simpleoutput" value="Test2.tabular">
257 <assert_contents>
258 <has_text_matching expression="0\t2003-12-15\t0.5"/>
259 <has_text_matching expression="23\t2004-12-15\t0.5"/>
260 </assert_contents>
261 </output>
262 </test>
263 </tests>
264
265 <help><![CDATA[
266 **What it does**
267
268 This tool extracts variable values with custom conditions on dimensions.
269
270 It can use manualy given coordinates or automaticaly take them from a tabular file to filter informations.
271
272 If no values are availables at a coordinate X, the tool will search the closest coordinate with a non NA value.
273
274 Filter can be set on every dimension. Available filtering operations are : =, >, <, >=, <=, [interval], ]interval[.
275
276
277
278 **Input**
279
280 A netcdf file (.nc).
281
282 Variable tabular file from 'Netcdf Metadate Info'.
283
284 Tabular file with coordinates and the following structure : 'lat' 'lon'.
285
286
287 **Outputs**
288
289 A single output with values for the wanted variable if there is only one coordinate.
290
291 A data collection where one file is created for every coordinate, if multiple coordinates from tabular file.
292
293
294 -------------------------------------------------
295
296 The xarray select tool can be used after the xarray Info.
297 ]]></help>
298 </tool>