#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
########################################################################
# Author: Alexander Mahura : 2023-08-22
########################################################################

# PRE-SETUP (TESTING FOR LIMITED ODB DATASET & LIMITED GEOGRAPHICAL AREA)
# FOR AIR TEMPERATURE AT 2 METRE
# ANY OTHER METEOROLOGICAL PARAMETER (FROM SYNOP LISTED) CAN BE ADDED
#
# Producing quantile rank histogram statistics and plots 
# on example of 2 m temperature (using limited open odb datasets)
#
# Met.variable, start & end year, start & end month
varMETnum=$1
b_yy_start=$2
b_yy_end=$3
b_mm_start=$4
b_mm_end=$5

echo "   varMETnum, b_yy_start, b_yy_end, b_mm_start, b_mm_end : $varMETnum $b_yy_start $b_yy_end $b_mm_start $b_mm_end"

echo "*****************************************************************"
echo " STATS - PRODUCING QUANTILE RANK HISTOGRAM STATISTICS AND PLOTS"
echo "         ON EXAMPLE OF METEOROLOGICAL VARIABLE: $varMETnum"
echo "         AT RADIOSOUNDING STATIONS"
echo "*****************************************************************"

cd STATRS
pwd
#t exit 

echo "*****************************************************************"
echo " STEP STATS-1 - PRODUCE RANK HISTOGRAMS FOR ALL RADIOSOUNDING STATIONS"
echo "*****************************************************************"

#./produce_rank_histograms_all_stations.sh 39 2020 2020 1 12
./produce_rank_histograms_all_stations.sh $varMETnum $b_yy_start $b_yy_end $b_mm_start $b_mm_end

echo "*****************************************************************"
echo " STEP STATS-2 - PRODUCE STANDARD PLOTS FOR EACH RADIOSOUNDING STATION"
echo "*****************************************************************"

#./produce_standard_plots_all_stations.sh 39 2020 2020 1 12
./produce_standard_plots_all_stations.sh $varMETnum $b_yy_start $b_yy_end $b_mm_start $b_mm_end

echo "*****************************************************************"
echo " STEP STATS-3 - PRODUCE SUMMARY RANK HISTOGRAMS FOR ALL STATIONS"
echo "*****************************************************************"

#./summary_rank_histograms_all_stations.sh 39 2020 2020 1 12
./summary_rank_histograms_all_stations.sh $varMETnum $b_yy_start $b_yy_end $b_mm_start $b_mm_end

echo "*****************************************************************"
echo "               ALL STATS-# STEP COMPLETED"
echo "*****************************************************************"

exit
