Created
September 4, 2020 10:04
-
-
Save Try2Code/1b8e26eb306c7c0fb7e197f6528644df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# HELPER FUNCTIONS ============================================================= | |
DEBUG='false' | |
function lt() { | |
local lowNum=$1 | |
local highNum=$2 | |
if [ 1 -eq $((`echo "$lowNum < $highNum"| bc`)) ]; then | |
[ 'true' == "${DEBUG}" ] && echo -e "$lowNum < $highNum"; | |
else | |
[ 'true' == "${DEBUG}" ] && echo -e "$lowNum >= $highNum"; | |
exit 1; | |
fi | |
} | |
function gt() { | |
local highNum=$1 | |
local lowNum=$2 | |
if [ 1 -eq $((`echo "$highNum > $lowNum"| bc`)) ]; then | |
[ 'true' == "${DEBUG}" ] && echo -e "$highNum > $lowNum"; | |
else | |
[ 'true' == "${DEBUG}" ] && echo -e "$highNum <= $lowNum"; | |
exit 1; | |
fi | |
} | |
function inBetween() { | |
local lowNum=$1 | |
local highNum=$2 | |
local betweenNum=$3 | |
lt $lowNum $betweenNum | |
gt $highNum $betweenNum | |
exit 0 | |
} | |
# HELPER FUNCTIONS ============================================================= | |
[ 'true' == "${DEBUG}" ] && set -x | |
ifile=atm_amip_short_atm_3d_ml_19790101T000000Z.nc | |
HUS_highValue=0.0018 | |
HUS_lowValue=0.0016 | |
HUS_dataValue=$(cdo -s -outputkey,value,nohead -timmean -fldmean -vertmean -select,name=hus,timestep=-1 ${ifile}) | |
inBetween ${HUS_lowValue} ${HUS_highValue} ${HUS_dataValue} | |
CLW_highValue=3.5E-6 | |
CLW_lowValue=3.0E-6 | |
CLW_dataValue=$(cdo -s -outputf,'%G' -timmean -fldmean -vertmean -select,name=clw,timestep=-1 ${ifile}) | |
inBetween ${CLW_lowValue} ${CLW_highValue} ${CLW_dataValue} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment