-
Notifications
You must be signed in to change notification settings - Fork 0
/
hist_osd_profile_counts.py
60 lines (49 loc) · 1.66 KB
/
hist_osd_profile_counts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import matplotlib.pyplot as plt
import pandas as pd
import os
import numpy as np
def do_hist_profile_counts(time, counts, output_name,
instrument, barcol):
# Adjust the start year
# to account for no CTD data before 1950
start_idx = 0
profile_count = counts[start_idx]
while profile_count == 0:
start_idx += 1
profile_count = counts[start_idx]
# plt.hist(time, bins=num_bins, align='left',
# c=barcol, alpha=0.5)
barwidth = 1.
plt.bar(time[start_idx:], counts[start_idx:],
align='edge', width=barwidth, color=barcol,
edgecolor=barcol, alpha=1)
# plt.stairs(counts[start_idx:], time[start_idx-1:],
# fill=True, color=barcol)
# plt.step(counts[start_idx:], time[start_idx:],
# fill=True, color=barcol)
# Add gridlines
plt.grid(color='lightgrey')
plt.ylabel(f'Num of {instrument} Profiles')
plt.tight_layout()
plt.savefig(output_name)
plt.close()
return
parent_dir = 'C:\\Users\\HourstonH\\Documents\\ctd_bot_profile_counts\\'
input_file = os.path.join(
parent_dir, 'osd_archive_profile_counts_sept29.csv')
df = pd.read_csv(input_file)
# Make bottle and che histogram
# alpha controls the opacity
png_bot = os.path.join(
parent_dir, 'osd_bot_profile_counts_per_year.png')
do_hist_profile_counts(
df.loc[:, 'Year'],
df.loc[:, 'BOT'] + df.loc[:, 'CHE'],
png_bot, 'BOT', barcol='tomato')
# Make ctd histogram
png_ctd = os.path.join(
parent_dir, 'osd_ctd_profile_counts_per_year.png')
do_hist_profile_counts(
df.loc[:, 'Year'],
df.loc[:, 'CTD'],
png_ctd, 'CTD', barcol='royalblue')