sigma to pressure?
Added by Gerd Buerger about 14 years ago
Hi,
is there an easy way to convert sigma to pressure levels using cdo? There is ml2pl but that assumes hybrid coordinates.
Gerd
Replies (3)
RE: sigma to pressure? - Added by Uwe Schulzweida about 14 years ago
Hi Gerd,
no, we don't have a sigma to pressure levels converter in CDO.
Regards,
Uwe
RE: sigma to pressure? - Added by Luke Davis over 2 years ago
I know this thread is ancient but any chance this could be added? The FGOALS models in CMIP5 and CMIP6 both use pure sigma coordinates and are the only one I'm having trouble interpolating.
RE: sigma to pressure? - Added by Luke Davis over 2 years ago
For posterity (and anyone coming across this thread) here's a bash function that can translate FGOALS model output to hybrid coordinates compatible with cdo ml2pl
. The file should have sigma coordinates lev
, coordinate boundaries lev_bnds
(these can also be generated using ncap2 -s '<other_math>; lev_bnds = make_bounds(lev, $bnds, "lev_bnds")'
, surface pressure ps
, and model top pressure ptop
.
sigma_to_hybrid() {
for file in "$@"; do
ncap2 -O -s '
b[$lev] = lev;
ap[$lev] = (1 - lev) * ptop;
b_bnds[$lev, $bnds] = lev_bnds;
ap_bnds[$lev, $bnds] = (1 - lev_bnds) * ptop;
' "$file" "$file" \
&& ncatted -O \
-a long_name,lev,o,c,"atmospheric model level" \
-a standard_name,lev,o,c,"atmosphere_hybrid_sigma_pressure_coordinate" \
-a formula,lev,o,c,"p = ap + b*ps" \
-a formula_terms,lev,o,c,"ap: ap b: b ps: ps" \
-a long_name,lev_bnds,o,c,"atmospheric model level bounds" \
-a standard_name,lev_bnds,o,c,"atmosphere_hybrid_sigma_pressure_coordinate" \
-a formula,lev_bnds,o,c,"p = ap + b*ps" \
-a formula_terms,lev_bnds,o,c,"ap: ap_bnds b: b_bnds ps: ps" \
-a ,ap,d,, -a ,b,d,, -a ,ap_bnds,d,, -a ,b_bnds,d,, \
-a long_name,ap,o,c,"vertical coordinate formula term: ap(k)" \
-a long_name,b,o,c,"vertical coordinate formula term: b(k)" \
-a long_name,ap_bnds,o,c,"vertical coordinate formula term: ap(k+1/2)" \
-a long_name,b_bnds,o,c,"vertical coordinate formula term: b(k+1/2)" \
"$file" "$file" \
&& ncks -C -O -x -v ptop "$file" "$file" \
|| echo "Warning: Failed to translate file '$file'."
done
}
This is the relevant output of ncdump -h
before interpolation:
$ ncdump -h tmp_sig.nc
double lev(lev) ;
lev:bounds = "lev_bnds" ;
lev:axis = "Z" ;
lev:positive = "down" ;
lev:long_name = "sigma coordinate" ;
lev:standard_name = "atmosphere_sigma_coordinate" ;
lev:formula = "p = ptop + sigma*(ps - ptop)" ;
lev:formula_terms = "ptop: ptop sigma: lev ps: ps" ;
double lev_bnds(lev, bnds) ;
lev_bnds:formula = "p = ptop + sigma*(ps - ptop)" ;
lev_bnds:standard_name = "atmosphere_sigma_coordinate" ;
lev_bnds:units = "" ;
lev_bnds:formula_terms = "ptop: ptop sigma: lev_bnds ps: ps" ;
double ptop ;
ptop:long_name = "pressure at top of model" ;
ptop:units = "Pa" ;
float ps(time, lat, lon) ;
ps:long_name = "Surface Air Pressure" ;
ps:units = "Pa" ;
This is the relevant output after interpolation with sigma_to_hybrid
:
$ cp tmp_sig.nc tmp_sig_repair.nc
$ sigma_to_hybrid tmp_sig_repair.nc
$ ncdump -h tmp_sig_repair.nc
double ap(lev) ;
ap:long_name = "vertical coordinate formula term: ap(k)" ;
double ap_bnds(lev, bnds) ;
ap_bnds:long_name = "vertical coordinate formula term: ap(k+1/2)" ;
double b(lev) ;
b:long_name = "vertical coordinate formula term: b(k)" ;
double b_bnds(lev, bnds) ;
b_bnds:long_name = "vertical coordinate formula term: b(k+1/2)" ;
double lev(lev) ;
lev:bounds = "lev_bnds" ;
lev:axis = "Z" ;
lev:positive = "down" ;
lev:long_name = "atmospheric model level" ;
lev:standard_name = "atmosphere_hybrid_sigma_pressure_coordinate" ;
lev:formula = "p = ap + b*ps" ;
lev:formula_terms = "ap: ap b: b ps: ps" ;
double lev_bnds(lev, bnds) ;
lev_bnds:formula = "p = ap + b*ps" ;
lev_bnds:standard_name = "atmosphere_hybrid_sigma_pressure_coordinate" ;
lev_bnds:units = "" ;
lev_bnds:formula_terms = "ap: ap_bnds b: b_bnds ps: ps" ;
lev_bnds:long_name = "atmospheric model level bounds" ;
Then cdo ml2pl
works with the repaired file:
$ cdo ml2pl,100000/20000/-20000 tmp_sig_repair.nc tmp_sig_vert.nc
$ ncdump -h tmp_sig_vert.nc
double plev(plev) ;
plev:standard_name = "air_pressure" ;
plev:long_name = "pressure" ;
plev:units = "Pa" ;
plev:positive = "down" ;
plev:axis = "Z" ;
tmp_sig.nc (1.5 MB) tmp_sig.nc | |||
tmp_sig_repair.nc (1.51 MB) tmp_sig_repair.nc | |||
tmp_sig_vert.nc (350 KB) tmp_sig_vert.nc |