[187] | 1 | #!/bin/bash |
---|
| 2 | ## g.e. # ./make_met-aquaplanet.bash met_em.d01.1979-01-01_00\:00\:00.nc SST control 273.15:27. |
---|
| 3 | ## g.e. # ./make_met-aquaplanet.bash met_em.d01.1979-01-01_00\:00\:00.nc SST KEQ 273.15:27.:1.:60.0:15.:15. |
---|
| 4 | ## g.e. # ./make_met-aquaplanet.bash met_em.d01.1979-01-01_00\:00\:00.nc SST HS 315.0:0.0:60.0 |
---|
| 5 | if test $1 = '-h'; then |
---|
| 6 | echo "******************************" |
---|
| 7 | echo "*** Shell script to make ***" |
---|
| 8 | echo "*** an aqua-planet met_em ***" |
---|
| 9 | echo "******************************" |
---|
| 10 | echo "make_met-aquaplanet.bash [met_emfile](met_em file to transform) [SSTname](name of the SST) [sstkind](kind of SST profile from Neale & Hoskins, 2001) [ref:amp/addvalues](amplitude or additional values when required (KEQ, KW1), HS: Held & Suarez, 1994 conditions (uses [ref]:[amp]:[perAmp, as /\Ty])" |
---|
| 11 | echo "[addvalues]=[reference]:[amp]:[perAmp]:[L0]:[dL]:[dl]" |
---|
| 12 | echo " [ref]: value for the non-perturbation" |
---|
| 13 | echo " [amp]: anomaly amplitude (in [units])" |
---|
| 14 | echo " [perAmp]: perturbation anomaly amplitude (in [units])" |
---|
| 15 | echo " [L0]: longitude of maximum anomaly (in deg)" |
---|
| 16 | echo " [dL]: decayment in longitude (in deg)" |
---|
| 17 | echo " [dl]: decayment in latitude (in deg)" |
---|
| 18 | else |
---|
| 19 | rootsh=`pwd` |
---|
| 20 | export PATH=/u/lflmd/bin/gcc_Python-2.7.5/bin:${PATH} |
---|
[189] | 21 | ncvarhome=${HOME}/UNSW-CCRC-WRF/tools/python |
---|
[187] | 22 | errormsg='ERROR -- error -- ERROR -- error' |
---|
| 23 | |
---|
| 24 | met_emfile=$1 |
---|
| 25 | sstname=$2 |
---|
| 26 | sstkind=$3 |
---|
| 27 | addvalues=$4 |
---|
| 28 | |
---|
| 29 | if test ! ${sstkind} = 'original'; then |
---|
| 30 | ofile='aqua_met-em_'${sstkind}'.nc' |
---|
| 31 | else |
---|
| 32 | ofile='aqua_met-em.nc' |
---|
| 33 | fi |
---|
| 34 | |
---|
| 35 | rm ${ofile} > /dev/null |
---|
| 36 | |
---|
[189] | 37 | zerovars='LANDMASK:HGT_M:HGT_U:HGT_V:SLPX:SLPY:CON:VAR:OA1:OA2:OA3:OA4:OL1:OL2:OL3:OL4:SKINTEMP:SEAICE:SNOW' |
---|
[187] | 38 | # Fixing p_top at 0.0001 hPa) |
---|
| 39 | ## zTopvars='PRES:GHT:RH:VV:UU:TT' |
---|
| 40 | zTopvars='PRES@0.0001' |
---|
| 41 | |
---|
| 42 | ## keepvars='XLAT_M:XLONG_M:XLAT_U:XLONG_U:XLAT_V:XLONG_V:CLAT:CLONG:MAPFAC_M:MAPFAC_V:MAPFAC_U:MAPFAC_MX:MAPFAC_VX:MAPFAC_UX:MAPFAC_MY:MAPFAC_VY:MAPFAC_UY:E:F:SINALPHA:COSALPHA' |
---|
| 43 | keepvars='' |
---|
[189] | 44 | specificvars='LANDUSEF|0:LU_INDEX|1:SOILTEMP|0:SOILCTOP|0:SCT_DOM|14:SOILCBOT|0:SCB_DOM|14:ALBEDO12M|8:GREENFRAC|0:SNOALB|0:SLOPECAT|0' |
---|
[187] | 45 | # specificvars='' |
---|
| 46 | thresvars='SST|273.15|below|275.:' |
---|
[189] | 47 | dimvars='LANDUSEF|z-dimension0024,15,sumc,1:' |
---|
[187] | 48 | |
---|
| 49 | cp ${met_emfile} ${ofile} |
---|
| 50 | |
---|
| 51 | # zerovars |
---|
| 52 | ## |
---|
| 53 | ivar=1 |
---|
| 54 | echo "zeroing..." |
---|
| 55 | zerov=`echo ${zerovars} | tr ':' ' '` |
---|
| 56 | for var in ${zerov}; do |
---|
| 57 | echo " "${var}"..." |
---|
[189] | 58 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${var} -o valmod -S mulc,0. |
---|
[187] | 59 | ivar=`expr ${ivar} + 1` |
---|
| 60 | ## exit |
---|
| 61 | done # end of zeroingvars |
---|
| 62 | |
---|
| 63 | # giving values |
---|
| 64 | ## |
---|
| 65 | echo "giving values..." |
---|
| 66 | givv=`echo ${specificvars} | tr ':' ' '` |
---|
| 67 | for var in ${givv}; do |
---|
| 68 | varn=`echo ${var} | tr '|' ' ' | awk '{print $1}'` |
---|
| 69 | varv=`echo ${var} | tr '|' ' ' | awk '{print $2}'` |
---|
| 70 | echo " "${varn}"..." |
---|
[189] | 71 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${varn} -o valmod -S mulc,0. |
---|
| 72 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${varn} -o valmod -S sumc,${varv} |
---|
[187] | 73 | ivar=`expr ${ivar} + 1` |
---|
| 74 | ## exit |
---|
| 75 | done # end of givingvars |
---|
| 76 | |
---|
| 77 | # threshold values |
---|
| 78 | ## |
---|
| 79 | echo "threshold values..." |
---|
| 80 | givv=`echo ${thresvars} | tr ':' ' '` |
---|
| 81 | for var in ${givv}; do |
---|
| 82 | varn=`echo ${var} | tr '|' ' ' | awk '{print $1}'` |
---|
| 83 | vart=`echo ${var} | tr '|' ' ' | awk '{print $2}'` |
---|
| 84 | vark=`echo ${var} | tr '|' ' ' | awk '{print $3}'` |
---|
| 85 | varv=`echo ${var} | tr '|' ' ' | awk '{print $4}'` |
---|
| 86 | if test ${vark} = 'below'; then |
---|
| 87 | echo " "${varn}" values below "${vart}" to "${varv}"..." |
---|
[189] | 88 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${varn} -o valmod -S lowthres,${vart},${varv} |
---|
[187] | 89 | else |
---|
| 90 | echo " "${varn}" values above "${vart}" to "${varv}"..." |
---|
[189] | 91 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${varn} -o valmod -S upthres,${vart},${varv} |
---|
[187] | 92 | fi |
---|
| 93 | ivar=`expr ${ivar} + 1` |
---|
| 94 | ## exit |
---|
| 95 | done # end of thresvars |
---|
| 96 | |
---|
[189] | 97 | # dimension values |
---|
| 98 | ## |
---|
| 99 | ivar=1 |
---|
| 100 | echo "dimension values..." |
---|
| 101 | dimv=`echo ${dimvars} | tr ':' ' '` |
---|
| 102 | for var in ${dimv}; do |
---|
| 103 | varn=`echo ${var} | tr '|' ' ' | awk '{print $1}'` |
---|
| 104 | varv=`echo ${var} | tr '|' ' ' | awk '{print $2}'` |
---|
| 105 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${varn} -o valmod_dim -S ${varv} |
---|
| 106 | ivar=`expr ${ivar} + 1` |
---|
| 107 | ## exit |
---|
| 108 | done # end of thresvars |
---|
| 109 | |
---|
[187] | 110 | # Imposing SST |
---|
| 111 | ## |
---|
| 112 | if test ! ${sstkind} = 'original'; then |
---|
| 113 | python sfcVAR_global_modification.py -f ${ofile} -v ${sstname} -k ${sstkind} -L XLONG_M -l XLAT_M -s ${addvalues} |
---|
| 114 | npy=$? |
---|
| 115 | if test ! ${npy} -eq 0; then |
---|
| 116 | echo ${errormsg} |
---|
| 117 | echo " Pythhon 'sfcVAR_global_modification.py' does not work!" |
---|
| 118 | echo ${errormsg} |
---|
| 119 | exit |
---|
| 120 | fi |
---|
| 121 | fi |
---|
| 122 | |
---|
| 123 | # Without including extra level |
---|
| 124 | exit |
---|
| 125 | |
---|
| 126 | # Ztop variables |
---|
| 127 | ## |
---|
| 128 | echo " Adding top variables at p=0 i.." |
---|
| 129 | ztopvars=`echo ${zTopvars} | tr ':' ' '` |
---|
| 130 | for zvar in ${ztopvars}; do |
---|
| 131 | zvarn=`echo ${zvar} | tr '@' ' ' | awk '{print $1}'` |
---|
| 132 | zvarv=`echo ${zvar} | tr '@' ' ' | awk '{print $2}'` |
---|
| 133 | echo " "${zvar} |
---|
[189] | 134 | python ${ncvarhome}/nc_var.py -f ${ofile} -v ${zvarn} -o addvals -S '1:last:1:'${zvarv} |
---|
[187] | 135 | done |
---|
[189] | 136 | python ${ncvarhome}/nc_var.py -f ${ofile} -o gaddattrk -S 'BOTTOM-TOP_GRID_DIMENSION|39|Inp32' |
---|
[187] | 137 | |
---|
| 138 | # Giving the geopotential and temperature at the top (assuming p_top 0.0001 hPa) |
---|
| 139 | python values_Zlevel.py -f ${ofile} -z -1 -g GHT -H HGT_M -L XLONG_M -l XLAT_M -p PRES -r RH -t TT -P -1,-1 |
---|
| 140 | |
---|
| 141 | echo "Aqua-planet like '"${ofile}"' file generated" |
---|
| 142 | |
---|
| 143 | fi |
---|