Commit 21b8339e authored by Pierre-Antoine Bretonnière's avatar Pierre-Antoine Bretonnière
Browse files

Merge branch 'develop-testeleftheria' into 'master'

Develop testeleftheria

Hi,

I added a new function (vertmeanvar) to compute weighted vertical means in the ocean, on either temperature or salinity (potentially on every quantity on gridT). The input levels should be in level number, and they are specified in the configure file with the 2 new variables level1 and level2 (the modified config file is part of the commit). People who would be interested in this and could check it: @vguemas  @cprodhomme  @pabretonniere

Cheers
Eleftheria
parents bc635ed5 02c71531
......@@ -39,6 +39,8 @@ PATH=/cfu/software/cdftools2.1/:$PATH
Pacific and Indian subtropical gyres and indice of the Antarctic
Circumpolar Current strength
'usalc' : upper layer salt content 0-300m
'temp_lev' : temperature, vertical mean between dif levels (2D)
'sal_lev' : salinity, vertical mean between dif levels (2D)
'lmsalc' : middle + lower layer salt content 300m-bottom
'ohc' : global total ocean heat content
'ohc_specified_layer' : Pointwise ocean heat content in a specified ocean thickness (at present 0-300 m)
......@@ -95,3 +97,5 @@ PATH=/cfu/software/cdftools2.1/:$PATH
'uArctohc' : Arctic (65-90N) upper (0-350m) ocean heat content
'mArctohc' : Arctic (65-90N) middle (350-800m) ocean heat content
'lArctohc' : Arctic (65-90N) lower (800m-bottom) ocean heat content
'temp_lev' : vertical mean of ocean temp (weighted) between level1 and level2 (in numbers, not in meters), specified in the config file
'sal_lev' : vertical mean of ocean sal (weighted) between level1 and level2 (in numbers, not in meters), specified in the config file
......@@ -1161,4 +1161,84 @@ function gather_memb {
ncpdq -O -h -a time,ensemble ${3} ${3}
}
###############################################################################
# Choose vertical level in ocean, or vertically average between
# 2 or more ocean levels #
# #
# $1 : input file name #
# $2: input variable name (votemper or vosaline) #
# $3 : upper depth of the layer (in level number) #
# $4 : lower depth of the layer (in level number. If same as the #
# upper layer, then the script just selects this layer. If its #
# different, a vertical integral (weighted) between upper and lower #
# level is computed #
# $5 : output file name (=> 2D field ) #
# #
# Created in February 2012 Author : vguemas@ic3.cat #
# Modified (more generic,
# i.e. for any input var) in December 2014 #
# Author : eleftheria.exarchou@ic3.cat #
###############################################################################
function vertmeanvar {
typeset var ntime=`cdo ntime $1`
typeset var list=""
typeset var jt
for jt in $(seq 1 $ntime); do
ncks -d time,$((jt-1)) $1 a1
# The oras4 data do not have gdepth data in their mask, but only gdept_0, so:
if grep -q nemovar_s4 $1 ; then
l1=$(( $3 % 6 ))
l2=$(( $4 % 6 ))
ll1=$(( $3 / 6 + 1 ))
ll2=$(( $4 / 6 + 1 ))
lev1=`echo $(cdo output -selvar,gdept_0 mesh_zgr.nc | sed -n ${ll1}p | awk '{ print $'$l1' }')`
lev2=`echo $(cdo output -selvar,gdept_0 mesh_zgr.nc | sed -n ${ll2}p | awk '{ print $'$l2' }')`
else
l1=$(($3+1))
l2=$(($4+1))
lev1=`echo $(cdo info -seltimestep,1 -selvar,gdept mesh_zgr.nc | sed -n ${l1}p | awk '{ print $10 }')`
lev2=`echo $(cdo info -seltimestep,1 -selvar,gdept mesh_zgr.nc | sed -n ${l2}p | awk '{ print $10 }')`
fi
cdfvertmean a1 $2 T $lev1 $lev2
rm -f a1
ncrename -O -v sovertmean,vertmean -d time_counter,time -v time_counter,time vertmean.nc
mv vertmean.nc outputvertmean_$jt.nc
list=$list" "outputvertmean_$jt.nc
rm -f intvertmean.nc a?
# #test on cdo version: if >1.5.6, remove valid_min/max attributes to avoid values out of that range to be replaced by NaN
ncatted -O -a valid_max,vertmean,d,, outputvertmean_$jt.nc outputvertmean_$jt.nc
ncatted -O -a valid_min,vertmean,d,, outputvertmean_$jt.nc outputvertmean_$jt.nc
ncatted -O -a standard_name,time,a,c,time outputvertmean_$jt.nc outputvertmean_$jt.nc
ncatted -O -a units,time,o,c,'seconds since 1993-05-01 00:00:00' outputvertmean_$jt.nc outputvertmean_$jt.nc
ncatted -O -a long_name,time,a,c,'Time axis' outputvertmean_$jt.nc outputvertmean_$jt.nc
done
cdo cat $list $5
ncks -A -v time $1 $5
rm -f $list
setminmax $5 vertmean
ncrename -v vertmean,$2 $5
#typeset var level=`echo $(cdo info -selvar,$2 -setctomiss,0 $5 | sed -n 2p | awk '{ print $7 }')`
#typeset var lev=`echo $(cdo info -seltimestep,1 -selvar,$2 -setctomiss,0 $1 | grep $level | awk '{ print $1 }')`
lev=$3
echo $lev
cp $5 tmp_${lev}.nc
## Here we interpolate horizontally onto a regular grid
ln -sf /cfu/autosubmit/con_files/weigths/${NEMOVERSION}/rmp_${NEMOVERSION}_to_*_lev${lev}.nc rmp_${NEMOVERSION}_to_regular_lev${lev}.nc
ln -sf /cfu/pub/scripts/interpolation/scrip_use scrip_use
cat > scrip_use_in <<EOF
&remap_inputs
remap_wgt = 'rmp_${NEMOVERSION}_to_regular_lev${lev}.nc'
infile = 'tmp_${lev}.nc'
invertlat = FALSE
var = '$2'
fromregular = FALSE
outfile = 'tmp_${lev}_int.nc'
/
EOF
./scrip_use
cdo setgrid,t106grid tmp_${lev}_int.nc tmpout1.nc
cdo invertlatdata tmpout1.nc $5
ncatted -O -a long_name,${2},o,c,'vertical average of temp/sal between '${lev1}'m and '${lev2}'m' $5
rm -f tmp_* tmpout* rmp_${NEMOVERSION}_to_regular_lev* scrip_use scrip_use_in
}
#!/bin/bash
# This is an example of a configuration_file needed to launch ocean_pp.bash. For any other information about how to use it, you can refer to the README or the cfu wiki (http://ic3.cat/wikicfu/index.php/Tools#update_February_2013).
listpost=( )
listpost=('temp_lev' 'sal_lev')
# Valid options : ('siasiesiv' 'ohc' 'moc' 'max_moc' 'area_moc' 'ext_raw_ice' (previously 'ice') 'ext_raw_oce' (previously 'sstsssmld') 'heat_sal_mxl' 'psi' 'usalc' 'lmsalc' 'uohc' 'mohc' 'lohc' 'xohc' 'ohc_specified_layer' 'stc' 'vert_Tsections' 'vert_Ssections' '3dtemp' '3dsal' 'TSec_ave190-220E' 'SSec_ave190-220E' 'NAtlohc' 'xNAtlohc' 'uNAtlohc' 'mNAtlohc' 'lNAtlohc' 'NPacohc' 'xNPacohc' 'uNPacohc' 'mNPacohc' 'lNPacohc' 'TAtlohc' 'xTAtlohc' 'uTAtlohc' 'mTAtlohc' 'lTAtlohc' 'TPacohc' 'xTPacohc' 'uTPacohc' 'mTPacohc' 'lTPacohc' 'TIndohc' 'xTIndohc' 'uTIndohc' 'mTIndohc' 'lTIndohc' 'Antaohc' 'xAntaohc' 'uAntaohc' 'mAntaohc' 'lAntaohc' 'Arctohc' 'xArctohc' 'uArctohc' 'mArctohc' 'lArctohc' )
# Beware that the max_moc diagnostics can not be computed if you don't process complete years (because that's a diagnostic computed from annual means)
raw_vars_ocean=( 'default' ) # If listpost contains "ext_raw_oce" option, this is the list ocean variables you want to extract. If nothing is specified, all variables present in input file will be treated. If raw_vars_ocean='default', sosstsst, sosaline, somixhgt and somxl010 will be extracted.
raw_vars_ice=( 'default' ) # If listpost contains "ext_raw_ice" option, this is the list of seaice variables you want to extract. If nothing is specified, all variables will be treated. If raw_vars_ice='default', isnowthi, iicethic, ileadfra, iicetemp, and ice_pres will be extracted.
expid=i00k # expid or nemovar_s4 / nemovar_combine / glorys2v1
level1=1
level2=14 #If temp_lev or sal_lev is chosen on listpost, the lev1 and lev2 correspond to the levels between which the vertical mean has to be calculated. Lev1 and lev2 should be between 1,42 or 1,46, depending on the numbers of vertical levels on the original files.
raw_vars_ocean=( '' ) # If listpost contains "ext_raw_oce" option, this is the list ocean variables you want to extract. If nothing is specified, all variables present in input file will be treated. If raw_vars_ocean='default', sosstsst, sosaline, somixhgt and somxl010 will be extracted.
raw_vars_ice=( '' ) # If listpost contains "ext_raw_ice" option, this is the list of seaice variables you want to extract. If nothing is specified, all variables will be treated. If raw_vars_ice='default', isnowthi, iicethic, ileadfra, iicetemp, and ice_pres will be extracted.
expid=m02j # expid or nemovar_s4 / nemovar_combine / glorys2v1
mod='ecearth' # nemo / ecearth
typeoutput='MMO' # diags / MMO
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
listmemb=( 0 1 2 3 4 ) # list of members
syeari=1960 # first start date, format "yyyy"
syearf=2005 # last start date, format "yyyy"
listmemb=( 0 1 2 3 4 5 6 7 8 9 ) # list of members
syeari=1993 # first start date, format "yyyy"
syearf=2009 # last start date, format "yyyy"
moni=11 # first month of the hindcast, format "mm", e.g. 05 for May
intsdate=1 # interval between start dates
chunklen=4 # length of the chunks (in months)
......@@ -25,7 +27,7 @@ yearf= # last year to post-process in the fist start date
# If you fill up the year argument, complete years will be processed, year by
# year from moni
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NEMOVERSION=Ec2.3_O1L42 # NEMO version
NEMOVERSION=Ec3.0_O1L46 # NEMO version
# Valid options : Ec2.3_O1L42 for Ec-Earth 2.3 ORCA1 L42
# Ec3.0_O1L46 for Ec-Earth 3.0 ORCA1 L46
# Ec3.0_O25L46 for Ec-Earth 3.0 ORCA0.25 L46
......@@ -36,7 +38,7 @@ NEMOVERSION=Ec2.3_O1L42 # NEMO version
# glorys2v1_O25L75 for Nemo GLORYS2v1 ORCA025L75
# ucl_O2L31 for Nemo UCL ORCA2L31
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PATHCOMMONOCEANDIAG='/home/'${USER}'/autosubmit/postp/ocean'
PATHCOMMONOCEANDIAG='/home/'${USER}'/ocean_diagnostics'
CON_FILES='/cfu/autosubmit/con_files'
rootout='/cfunas/exp/'${mod}'/'${expid}'/monthly_mean'
#rootout='/cfunas/exp/'${mod}'/'${expid}'/daily_mean'
......@@ -244,6 +244,24 @@ for ((yeari=$syeari;yeari<=$syearf;yeari=$(($yeari+intsdate)))) ; do
fi
;;
'temp_lev')
if [[ $typeoutput == 'MMO' ]] ; then
if [ ! -f temp_lev${level1}-${level2}_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc ] ; then
vertmeanvar grid_T_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc votemper $level1 $level2 temp_lev${level1}-${level2}_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc
fi
fi
;;
'sal_lev')
if [[ $typeoutput == 'MMO' ]] ; then
if [ ! -f sal_lev${level1}-${level2}_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc ] ; then
vertmeanvar grid_T_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc vosaline $level1 $level2 sal_lev${level1}-${level2}_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc
fi
fi
;;
'ohc_specified_layer')
if [ ! -f ohc_2d_avg_0-300m_${expid}_${yeari}${moni}01_fc${memb}_${year0}$(printf "%02d" ${mon0})_${yearf}$(printf "%02d" ${monf}).nc ];then
case $typeoutput in
......@@ -445,6 +463,8 @@ for ((yeari=$syeari;yeari<=$syearf;yeari=$(($yeari+intsdate)))) ; do
'psi') dirout='psi' ; files=('psi') ;;
'gyres') dirout='psi' ; files=('gyres') ;;
'usalc') dirout='saltc' ; files=('sal_0-300m') ;;
'temp_lev') dirout='temp_lev'${level1}-${level2} ; files=('temp_lev'${level1}-${level2}) ;;
'sal_lev') dirout='sal_lev'${level1}-${level2} ; files=('sal_lev'${level1}-${level2}) ;;
'lmsalc') dirout='saltc' ; files=('sal_300-5400m') ;;
'ohc_specified_layer') dirout='heatc' ; files=('ohc_2d_avg_0-300m' 'ohc_2d_avg_300-800m') ;;
'vert_Tsections') dirout='sections' ; files=('temp_0N' 'temp_45N' 'temp_45S' 'temp_30W' 'temp_80E' 'temp_180E') ;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment