#
# These values should override values used in python or bash scripts
#
# where the tower ascii files get pushed to
export TOWER_INCOMING_DIR=/mnt/inst-data/incoming/aoss/tower
# The archived location (primary raw)
export TOWER_PRAW_DIR=/mnt/inst-data/raw/aoss/tower
# Where generated products go
export TOWER_CACHE_DIR=/mnt/inst-data/cache/aoss/tower
# Python environment to use and where scripts are location
export ENV=/data1/software/aoss-tower3
# Directory where logs will be stored
export LOGDIR=$ENV/logs
# Directory where work files can be placed (inside a separate temp directory)
export WORKDIR=/mnt/inst-data/tmp

log_info() {
    echo "INFO: $*" &>> $logfile
}

oops() {
    echo "ERROR: $*" &>> $logfile
    exit 1
}

day_before() {
    date %Y%m%d --date "$1 -1 day"
}

work_dir() {
    mktemp -d --tmpdir="$WORKDIR" "work_$1_"
}

cache_level_00_file() {
    d=$1
    year=${d:0:4}
    month=${d:4:2}
    day=${d:6:2}
    echo "${TOWER_CACHE_DIR}/aoss/tower/level_00/version_00/${year}/${month}/${day}/aoss_tower.${year}-${month}-${day}.ascii"
}

cache_level_b1_file() {
    d=$1
    year=${d:0:4}
    month=${d:4:2}
    day=${d:6:2}
    echo "${TOWER_CACHE_DIR}/aoss/tower/level_b1/version_00/${year}/${month}/${day}/aoss_tower.${year}-${month}-${day}.nc"
}