annotate gaiac_windrose_plot/gaiac_windrose_plot.py @ 0:0a8233db930e draft

planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
author jay
date Thu, 15 May 2025 14:46:28 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
1 import numpy as np
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
2 import pandas as pd
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
3 import matplotlib.pyplot as plt
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
4 import argparse
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
5 from windrose import WindroseAxes
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
6
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
7 def wind_rose (infile, clm_list_dir, clm_list_ws, outfile):
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
8 df=pd.read_csv(infile, sep="\t")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
9 cl = df.columns.tolist()
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
10
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
11 clms_dir = cl[int(clm_list_dir)-1]
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
12 clms_ws = cl[int(clm_list_ws)-1]
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
13
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
14 ax = WindroseAxes.from_ax()
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
15 ax.bar(df[clms_dir], df[clms_ws], normed=True, opening=0.8, edgecolor='white')
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
16 ax.set_legend(bbox_to_anchor=(1.05, 0.5))
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
17 ax.set_xticklabels(['W', 'NW', 'N', 'NE', 'E', 'SE','S', 'SW'])
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
18
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
19 plt.savefig(outfile, dpi=300,bbox_inches="tight")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
20
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
21
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
22 if __name__=="__main__":
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
23
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
24 parser = argparse.ArgumentParser()
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
25 parser.add_argument("-I", "--infile", required=True, default=None, help=".tsv")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
26 parser.add_argument("-d", "--column_list_dir", required=False, default=False, help="Path to target tsv file")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
27 parser.add_argument("-w", "--column_list_ws", required=False, default=False, help="Path to target tsv file")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
28 parser.add_argument("-O", "--output", required=False, default='Out.png', help="Path to target tsv file")
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
29
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
30 args = parser.parse_args()
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
31
0a8233db930e planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
32 wind_rose(args.infile, args.column_list_dir, args.column_list_ws, args.output)