In [1]:
%matplotlib inline
import nivapy3 as nivapy
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sn
plt.style.use('ggplot')
In [2]:
# Connect to NIVABASE
eng = nivapy.da.connect()
In [3]:
# Query projects
prj_grid = nivapy.da.select_resa_projects(eng)
prj_grid
In [4]:
# Get project
prj_df = prj_grid.get_selected_df()
prj_df
Out[4]:
In [5]:
# Get project stations
stn_df = nivapy.da.select_resa_project_stations(prj_df, eng)
print(len(stn_df), 'stations in project.')
stn_df.head()
Out[5]:
In [6]:
# Map of stations
nivapy.spatial.quickmap(stn_df,
popup='station_code',
cluster=True)
Out[6]:
In [7]:
# Get available pars
st_dt = '1990-01-01'
end_dt = '2016-12-31'
par_grid = nivapy.da.select_resa_station_parameters(stn_df,
st_dt,
end_dt,
eng)
par_grid
In [11]:
# Select all pars
par_df = par_grid.get_selected_df()
print(len(par_df), 'parameters selected.')
par_df.head()
Out[11]:
In [12]:
# Get chem
wc_df, dup_df = nivapy.da.select_resa_water_chemistry(stn_df,
par_df,
st_dt,
end_dt,
eng,
drop_dups=True,
lod_flags=False)
wc_df.head()
Out[12]:
In [13]:
# Save output
out_csv = r'../../update_autumn_2018/results/all_chem_1990-2016.csv'
wc_df.to_csv(out_csv, index=False, encoding='utf-8')