cbin_avrg - sinotec2/CAMx_utility GitHub Wiki

###Purpose In accordance with MM5 results, the CAMx simulations always begin and end at 20:00(L)(12:00Z). When calculating the daily mean and monthly mean will encounter difficulties. More than that, the seasonal statistics are required in modeling regulation, the combination of monthly results are important preprocessing step.
This cbin tool connects 2 successive simulation results to form a overall file with appropriate start and end time in header and correct joint of tails.
###Usage
cbin_avrg file1 file2 ... file_out
(at least 3 files, with extensions)
###Examples ####join successive avrg.grd files to a whole season file
Since the autumn/winter seasonal simulation are required by the modelling regulation for PM simulations and the spring/autumn seasons for ozone simulations, combination of monthly results in certain season is an important preprocessing step of seasonal statistics. The following examples are shown to prepare the winter and spring files respectively:

$ for i in Hs 4G 6C4G;do nohup cbin_avrg.ser con01/1001_$i.S.grd01 con02/1002_$i.S.grd01 con12/1012_$i.S.grd01 ../Winter/DJF_$i.S.grd02L;done&
$ for i in Hs 4G 6C4G;do nohup cbin con03/1003_$i.S.grd02 con04/1004_$i.S.grd02 con04/1004_$i.S.grd02 ../Spring/MAM_$i.S.grd02L;done&

####Continuing executions of cbin(cbin_all)
Two arguments are needed for script file cbin_all:

  1. quoted file name(s), may include directory, wild cards(*、?、[...]), be quoted by "...".
  2. the resultant file name

[kuang@master bin]$ cat cbin_all
# note! the argument must be quoted as "$1"
first=1
for i in $(ls -l $1|awk8);do
if [ "$first" == "1" ]; then
cp -f $i cbin_all.result
first=0
else
cbin_avrg.ser cbin_all.result $i tmp
mv tmp cbin_all.result
fi
echo $first" "$i
done
mv cbin_all.result $2

###How to verify the start and end time in avrg file?

  1. One may check the ROOT.out file with command tail, whether the camx program is perfectly executed to the last hour of simulation。
  2. Using th command tmavrg _FILE_(time average of FILE) to check the end time is same as described in the header. If not so, massage will appear on the screen。
  3. Execute cbindirectly, the date and time of each file and time frame will print on the screen。

###Serial and parallel versions of cbin_avrg ####Serial versioncbin_avrg.ser
Although the speed of serial version is slower, but more faithful. Besides, as execution of cbin_all, the resultant file will get larger and larger, the serial version of cbin will be easier to process.
####Parallel versioncbin_avrg.par
If the periods of simulation are short, the parallel version will be more efficient.


#Simular program over_avrg
###General
over_avrg is modified from cbin_avrg. cbin_avrg connects 2 successive avrg files without overlapping, while over_avrg can handle files with overlapping in time. For two files occasion, the data of file1 will substitute file2 for the same time. When encounter the end of file1, the data of file2 will copied to the resultant file. There is only serial version for over_avrg
###Usage
over_avrg file1 file2 ... file_out
(with extensions, at least 3 files, not much more than 300.)
###Notice

  1. If file1 is incomplete in tail of file. The insufficiency in data matrix will be filled by the content of file2. The last time frame is mixed with both files and some mistakes will arise in case of not properly restarting of next file.
  2. over_avrg will correct the errors existing in the starting and ending time of resultant header。