In [1]:
#%matplotlib inline
import pandas as pd
import platform
import sys
import numpy as np
from datetime import datetime, date, timedelta
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib
#from pylab import rcParams
#rcParams['figure.figsize'] = 15, 10

In [2]:
import wellapplication as wa

In [3]:
print("Operating System " + platform.system() + " " + platform.release())
print("Python Version " + str(sys.version))
print("Pandas Version " + str(pd.__version__))
print("Numpy Version " + str(np.__version__))
print("Matplotlib Version " + str(matplotlib.__version__))
print("Well Application Version " + str(wa.__version__))


Operating System Windows 7
Python Version 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
Pandas Version 0.18.1
Numpy Version 1.11.0
Matplotlib Version 1.5.1
Well Application Version 0.2.13

Call usgs class of wellapplication


In [4]:
USGS = wa.usgs()

Set working environment.


In [10]:
rootlocal = 'E:/GIS/'

Read in data prepared by ArcGIS.


In [11]:
matchedStations = pd.read_csv(rootlocal + "USGS_WL_WELLS_HUCS.txt")

In [12]:
matchedStations


Out[12]:
OBJECTID Join_Count TARGET_FID agency_cd station_nm site_tp_cd dec_lat_va dec_long_va coord_acy_cd dec_coord_datum_cd ... AreaAcres AreaSqKm HUC12 Name ToHUC NonContributingAcres NonContributingSqKm HUC10 HUC8 GWArea
0 1 0 858 USGS 218 S15 E66 09BADB1 GW 36.649972 -114.613601 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
1 2 0 859 USGS 220 S15 E67 07AB 1 GW 36.650251 -114.536652 T NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
2 3 0 862 USGS 220 S15 E66 01DDCC1 GW 36.652195 -114.551097 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
3 4 0 863 USGS 220 S15 E66 01DCCA1 GW 36.652750 -114.554153 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
4 5 1 865 USGS 205 S15 E66 03AAAD1 GW 36.665528 -114.585543 S NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
5 6 1 866 USGS 205 S14 E66 35DDAB1 GW 36.669417 -114.568876 S NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
6 7 0 867 USGS 220 S14 E67 31DACD1 GW-TH 36.670528 -114.532207 F NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
7 8 1 868 USGS 205 S14 E66 35CACC1 GW 36.670528 -114.581099 S NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
8 9 1 869 USGS 205 S14 E66 35CAD 1 GW 36.671083 -114.577487 F NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
9 10 0 870 USGS 220 S15 E66 01DD 1 GW 36.653862 -114.550264 M NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
10 11 1 871 USGS 205 S14 E66 35ABCD1 GW 36.678028 -114.575265 S NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
11 12 1 872 USGS 222 S14 E69 33ABC 1 D & HA GW 36.676944 -114.282222 5 NAD83 ... 29037.0 117.508674 1.501001e+11 Government Spring-Virgin River 150100100706 0.0 0.0 1501001007 15010010 NaN
12 13 0 873 USGS 218 S14 E65 36BADA1 GW 36.678860 -114.666937 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
13 14 0 874 USGS 218 S14 E65 36BA 1 GW 36.679693 -114.659436 T NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
14 15 0 876 USGS 205 S15 E66 02BB 1 GW 36.664694 -114.583599 M NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
15 16 1 877 USGS 205 S14 E66 35D 1 GW 36.666639 -114.569154 M NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
16 17 0 878 USGS 218 S15 E66 04AA 1 GW 36.659972 -114.607211 M NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
17 18 0 879 USGS 218 S14 E65 25CDBB1 GW 36.684971 -114.671381 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
18 19 0 880 USGS 218 S14 E65 25CDBB2 GW 36.684971 -114.671381 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
19 20 1 881 USGS 205 S14 E66 27AC 1 GW 36.690250 -114.592488 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
20 21 1 882 USGS 205 S14 E66 27AC 2 GW 36.690250 -114.592488 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
21 22 1 883 USGS 205 S14 E66 27AC 3 GW 36.690250 -114.592488 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
22 23 1 885 USGS 205 S14 E66 26BDAD1 MOAPA MW-01 GW 36.691200 -114.576086 5 NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
23 24 1 886 USGS 205 S14 E66 35CB 1 NVP GW 36.672222 -114.582083 M NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
24 25 1 887 USGS 205 S14 E66 27AA 1 GW 36.693861 -114.587766 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
25 26 1 888 USGS 205 S14 E66 27BA 1 GW 36.693861 -114.596933 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
26 27 0 889 USGS 218 S14 E65 26AAAB1 GW 36.696082 -114.678326 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
27 28 1 890 USGS 205 S14 E66 21DD 1 GW 36.697472 -114.606378 T NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
28 29 1 892 USGS 205 S14 E66 22DBD 1 GW 36.699972 -114.591099 F NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
29 30 1 894 USGS 205 S14 E66 22DBB 1 GW 36.701916 -114.594988 F NAD83 ... 32713.0 132.384931 1.501001e+11 Cane Springs-Meadow Valley Wash 150100120904 0.0 0.0 1501001309 15010013 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
18184 18185 1 25652 USGS (D- 1-20)12dca- 1 GW 40.743290 -109.622921 F NAD83 ... 14876.0 60.201089 1.406001e+11 Headwaters Big Brush Creek 140600100202 0.0 0.0 1406001002 14060010 NaN
18185 18186 1 25653 USGS (D- 1-23) 8caa- 1 GW 40.746626 -109.363745 T NAD83 ... 28143.0 113.890781 1.404011e+11 Matt Warner Reservoir 140401060905 0.0 0.0 1404010609 14040106 NaN
18186 18187 1 25654 USGS (D- 1-23)12acb- 1 GW 40.750515 -109.285132 T NAD83 ... 28143.0 113.890781 1.404011e+11 Matt Warner Reservoir 140401060905 0.0 0.0 1404010609 14040106 NaN
18187 18188 1 25655 USGS (D- 1-22) 7aac- 1 GW 40.751347 -109.487361 F NAD83 ... 27716.0 112.162772 1.404011e+11 Cart Creek 140401060805 0.0 0.0 1404010608 14040106 NaN
18188 18189 1 25691 USGS 12-110-02ca 01 GW 41.049958 -109.780984 T NAD83 ... 30998.0 125.444566 1.404011e+11 Logan Hollow-Henrys Fork 140401060303 0.0 0.0 1404010603 14040106 NaN
18189 18190 1 25710 USGS 14-111-23cd 01 GW 41.177179 -109.896538 T NAD83 ... 40155.0 162.501663 1.404011e+11 Little Dry Creek 140401060303 0.0 0.0 1404010603 14040106 NaN
18190 18191 1 25728 USGS 16-107-22ddd01 GW 41.346630 -109.446524 S NAD83 ... 26260.0 106.270544 1.404011e+11 Firehole Canyon 140401060105 0.0 0.0 1404010601 14040106 NaN
18191 18192 1 25731 USGS 16-110-05cdd01 GW 41.376070 -109.842368 F NAD83 ... 30186.0 122.158516 1.404011e+11 Upper Little Dry Creek 140401070909 0.0 0.0 1404010709 14040107 NaN
18192 18193 1 25746 USGS 17-111-09bc 01 GW 41.470235 -109.959313 F NAD83 ... 34515.0 139.677373 1.404011e+11 Upper Meadow Springs Wash 140401071004 0.0 0.0 1404010710 14040107 NaN
18193 18194 1 25752 USGS 18-110-27acc01 GW 41.512182 -109.816811 F NAD83 ... 34515.0 139.677373 1.404011e+11 Upper Meadow Springs Wash 140401071004 0.0 0.0 1404010710 14040107 NaN
18194 18195 0 25755 USGS 18-107-22ddc01 GW 41.518298 -109.467357 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
18195 18196 1 25756 USGS 18-109-26bab01 GW 41.518295 -109.685975 S NAD83 ... 34705.0 140.446276 1.404011e+11 The Bluffs-Blacks Fork 140401071007 0.0 0.0 1404010710 14040107 NaN
18196 18197 1 25760 USGS 18-110-21dba01 GW 41.524403 -109.833478 S NAD83 ... 32852.0 132.947445 1.404011e+11 Lower Meadow Springs Wash 140401071007 0.0 0.0 1404010710 14040107 NaN
18197 18198 0 25761 USGS 18-107-22acc01 GW 41.525242 -109.470413 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
18198 18199 0 25762 USGS 18-107-23bcc01 GW 41.526076 -109.462635 S NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN
18199 18200 1 25764 USGS 18-110-17bac01 GW 41.544958 -109.860145 S NAD83 ... 32852.0 132.947445 1.404011e+11 Lower Meadow Springs Wash 140401071007 0.0 0.0 1404010710 14040107 NaN
18200 18201 1 25767 USGS 18-109-14cab01 GW 41.540239 -109.687363 S NAD83 ... 34705.0 140.446276 1.404011e+11 The Bluffs-Blacks Fork 140401071007 0.0 0.0 1404010710 14040107 NaN
18201 18202 1 25786 USGS 18-109-02bd 01 GW 41.571628 -109.685141 F NAD83 ... 34705.0 140.446276 1.404011e+11 The Bluffs-Blacks Fork 140401071007 0.0 0.0 1404010710 14040107 NaN
18202 18203 1 25790 USGS 18-111-04bbb01 GW 41.576901 -109.961258 F NAD83 ... 29418.0 119.050527 1.404011e+11 Town of Granger-Blacks Fork 140401071002 0.0 0.0 1404010710 14040107 NaN
18203 18204 1 25800 USGS 19-111-32bb 01 GW 41.589678 -109.978758 F NAD83 ... 30208.0 122.247547 1.404011e+11 Zieglers Wash-Hams Fork 140401071001 0.0 0.0 1404010706 14040107 NaN
18204 18205 1 25803 USGS 19-111-30dad02 GW 41.595511 -109.982370 S NAD83 ... 30208.0 122.247547 1.404011e+11 Zieglers Wash-Hams Fork 140401071001 0.0 0.0 1404010706 14040107 NaN
18205 18206 1 25804 USGS 19-111-30da 01 GW 41.596622 -109.983203 F NAD83 ... 30208.0 122.247547 1.404011e+11 Zieglers Wash-Hams Fork 140401071001 0.0 0.0 1404010706 14040107 NaN
18206 18207 1 25806 USGS 19-111-30ad 01 GW 41.600789 -109.983203 F NAD83 ... 29418.0 119.050527 1.404011e+11 Town of Granger-Blacks Fork 140401071002 0.0 0.0 1404010710 14040107 NaN
18207 18208 1 25819 USGS 19-110-17cd 01 GW 41.621624 -109.859034 F NAD83 ... 41020.0 166.002197 1.404011e+11 Eckes Draw-Blacks Fork 140401071005 0.0 0.0 1404010710 14040107 NaN
18208 18209 1 25820 USGS 19-111-14dda01 GW 41.622734 -109.905146 F NAD83 ... 29418.0 119.050527 1.404011e+11 Town of Granger-Blacks Fork 140401071002 0.0 0.0 1404010710 14040107 NaN
18209 18210 1 25883 USGS 20-110-26bb 01 GW 41.690791 -109.806255 F NAD83 ... 41020.0 166.002197 1.404011e+11 Eckes Draw-Blacks Fork 140401071005 0.0 0.0 1404010710 14040107 NaN
18210 18211 1 25893 USGS 20-111-23aad01 GW 41.701900 -109.908202 S NAD83 ... 33896.0 137.172367 1.404011e+11 Lower Sevenmile Gulch 140401071002 0.0 0.0 1404010708 14040107 NaN
18211 18212 1 25894 USGS 20-110-16db 01 GW 41.712179 -109.834867 F NAD83 ... 41020.0 166.002197 1.404011e+11 Eckes Draw-Blacks Fork 140401071005 0.0 0.0 1404010710 14040107 NaN
18212 18213 1 25898 USGS 20-110-07d 01 GW 41.724400 -109.871535 F NAD83 ... 41020.0 166.002197 1.404011e+11 Eckes Draw-Blacks Fork 140401071005 0.0 0.0 1404010710 14040107 NaN
18213 18214 0 25914 USGS 20-110-04aa 01 GW 41.744401 -109.830422 F NAD83 ... 0.0 0.000000 NaN NaN NaN 0.0 0.0 0 0 NaN

18214 rows × 29 columns

Show columns in imported column.


In [13]:
matchedStations.columns


Out[13]:
Index([u'OBJECTID', u'Join_Count', u'TARGET_FID', u'agency_cd', u'station_nm',
       u'site_tp_cd', u'dec_lat_va', u'dec_long_va', u'coord_acy_cd',
       u'dec_coord_datum_cd', u'alt_va', u'alt_acy_va', u'alt_datum_cd',
       u'huc_cd', u'UTM_X', u'UTM_Y', u'site_no', u'TNMID', u'GNIS_ID',
       u'AreaAcres', u'AreaSqKm', u'HUC12', u'Name', u'ToHUC',
       u'NonContributingAcres', u'NonContributingSqKm', u'HUC10', u'HUC8',
       u'GWArea'],
      dtype='object')

Get list of stations for each groundwater area.


In [14]:
stationLists = matchedStations.groupby(['GWArea'])['site_no'].unique()

Create dictionary matching HUC names to HUC 8 codes.


In [15]:
nameit = pd.Series(matchedStations.Name.values, index = matchedStations.HUC8).to_dict()

Generate site and data files from HUC 8 in list.


In [16]:
sites = {}
data = {}

areaList = list(matchedStations.HUC8.unique())[1:]

for area in areaList:
    try:
        sites[area] = USGS.getStationInfoFromHUC(area)
        data[area] = USGS.getWLfromHUC(area)
        print area
    except:
        print("no data for " + str(area))
        pass


15010013
15010010
16030006
16020301
16020306
16020308
16020307
17040211
15010009
15010003
14070007
15010008
16030001
16030002
16030007
16020302
16030009
16030003
16030008
16030005
16020303
16020201
16020304
16020305
16020204
16020310
16020102
16020309
16010204
16010203
16010202
17040210
14080204
14070006
14080205
14070005
14070001
14070003
14070004
14060008
14070002
14060009
16030004
14060007
16020202
14060005
14060003
14060004
16020203
16020101
16010101
14040106
16010102
14040107
14040108
16010201
14080201
14080202
14080203
14030002
14030005
14030004
14030001
14010005
14060006
14050007
14060010

Combine dictionaries into a complete data and stations file.


In [17]:
allsites = pd.concat(sites)
alldata = pd.concat(data)

Save files as csv files and an excel file.


In [18]:
allsites.to_csv(rootlocal + 'USGSSites.csv')
alldata.to_csv(rootlocal + 'USGSData.csv')

In [19]:
writer = pd.ExcelWriter(rootlocal + 'USGS_WL_UT.xlsx')
allsites.to_excel(writer,'sites')
alldata.to_excel(writer,'data')
writer.save()

Generate and save plots to a pdf file. Skip error files.


In [20]:
pdf_pages = PdfPages(rootlocal + 'HydrographSummary.pdf')



for area in areaList:
    try:
        plots = USGS.HUCplot(sites[area],data[area]) 
        fig = plots[0]
        fig.suptitle(str(area) + " = " + nameit[area])
        pdf_pages.savefig(fig)
        plt.close(fig)
        fig2 = plots[1]
        fig2.suptitle(str(area) + " = " + nameit[area])
        pdf_pages.savefig(fig2)
        plt.close(fig2)
        print(str(area) + " = " + nameit[area])
    except:
        print("no plot for " + str(area) + " = " + str(nameit[area]))
        pass
        

# Write the PDF document to the disk
pdf_pages.close()


no plot for 15010013 = Craw Creek
15010010 = East Fork Beaver Dam Wash
no plot for 16030006 = Mertons Spring
no plot for 16020301 = Little Red Cedar Wash
16020306 = Indian Wash
no plot for 16020308 = Park Valley-Dove Creek
no plot for 16020307 = Upper Rock Spring Creek
no plot for 17040211 = Goose Creek-Oakley Valley
no plot for 15010009 = Lower Fort Pearce Wash
no plot for 15010003 = Reservoir Canyon-Kanab Creek
no plot for 14070007 = Henrieville Creek
no plot for 15010008 = Upper Moody Wash
no plot for 16030001 = Piute Reservoir
16030002 = Koosharem Reservoir
16030007 = Big Spring-Beaver River
no plot for 16020302 = Wah Wah Mountains-Frontal Pine Valley Hardpan
16030009 = Pony Express Reservoir-Frontal Sevier Lake
no plot for 16030003 = Axhandle Canyon-Sevier River
16030008 = Outlet Beaver River
no plot for 16030005 = Lampson Canyon-Chicken Creek
no plot for 16020303 = The Honeycombs
no plot for 16020201 = Headwaters Dry Creek
no plot for 16020304 = Sixmile Creek-Frontal Great Salt Lake
16020305 = Delle
no plot for 16020204 = Outlet Jordan River-Frontal Great Salt Lake
no plot for 16020310 = Great Salt Lake
no plot for 16020102 = Cutler Creek-North Fork Ogden River
no plot for 16020309 = Bull Canyon
no plot for 16010204 = Mantua Reservoir-Box Elder Creek
no plot for 16010203 = Hells Kitchen Canyon-Logan River
no plot for 16010202 = Mcpherson Canyon-Bear River
no plot for 17040210 = Horse Butte-Raft River
14080204 = Mexican Water-Walker Creek
no plot for 14070006 = Escalante Canyon
no plot for 14080205 = Cedar Point-San Juan River
no plot for 14070005 = Deer Creek
no plot for 14070001 = Lower Gypsum Canyon
14070003 = U M Creek
no plot for 14070004 = White Roost Canyon
no plot for 14060008 = Blaze Canyon
no plot for 14070002 = Christiansen Wash-Quitchupah Creek
14060009 = Right Fork Huntington Creek
no plot for 16030004 = Dry Creek-San Pitch River
no plot for 14060007 = Tabbyune Creek-White River
16020202 = Outlet Hobble Creek-Frontal Utah Lake
no plot for 14060005 = Lower Pleasant Valley Wash-Pariette Draw
no plot for 14060003 = Upper Deep Creek
no plot for 14060004 = Current Creek Reservoir
no plot for 16020203 = Drain Tunnel Creek
no plot for 16020101 = Upper Lost Creek
no plot for 16010101 = Antelope Creek-Bear River
no plot for 14040106 = Firehole Canyon
16010102 = Thomas Fork-Dry Creek
14040107 = Eckes Draw-Blacks Fork
no plot for 14040108 = Lower North Fork Little Muddy Creek
16010201 = Red Mountain
14080201 = Johnson Creek
no plot for 14080202 = Dawson Draw-Yellowjacket Canyon
no plot for 14080203 = Spring Creek-Vega Creek
no plot for 14030002 = Outlet West Paradox Creek
no plot for 14030005 = Salt Valley Wash
no plot for 14030004 = North Lobe Creek-West Creek
no plot for 14030001 = Danish Wash
no plot for 14010005 = West Fork Parachute Creek
no plot for 14060006 = 140600060405-Willow Creek
no plot for 14050007 = Coal Oil Gulch-Stinking Water Creek
no plot for 14060010 = Headwaters Big Brush Creek
C:\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\matplotlib\pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

In [23]:
pdf = PdfPages(rootlocal + 'monthly.pdf')
grp = "month"

itergroup = 'm'

data = "diff"
title = 'Change in Water Level (ft)'
monthlyPlot(df, grp, data, title)
plt.title('All Wells')
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.title(TypeDict[f])
    pdf.savefig(n)
    plt.close()

data = 'avgDiffWL'
title = 'Deviation from Mean Water Level (ft)'
monthlyPlot(df, grp, data, title)
plt.title('All Wells')
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.title(TypeDict[f])
    pdf.savefig(n)
    plt.close()
    
data = 'stdWL'
title = 'Standardized Deviation from Mean Water Level (ft)'
monthlyPlot(df, grp, data, title)
plt.title('All Wells')
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.title(TypeDict[f])
    pdf.savefig(n)
    plt.close()
    
grp = pd.TimeGrouper("M")
data = "diff"
title = 'Change in Water Level (ft)'
monthlyPlot(df, grp, data, title)
plt.title('All Wells')
plt.ylim(-0.1,0.1)
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.ylim(-0.1,0.1)
    plt.title(TypeDict[f])
    pdf.savefig(n)
    plt.close()
    
grp = pd.TimeGrouper("M")
data = "stdWL"
title = 'Standardized Deviation from Mean Water Level'
monthlyPlot(df, grp, data, title)
plt.ylim(-3,3)
plt.title('All Wells')
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.title(TypeDict[f])
    plt.ylim(-3,3)
    pdf.savefig(n)
    plt.close()
    
grp = pd.TimeGrouper("M")
data = 'avgDiffWL'
title = 'Deviation from Mean Water Level (ft)'
monthlyPlot(df, grp, data, title)
plt.title('All Wells')
for f, h in df.groupby('MonType'):
    n = monthlyPlot(h, grp, data, title)
    plt.title(TypeDict[f])
    pdf.savefig(n)
    plt.close()
    
pdf.close()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-23-e0df6ce81f4c> in <module>()
      6 data = "diff"
      7 title = 'Change in Water Level (ft)'
----> 8 monthlyPlot(df, grp, data, title)
      9 plt.title('All Wells')
     10 for f, h in df.groupby('MonType'):

NameError: name 'monthlyPlot' is not defined

In [ ]:
df1,df2 = self.WLStatdf(siteinfo, data)
        wlLongSt = df1[df1['cnt']>2]
        wlLongSt2 = df2[df2['cnt']>2]
        
        self.stand = wlLongSt
        self.diffs = wlLongSt2
          
        fig1 = plt.figure()
        x = wlLongSt.index
        y = wlLongSt['mean']
        plt.plot(x,y,label='Average Groundwater Level Variation')
        plt.fill_between(wlLongSt.index, wlLongSt['meanpluserr'], wlLongSt['meanminuserr'], 
                         facecolor='blue', alpha=0.4, linewidth=0.5, label= "Std Error")
        plt.grid(which='both')
        plt.ylabel('Depth to Water z-score')
        plt.xticks(rotation=45)
        self.zPlot = fig1        
        
        fig2 = plt.figure()
        x = wlLongSt2.index
        y = wlLongSt2['mean']
        plt.plot(x,y,label='Average Groundwater Level Changes')
        plt.fill_between(wlLongSt.index, wlLongSt2['meanpluserr'], wlLongSt2['meanminuserr'], 
                         facecolor='blue', alpha=0.4, linewidth=0.5, label= "Std Error")
        plt.grid(which='both')
        plt.ylabel('Change in Average Depth to Water (ft)')
        plt.xticks(rotation=45)
        self.wlPlot = fig2
        
        return fig1, fig2, wlLongSt, wlLongSt2

In [ ]:
area = 16020302
pdf_pages = PdfPages(rootlocal + 'E:/GIS/HydrographSummarySingle.pdf')
plots = USGS.HUCplot(sites[area],data[area]) 
fig = plots[0]
fig.suptitle(str(area) + " = " + nameit[area])
pdf_pages.savefig(fig)
plt.close(fig)
fig2 = plots[1]
fig2.suptitle(str(area) + " = " + nameit[area])
pdf_pages.savefig(fig2)
plt.close(fig2)
print(str(area) + " = " + nameit[area])
pdf_pages.close()

In [ ]:


In [ ]: