annotate gaiac_windrose_plot/gaiac_windrose_plot.py @ 3:9de2b10ed246 draft default tip

planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit e9587f93346c7b55e1be00bad5844bf2db3ed03d-dirty
author jay
date Thu, 10 Jul 2025 19:40:38 +0000
parents abfc2c9779d6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
1 import numpy as np
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
2 import pandas as pd
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
3 import matplotlib.pyplot as plt
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
4 import argparse
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
5 from windrose import WindroseAxes
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
6
abfc2c9779d6 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):
abfc2c9779d6 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")
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
9 cl = df.columns.tolist()
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
10
abfc2c9779d6 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]
abfc2c9779d6 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]
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
13
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
14 ax = WindroseAxes.from_ax()
abfc2c9779d6 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')
abfc2c9779d6 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))
abfc2c9779d6 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'])
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
18
abfc2c9779d6 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")
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
20
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
21
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
22 if __name__=="__main__":
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
23
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
24 parser = argparse.ArgumentParser()
abfc2c9779d6 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")
abfc2c9779d6 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")
abfc2c9779d6 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")
abfc2c9779d6 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")
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
29
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
30 args = parser.parse_args()
abfc2c9779d6 planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff changeset
31
abfc2c9779d6 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)