changeset 2:abdc27e01dca draft default tip

planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/climate-stripes commit e4c144851549600ffde5bcf875304d5edd98e2b1
author climate
date Sat, 09 Jul 2022 09:02:01 +0000
parents c6f2435d680b
children
files climate-stripes.xml climate_stripes.py test-data/T2Mstripes_with_axis.png
diffstat 3 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/climate-stripes.xml	Tue Apr 14 15:08:10 2020 -0400
+++ b/climate-stripes.xml	Sat Jul 09 09:02:01 2022 +0000
@@ -1,9 +1,16 @@
-<tool id="climate_stripes" name="climate stripes" version="1.0.1">
+<tool id="climate_stripes" name="climate stripes" version="1.0.2">
     <description>from timeseries</description>
+    <edam_topics>
+      <edam_topic>topic_3855</edam_topic>
+      <edam_topic>topic_3318</edam_topic>
+    </edam_topics>
+    <edam_operations>
+      <edam_operation>operation_0337</edam_operation>
+    </edam_operations>
     <requirements>
         <requirement type="package" version="3">python</requirement>
-        <requirement type="package" version="3.1.1">matplotlib</requirement>
-        <requirement type="package" version="1.0.0">pandas</requirement>
+        <requirement type="package" version="3.5.2">matplotlib</requirement>
+        <requirement type="package" version="1.4.3">pandas</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
        python3 '$__tool_directory__/climate_stripes.py'
@@ -21,6 +28,9 @@
             #if str($adv.format_plot).strip()
                 --format_plot '$adv.format_plot'
             #end if
+            #if $adv.nxsplit
+                --nxsplit '$adv.nxsplit'
+            #end if
             --output image.png
     ]]></command>
     <inputs>
@@ -28,6 +38,7 @@
         <param name="variable" type="text" value="global" label="column name to use for plotting" />
         <param name="title" type="text" value="" label="plot title" />
         <section name="adv" title="Advanced Options" expanded="false">
+            <param name="nxsplit" type="integer" optional="true" label="number of values per intervals" />
             <param name="xname" type="text" value="" label="column name to use for x-axis" />
             <param name="format_date" type="text" value="" label="format for input date/time column" />
             <param name="format_plot" type="text" value="" label="format for plotting dates on the x-axis" />
@@ -127,6 +138,7 @@
             <param name="variable" value="global" />
             <param name="title" value="Surface Temperature stripes (1979-2019)" />
             <param name="colormap" value="OrRd" />
+            <param name="nxsplit" value="50" />
             <param name="xname" value="Month" />
             <param name="format_date" value="XYXm" />
             <param name="format_plot" value="XY" />
--- a/climate_stripes.py	Tue Apr 14 15:08:10 2020 -0400
+++ b/climate_stripes.py	Sat Jul 09 09:02:01 2022 +0000
@@ -72,7 +72,10 @@
             self.plot_format = plot_format.replace('X', '%')
 
     def read_data(self):
-        self.data = pd.read_csv(self.input, sep='\t')
+        if self.xname is not None:
+            self.data = pd.read_csv(self.input, sep='\t', index_col=self.xname, infer_datetime_format=True)
+        else:
+            self.data = pd.read_csv(self.input, sep='\t')
 
     def create_stripes(self):
         data = np.zeros((2, self.data[self.valname].shape[0]), dtype='float')
@@ -86,16 +89,11 @@
                    vmax=self.data[self.valname].quantile(q=0.99))
         if self.title:
             plt.title(self.title)
-        if self.xname:
+        if self.xname is not None:
             nrange = self.data.index.values
-            n = int(np.floor((nrange.max() - nrange.min())/int(self.nxsplit)))
-            date_list = self.data[self.xname].loc[::n].apply(
-                             lambda x: pd.to_datetime(str(x),
-                                                      format=self.format))
+            date_list = pd.to_datetime(nrange[::int(self.nxsplit)], format=self.format)
             date_list = [i.strftime(self.plot_format) for i in date_list]
-            nval = int(self.data[self.xname].loc[::n].shape[0])
-            ax.xaxis.set_major_locator(plt.MaxNLocator(nval))
-            ax.xaxis.set_ticklabels(date_list)
+            ax.set_xticks(np.arange(0, len(nrange), int(self.nxsplit)), date_list)
             ax.xaxis.set_tick_params(rotation=45)
         else:
             ax.set_xticks([])
Binary file test-data/T2Mstripes_with_axis.png has changed