Repository 'xarray_metadata_info'
hg clone https://toolshed.g2.bx.psu.edu/repos/ecology/xarray_metadata_info

Changeset 4:9bbaab36a5d4 (2022-01-20)
Previous changeset 3:663268794710 (2021-06-06) Next changeset 5:00de53d18b99 (2022-07-31)
Commit message:
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/data_manipulation/xarray/ commit 2166974df82f97557b082a9e55135098e61640c4"
modified:
macros.xml
test-data/all.netcdf
test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0.png
test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time1.png
test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time50.png
test-data/info_file.txt
test-data/small.netcdf
test-data/version.tabular
xarray_mapplot.py
xarray_metadata_info.xml
xarray_netcdf2netcdf.py
xarray_tool.py
added:
macros_mapplot.xml
macros_netcdf2netcdf.xml
macros_tests_netcdf2netcdf.xml
test-data/chl_alltimes.nc
test-data/chl_nh4.netcdf
test-data/chl_phy_where.netcdf
test-data/chl_where_drop.netcdf
test-data/data_from_20040615.nc
test-data/data_to_20040615.nc
test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0_title.png
test-data/select_by_values.netcdf
test-data/small_all_variables.netcdf
test-data/where_condition.txt
test-data/where_condition_simple.txt
removed:
README.md
b
diff -r 663268794710 -r 9bbaab36a5d4 README.md
--- a/README.md Sun Jun 06 08:49:43 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
b
@@ -1,8 +0,0 @@
-# Xarray tools for netCDF
-## netCDF metadata information
-
-The first tool `xarray_metadata_info ` uses xarray to provide users with general information about variable names, dimensions
-and attributes.
-Variables that can be extracted and dimensions available are printed in a tabular file.
-
-The tool also print a general information file. It's the result of the xarray method info().
b
diff -r 663268794710 -r 9bbaab36a5d4 macros.xml
--- a/macros.xml Sun Jun 06 08:49:43 2021 +0000
+++ b/macros.xml Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -1,185 +1,28 @@\n-<macros>\n-    <token name="@TOOL_VERSION@">0.18.2</token>\n-    <token name="@VERSION_SUFFIX@">0</token>\n-    <xml name="edam_ontology">\n-        <edam_topics>\n-            <edam_topic>topic_0610</edam_topic>\n-            <edam_topic>topic_3050</edam_topic>\n-        </edam_topics>\n-    </xml>\n-    <xml name="citations">\n-        <citations>\n-            <citation type="bibtex">\n-                @article{hoyer2017xarray,\n-                    title     = {xarray: {N-D} labeled arrays and datasets in {Python}},\n-                    author    = {Hoyer, S. and J. Hamman},\n-                    journal   = {Journal of Open Research Software},\n-                    volume    = {5},\n-                    number    = {1},\n-                    year      = {2017},\n-                    publisher = {Ubiquity Press},\n-                    doi       = {10.5334/jors.148},\n-                    url       = {http://doi.org/10.5334/jors.148}\n-                }\n-            </citation>\n-        </citations>\n-    </xml>\n-    <xml name="customize_appearance_plots">\n-        <param name="borders" type="float" optional="true" label="Add country borders with alpha value [0-1] (optional)" />\n-        <param name="coastline" type="float" optional="true" label="Add coastline with alpha value [0-1] (optional)" />\n-        <param name="ocean" type="float" optional="true" label="Add ocean with alpha value [0-1] (optional)" />\n-        <param name="land" type="float" optional="true" label="Add land with alpha value [0-1] (optional)" />\n-        <param name="title" type="text" optional="true" label="Specify plot title (optional)" />\n-        <param name="colorbar_label" type="text"  optional="true" label="Set a label for colormap (optional)" />\n-        <param name="cmap" type="select" optional="true" label="Specify which colormap to use for plotting (optional)">\n-            <option value="cm.batlow">batlow</option>\n-            <option value="cm.batlowW">batlowW</option>\n-            <option value="cm.batlowK">batlowK</option>\n-            <option value="cm.devon">devon</option>\n-            <option value="cm.davos">davos</option>\n-            <option value="cm.oslo">oslo</option>\n-            <option value="cm.lapaz">lapaz</option>\n-            <option value="cm.acton">acton</option>\n-            <option value="cm.lajolla">lajolla</option>\n-            <option value="cm.bilbao">bilbao</option>\n-            <option value="cm.grayC">grayC</option>\n-            <option value="cm.tokyo">tokyo</option>\n-            <option value="cm.turku">turku</option>\n-            <option value="cm.bamako">bamako</option>\n-            <option value="cm.nuuk">nuuk</option>\n-            <option value="cm.hawaii">hawaii</option>\n-            <option value="cm.buda">buda</option>\n-            <option value="cm.imola">imola</option>\n-            <option value="cm.broc">broc</option>\n-            <option value="cm.lisbon">lisbon</option>\n-            <option value="cm.roma">roma</option>\n-            <option value="cm.cork">cork</option>\n-            <option value="cm.tofino">tofino</option>\n-            <option value="cm.bam">bam</option>\n-            <option value="cm.vik">vik</option>\n-            <option value="cm.berlin">berlin</option>\n-            <option value="cm.vanimo">vanimo</option>\n-            <option value="cm.oleron">oleron</option>\n-            <option value="cm.bukavu">bukavu</option>\n-            <option value="cm.fes">fes</option>\n-            <option value="cm.romaO">romaO</option>\n-            <option value="cm.bamO">bamO</option>\n-            <option value="cm.brocO">brocO</option>\n-            <option value="cm.corkO">corkO</option>\n-            <option value="cm.vikO">vikO</option>\n-            <option value="cm.batlow_r">batlow_r</option>\n-            <option value="cm.batlowW_r">batlowW_r</option>\n-            <option value="cm.batlowK_r">batlowK_r</option>\n-            <option value="cm.devon_r">devon_r</option>\n-            <option valu'..b'tion value="RdGy">RdGy</option>\n-            <option value="RdPu">RdPu</option>\n-            <option value="RdBu_r">RdBu_r</option>\n-            <option value="RdGy_r">RdGy_r</option>\n-            <option value="RdPu_r">RdPu_r</option>\n-            <option value="RdYlBu">RdYlBu</option>\n-            <option value="RdYlGn">RdYlGn</option>\n-            <option value="Reds">Reds</option>\n-            <option value="Set1">Set1</option>\n-            <option value="Set2">Set2</option>\n-            <option value="Set3">Set3</option>\n-            <option value="Spectral">Spectral</option>\n-            <option value="Wistia">Wistia</option>\n-            <option value="YlGn">YlGn</option>\n-            <option value="YlGnBu">YlGnBu</option>\n-            <option value="YlOrBr">YlOrBr</option>\n-            <option value="YlOrRd">YlOrRd</option>\n-            <option value="afmhot">afmhot</option>\n-            <option value="autumn">autumn</option>\n-            <option value="binary">binary</option>\n-            <option value="bone">bone</option>\n-            <option value="brg">brg</option>\n-            <option value="bwr">bwr</option>\n-            <option value="cool">cool</option>\n-            <option value="coolwarm" selected="true">coolwarm</option>\n-            <option value="copper">copper</option>\n-            <option value="cubehelix">cubehelix</option>\n-            <option value="flag">flag</option>\n-            <option value="gist_earth">gist_earth</option>\n-            <option value="gist_gray">gist_gray</option>\n-            <option value="gist_heat">gist_heat</option>\n-            <option value="gist_ncar">gist_ncar</option>\n-            <option value="gist_rainbow">gist_rainbow</option>\n-            <option value="gist_stern">gist_stern</option>\n-            <option value="gist_yarg">gist_yarg</option>\n-            <option value="gnuplot">gnuplot</option>\n-            <option value="gnuplot2">gnuplot2</option>\n-            <option value="gray">gray</option>\n-            <option value="hot">hot</option>\n-            <option value="hsv">hsv</option>\n-            <option value="jet">jet</option>\n-            <option value="nipy_spectral">nipy_spectral</option>\n-            <option value="ocean">ocean</option>\n-            <option value="pink">pink</option>\n-            <option value="prism">prism</option>\n-            <option value="rainbow">rainbow</option>\n-            <option value="seismic">seismic</option>\n-            <option value="spring">spring</option>\n-            <option value="summer">summer</option>\n-            <option value="tab10">tab10</option>\n-            <option value="tab20">tab20</option>\n-            <option value="tab20b">tab20b</option>\n-            <option value="tab20c">tab20c</option>\n-            <option value="terrain">terrain</option>\n-            <option value="winter">winter</option>\n-        </param>\n-    </xml>\n-</macros>\n+<macros>\r\n+    <token name="@TOOL_VERSION@">0.20.2</token>\r\n+    <token name="@VERSION_SUFFIX@">0</token>\r\n+    <token name="@PROFILE@">20.05</token>\r\n+    <xml name="edam_ontology">\r\n+        <edam_topics>\r\n+            <edam_topic>topic_0610</edam_topic>\r\n+            <edam_topic>topic_3050</edam_topic>\r\n+        </edam_topics>\r\n+    </xml>\r\n+    <xml name="citations">\r\n+        <citations>\r\n+            <citation type="bibtex">\r\n+                @article{hoyer2017xarray,\r\n+                    title     = {xarray: {N-D} labeled arrays and datasets in {Python}},\r\n+                    author    = {Hoyer, S. and J. Hamman},\r\n+                    journal   = {Journal of Open Research Software},\r\n+                    volume    = {5},\r\n+                    number    = {1},\r\n+                    year      = {2017},\r\n+                    publisher = {Ubiquity Press},\r\n+                    doi       = {10.5334/jors.148},\r\n+                    url       = {http://doi.org/10.5334/jors.148}\r\n+                }\r\n+            </citation>\r\n+        </citations>\r\n+    </xml>\r\n+</macros>\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 macros_mapplot.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros_mapplot.xml Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -0,0 +1,213 @@\n+<macros>\r\n+    <xml name="config_map">\r\n+        <configfiles>\r\n+            <configfile name="map_customization"><![CDATA[\r\n+{\r\n+#if $condi_datetime.datetime=="yes"\r\n+"time":"$condi_datetime.time_values",\r\n+#end if\r\n+"latitude":\'$lat_dim\',\r\n+"longitude":\'$lon_dim\',\r\n+#if $colorbar_label\r\n+"label":\'$colorbar_label\',\r\n+#end if\r\n+#if $title\r\n+"title":"$title",\r\n+#end if\r\n+#if $cmap\r\n+"cmap":\'$cmap\',\r\n+#end if\r\n+#if $land\r\n+"land":\'$land\',\r\n+#end if\r\n+#if $ocean\r\n+"ocean":\'$ocean\',\r\n+#end if\r\n+#if $coastline\r\n+"coastline":\'$coastline\',\r\n+#end if\r\n+#if $borders\r\n+"borders":\'$borders\',\r\n+#end if\r\n+#if $threshold\r\n+"threshold":\'$threshold\',\r\n+#end if\r\n+#if $range\r\n+"range":\'$range\',\r\n+#end if\r\n+#if $xlim\r\n+"xlim":\'$xlim\',\r\n+#end if\r\n+#if $ylim\r\n+"ylim":\'$ylim\',\r\n+#end if\r\n+}\r\n+            ]]>\r\n+            </configfile>\r\n+            <configfile name="map_projection"><![CDATA[\r\n+#if $proj\r\n+\'$proj\'\r\n+#end if \r\n+            ]]>\r\n+            </configfile>\r\n+        </configfiles>\r\n+    </xml>\r\n+    <xml name="customize_appearance_plots">\r\n+        <param name="borders" type="float" optional="true" label="Add country borders with alpha value [0-1] (optional)" />\r\n+        <param name="coastline" type="float" optional="true" label="Add coastline with alpha value [0-1] (optional)" />\r\n+        <param name="ocean" type="float" optional="true" label="Add ocean with alpha value [0-1] (optional)" />\r\n+        <param name="land" type="float" optional="true" label="Add land with alpha value [0-1] (optional)" />\r\n+        <param name="title" type="text" optional="true" label="Specify plot title (optional)" />\r\n+        <param name="colorbar_label" type="text" optional="true" label="Set a label for colormap (optional)" />\r\n+        <param name="cmap" type="select" optional="true" label="Specify which colormap to use for plotting (optional)">\r\n+            <option value="cm.batlow">batlow</option>\r\n+            <option value="cm.batlowW">batlowW</option>\r\n+            <option value="cm.batlowK">batlowK</option>\r\n+            <option value="cm.devon">devon</option>\r\n+            <option value="cm.davos">davos</option>\r\n+            <option value="cm.oslo">oslo</option>\r\n+            <option value="cm.lapaz">lapaz</option>\r\n+            <option value="cm.acton">acton</option>\r\n+            <option value="cm.lajolla">lajolla</option>\r\n+            <option value="cm.bilbao">bilbao</option>\r\n+            <option value="cm.grayC">grayC</option>\r\n+            <option value="cm.tokyo">tokyo</option>\r\n+            <option value="cm.turku">turku</option>\r\n+            <option value="cm.bamako">bamako</option>\r\n+            <option value="cm.nuuk">nuuk</option>\r\n+            <option value="cm.hawaii">hawaii</option>\r\n+            <option value="cm.buda">buda</option>\r\n+            <option value="cm.imola">imola</option>\r\n+            <option value="cm.broc">broc</option>\r\n+            <option value="cm.lisbon">lisbon</option>\r\n+            <option value="cm.roma">roma</option>\r\n+            <option value="cm.cork">cork</option>\r\n+            <option value="cm.tofino">tofino</option>\r\n+            <option value="cm.bam">bam</option>\r\n+            <option value="cm.vik">vik</option>\r\n+            <option value="cm.berlin">berlin</option>\r\n+            <option value="cm.vanimo">vanimo</option>\r\n+            <option value="cm.oleron">oleron</option>\r\n+            <option value="cm.bukavu">bukavu</option>\r\n+            <option value="cm.fes">fes</option>\r\n+            <option value="cm.romaO">romaO</option>\r\n+            <option value="cm.bamO">bamO</option>\r\n+            <option value="cm.brocO">brocO</option>\r\n+            <option value="cm.corkO">corkO</option>\r\n+            <option value="cm.vikO">vikO</option>\r\n+            <option value="cm.batlow_r">batlow_r</option>\r\n+            <option value="cm.batlowW_r">batlowW_r</option>\r\n+            <option value="cm.batlowK_r">batlowK_r</option>\r\n+            <option value="cm.devon_r">devon'..b'       <option value="BuGn">BuGn</option>\r\n+            <option value="BuPu">BuPu</option>\r\n+            <option value="CMRmap">CMRmap</option>\r\n+            <option value="Dark2">Dark2</option>\r\n+            <option value="GnBu">GnBu</option>\r\n+            <option value="Greens">Greens</option>\r\n+            <option value="Greys">Greys</option>\r\n+            <option value="OrRd">OrRd</option>\r\n+            <option value="Oranges">Oranges</option>\r\n+            <option value="PRGn">PRGn</option>\r\n+            <option value="Paired">Paired</option>\r\n+            <option value="Pastel1">Pastel1</option>\r\n+            <option value="Pastel2">Pastel2</option>\r\n+            <option value="PiYG">PiYG</option>\r\n+            <option value="PuBu">PuBu</option>\r\n+            <option value="PuBuGn">PuBuGn</option>\r\n+            <option value="PuOr">PuOr</option>\r\n+            <option value="PuRd">PuRd</option>\r\n+            <option value="Purples">Purples</option>\r\n+            <option value="RdBu">RdBu</option>\r\n+            <option value="RdGy">RdGy</option>\r\n+            <option value="RdPu">RdPu</option>\r\n+            <option value="RdBu_r">RdBu_r</option>\r\n+            <option value="RdGy_r">RdGy_r</option>\r\n+            <option value="RdPu_r">RdPu_r</option>\r\n+            <option value="RdYlBu">RdYlBu</option>\r\n+            <option value="RdYlGn">RdYlGn</option>\r\n+            <option value="Reds">Reds</option>\r\n+            <option value="Set1">Set1</option>\r\n+            <option value="Set2">Set2</option>\r\n+            <option value="Set3">Set3</option>\r\n+            <option value="Spectral">Spectral</option>\r\n+            <option value="Wistia">Wistia</option>\r\n+            <option value="YlGn">YlGn</option>\r\n+            <option value="YlGnBu">YlGnBu</option>\r\n+            <option value="YlOrBr">YlOrBr</option>\r\n+            <option value="YlOrRd">YlOrRd</option>\r\n+            <option value="afmhot">afmhot</option>\r\n+            <option value="autumn">autumn</option>\r\n+            <option value="binary">binary</option>\r\n+            <option value="bone">bone</option>\r\n+            <option value="brg">brg</option>\r\n+            <option value="bwr">bwr</option>\r\n+            <option value="cool">cool</option>\r\n+            <option value="coolwarm" selected="true">coolwarm</option>\r\n+            <option value="copper">copper</option>\r\n+            <option value="cubehelix">cubehelix</option>\r\n+            <option value="flag">flag</option>\r\n+            <option value="gist_earth">gist_earth</option>\r\n+            <option value="gist_gray">gist_gray</option>\r\n+            <option value="gist_heat">gist_heat</option>\r\n+            <option value="gist_ncar">gist_ncar</option>\r\n+            <option value="gist_rainbow">gist_rainbow</option>\r\n+            <option value="gist_stern">gist_stern</option>\r\n+            <option value="gist_yarg">gist_yarg</option>\r\n+            <option value="gnuplot">gnuplot</option>\r\n+            <option value="gnuplot2">gnuplot2</option>\r\n+            <option value="gray">gray</option>\r\n+            <option value="hot">hot</option>\r\n+            <option value="hsv">hsv</option>\r\n+            <option value="jet">jet</option>\r\n+            <option value="nipy_spectral">nipy_spectral</option>\r\n+            <option value="ocean">ocean</option>\r\n+            <option value="pink">pink</option>\r\n+            <option value="prism">prism</option>\r\n+            <option value="rainbow">rainbow</option>\r\n+            <option value="seismic">seismic</option>\r\n+            <option value="spring">spring</option>\r\n+            <option value="summer">summer</option>\r\n+            <option value="tab10">tab10</option>\r\n+            <option value="tab20">tab20</option>\r\n+            <option value="tab20b">tab20b</option>\r\n+            <option value="tab20c">tab20c</option>\r\n+            <option value="terrain">terrain</option>\r\n+            <option value="winter">winter</option>\r\n+        </param>\r\n+    </xml>\r\n+</macros>\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 macros_netcdf2netcdf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros_netcdf2netcdf.xml Thu Jan 20 17:09:40 2022 +0000
b
b'@@ -0,0 +1,143 @@\n+<macros>\r\n+    <xml name="coord_range">\r\n+        <repeat name="user_choice" title="Filter by coordinate values" min="0" max="20" help="Use this option to filter on the values of the selected coordinate">\r\n+            <param name="dim" type="select" label="Dimensions">\r\n+                <options from_dataset="var_tab">\r\n+                    <column name="value" index="0"/>\r\n+                </options>\r\n+            </param>\r\n+            <conditional name="condi_between">\r\n+                <param name="comparator" type="select" label="Comparator">\r\n+                    <option value="is">is</option>\r\n+                    <option value="from">from</option>\r\n+                    <option value="to">to</option>\r\n+                    <option value="sl">slice(threshold1,threshold2)</option>\r\n+                </param>\r\n+                <when value="sl">\r\n+                    <param name="t1" type="text" value="" label="Choose the start value for slice"/>\r\n+                    <param name="t2" type="text" value="" label="Choose the end value for slice"/>\r\n+                </when>\r\n+                <when value="to">\r\n+                    <param name="value" type="text" value="" label="Choose the end value"/>\r\n+                </when>\r\n+                <when value="from">\r\n+                    <param name="value" type="text" value="" label="Choose the start value"/>\r\n+                </when>\r\n+                <when value="is">\r\n+                    <param name="value" type="text" value="" label="Choose the value to select"/>\r\n+                    <yield />\r\n+                </when>\r\n+            </conditional>\r\n+        </repeat>\r\n+    </xml>\r\n+    <xml name="section_variables">\r\n+        <section name="variable" title="Select variables">\r\n+            <param name="var" type="select" multiple="true" label="Choose variables to extract">\r\n+                <options from_dataset="var_tab">\r\n+                    <column name="name" index="0"/>\r\n+                    <column name="value" index="0"/>\r\n+                </options>\r\n+            </param>\r\n+            <param type="float" name="scale" optional="true" help="scale factor (float) to apply to the selected variable (optional and only if a variable is selected)"/>\r\n+            <param name="write_all" type="boolean" checked="false" label="Write all variables to new netCDF file (only if a variable is selected)"/>\r\n+            <param name="keep_attributes" type="boolean" checked="true" label="Keep all attributes (only if a variable is selected)"/>\r\n+        </section>\r\n+    </xml>\r\n+    <xml name="section_coords">\r\n+        <section name="subset_coords" title="Subset by coordinates">\r\n+            <conditional name="tsel">\r\n+                <param name="by_click" type="select" optional="true" label="Coordinate values">\r\n+                    <option value="sel">Coordinate values (sel)</option>\r\n+                    <option value="isel">Coordinate indices (isel)</option>\r\n+                    <option value="isel_list" selected="true">Coordinate values from list</option>\r\n+                </param>\r\n+                <when value="sel">\r\n+                    <expand macro="coord_range">\r\n+                        <param name="method" type="select" multiple="false" label="Choose selection method">\r\n+                            <option value="None">only exact matches</option>\r\n+                            <option value="nearest">use nearest valid index value</option>\r\n+                            <option value="pad">propagate last valid index value forward</option>\r\n+                            <option value="backfill">propagate next valid index value backward</option>\r\n+                        </param>\r\n+                    </expand>\r\n+                </when>\r\n+                <when value="isel">\r\n+                    <expand macro="coord_range"/>\r\n+                </when>\r\n+                <when value="isel_list">\r\n+                    <repeat name="user_choice" title="Filte'..b'>\r\n+                                <option value="is">is</option>\r\n+                                <option value="from">from</option>\r\n+                                <option value="to">to</option>\r\n+                                <option value="sl">slice(threshold1,threshold2)</option>\r\n+                            </param>\r\n+                            <when value="sl">\r\n+                                <param name="t1" type="select" multiple="false" label="Choose the start value for slice">\r\n+                                    <options from_dataset="dim_tab">\r\n+                                        <column name="name" index="1"/>\r\n+                                        <column name="value" index="0"/>\r\n+                                    </options>\r\n+                                </param>\r\n+                                <param name="t2" type="select" multiple="false" label="Choose the end value for slice">\r\n+                                    <options from_dataset="dim_tab">\r\n+                                        <column name="name" index="1"/>\r\n+                                        <column name="value" index="0"/>\r\n+                                    </options>\r\n+                                </param>\r\n+                            </when>\r\n+                            <when value="is">\r\n+                                <param name="value" type="select" multiple="false" label="Choose the value to select">\r\n+                                    <options from_dataset="dim_tab">\r\n+                                        <column name="name" index="1"/>\r\n+                                        <column name="value" index="0"/>\r\n+                                    </options>\r\n+                                </param>\r\n+                            </when>\r\n+                            <when value="to">\r\n+                                <param name="value" type="select" multiple="false" label="Choose the end value">\r\n+                                    <options from_dataset="dim_tab">\r\n+                                        <column name="name" index="1"/>\r\n+                                        <column name="value" index="0"/>\r\n+                                    </options>\r\n+                                </param>\r\n+                            </when>\r\n+                            <when value="from">\r\n+                                <param name="value" type="select" multiple="false" label="Choose the start value">\r\n+                                    <options from_dataset="dim_tab">\r\n+                                        <column name="name" index="1"/>\r\n+                                        <column name="value" index="0"/>\r\n+                                    </options>\r\n+                                </param>\r\n+                            </when>\r\n+                        </conditional>\r\n+                    </repeat>\r\n+                </when>\r\n+            </conditional>\r\n+        </section>\r\n+    </xml>\r\n+    <xml name="section_where">\r\n+        <section name="mask_values" title="Advanced options to mask by values">\r\n+            <conditional name="mask_condi">\r\n+                <param name="mask_option" type="select" multiple="false" label="Option for masked values">\r\n+                    <option value="keep" selected="true">Fill with NA</option>\r\n+                    <option value="drop">Drop values</option>\r\n+                    <option value="other">Set constant</option>\r\n+                </param>\r\n+                <when value="keep"/>\r\n+                <when value="drop"/>\r\n+                <when value="other">\r\n+                    <param name="set_other" type="float" value="0" label="Value to use for locations in this object where cond is False." />\r\n+                </when>\r\n+            </conditional>\r\n+            <param name="where_condition" type="data" optional="true" format="txt" label="file containing a where expression" />\r\n+        </section>\r\n+    </xml>\r\n+</macros>\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 macros_tests_netcdf2netcdf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros_tests_netcdf2netcdf.xml Thu Jan 20 17:09:40 2022 +0000
b
b'@@ -0,0 +1,263 @@\n+<macros>\r\n+    <xml name="section_tests">\r\n+        <tests>\r\n+            <test>\r\n+                <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\r\n+                <param name="var_tab" value="var_tab_dataset-ibi"/>\r\n+                <section name="variable">\r\n+                    <param name="var" value="chl"/>\r\n+                    <param name="scale" value="1000.5"/>\r\n+                </section>\r\n+                <section name="subset_coords">\r\n+                    <conditional name="tsel">\r\n+                        <param name="by_click" value="isel_list"/>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="time"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="10"/>\r\n+                                <param name="t2" value="12"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="latitude"/>\r\n+                            <param name="dim_tab" value="latitude.tabular"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="5"/>\r\n+                                <param name="t2" value="10"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="longitude"/>\r\n+                            <param name="dim_tab" value="longitude.tabular"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="4"/>\r\n+                                <param name="t2" value="10"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                    </conditional>\r\n+                </section>\r\n+                <output name="output_netcdf" file="small.netcdf" compare="sim_size" delta="1000"/>\r\n+            </test>\r\n+            <test>\r\n+                <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\r\n+                <param name="var_tab" value="var_tab_dataset-ibi"/>\r\n+                <section name="variable">\r\n+                    <param name="var" value="chl"/>\r\n+                    <param name="scale" value="1000.5"/>\r\n+                    <param name="write_all" value="true"/>\r\n+                    <param name="keep_attribute" value="false"/>\r\n+                </section>\r\n+                <section name="subset_coords">\r\n+                    <conditional name="tsel">\r\n+                        <param name="by_click" value="isel_list"/>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="time"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="10"/>\r\n+                                <param name="t2" value="12"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="latitude"/>\r\n+                            <param name="dim_tab" value="latitude.tabular"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="5"/>\r\n+                                <param name="t2" value="1'..b'ame="method" value="nearest"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                    </conditional>\r\n+                </section>\r\n+                <output name="output_netcdf" file="select_by_values.netcdf" compare="sim_size" delta="500"/>\r\n+            </test>\r\n+            <test>\r\n+                <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\r\n+                <param name="var_tab" value="var_tab_dataset-ibi"/>\r\n+                <section name="variable">\r\n+                    <param name="var" value="chl,phy"/>\r\n+                </section>\r\n+                <section name="mask_values">\r\n+                    <conditional name="mask_condi">\r\n+                        <param name="mask_option" value="other"/>\r\n+                        <param name="set_other" value="1000"/>\r\n+                    </conditional>\r\n+                    <param name="where_condition" ftype="txt" value="where_condition.txt"/>\r\n+                </section>\r\n+                <output name="output_netcdf" file="chl_phy_where.netcdf" compare="sim_size" delta="500"/>\r\n+            </test>\r\n+            <test>\r\n+                <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\r\n+                <param name="var_tab" value="var_tab_dataset-ibi"/>\r\n+                <section name="variable">\r\n+                    <param name="var" value="chl"/>\r\n+                    <param name="scale" value="1000.5"/>\r\n+                    <param name="write_all" value="true"/>\r\n+                    <param name="keep_attribute" value="true"/>\r\n+                </section>\r\n+                <section name="subset_coords">\r\n+                    <conditional name="tsel">\r\n+                        <param name="by_click" value="isel_list"/>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="time"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="10"/>\r\n+                                <param name="t2" value="12"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="latitude"/>\r\n+                            <param name="dim_tab" value="latitude.tabular"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="0"/>\r\n+                                <param name="t2" value="10"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                        <repeat name="user_choice">\r\n+                            <param name="dim" value="longitude"/>\r\n+                            <param name="dim_tab" value="longitude.tabular"/>\r\n+                            <conditional name="condi_between">\r\n+                                <param name="comparator" value="sl"/>\r\n+                                <param name="t1" value="1"/>\r\n+                                <param name="t2" value="20"/>\r\n+                            </conditional>\r\n+                        </repeat>\r\n+                    </conditional>\r\n+                </section>\r\n+                <section name="mask_values">\r\n+                    <conditional name="mask_condi">\r\n+                        <param name="mask_option" value="drop"/>\r\n+                    </conditional>\r\n+                    <param name="where_condition" ftype="txt" value="where_condition_simple.txt"/>\r\n+                </section>\r\n+                <output name="output_netcdf" file="chl_where_drop.netcdf" compare="sim_size" delta="500"/>\r\n+            </test>\r\n+        </tests>\r\n+    </xml>\r\n+</macros>\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/all.netcdf
b
Binary file test-data/all.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/chl_alltimes.nc
b
Binary file test-data/chl_alltimes.nc has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/chl_nh4.netcdf
b
Binary file test-data/chl_nh4.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/chl_phy_where.netcdf
b
Binary file test-data/chl_phy_where.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/chl_where_drop.netcdf
b
Binary file test-data/chl_where_drop.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/data_from_20040615.nc
b
Binary file test-data/data_from_20040615.nc has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/data_to_20040615.nc
b
Binary file test-data/data_to_20040615.nc has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0.png
b
Binary file test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0.png has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0_title.png
b
Binary file test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time0_title.png has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time1.png
b
Binary file test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time1.png has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time50.png
b
Binary file test-data/dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133_time50.png has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/info_file.txt
--- a/test-data/info_file.txt Sun Jun 06 08:49:43 2021 +0000
+++ b/test-data/info_file.txt Thu Jan 20 17:09:40 2022 +0000
b
@@ -1,9 +1,9 @@
 xarray.Dataset {
 dimensions:
+ time = 145 ;
  depth = 1 ;
  latitude = 97 ;
  longitude = 103 ;
- time = 145 ;
 
 variables:
  float32 phy(time, depth, latitude, longitude) ;
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/select_by_values.netcdf
b
Binary file test-data/select_by_values.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/small.netcdf
b
Binary file test-data/small.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/small_all_variables.netcdf
b
Binary file test-data/small_all_variables.netcdf has changed
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/version.tabular
--- a/test-data/version.tabular Sun Jun 06 08:49:43 2021 +0000
+++ b/test-data/version.tabular Thu Jan 20 17:09:40 2022 +0000
b
@@ -1,1 +1,1 @@
-Galaxy xarray version 0.18.2
+Galaxy xarray version 0.20.2
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/where_condition.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/where_condition.txt Thu Jan 20 17:09:40 2022 +0000
b
@@ -0,0 +1,1 @@
+((chl > 1) | (chl < 45)) & (nh4 > 1)
b
diff -r 663268794710 -r 9bbaab36a5d4 test-data/where_condition_simple.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/where_condition_simple.txt Thu Jan 20 17:09:40 2022 +0000
b
@@ -0,0 +1,1 @@
+nh4 > 5.15
b
diff -r 663268794710 -r 9bbaab36a5d4 xarray_mapplot.py
--- a/xarray_mapplot.py Sun Jun 06 08:49:43 2021 +0000
+++ b/xarray_mapplot.py Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -1,457 +1,411 @@\n-#!/usr/bin/env python3\n-#\n-#\n-# usage: xarray_mapplot.py [-h] [--proj PROJ]\n-#                               [--cmap CMAP]\n-#                               [--output OUTPUT]\n-#                               [--time TIMES]\n-#                               [--nrow NROW]\n-#                               [--ncol NCOL]\n-#                               [--title title]\n-#                               [--latitude LATITUDE]\n-#                               [--longitude LONGITUDE]\n-#                               [--land ALPHA-LAND]\n-#                               [--ocean ALPHA-OCEAN]\n-#                               [--coastline ALPHA-COASTLINE]\n-#                               [--borders ALPHA-BORDERS]\n-#                               [--xlim "x1,x2"]\n-#                               [--ylim "y1,y2"]\n-#                               [--range "valmin,valmax"]\n-#                               [--threshold VAL]\n-#                               [--label label-colorbar]\n-#                               [--shift]\n-#                               [-v]\n-#                               input varname\n-#\n-# positional arguments:\n-#  input            input filename with geographical coordinates (netCDF\n-#                   format)\n-#  varname          Specify which variable to plot (case sensitive)\n-#\n-# optional arguments:\n-#  -h, --help       show this help message and exit\n-#  --proj PROJ      Specify the projection on which we draw\n-#  --cmap CMAP      Specify which colormap to use for plotting\n-#  --output OUTPUT  output filename to store resulting image (png format)\n-#  --time TIMES     time index from the file for multiple plots ("0 1 2 3")\n-#  --title          plot or subplot title\n-#  --latitude        variable name for latitude\n-#  --longitude       variable name for longitude\n-#  --land            add land on plot with alpha value [0-1]\n-#  --ocean           add oceans on plot with alpha value [0-1]\n-#  --coastline       add coastline with alpha value [0-1]\n-#  --borders         add country borders with alpha value [0-1]\n-#  --xlim            limited geographical area longitudes "x1,x2"\n-#  --ylim            limited geographical area latitudes "y1,y2"\n-#  --range           "valmin,valmax" for plotting\n-#  --threshold       do not plot values below threshold\n-#  --label           set a label for colormap\n-#  --shift           shift longitudes if specified\n-#  -v, --verbose    switch on verbose mode\n-#\n-\n-import argparse\n-import ast\n-import warnings\n-from pathlib import Path\n-\n-import cartopy.crs as ccrs\n-import cartopy.feature as feature\n-\n-from cmcrameri import cm\n-\n-import matplotlib as mpl\n-mpl.use(\'Agg\')\n-from matplotlib import pyplot  # noqa: I202,E402\n-\n-import xarray as xr  # noqa: E402\n-\n-\n-class MapPlotXr ():\n-    def __init__(self, input, proj, varname, cmap, output, verbose=False,\n-                 time=[], title="", latitude="latitude",\n-                 longitude="longitude", land=0, ocean=0,\n-                 coastline=0, borders=0, xlim=[], ylim=[],\n-                 threshold="", label="", shift=False,\n-                 range_values=[]):\n-        self.input = input\n-        print("PROJ", proj)\n-        if proj != "" and proj is not None:\n-            self.proj = proj.replace(\'X\', \':\')\n-        else:\n-            self.proj = proj\n-        self.varname = varname\n-        self.get_cmap(cmap)\n-        self.time = time\n-        self.latitude = latitude\n-        self.longitude = longitude\n-        self.land = land\n-        self.ocean = ocean\n-        self.coastline = coastline\n-        self.borders = borders\n-        self.xlim = xlim\n-        self.ylim = ylim\n-        self.range = range_values\n-        self.threshold = threshold\n-        self.shift = shift\n-        self.xylim_supported = False\n-        self.colorbar = True\n-        self.title = title\n-        if output is None:\n-            self.output = Path(input).stem + \'.png\'\n-        else:\n-            self.output = output\n-        self.verbose = '..b'd)\r\n+\r\n+        if self.range == []:\r\n+            minval = self.dset[self.varname].min()\r\n+            maxval = self.dset[self.varname].max()\r\n+        else:\r\n+            minval = self.range[0]\r\n+            maxval = self.range[1]\r\n+\r\n+        if self.verbose:\r\n+            print("minval: ", minval)\r\n+            print("maxval: ", maxval)\r\n+\r\n+        # pass extent with vmin and vmax parameters\r\n+        proj_t = ccrs.PlateCarree()\r\n+        if ts is None:\r\n+            self.dset.where(\r\n+                 self.dset[self.varname] > threshold\r\n+                 )[self.varname].plot(ax=ax,\r\n+                                      vmin=minval,\r\n+                                      vmax=maxval,\r\n+                                      transform=proj_t,\r\n+                                      cmap=self.cmap,\r\n+                                      cbar_kwargs=self.label\r\n+                                      )\r\n+            if self.title != "" and self.title is not None:\r\n+                pyplot.title(self.title)\r\n+            pyplot.savefig(self.output)\r\n+        else:\r\n+            if self.colorbar:\r\n+                self.dset.where(\r\n+                     self.dset[self.varname] > threshold\r\n+                     )[self.varname].isel(time=ts).plot(ax=ax,\r\n+                                                        vmin=minval,\r\n+                                                        vmax=maxval,\r\n+                                                        transform=proj_t,\r\n+                                                        cmap=self.cmap,\r\n+                                                        cbar_kwargs=self.label\r\n+                                                        )\r\n+            else:\r\n+                self.dset.where(\r\n+                     self.dset[self.varname] > minval\r\n+                     )[self.varname].isel(time=ts).plot(ax=ax,\r\n+                                                        vmin=minval,\r\n+                                                        vmax=maxval,\r\n+                                                        transform=proj_t,\r\n+                                                        cmap=self.cmap,\r\n+                                                        add_colorbar=False)\r\n+            if self.title != "" and self.title is not None:\r\n+                pyplot.title(self.title + "(time = " + str(ts) + \')\')\r\n+            pyplot.savefig(self.output[:-4] + "_time" + str(ts) +\r\n+                           self.output[-4:])  # assume png format\r\n+\r\n+\r\n+if __name__ == \'__main__\':\r\n+    warnings.filterwarnings("ignore")\r\n+    parser = argparse.ArgumentParser()\r\n+    parser.add_argument(\r\n+        \'input\',\r\n+        help=\'input filename with geographical coordinates (netCDF format)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--proj\',\r\n+        help=\'Config file with the projection on which we draw\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'varname\',\r\n+        help=\'Specify which variable to plot (case sensitive)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--output\',\r\n+        help=\'output filename to store resulting image (png format)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--config\',\r\n+        help=\'pass plotting parameters via a config file\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--shift\',\r\n+        help=\'shift longitudes if specified\',\r\n+        action="store_true"\r\n+    )\r\n+    parser.add_argument(\r\n+        "-v", "--verbose",\r\n+        help="switch on verbose mode",\r\n+        action="store_true")\r\n+    args = parser.parse_args()\r\n+\r\n+    dset = MapPlotXr(input=args.input, varname=args.varname,\r\n+                     output=args.output, verbose=args.verbose,\r\n+                     config_file=args.config, proj=args.proj,\r\n+                     shift=args.shift)\r\n+\r\n+    if dset.time == []:\r\n+        dset.plot()\r\n+    else:\r\n+        for t in dset.time:\r\n+            dset.plot(t)\r\n+            dset.shift = False   # only shift once\r\n+            dset.colorbar = True\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 xarray_metadata_info.xml
--- a/xarray_metadata_info.xml Sun Jun 06 08:49:43 2021 +0000
+++ b/xarray_metadata_info.xml Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -1,86 +1,86 @@\n-<tool id="xarray_metadata_info" name="NetCDF xarray Metadata Info" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">\n-    <description>summarize content of a Netcdf file</description>\n-    <macros>\n-        <import>macros.xml</import>\n-    </macros>\n-    <expand macro="edam_ontology"/>\n-    <requirements>\n-        <requirement type="package" version="3">python</requirement>\n-        <requirement type="package" version="1.5.6">netcdf4</requirement>\n-        <requirement type="package" version="@TOOL_VERSION@">xarray</requirement>\n-        <requirement type="package" version="0.9.0">geopandas</requirement>\n-        <requirement type="package" version="1.7.1">shapely</requirement>\n-    </requirements>\n-    <command detect_errors="exit_code"><![CDATA[\n-        python3 \'$__tool_directory__/xarray_tool.py\' \'$input\' --info \'$info\' --summary \'$output\'\n-    ]]></command>\n-    <inputs>\n-        <param type="data" name="input" label="Netcdf file" format="netcdf,h5" help="Netcdf file you need information about."/>\n-    </inputs>\n-    <outputs>\n-        <data name="output" format="tabular" label="Metadata infos from ${input.name}" from_work_dir="variables.tabular"/>\n-        <data name="info" label="info file" format="txt"/>\n-    </outputs>\n-    <tests>\n-        <test>\n-             <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\n-             <param name="output" value="Metadata_infos_from_dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc.Variables.tab"/>\n-             <output name="info" value="info_file.txt">\n-                 <assert_contents>\n-                     <has_text_matching expression="depth\\s+=\\s+1"/>\n-                     <has_text_matching expression="latitude\\s+=\\s+97"/>\n-                     <has_text_matching expression="longitude\\s+=\\s+103"/>\n-                     <has_text_matching expression="time\\s+=\\s+145"/>\n-                 </assert_contents>\n-             </output>\n-             <output name="output" ftype="tabular" file="Metadata_infos_from_dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc.Variables.tab">\n-                 <assert_contents>\n-                     <has_text_matching expression="VariableName\\tNumberOfDimensions\\tDim0Name\\tDim0Size\\tDim1Name\\tDim1Size\\tDim2Name\\tDim2Size\\tDim3Name\\tDim3Size"/>\n-                     <has_text_matching expression="phy\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\n-                     <has_text_matching expression="chl\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\n-                     <has_text_matching expression="nh4\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\n-                     <has_text_matching expression="time\\t1\\ttime\\t145"/>\n-                     <has_text_matching expression="longitude\\t1\\tlongitude\\t103"/>\n-                     <has_text_matching expression="latitude\\t1\\tlatitude\\t97"/>\n-                     <has_text_matching expression="depth\\t1\\tdepth\\t1"/>\n-                 </assert_contents>\n-             </output>\n-        </test>\n-    </tests>\n-    <help><![CDATA[\n-**What it does**\n-\n-First the tool will give general information about the input in a \'info file\' output. (command $ncdump -h inputfile)\n-\n-Then, a general tabular \'variables\' summarize dimensions details inside each available variable.\n-\n-\n-The summary tabular file has the general structure :\n-\n-\n-    Variable1    Var1_Number_of_Dim    Dim1    Dim1_size   ...    DimN    DimN_size\n-\n-    VariableX    VarX_Number_of_Dim    DimX1   DimX1_size  ...    DimXN   DimXN_size\n-\n-    ...\n-\n-\n-**Input**\n-\n-A netcdf file (xxx.nc).\n-\n-**Outputs**\n-\n-An Information file.\n-\n-A summary tabular file.\n-\n-\n---------------------------------\n-\n-The Netcdf Info tool use the netcdf functions : https://www.unidata.ucar.edu/software/netcdf/docs/index.html\n-\n-Run this tool before considering using Netcdf Read.\n-    ]]></help>\n-    <expand macro="citations"/>\n-</'..b'OL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">\r\n+    <description>summarize content of a Netcdf file</description>\r\n+    <macros>\r\n+        <import>macros.xml</import>\r\n+    </macros>\r\n+    <expand macro="edam_ontology"/>\r\n+    <requirements>\r\n+        <requirement type="package" version="@TOOL_VERSION@">xarray</requirement>\r\n+        <requirement type="package" version="3">python</requirement>\r\n+        <requirement type="package" version="1.5.6">netcdf4</requirement>\r\n+        <requirement type="package" version="0.9.0">geopandas</requirement>\r\n+        <requirement type="package" version="1.7.1">shapely</requirement>\r\n+    </requirements>\r\n+    <command detect_errors="exit_code"><![CDATA[\r\n+        python3 \'$__tool_directory__/xarray_tool.py\' \'$input\' --info \'$info\' --summary \'$output\'\r\n+    ]]>    </command>\r\n+    <inputs>\r\n+        <param type="data" name="input" label="Netcdf file" format="netcdf,h5" help="Netcdf file you need information about."/>\r\n+    </inputs>\r\n+    <outputs>\r\n+        <data name="output" format="tabular" label="Metadata infos from ${input.name}" from_work_dir="variables.tabular"/>\r\n+        <data name="info" label="info file" format="txt"/>\r\n+    </outputs>\r\n+    <tests>\r\n+        <test>\r\n+            <param name="input" value="dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc"/>\r\n+            <param name="output" value="Metadata_infos_from_dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc.Variables.tab"/>\r\n+            <output name="info" value="info_file.txt">\r\n+                <assert_contents>\r\n+                    <has_text_matching expression="depth\\s+=\\s+1"/>\r\n+                    <has_text_matching expression="latitude\\s+=\\s+97"/>\r\n+                    <has_text_matching expression="longitude\\s+=\\s+103"/>\r\n+                    <has_text_matching expression="time\\s+=\\s+145"/>\r\n+                </assert_contents>\r\n+            </output>\r\n+            <output name="output" ftype="tabular" file="Metadata_infos_from_dataset-ibi-reanalysis-bio-005-003-monthly-regulargrid_1510914389133.nc.Variables.tab">\r\n+                <assert_contents>\r\n+                    <has_text_matching expression="VariableName\\tNumberOfDimensions\\tDim0Name\\tDim0Size\\tDim1Name\\tDim1Size\\tDim2Name\\tDim2Size\\tDim3Name\\tDim3Size"/>\r\n+                    <has_text_matching expression="phy\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\r\n+                    <has_text_matching expression="chl\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\r\n+                    <has_text_matching expression="nh4\\t4\\ttime\\t145\\tdepth\\t1\\tlatitude\\t97\\tlongitude\\t103"/>\r\n+                    <has_text_matching expression="time\\t1\\ttime\\t145"/>\r\n+                    <has_text_matching expression="longitude\\t1\\tlongitude\\t103"/>\r\n+                    <has_text_matching expression="latitude\\t1\\tlatitude\\t97"/>\r\n+                    <has_text_matching expression="depth\\t1\\tdepth\\t1"/>\r\n+                </assert_contents>\r\n+            </output>\r\n+        </test>\r\n+    </tests>\r\n+    <help><![CDATA[\r\n+**What it does**\r\n+\r\n+First the tool will give general information about the input in a \'info file\' output. (command $ncdump -h inputfile)\r\n+\r\n+Then, a general tabular \'variables\' summarize dimensions details inside each available variable.\r\n+\r\n+\r\n+The summary tabular file has the general structure :\r\n+\r\n+\r\n+    Variable1    Var1_Number_of_Dim    Dim1    Dim1_size   ...    DimN    DimN_size\r\n+\r\n+    VariableX    VarX_Number_of_Dim    DimX1   DimX1_size  ...    DimXN   DimXN_size\r\n+\r\n+    ...\r\n+\r\n+\r\n+**Input**\r\n+\r\n+A netcdf file (xxx.nc).\r\n+\r\n+**Outputs**\r\n+\r\n+An Information file.\r\n+\r\n+A summary tabular file.\r\n+\r\n+\r\n+--------------------------------\r\n+\r\n+The Netcdf Info tool use the netcdf functions : https://www.unidata.ucar.edu/software/netcdf/docs/index.html\r\n+\r\n+Run this tool before considering using Netcdf Read.\r\n+    ]]>    </help>\r\n+    <expand macro="citations"/>\r\n+</tool>\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 xarray_netcdf2netcdf.py
--- a/xarray_netcdf2netcdf.py Sun Jun 06 08:49:43 2021 +0000
+++ b/xarray_netcdf2netcdf.py Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -1,133 +1,268 @@\n-#!/usr/bin/env python3\n-#\n-#  Apply operations on selected variables\n-# - scale\n-# one can also select the range of time (for timeseries)\n-# to apply these operations over the range only\n-# when a range of time is selected and when scaling, one\n-# can choose to save the entire timeseries or\n-# the selected range only.\n-# when scaling, one can add additional filters on dimensions\n-# (typically used to filter over latitudes and longitudes)\n-\n-\n-import argparse\n-import warnings\n-\n-import xarray as xr  # noqa: E402\n-\n-\n-class netCDF2netCDF ():\n-    def __init__(self, infile, varname, scale="",\n-                 output="output.netcdf",\n-                 write_all=False,\n-                 filter_list="",\n-                 verbose=False):\n-        self.infile = infile\n-        self.verbose = verbose\n-        self.varname = varname\n-        self.write_all = write_all\n-        self.filter = filter_list\n-        self.selection = {}\n-        if scale == "" or scale is None:\n-            self.scale = 1\n-        else:\n-            self.scale = float(scale)\n-        if output is None:\n-            self.output = "output.netcdf"\n-        else:\n-            self.output = output\n-        # initialization\n-        self.dset = None\n-        self.subset = None\n-        if self.verbose:\n-            print("infile: ", self.infile)\n-            print("varname: ", self.varname)\n-            print("filter_list: ", self.filter)\n-            print("scale: ", self.scale)\n-            print("write_all: ", self.write_all)\n-            print("output: ", self.output)\n-\n-    def dimension_selection(self, single_filter):\n-        split_filter = single_filter.split(\'#\')\n-        dimension_varname = split_filter[0]\n-        op = split_filter[1]\n-        ll = int(split_filter[2])\n-        if (op == \'sl\'):\n-            rl = int(split_filter[3])\n-            self.selection[dimension_varname] = slice(ll, rl)\n-        elif (op == \'to\'):\n-            self.selection[dimension_varname] = slice(None, ll)\n-        elif (op == \'from\'):\n-            self.selection[dimension_varname] = slice(ll, None)\n-        elif (op == \'is\'):\n-            self.selection[dimension_varname] = ll\n-\n-    def filter_selection(self):\n-        for single_filter in self.filter:\n-            self.dimension_selection(single_filter)\n-        if self.write_all:\n-            self.ds[self.varname] = \\\n-                self.ds[self.varname].isel(self.selection)*self.scale\n-        else:\n-            self.dset = \\\n-                self.ds[self.varname].isel(self.selection)*self.scale\n-\n-    def compute(self):\n-        if self.dset is None:\n-            self.ds = xr.open_dataset(self.infile)\n-            if self.filter:\n-                self.filter_selection()\n-                if self.verbose:\n-                    print(self.selection)\n-            elif self.write_all is not None:\n-                self.dset = self.ds[self.varname]\n-\n-    def save(self):\n-        if self.write_all:\n-            self.ds.to_netcdf(self.output)\n-        else:\n-            self.dset.to_netcdf(self.output)\n-\n-\n-if __name__ == \'__main__\':\n-    warnings.filterwarnings("ignore")\n-    parser = argparse.ArgumentParser()\n-    parser.add_argument(\n-        \'input\',\n-        help=\'input filename in netCDF format\'\n-    )\n-    parser.add_argument(\n-        \'varname\',\n-        help=\'Specify which variable to plot (case sensitive)\'\n-    )\n-    parser.add_argument(\n-        \'--filter\',\n-        nargs="*",\n-        help=\'Filter list variable#operator#value_s#value_e\'\n-    )\n-    parser.add_argument(\n-        \'--output\',\n-        help=\'Output filename to store the resulting netCDF file\'\n-    )\n-    parser.add_argument(\n-        \'--scale\',\n-        help=\'scale factor to apply to selection (float)\'\n-    )\n-    parser.add_argument(\n-        "--write_all",\n-        help="write all data to netCDF",\n-        action="store_true")\n-    parser.add_argument(\n-        "-v", "--verbose",\n-        help="switch on verbose mode",\n-     '..b'here(\r\n+                        self.eval_where(self.where),\r\n+                        other=float(self.other)\r\n+                        )\r\n+                else:\r\n+                    self.ds = self.ds.where(\r\n+                        self.eval_where(self.where)\r\n+                        )\r\n+            self.filter_selection()\r\n+            if self.verbose:\r\n+                print(self.selection)\r\n+\r\n+    def save(self):\r\n+        if self.varname != \'None\' and \\\r\n+            self.varname is not None and \\\r\n+                not self.write_all:\r\n+            self.dset[self.varname].to_netcdf(self.output)\r\n+        else:\r\n+            self.dset.to_netcdf(self.output)\r\n+\r\n+    def is_float(self, element) -> bool:\r\n+        try:\r\n+            float(element)\r\n+            return True\r\n+        except ValueError:\r\n+            return False\r\n+\r\n+    def eval_where(self, where_condition):\r\n+        eval_cond = None\r\n+        list_names = list(set(\r\n+                        list(self.ds.keys()) +\r\n+                        list(self.ds.coords.keys()))\r\n+                        )\r\n+        wcond = where_condition\r\n+        check_cond = where_condition\r\n+        for var in list_names:\r\n+            wcond = wcond.replace(var, \' self.ds.\' + var + \' \')\r\n+            check_cond = check_cond.replace(var, \'\')\r\n+        to_remove = "[><=&|()]"\r\n+        check_cond = re.sub(to_remove, "", check_cond).replace("!", "")\r\n+        check_cond = re.sub(\' +\', \' \', check_cond).strip()\r\n+        list_flt = check_cond.split(" ")\r\n+        no_convert = False\r\n+        for num in list_flt:\r\n+            if not self.is_float(num):\r\n+                no_convert = True\r\n+        if not no_convert:\r\n+            eval_cond = eval(wcond)\r\n+        return eval_cond\r\n+\r\n+\r\n+if __name__ == \'__main__\':\r\n+    warnings.filterwarnings("ignore")\r\n+    parser = argparse.ArgumentParser()\r\n+    parser.add_argument(\r\n+        \'input\',\r\n+        help=\'input filename in netCDF format\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'varname\',\r\n+        help=\'Specify which variable to plot (case sensitive)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--filter\',\r\n+        nargs="*",\r\n+        help=\'Filter list variable#operator#value_s#value_e\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--where\',\r\n+        help=\'filename with where condition to be evaluated\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--output\',\r\n+        help=\'Output filename to store the resulting netCDF file\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--scale\',\r\n+        help=\'scale factor to apply to selection (float)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--other\',\r\n+        help=\'Value to use for locations where condition is False (float)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        "--write_all",\r\n+        help="write all data to netCDF",\r\n+        action="store_true")\r\n+    parser.add_argument(\r\n+        "--keep_attributes",\r\n+        help="Keep all attributes",\r\n+        action="store_true")\r\n+    parser.add_argument(\r\n+        "-v", "--verbose",\r\n+        help="switch on verbose mode",\r\n+        action="store_true")\r\n+    parser.add_argument(\r\n+        "--selection",\r\n+        help="select by values",\r\n+        action="store_true")\r\n+    parser.add_argument(\r\n+        "--drop",\r\n+        help="drop values where condition is not met",\r\n+        action="store_true")\r\n+    args = parser.parse_args()\r\n+\r\n+    print("args.selection", args.selection)\r\n+    dset = netCDF2netCDF(infile=args.input, varname=args.varname,\r\n+                         scale=args.scale, output=args.output,\r\n+                         write_all=args.write_all,\r\n+                         sel=args.selection,\r\n+                         keep_attributes=args.keep_attributes,\r\n+                         filter_list=args.filter,\r\n+                         where_config=args.where,\r\n+                         drop=args.drop, other=args.other,\r\n+                         verbose=args.verbose)\r\n+    dset.compute()\r\n+    dset.save()\r\n'
b
diff -r 663268794710 -r 9bbaab36a5d4 xarray_tool.py
--- a/xarray_tool.py Sun Jun 06 08:49:43 2021 +0000
+++ b/xarray_tool.py Thu Jan 20 17:09:40 2022 +0000
[
b'@@ -1,365 +1,365 @@\n-# xarray tool for:\n-# - getting metadata information\n-# - select data and save results in csv file for further post-processing\n-\n-import argparse\n-import csv\n-import os\n-import warnings\n-\n-import geopandas as gdp\n-\n-import pandas as pd\n-\n-from shapely.geometry import Point\n-from shapely.ops import nearest_points\n-\n-import xarray as xr\n-\n-\n-class XarrayTool ():\n-    def __init__(self, infile, outfile_info="", outfile_summary="",\n-                 select="", outfile="", outputdir="", latname="",\n-                 latvalN="", latvalS="", lonname="", lonvalE="",\n-                 lonvalW="", filter_list="", coords="", time="",\n-                 verbose=False, no_missing=False, coords_info=None,\n-                 tolerance=None):\n-        self.infile = infile\n-        self.outfile_info = outfile_info\n-        self.outfile_summary = outfile_summary\n-        self.select = select\n-        self.outfile = outfile\n-        self.outputdir = outputdir\n-        self.latname = latname\n-        if tolerance != "" and tolerance is not None:\n-            self.tolerance = float(tolerance)\n-        else:\n-            self.tolerance = -1\n-        if latvalN != "" and latvalN is not None:\n-            self.latvalN = float(latvalN)\n-        else:\n-            self.latvalN = ""\n-        if latvalS != "" and latvalS is not None:\n-            self.latvalS = float(latvalS)\n-        else:\n-            self.latvalS = ""\n-        self.lonname = lonname\n-        if lonvalE != "" and lonvalE is not None:\n-            self.lonvalE = float(lonvalE)\n-        else:\n-            self.lonvalE = ""\n-        if lonvalW != "" and lonvalW is not None:\n-            self.lonvalW = float(lonvalW)\n-        else:\n-            self.lonvalW = ""\n-        self.filter = filter_list\n-        self.time = time\n-        self.coords = coords\n-        self.verbose = verbose\n-        self.no_missing = no_missing\n-        # initialization\n-        self.dset = None\n-        self.gset = None\n-        self.coords_info = coords_info\n-        if self.verbose:\n-            print("infile: ", self.infile)\n-            print("outfile_info: ", self.outfile_info)\n-            print("outfile_summary: ", self.outfile_summary)\n-            print("outfile: ", self.outfile)\n-            print("select: ", self.select)\n-            print("outfile: ", self.outfile)\n-            print("outputdir: ", self.outputdir)\n-            print("latname: ", self.latname)\n-            print("latvalN: ", self.latvalN)\n-            print("latvalS: ", self.latvalS)\n-            print("lonname: ", self.lonname)\n-            print("lonvalE: ", self.lonvalE)\n-            print("lonvalW: ", self.lonvalW)\n-            print("filter: ", self.filter)\n-            print("time: ", self.time)\n-            print("coords: ", self.coords)\n-            print("coords_info: ", self.coords_info)\n-\n-    def info(self):\n-        f = open(self.outfile_info, \'w\')\n-        ds = xr.open_dataset(self.infile)\n-        ds.info(f)\n-        f.close()\n-\n-    def summary(self):\n-        f = open(self.outfile_summary, \'w\')\n-        ds = xr.open_dataset(self.infile)\n-        writer = csv.writer(f, delimiter=\'\\t\')\n-        header = [\'VariableName\', \'NumberOfDimensions\']\n-        for idx, val in enumerate(ds.dims.items()):\n-            header.append(\'Dim\' + str(idx) + \'Name\')\n-            header.append(\'Dim\' + str(idx) + \'Size\')\n-        writer.writerow(header)\n-        for name, da in ds.data_vars.items():\n-            line = [name]\n-            line.append(len(ds[name].shape))\n-            for d, s in zip(da.shape, da.sizes):\n-                line.append(s)\n-                line.append(d)\n-            writer.writerow(line)\n-        for name, da in ds.coords.items():\n-            line = [name]\n-            line.append(len(ds[name].shape))\n-            for d, s in zip(da.shape, da.sizes):\n-                line.append(s)\n-                line.append(d)\n-            writer.writerow(line)\n-        f.close()\n-\n-    def rowfilter(self,'..b'       self.lonvalE = row[1]\r\n+            self.outfile = (os.path.join(self.outputdir,\r\n+                            self.select + \'_\' +\r\n+                            str(row.Index) + \'.tabular\'))\r\n+            self.selection()\r\n+\r\n+    def get_coords_info(self):\r\n+        ds = xr.open_dataset(self.infile)\r\n+        for c in ds.coords:\r\n+            filename = os.path.join(self.coords_info,\r\n+                                    c.strip() +\r\n+                                    \'.tabular\')\r\n+            pd = ds.coords[c].to_pandas()\r\n+            pd.index = range(len(pd))\r\n+            pd.to_csv(filename, header=False, sep=\'\\t\')\r\n+\r\n+\r\n+if __name__ == \'__main__\':\r\n+    warnings.filterwarnings("ignore")\r\n+    parser = argparse.ArgumentParser()\r\n+\r\n+    parser.add_argument(\r\n+        \'infile\',\r\n+        help=\'netCDF input filename\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--info\',\r\n+        help=\'Output filename where metadata information is stored\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--summary\',\r\n+        help=\'Output filename where data summary information is stored\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--select\',\r\n+        help=\'Variable name to select\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--latname\',\r\n+        help=\'Latitude name\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--latvalN\',\r\n+        help=\'North latitude value\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--latvalS\',\r\n+        help=\'South latitude value\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--lonname\',\r\n+        help=\'Longitude name\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--lonvalE\',\r\n+        help=\'East longitude value\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--lonvalW\',\r\n+        help=\'West longitude value\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--tolerance\',\r\n+        help=\'Maximum distance between original and selected value for \'\r\n+             \' inexact matches e.g. abs(index[indexer] - target) <= tolerance\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--coords\',\r\n+        help=\'Input file containing Latitude and Longitude\'\r\n+             \'for geographical selection\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--coords_info\',\r\n+        help=\'output-folder where for each coordinate, coordinate values \'\r\n+             \' are being printed in the corresponding outputfile\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--filter\',\r\n+        nargs="*",\r\n+        help=\'Filter list variable#operator#value_s#value_e\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--time\',\r\n+        help=\'select timeseries variable#operator#value_s[#value_e]\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--outfile\',\r\n+        help=\'csv outfile for storing results of the selection\'\r\n+             \'(valid only when --select)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        \'--outputdir\',\r\n+        help=\'folder name for storing results with multiple selections\'\r\n+             \'(valid only when --select)\'\r\n+    )\r\n+    parser.add_argument(\r\n+        "-v", "--verbose",\r\n+        help="switch on verbose mode",\r\n+        action="store_true"\r\n+    )\r\n+    parser.add_argument(\r\n+        "--no_missing",\r\n+        help="""Do not take into account possible null/missing values\r\n+                (only valid for single location)""",\r\n+        action="store_true"\r\n+    )\r\n+    args = parser.parse_args()\r\n+\r\n+    p = XarrayTool(args.infile, args.info, args.summary, args.select,\r\n+                   args.outfile, args.outputdir, args.latname,\r\n+                   args.latvalN, args.latvalS, args.lonname,\r\n+                   args.lonvalE, args.lonvalW, args.filter,\r\n+                   args.coords, args.time, args.verbose,\r\n+                   args.no_missing, args.coords_info, args.tolerance)\r\n+    if args.info:\r\n+        p.info()\r\n+    if args.summary:\r\n+        p.summary()\r\n+    if args.coords:\r\n+        p.selection_from_coords()\r\n+    elif args.select:\r\n+        p.selection()\r\n+    elif args.coords_info:\r\n+        p.get_coords_info()\r\n'