<jupyter_start><jupyter_text>How does the width of a glacier affect its ability to store water? Question: **How does [this glacier] differ from [this one]?**We have already seen that the slope and mass balance of the glacier affect its volume, and therefore its water storage. But also the width of the glacier, specifically the width in the accumulation zone, is important. We are going to investigate the effect of width in this notebook.[this glacier]: https://www.swisseduc.ch/glaciers/earth_icy_planet/glaciers02-en.html?id=4[this one]: https://www.swisseduc.ch/glaciers/alps/grosser_aletschgletscher/aletsch_flugbilder-en.html?id=8<jupyter_code># import oggm-edu helper package
import oggm_edu as edu
# import modules, constants and set plotting defaults
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (9, 6)  # Default plot size

# Scientific packages
import numpy as np

# Constants
from oggm import cfg
cfg.initialize()

# OGGM models
from oggm.core.massbalance import LinearMassBalance
from oggm.core.flowline import FluxBasedModel, RectangularBedFlowline
# There are several numerical implementations in OGGM core. We use the "FluxBasedModel"
from functools import partial
FlowlineModel = partial(FluxBasedModel, min_dt=0, cfl_number=0.01)

# Local library
import CdeC as cdec<jupyter_output><empty_output><jupyter_text>The essentials We follow similar steps to what we did in [glacier_bed_slope](1_glacier_bed_slope.ipynb) to set up the basic model.  Set up the glacier bed and add ice (with mass balance)<jupyter_code># define horizontal resolution of the model:
# nx: number of grid points
# map_dx: grid point spacing in meters
nx = 200
map_dx = 100
# define glacier slope and how high up it is
slope = 0.1
top = 3400 #m, the peak elevation
initial_width = 300 # width in meters
# create a linear bedrock profile from top to bottom
bottom = top - nx*map_dx*slope #m, elevation of the bottom of the incline based on the slope we defined
bed_h, surface_h = edu.define_linear_bed(top, bottom, nx)
# ask the model to calculate the distance from the top to the bottom of the glacier in km
distance_along_glacier = edu.distance_along_glacier(nx, map_dx)
# Now describe the widths in "grid points" for the model, based on grid point spacing map_dx
widths = np.zeros(nx) + initial_width/map_dx
# Define our bed
init_flowline = RectangularBedFlowline(surface_h=surface_h, bed_h=bed_h, widths=widths, map_dx=map_dx)
# ELA at 3000m a.s.l., gradient 4 mm m-1
ELA = 3000 #equilibrium line altitude in meters above sea level
altgrad = 4 #altitude gradient in mm/m
mb_model = LinearMassBalance(ELA, grad=altgrad)
example_model = FlowlineModel(init_flowline, mb_model=mb_model, y0=0.)
example_model.run_until_equilibrium(rate=0.006)<jupyter_output><empty_output><jupyter_text>Let's make a graph to confirm that we have correctly configured the glacier.<jupyter_code>plt.plot(distance_along_glacier, example_model.fls[-1].surface_h, label='Glacier geometry')
edu.plot_xz_bed(x=distance_along_glacier, bed=bed_h)<jupyter_output><empty_output><jupyter_text>Glaciers of various widths As we know from [notebook 2](2_mass_balance.ipynb), glaciers collect mass (from snow) at the top. We will investigate the influence of width on this mass collection by comparing three glaciers similar to our first, each with a different width at its top.First we define the widths to compare (`width_tests`), and how many years to let the glaciers grow with these widths.<jupyter_code># Define the widths we want to compare: (our first experiment used a width of 300 m)
width_tests = [150, 300, 1000]
# Define the time period for which the glacier should be calculated:
years = 300<jupyter_output><empty_output><jupyter_text>Activity: formulate a hypothesisIn the photo below, by Hambrey and Alean ([more here]), there are glaciers of various upper widths. **For each width that we compare in width_tests, choose a glacier in the photo that corresponds.**![Hintereisferner](https://www.swisseduc.ch/glaciers/alps/hintereisferner/icons/hintereisferner_overview.jpg "Hintereisferner with Weißkugel, Hambrey & Alean")**Based on the photo and your intuition, draw a diagram of the relationship between (X axis) the width of the accumulation zone and (Y axis) the length of the glacier.**[more here]: https://www.swisseduc.ch/glaciers/ Now we ask that the model make glaciers of our chosen widths. We use a "for" loop because we want to do the same steps (set up a glacier and save the resulting shape) for each test (each different width).In the cell below, can you identify how we modify the width *only at the top (the accumulation zone)*? What would we modify to simulate a different width in the lower portion of the glacier?<jupyter_code># Here is where we will store the results of our test
models = []
# Colors for the graphs
colors = ['C1', 'C3', 'C5'] 

for k, width in enumerate(width_tests):
    widths_k = np.copy(widths)
    widths_k[0:15] = width/map_dx #set different width only in the upper portion
    flowline = RectangularBedFlowline(surface_h=surface_h, bed_h=bed_h, widths=widths_k, map_dx=map_dx)
    # The models require the initial glacier bed, a mass balance model, and an initial time (the year y0)
    models.append(FlowlineModel(flowline, mb_model=mb_model, y0=0.))
    # First, look at the state of the glacier models after the chosen amount of years
    models[k].run_until(years)<jupyter_output><empty_output><jupyter_text>Let's graph the shape of our glaciers:<jupyter_code>f1, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(21,5))
ax_list = (ax1, ax2, ax3)

for k, width in enumerate(width_tests):
    ax = ax_list[k]
    ax.plot(distance_along_glacier, models[k].fls[-1].surface_h, label='Upstream width {} m'.format(width), color=colors[k])
    cdec.plot_xz_bed(distance_along_glacier, models[k].fls[-1].bed_h, ax=ax)<jupyter_output><empty_output><jupyter_text>**Does this result support your hypothesis or not? Describe why or why not.** Now, we make another graph to find out the volume of ice each glacier stores:<jupyter_code># Now plot the volume of each of our test glaciers versus upstream width
plt.figure()
ax = plt.axes()
for k, width in enumerate(width_tests):
    ax.scatter(width, models[k].volume_km3, color=colors[k])
ax.set_xlabel('Upstream width [m]')
ax.set_ylabel('Ice volume [km3]');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08369905956112852, 'fraction_numerical': 0.013636363636363636, 'mean_word_length': 5.612435233160622, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '191795', 'license': 'MIT', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2010, 'n_words': 758, 'path': 'English/3_glacier_width.ipynb', 'repo_name': 'ehultee/glacio-CdeC', 'size': '6380'}