<jupyter_start><jupyter_text>Kudryavtsev Model* Link to this notebook: https://github.com/csdms/pymt/blob/master/notebooks/ku.ipynb* Install command: `$ conda install notebook pymt_permamodel`* Download local copy of notebook:  `$ curl -O https://raw.githubusercontent.com/csdms/pymt/master/notebooks/ku.ipynb` Introduction to Permafrost Processes - Lesson 2 Kudryavtsev ModelThis lab has been designed and developed by <NAME> and <NAME>, CSDMS, University of Colorado, CO with assistance of <NAME>, <NAME> at CSDMS, University of Colorado, CO, and <NAME>, at Los Alamos National Labs, NM. These labs are developed with support from NSF Grant 1503559, ‘Towards a Tiered Permafrost Modeling Cyberinfrastructure’  Classroom organizationThis lab is the second in a series of introduction to permafrost process modeling, designed for inexperienced users. In this first lesson, we explore the Air Frost Number model and learn to use the CSDMS Python Modeling Toolkit ([PyMT](https://github.com/csdms/pymt)). We implemented a basic configuration of the Air Frost Number (as formulated by Nelson and Outcalt in 1987). This series of labs is designed for inexperienced modelers to gain some experience with running a numerical model, changing model inputs, and analyzing model output. Specifically, this first lab looks at what controls permafrost occurrence and compares the occurrence of permafrost in Russia. Basic theory on the Air Frost Number is presented in [Frost Number Model Lecture 1](https://csdms.colorado.edu/wiki/File:FrostNumberModel_Lecture1.pptx).This lab is the second in a series of introduction to permafrost process modeling, designed for inexperienced users. In this second lesson, we explore the Kudryavstev model and learn to use the CSDMS Python Modeling Toolkit ([PyMT](https://github.com/csdms/pymt)). We implemented the Kudryavstev model (as formulated in Anisimov et al.1997). It is dubbed the Ku-model. This series of labs is designed for inexperienced modelers to gain some experience with running a numerical model, changing model inputs, and analyzing model output. Specifically, this lab looks at what controls soil temperature and active layer thickness and compares model output with observed longterm data collected at permafrost active layer thickness monitoring sites in Fairbanks and Barrow, Alaska. Basic theory on the Kudryavstev model is presented in [Kudryavtsev Model Lecture 2](https://csdms.colorado.edu/wiki/File:KudryavtsevModel_Lecture2.pptx)This lab will likely take ~ 1,5 hours to complete in the classroom. This time assumes you are unfamiiar with the PyMT and need to learn setting parameters, saving runs, downloading data and looking at output (otherwise it will be much faster).We will use netcdf files for output, this is a standard output from all CSDMS models. If you have no experience with visualizing these files, Panoply software will be helpful. Find instructions on how to use this software. Learning objectives Skills* familiarize with a basic configuration of the Kudryavstev Model for 1D (a single location).* hands-on experience with visualizing NetCDF time series with Panoply.* data to model comparisons and how to think about uncertainty in data and model output. Topical learning objectives:* what are controls on permafrost soil temperature* what is a steady-state model* what are important parameters for calculating active layer thickness* active layer thickness evolution with climate warming in two locations in Alaska References and More information <NAME>., <NAME>., & <NAME>. (1997). *Global warming and active-layer thickness: results from transient general circulation models.* Global and Planetary Change, 15(3-4), 61-77. DOI:10.1016/S0921-8181(97)00009-X  <NAME>., <NAME>., 2003. *A model for regional-scale estimation of temporal and spatial variability of active layer thickness and mean nnaual ground emperatures.* Permafrost and periglacial processes 14, 125-139. DOI: 10.1002/ppp.449  <NAME>., 2005. *Influence of the seasonal snow cover on the ground thermal regime: an overview.* Review of Geophysics, 43, RG4002.  The Kudryavtsev ModelThe Kudryavtsev et al. (1974), or *Ku* model, presents anapproximate solution of the Stefan problem. The model provides asteady-state solution under the assumption of sinusoidal airtemperature forcing. It considers snow, vegetation, and soil layersas thermal damping to variation of air temperature. The layer ofsoil is considered to be a homogeneous column with different thermalproperties in the frozen and thawed states. The main outputs areannual maximum frozen/thaw depth and mean annual temperature at thetop of permafrost (or at the base of the active layer). It can beapplied over a wide variety of climatic conditions.<jupyter_code># Load standard Python modules
import numpy as np
import matplotlib.pyplot as plt
# Load PyMT model(s)
import pymt.models
ku = pymt.models.Ku()<jupyter_output>[33;01m➡ models: FrostNumber, Ku, Hydrotrend[39;49;00m<jupyter_text>Part 1We will run the Kudryatsev model for conditions in Barrow, Alaska in a very cold year, 1964. The mean annaul temperature for 1964 was -15.21C, the amplitude over that year was 18.51C. It was close to normal snow year, meaning the average snow thickness over this winter was 0.22m.Adapt the settings in the Ku model for Barrow 1964. Make sure you request an output file. Save the simulation settings and submit your simulation. Download the model results and open them in Panoply.<jupyter_code>config_file, run_folder = ku.setup(T_air=-15.21, A_air=18.51)
ku.initialize(config_file, run_folder)
ku.update()
ku.output_var_names
ku.get_value('soil__active_layer_thickness')<jupyter_output><empty_output><jupyter_text>Q1.1: What was the active layer thickness the model predicted? *Sketch a soil profile for winter conditions versus August conditions, indicate where the frozen-unfrozen boundary is in each two cases.*  Q1.2: How do you think snow affects the active layer thickness predictions?   Part 2Run the Kudryatsev model with a range of snow conditions (0 m as the one extreme, and in extremely snowy years, the mean snow thickness over the winter is 0.4m in Barrow). Set these two simulations, run them and dowload the files.<jupyter_code>args = ku.setup(h_snow=0.)
ku.initialize(*args)
ku.update()
ku.get_value('soil__active_layer_thickness')
args = ku.setup(h_snow=0.4)
ku.initialize(*args)
ku.update()
ku.get_value('soil__active_layer_thickness')<jupyter_output>Ku model component: Initializing...<jupyter_text>Q2.1: What happens if there is no snow at all (0 m)?    Q2.2: What is the active layer thickness prediction for a very snowy year?  Part 3Run the Kudryatsev model with a range of soil water contents. What happens if there is 20% more, and 20% less soil water content?<jupyter_code>args = ku.setup(vwc_H2O=0.2)
ku.initialize(*args)
ku.update()
ku.get_value('soil__active_layer_thickness')
args = ku.setup(vwc_H2O=0.6)
ku.initialize(*args)
ku.update()
ku.get_value('soil__active_layer_thickness')<jupyter_output>Ku model component: Initializing...<jupyter_text>Q3.1: Is this selected range of 20% realistic for soils in permafrost regions?  Q3.2: From the theory presented in the associated lecture notes, how do you think soil water content in summer affects the soil temperature?  Part 4Posted here are time-series for climate conditions for both Barrow and Fairbanks, Alaska. Time-series are annual values and run from 1961-2015, the data include mean annual temperature (MAAT), temperature amplitude (TAMP) and winter-average snow depth (SD). These are text files, so you can plot them in your own favorite software or programming language.Choose which case you want to run, you will now run a 55 year simulation.<jupyter_code>import pandas
data = pandas.read_csv("https://raw.githubusercontent.com/mcflugen/pymt_ku/master/data/Barrow_1961-2015.csv")
data
maat = data["atmosphere_bottom_air__temperature"]
tamp = data["atmosphere_bottom_air__temperature_amplitude"]
snow_depth = data["snowpack__depth"]
ku = pymt.models.Ku()
args = ku.setup(end_year=2050)
ku.initialize(*args)
n_steps = int((ku.end_time - ku.time) / ku.time_step)
thickness = np.empty(n_steps)
for i in range(n_steps):
    ku.set_value("atmosphere_bottom_air__temperature", maat.values[i])
    ku.set_value("atmosphere_bottom_air__temperature_amplitude", tamp.values[i])
    ku.set_value("snowpack__depth", snow_depth.values[i])
    ku.update()
    thickness[i] = ku.get_value('soil__active_layer_thickness')
plt.plot(thickness) # This should be the same as the above but it's NOT! But now it is. BOOM!<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup