Skip to content

Commit

Permalink
training
Browse files Browse the repository at this point in the history
  • Loading branch information
jmills-ncar committed Jun 5, 2018
1 parent e548777 commit c407c2c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
27 changes: 24 additions & 3 deletions training/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@ USER root

RUN rm -r /home/docker/runTimeScripts

##################################
# Geospatial
#Get create_wrfinput.r
RUN mkdir /home/docker/wrf-hydro-training
RUN chmod -R 777 /home/docker/wrf-hydro-training
COPY ./create_wrfinput.R /home/docker/wrf-hydro-training/wrf_hydro_model_tools/create_wrfinput.R

#Get the entrypoint script to download the code release, start jupyter, etc
COPY ./entrypoint.sh /.
RUN chmod 777 /entrypoint.sh
#Bring in NLDAS data
RUN wget https://ral.ucar.edu/sites/default/files/public/ESMFregrid_NLDAS.tar_.gz \
&& tar -xf ESMFregrid_NLDAS.tar_.gz \
&& mv NLDAS /home/docker/wrf-hydro-training/regridding \
&& rm ESMFregrid_NLDAS.tar_.gz

#Get NLDAS forcing for regridding exercise
COPY ./nldas_forcing.tar.gz /home/docker/wrf-hydro-training/regridding/data/nldas_forcing.tar.gz

# install NCL
RUN wget https://www.earthsystemgrid.org/dataset/ncl.640.dap/file/ncl_ncarg-6.4.0-Debian8.6_64bit_gnu492.tar.gz \
&& mkdir /usr/local/ncl-6.4.0 \
&& tar -xzf ncl_ncarg-6.4.0-Debian8.6_64bit_gnu492.tar.gz -C /usr/local/ncl-6.4.0 \
&& rm ncl_ncarg-6.4.0-Debian8.6_64bit_gnu492.tar.gz

ENV NCARG_ROOT=/usr/local/ncl-6.4.0
ENV PATH=$NCARG_ROOT/bin:$PATH

############################
## Python
Expand Down Expand Up @@ -49,6 +65,11 @@ RUN wget http:https://cirrus.ucsd.edu/~pierce/ncdf/ncdf4_1.13.tar.gz \
RUN Rscript -e 'install.packages(c("optparse"), repos="https://cran.rstudio.com")'

############################
#Get the entrypoint script to download the code release, start jupyter, etc
COPY ./entrypoint.sh /.
RUN chmod 777 /entrypoint.sh

RUN chmod -R 777 /home/docker/wrf-hydro-training/

USER docker
WORKDIR /home/docker
Expand Down
2 changes: 1 addition & 1 deletion training/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


docker build "$@" -t wrfhydro/training:latest .
docker build "$@" -t wrfhydro/training:v5.0.0 .

exit $?
18 changes: 10 additions & 8 deletions training/create_wrfinput.R
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env Rscript

############################################################
# R script to create wrfinput file from geogrid.
# Usage: Rscript create_Wrfinput.R
Expand All @@ -6,7 +8,6 @@
# https://github.com/NCAR/hrldas-release/blob/release/HRLDAS/HRLDAS_forcing/lib/module_geo_em.F
# from M. Barlage.
############################################################
#!/usr/bin/env Rscript
library(optparse)
library(ncdf4)

Expand All @@ -15,13 +16,14 @@ option_list = list(
help="Path to input geogrid file", metavar="character"),
make_option(c("--outfile"), type="character", default="wrfinput_d01.nc",
help="output file name [default= %default]", metavar="character"),
make_option(c("--filltyp"), type="integer", default=3, help="Soil type to use as a fill value in case conflicts between soil water and land cover water cells.
If the script encounters a cell that is classified as land in the land use field (LU_INDEX) but is classified as a water soil type, it will replace the soil type with the value you
specify below. Ideally there are not very many of these, so you can simply choose the most
common soil type in your domain. Alternatively, you can set to a bad value (e.g., -8888)
to see how many of these conflicts there are. If you do this DO NOT RUN THE MODEL WITH THESE
BAD VALUES. Instead, fix them manually with a neighbor fill or similar fill algorithm.",
metavar="character"),
make_option(c("--filltyp"), type="integer", default=3, help="Soil type to use as a fill value in case
conflicts between soil water and land cover water cells. If the script encounters a cell
that is classified as land in the land use field (LU_INDEX) but is classified as a water
soil type, it will replace the soil type with the value you specify. Ideally there are
not very many of these, so you can simply choose the most common soil type in your domain.
Alternatively, you can set to a bad value (e.g., -8888) to see how many of these conflicts
there are. If you do this DO NOT RUN THE MODEL WITH THESE BAD VALUES. Instead, fix them
manually with a neighbor fill or similar fill algorithm. [default= %default]", metavar="character"),
make_option(c("--laimo"), type="integer", default=8,
help="output file name [default= %default]", metavar="character"),
make_option(c("--missfloat"), type="numeric", default=(-1.e+36),
Expand Down
22 changes: 12 additions & 10 deletions training/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ rm *testcase*.tar.gz
mv /home/docker/example_case /home/docker/wrf-hydro-training/example_case
echo "Retrieved the test case for release: $version"

#echo
#echo -e "\e[0;49;32m-----------------------------------\e[0m"
#echo -e "\e[7;49;32mRetrieving WRF-Hydro model tools\e[0m"
echo
echo -e "\e[0;49;32m-----------------------------------\e[0m"
echo -e "\e[7;49;32mRetrieving WRF-Hydro training\e[0m"

#release=$(curl -s https://api.github.com/repos/NCAR/wrf_hydro_model_tools/releases/latest)
#version=$(echo "$release" | grep "tag_name" | cut -d : -f 2,3 | tr -d \")
#version=$(echo $version | tr "," " ")
#git clone --branch $version https://github.com/NCAR/wrf_hydro_model_tools
#mv /home/docker/wrf_hydro_model_tools /home/docker/wrf-hydro-training/wrf_hydro_model_tools
release=$(curl -s https://api.github.com/repos/NCAR/wrf_hydro_model_tools/releases/latest)
version=$(echo "$release" | grep "tag_name" | cut -d : -f 2,3 | tr -d \")
version=$(echo $version | tr "," " ")
#git clone --branch $version https://github.com/NCAR/wrf_hydro_training
git clone https://github.com/NCAR/wrf_hydro_training
mv /home/docker/wrf_hydro_training/lessons /home/docker/wrf-hydro-training/lessons
rm -rf /home/docker/wrf_hydro_training/

echo
echo -e "\e[0;49;32m-----------------------------------\e[0m"
Expand All @@ -51,9 +53,9 @@ echo "Open your browser to the following address to access notebooks"
echo -e "\033[33;5;7mlocalhost:8888\033[0m"
echo
echo -e "The password to login is:"
echo -e "\033[33;5;7mnwmtraining\033[0m"
echo -e "\033[33;5;7mwrfhydrotraining\033[0m"
echo
echo "Type ctrl-C then y to shut down container."
echo "Press ctrl-C then type 'y' then press return to shut down container."
echo "NOTE ALL WORK WILL BE LOST UNLESS copied out of the container"

jupyter notebook --ip 0.0.0.0 --no-browser &> /dev/null
3 changes: 2 additions & 1 deletion training/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@
# from notebook.auth import passwd; passwd()
#
# The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = u'sha1:c4afd8e6cea6:3f096975b1040bd61db881a171834d092b3925df'
c.NotebookApp.password = u'sha1:a06bfa1e94d2:5e84b748cebc4d1f32adaba98699a32f059f83ca'


## Forces users to use a password for the Notebook server. This is useful in a
# multi user environment, for instance when everybody in the LAN can access each
Expand Down

0 comments on commit c407c2c

Please sign in to comment.