| 1 | #!/bin/ksh
|
|---|
| 2 | #
|
|---|
| 3 | # Script to transplant 1dvar retrieval into observations file,
|
|---|
| 4 | # and then convert into BUFR format.
|
|---|
| 5 | #
|
|---|
| 6 |
|
|---|
| 7 | export OBS=atm20110912_000312_M02_1230427200_N0019_XXXX.nc # input file, containing refractivity derived from bending angle
|
|---|
| 8 |
|
|---|
| 9 | export ANL=1dvar_sol.nc # 1dvar output, containing forward-modelled refractivity based on 1DVAR retrieval.
|
|---|
| 10 |
|
|---|
| 11 | export OUT2=atm20110912_000312_M02_1230427200_N0019_XXXX_1dvar.nc # new output ncdf file
|
|---|
| 12 |
|
|---|
| 13 | export OUTB=atm20110912_000312_M02_1230427200_N0019_XXXX_1dvar.bufr # new output bufr file
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | # Copy obs to output file, retaining source info in global history attribute
|
|---|
| 17 |
|
|---|
| 18 | ncks -a $OBS -O $OUT2
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | # Transplant required data
|
|---|
| 22 | # NB (1) "_sfc" serves as a proxy for lev2c, which is not stored as a dim=1 coord variable
|
|---|
| 23 | # (2) "dim_char64" ensures level_type is copied across
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | for lev in lev2b _sfc lev2d dim_char64 ; do # data on these levels to be transplanted.
|
|---|
| 27 |
|
|---|
| 28 | var_list=""
|
|---|
| 29 |
|
|---|
| 30 | # Find out which fields are present on each level
|
|---|
| 31 |
|
|---|
| 32 | for var in `ncdump -h $ANL |grep $lev |grep dim_unlim |cut -d"(" -f1 |rev |cut -d" " -f1` ; do
|
|---|
| 33 |
|
|---|
| 34 | var_list=$var_list","$var
|
|---|
| 35 |
|
|---|
| 36 | done
|
|---|
| 37 |
|
|---|
| 38 | var_list=`echo $var_list |cut -c2- |rev`
|
|---|
| 39 |
|
|---|
| 40 | #echo \$var_list = $var_list # If you want to check
|
|---|
| 41 |
|
|---|
| 42 | if [[ $var_list != "" ]] ; then
|
|---|
| 43 |
|
|---|
| 44 | ncks -v$var_list $ANL -A $OUT2 # append these fields to $OUT2
|
|---|
| 45 |
|
|---|
| 46 | fi
|
|---|
| 47 |
|
|---|
| 48 | done
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | # Unfortunately, and in contrast to what the NCO manual says, this procedure
|
|---|
| 52 | # overwrites some of the global attributes needed by ropp2bufr.
|
|---|
| 53 | # So reinstate them from $OBS.
|
|---|
| 54 |
|
|---|
| 55 | ncks -x -A $OBS $OUT2
|
|---|
| 56 |
|
|---|
| 57 | # To check you've done what you wanted:
|
|---|
| 58 | # ncdump -h $OBS `echo $OBS |sed -es/'.nc'/'.cdl'`
|
|---|
| 59 | # ncdump -h $OUT2 `echo $OUT2 |sed -es/'.nc'/'.cdl'`
|
|---|
| 60 | # diff *.cdl, or tkdiff *.cdl.
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | # Convert to bufr format
|
|---|
| 65 |
|
|---|
| 66 | /data/nwp1/idculv/ROPP/ropp-5.1/ifort/bin/ropp2bufr $OUT2 -o $OUTB
|
|---|
| 67 |
|
|---|
| 68 | # To check you've done what you wanted:
|
|---|
| 69 | # decbufr -dh $OUTB > ${OUTB}.dh
|
|---|
| 70 | # This could be compared with the bufr version of the original OBS file, if desired.
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|