How to use nz-stream-depletion

This section will describe how to use the nz-stream-depletion package.

The SD class

The SD class in the nz-stream-depletion package provides access to all of the stream depletion methods withouthaving to specify each function. You just feed in the appropriate input parameters and the SD will use the most appropriate method given the input parameters.

First we need to import the package and define some of those input aquifer parameters.

from nz_stream_depletion import SD

# Pumped aquifer
pump_aq_trans = 1000 # m/d
pump_aq_s = 0.1

# Well
pump_q = 50 # l/s
sep_distance = 500 # m

time1 = 6 # days
time2 = 7 # days
time1 = 30 # days
n_days = 150 # days

# streambed
stream_k = 1000 # m/d
stream_thick = 1 # m
stream_width = 1 # m
stream_cond = stream_k * stream_thick / stream_width

# aquitard
aqt_k = 0.1 # m/d
aqt_thick = 10 # m
aqt_s = 0.1

# upper aquifer
upper_aq_trans = 500
upper_aq_s = 0.05

Then we need to initialize the SD class. Once the SD class is initialized, we can take a look at the all_methods attribute to see all of the emthods and the parameter requirements.

In [1]: sd = SD()

In [2]: print(sd.all_methods)
{'theis_1941': ['pump_aq_trans', 'pump_aq_s', 'sep_distance'], 'hunt_1999': ['pump_aq_trans', 'pump_aq_s', 'stream_k', 'stream_thick', 'stream_width', 'sep_distance'], 'hunt_2003': ['pump_aq_trans', 'pump_aq_s', 'aqt_k', 'aqt_thick', 'aqt_s', 'stream_k', 'stream_thick', 'stream_width', 'sep_distance'], 'hunt_2009': ['pump_aq_trans', 'pump_aq_s', 'lower_aq_trans', 'lower_aq_s', 'aqt_k', 'aqt_thick', 'stream_k', 'stream_thick', 'stream_width', 'sep_distance'], 'ward_lough_2011': ['pump_aq_trans', 'pump_aq_s', 'upper_aq_trans', 'upper_aq_s', 'aqt_k', 'aqt_thick', 'stream_k', 'stream_thick', 'stream_width', 'sep_distance']}

Then we need to load the input aquifer parameters. The available methods attribute tells us what methods are available given the input parameters.

In [3]: sd = SD()

In [4]: available = sd.load_aquifer_data(pump_aq_trans=pump_aq_trans, pump_aq_s=pump_aq_s, sep_distance=sep_distance)

In [5]: print(available)
['theis_1941']

Once the input parameters have been loaded, you can calculate the stream depletion ratios using either sd.calc_sd_ratio for a specific number of pumping days (n_days) or sd.calc_sd_ratios for all of the ratios up to the pumping days. It can be helpful in certain coding circumstances to put the input parameters into a dictionary before passing them to the SD class.

In [6]: params2 = {'pump_aq_trans': pump_aq_trans, 'pump_aq_s': pump_aq_s, 'sep_distance': sep_distance, 'stream_k': stream_k, 'stream_thick': stream_thick, 'stream_width': stream_width}

In [7]: sd = SD()

In [8]: available = sd.load_aquifer_data(**params2)

In [9]: sd_ratio = sd.calc_sd_ratio(7)

In [10]: sd_ratios = sd.calc_sd_ratios(7)

In [11]: print(available)
['theis_1941', 'hunt_1999']

In [12]: print(sd_ratio)
0.17979760932708438

In [13]: print(sd_ratios)
[8.170694148276362e-05, 0.012081873210892132, 0.041004577820555124, 0.07656642910427265, 0.11288495663350082, 0.14756681656258458, 0.17979760932708438]

The last bit of functionality allows you to take a time series of extraction (pumping) data and determine the amount that is stream depleting over the entire record. The application of these stream depletion methods on variable pumping rates over time uses the superposition principle.

In [14]: params2 = {'pump_aq_trans': pump_aq_trans, 'pump_aq_s': pump_aq_s, 'sep_distance': sep_distance, 'stream_k': stream_k, 'stream_thick': stream_thick, 'stream_width': stream_width}

In [15]: extract_csv = 'https://raw.githubusercontent.com/mullenkamp/nz-stream-depletion/main/nz_stream_depletion/data/sample_flow.csv'

In [16]: extraction = pd.read_csv(extract_csv, index_col='time', parse_dates=True, infer_datetime_format=True, dayfirst=True).flow

In [17]: sd = SD()

In [18]: available = sd.load_aquifer_data(**params2)

In [19]: sd_rates = sd.calc_sd_extraction(extraction)

In [20]: print(sd_rates)
time
2010-10-06    0.000037
2010-10-07    0.005496
2010-10-08    0.018537
2010-10-09    0.034576
2010-10-10    0.051558
                ...   
2020-06-20    0.174635
2020-06-21    0.180846
2020-06-22    0.191781
2020-06-23    0.201990
2020-06-24    0.209487
Freq: D, Length: 3550, dtype: float64