-
Notifications
You must be signed in to change notification settings - Fork 1
/
11b_post_vert_interp_sep_by_szn.py
61 lines (48 loc) · 2.26 KB
/
11b_post_vert_interp_sep_by_szn.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
61
# Separate vertically interpolated value vs depth file by season
import pandas as pd
import numpy as np
from tqdm import trange
# infile = 'C:\\Users\\HourstonH\\Documents\\NEP_climatology\\data\\' \
# 'value_vs_depth\\11_replicate_check\\' \
# 'Oxy_1991_2020_value_vs_depth_rr_rep_val_check.csv'
infile = '/home/hourstonh/Documents/climatology/data/value_vs_depth/' \
'11_replicate_check/' \
'Oxy_1991_2020_value_vs_depth_rr_part2_rep_val_check.csv'
df_in = pd.read_csv(infile)
df_winter = pd.DataFrame()
df_spring = pd.DataFrame()
df_summer = pd.DataFrame()
df_fall = pd.DataFrame()
# Profile start indices
# (index of the first measurement of each profile in the vvd df)
prof_start_ind = np.unique(df_in.Profile_number, return_index=True)[1]
for i in trange(len(prof_start_ind)):
# Set profile end index
if i == len(prof_start_ind) - 1:
end_ind = len(df_in)
else:
end_ind = prof_start_ind[i + 1]
# Get profile data; np.arange not inclusive of end which we want here
# Convert dataframe columns to numpy arrays
indices = np.arange(prof_start_ind[i], end_ind)
# Extract month number from the date string YYYYMMDDhhmmss
prof_mth = int(str(df_in.loc[indices[0], 'Date_string'])[4:6])
if prof_mth in np.arange(1, 4):
df_winter = pd.concat([df_winter, df_in.loc[indices]])
elif prof_mth in np.arange(4, 7):
df_spring = pd.concat([df_spring, df_in.loc[indices]])
elif prof_mth in np.arange(7, 10):
df_summer = pd.concat([df_summer, df_in.loc[indices]])
elif prof_mth in np.arange(10, 13):
df_fall = pd.concat([df_fall, df_in.loc[indices]])
else:
print('Invalid profile month')
# Export dfs
# outdir = 'C:\\Users\\HourstonH\\Documents\\NEP_climatology\\data\\' \
# 'value_vs_depth\\11_replicate_check\\by_season\\'
outdir = '/home/hourstonh/Documents/climatology/data/value_vs_depth/' \
'11_replicate_check/by_season/'
df_winter.to_csv(outdir + 'Oxy_1991_2020_value_vs_depth_rr_JFM.csv', index=False)
df_spring.to_csv(outdir + 'Oxy_1991_2020_value_vs_depth_rr_AMJ.csv', index=False)
df_summer.to_csv(outdir + 'Oxy_1991_2020_value_vs_depth_rr_JAS.csv', index=False)
df_fall.to_csv(outdir + 'Oxy_1991_2020_value_vs_depth_rr_OND.csv', index=False)