Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from amsnyder/fix_p_coverage
Browse files Browse the repository at this point in the history
fix days of year for percent coverage
  • Loading branch information
amsnyder authored Jan 18, 2022
2 parents a7a3fa5 + 5094fd8 commit 3b6541a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion data_exploration/src/gap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ def gap_analysis_calc(source, var_dfs):
for year in years:
year_df = df[df.index.year==year][site]
# year_df.dropna(inplace=True)
var_site_gap_df.loc[year, 'p_coverage'] = year_df.count()/365
if year == datetime.datetime.today().year:
elapsed_days = datetime.datetime.today().timetuple().tm_yday
else:
elapsed_days = (datetime.datetime(year+1, 1, 1, 0, 0) - datetime.datetime(year, 1, 1, 0, 0)).days
var_site_gap_df.loc[year, 'p_coverage'] = year_df.count()/elapsed_days
deltas = year_df.dropna().index.to_series().diff()[1:]
gaps = deltas[deltas > dt.timedelta(days=1)]
var_site_gap_df.loc[year, 'n_gaps'] = len(gaps)
Expand Down

0 comments on commit 3b6541a

Please sign in to comment.