Skip to content

Commit

Permalink
Some tweaks to the docs notebook (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Mar 22, 2018
1 parent b110921 commit 0bc9737
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docs/notebooks/flowline_with_known_bedrock.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"# Constants\n",
"from oggm.cfg import SEC_IN_YEAR, A, RHO\n",
"# OGGM models\n",
"from oggm import utils\n",
"from oggm.core.flowline import FluxBasedModel, RectangularBedFlowline\n",
"from oggm.core.massbalance import MassBalanceModel"
]
Expand All @@ -55,7 +56,7 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('/home/mowglie/bedrock.csv', index_col=0)\n",
"df = pd.read_csv(utils.get_demo_file('ideal_bump_bedrock.csv'), index_col=0)\n",
"df.plot();"
]
},
Expand Down
37 changes: 28 additions & 9 deletions docs/notebooks/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"source": [
"fig = plt.figure(figsize=(9, 3))\n",
"ds = xr.open_dataset(utils.get_demo_file('HISTALP_oetztal.nc'))\n",
"ds.temp[:, 3, 3].resample('AS', dim='time').plot()\n",
"ds.temp[:, 3, 3].resample(time=\"AS\").mean().plot()\n",
"plt.title('HISTALP annual temperature (°C)');"
]
},
Expand Down Expand Up @@ -718,23 +718,29 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"# TODO"
"For the dynamics refer to the other notebooks in the same folder!"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
"source": [
"## Set up a run "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For setting up a real OGGM run with your own data, refer to [the documentation](http://oggm.readthedocs.io/en/latest/run.html)!"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -751,6 +757,19 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
18 changes: 16 additions & 2 deletions docs/notebooks/specmb_vs_ela.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"smodel = FlowlineModel(emodel.fls, mb_model=step_mb_model, y0=0.)\n",
"_, ds = smodel.run_until_and_store(yr_end)\n",
"# Keep only early vals\n",
"ds = ds.isel(time=ds.month==1)"
"ds = ds.isel(time=ds.hydro_month==1)"
]
},
{
Expand Down Expand Up @@ -269,7 +269,7 @@
"smodel = FlowlineModel(emodel.fls, mb_model=lin_mb_model, y0=0.)\n",
"_, ds = smodel.run_until_and_store(yr_end)\n",
"# Keep only early vals\n",
"ds = ds.isel(time=ds.month==1)"
"ds = ds.isel(time=ds.hydro_month==1)"
]
},
{
Expand Down Expand Up @@ -303,6 +303,7 @@
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -319,6 +320,19 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
6 changes: 5 additions & 1 deletion oggm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
pass

# API
from oggm.utils import GlacierDirectory, entity_task, global_task, gettempdir
from oggm.utils import (GlacierDirectory, entity_task, global_task,
gettempdir, get_demo_file)
from oggm.core.centerlines import Centerline
from oggm.core.flowline import Flowline

# Make sure we have the sample data at import
get_demo_file('')
8 changes: 6 additions & 2 deletions oggm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# Github repository and commit hash/branch name/tag name on that repository
# The given commit will be downloaded from github and used as source for all sample data
SAMPLE_DATA_GH_REPO = 'OGGM/oggm-sample-data'
SAMPLE_DATA_COMMIT = '5e15bb8c19191950b3ea0dbfe87d0d68e15aedc9'
SAMPLE_DATA_COMMIT = 'f8b7bab312c8830bfa56ed340ad763ecd6033655'

CRU_SERVER = ('https://crudata.uea.ac.uk/cru/data/hrg/cru_ts_4.01/cruts'
'.1709081022.v4.01/')
Expand Down Expand Up @@ -125,7 +125,11 @@ def _cached_download_helper(cache_obj_name, dl_func, reset=False):
"""
cache_dir = cfg.PATHS['dl_cache_dir']
cache_ro = cfg.PARAMS['dl_cache_readonly']
fb_cache_dir = os.path.join(cfg.PATHS['working_dir'], 'cache')
try:
# this is for real runs
fb_cache_dir = os.path.join(cfg.PATHS['working_dir'], 'cache')
except KeyError:
fb_cache_dir = ''

if not cache_dir:
# Defaults to working directory: it must be set!
Expand Down

0 comments on commit 0bc9737

Please sign in to comment.