From 9a0d0a1b059732671907fadf76ad26242fe1c006 Mon Sep 17 00:00:00 2001 From: Sebastian Ostberg <ostberg@pik-potsdam.de> Date: Tue, 26 Oct 2021 12:11:33 +0200 Subject: [PATCH] Initial full commit --- README.md | 22 ++++++- download_forecast.sh | 123 ++++++++++++++++++++++++++++++++++++ download_hist_timeseries.sh | 6 ++ rsync_pik | 1 + 4 files changed, 150 insertions(+), 2 deletions(-) create mode 100755 download_forecast.sh create mode 100755 download_hist_timeseries.sh create mode 100644 rsync_pik diff --git a/README.md b/README.md index a8b0f2f..e6e3358 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# WM_LPJmL_output +# World Modelers LPJmL model for raw simulation outputs -This project contains code ingest LPJmL crop yield forecasts and historical yield simulations into the World Modelers "Dojo" system. \ No newline at end of file +This project contains code to ingest LPJmL crop yield forecasts and historical yield simulations into the World Modelers "Dojo" system. This model returns raw, gridded simulation outputs that are not aggregated spatially or temporally. + +## Historical yield simulations +`download_hist_timeseries.sh` fetches pre-computed results of the historical yield simulation from the PIK server. + +## Crop yield forecasts +`download_forecast.sh` fetches pre-computed results of crop yield forecast simulations from the PIK server. +### Input knob settings +The following input knobs are available: +- fertilizer_scenario +- irrigation_scenario +- sowing_scenario +- weather_year + +Input knob settings are passed as command line arguments to `download_forecast.sh`. Example call: `download_forecast.sh -fertilizer_scenario reference -irrigation_scenario reference -sowing_scenario reference -weather_year 1984-1985` + +## Output +`download_hist_timeseries.sh` deposits a file `output/hist_timeseries.nc` +`download_forecast.sh` deposits a file `output/forecast_2021-2022.nc` diff --git a/download_forecast.sh b/download_forecast.sh new file mode 100755 index 0000000..ae4688e --- /dev/null +++ b/download_forecast.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# set defaults if missing command line parameters +fertilizer_scenario="reference" +sowing_scenario="reference" +irrigation_scenario="reference" +weather_year="1984-1985" + +## set valid options +fertilizer_options=( "reference" "refP25" "refP50" "refP100" ) +sowing_options=( "minus30" "minus15" "reference" "plus15" "plus30" ) +irrigation_options=( reference ) +weather_options=( "1984-1985" "1985-1986" "1986-1987" "1987-1988" "1988-1989" "1989-1990" "1990-1991" "1991-1992" "1992-1993" + "1993-1994" "1994-1995" "1995-1996" "1996-1997" "1997-1998" "1998-1999" "1999-2000" "2000-2001" "2001-2002" + "2002-2003" "2003-2004" "2004-2005" "2005-2006" "2006-2007" "2007-2008" "2008-2009" "2009-2010" "2010-2011" + "2011-2012" "2012-2013" "2013-2014" "2014-2015" "2015-2016" "2016-2017" "2017-2018" "2018-2019" "2019-2020" ) + +# read input parameters from command line +while(( "$#" )); do + case "$1" in + -fertilizer_scenario) + if [ $# -lt 2 ]; then + echo >&2 value for fertilizer_scenario missing + exit 1 + fi + fertilizer_scenario=$2 + shift 2 + ;; + -sowing_scenario) + if [ $# -lt 2 ]; then + echo >&2 value for sowing_scenario missing + exit 1 + fi + sowing_scenario=$2 + shift 2 + ;; + -irrigation_scenario) + if [ $# -lt 2 ]; then + echo >&2 value for irrigation_scenario missing + exit 1 + fi + irrigation_scenario=$2 + shift 2 + ;; + -weather_year) + if [ $# -lt 2 ]; then + echo >&2 value for weather_year missing + exit 1 + fi + weather_year=$2 + shift 2 + ;; + -*) + echo >&2 Invalid option $1 + exit 1 + ;; + *) + echo >&2 Invalid argument $1 + exit 1 + ;; + esac +done + +fert_valid=0 +for opt in ${fertilizer_options[@]}; do + if [ "$fertilizer_scenario" == "$opt" ]; then + fert_valid=1 + fi +done +if [ ${fert_valid} -lt 1 ]; then + echo >&2 Invalid fertilizer_scenario $fertilizer_scenario + exit 1 +fi +sowing_valid=0 +for opt in ${sowing_options[@]}; do + if [ "$sowing_scenario" == "$opt" ]; then + sowing_valid=1 + fi +done +if [ ${sowing_valid} -lt 1 ]; then + echo >&2 Invalid sowing_scenario $sowing_scenario + exit 1 +fi +irrig_valid=0 +for opt in ${irrigation_options[@]}; do + if [ "$irrigation_scenario" == "$opt" ]; then + irrig_valid=1 + fi +done +if [ ${irrig_valid} -lt 1 ]; then + echo >&2 Invalid irrigation_scenario $irrigation_scenario + exit 1 +fi +weather_valid=0 +for opt in ${weather_options[@]}; do + if [ "$weather_year" == "$opt" ]; then + weather_valid=1 + fi +done +if [ ${weather_valid} -lt 1 ]; then + echo >&2 Invalid weather_year $weather_year + exit 1 +fi + +if [ ${#sowing_scenario} -lt 5 ]; then + echo >&2 Invalid sowing_scenario $sowing_scenario + exit 1 +fi + +if [ "$irrigation_scenario" != "reference" ]; then + echo >&2 Invalid irrigation_scenario $irrigation_scenario + exit 1 +fi + +if [ ${#weather_year} -ne 9 ]; then + echo >&2 Invalid weather_year $weather_year + exit 1 +fi + +echo Fetching data for irrigation_scenario \"$irrigation_scenario\", fertilizer_scenario \"$fertilizer_scenario\", sowing_scenario \"$sowing_scenario\", and weather_year \"$weather_year\" from PIK server. + +run=set rsync --password-file=rsync_pik c2p2_user@rsync.pik-potsdam.de::c2p2/August2021_experiment/lpjml-results/forecast_2021-2022/irrigation_target_${irrigation_scenario}_n_rate_shift_${fertilizer_scenario}_sowing_delta_${sowing_scenario}/forecast_2021-2022_wy${weather_year}.nc output/forecast_2021-2022.nc +exit $? diff --git a/download_hist_timeseries.sh b/download_hist_timeseries.sh new file mode 100755 index 0000000..1f99766 --- /dev/null +++ b/download_hist_timeseries.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo Fetching data for historical timeseries from PIK server. + +run=set rsync --password-file=rsync_pik c2p2_user@rsync.pik-potsdam.de::c2p2/August2021_experiment/lpjml-results/hist_timeseries/hist_timeseries.nc output/hist_timeseries.nc +exit $? diff --git a/rsync_pik b/rsync_pik new file mode 100644 index 0000000..38e6669 --- /dev/null +++ b/rsync_pik @@ -0,0 +1 @@ +eveoLie1 -- GitLab