tpreprocess.sh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tpreprocess.sh (4657B)
       ---
            1 #!/bin/bash
            2 
            3 # Copyright (C) 2009-2014, 2016, 2017, 2018, 2019, 2020 The PISM Authors
            4 
            5 # Downloads SeaRISE "Present Day Greenland" master dataset NetCDF file, adjusts
            6 # metadata, and saves under new name ready for PISM.  See README.md.
            7 
            8 # depends on wget and NCO (ncrename, ncap2, ncatted, ncpdq, ncks; see
            9 # http://nco.sourceforge.net/)
           10 
           11 set -e  # exit on error
           12 
           13 echo "# =================================================================================="
           14 echo "# PISM std Greenland example: preprocessing"
           15 echo "# =================================================================================="
           16 echo
           17 
           18 # get file; see page http://websrv.cs.umt.edu/isis/index.php/Present_Day_Greenland
           19 DATAVERSION=1.1
           20 DATAURL=http://websrv.cs.umt.edu/isis/images/a/a5/
           21 DATANAME=Greenland_5km_v$DATAVERSION.nc
           22 
           23 echo "fetching master file ... "
           24 wget -nc ${DATAURL}${DATANAME}   # -nc is "no clobber"
           25 echo "  ... done."
           26 echo
           27 
           28 PISMVERSION=pism_$DATANAME
           29 echo -n "creating bootstrapable $PISMVERSION from $DATANAME ... "
           30 # copy the vars we want, and preserve history and global attrs
           31 ncks -O -v mapping,lat,lon,bheatflx,topg,thk,presprcp,smb,airtemp2m $DATANAME $PISMVERSION
           32 # convert from water equivalent thickness rate ("m year-1") to "kg m-2 year-1".
           33 # Assumes water density of 1000.0 kg m-3
           34 ncap2 -O -s "precipitation=presprcp*1000.0" $PISMVERSION $PISMVERSION
           35 ncatted -O -a units,precipitation,m,c,"kg m-2 year-1" $PISMVERSION
           36 ncatted -O -a long_name,precipitation,c,c,"mean annual precipitation rate" $PISMVERSION
           37 # delete incorrect standard_name attribute from bheatflx; there is no known standard_name
           38 ncatted -a standard_name,bheatflx,d,, $PISMVERSION
           39 # use pism-recognized name for 2m air temp
           40 ncrename -O -v airtemp2m,ice_surface_temp $PISMVERSION
           41 ncatted -O -a units,ice_surface_temp,c,c,"Celsius" $PISMVERSION
           42 # use pism-recognized name and standard_name for surface mass balance, after
           43 # converting from liquid water equivalent thickness per year to [kg m-2 year-1]
           44 ncap2 -O -s "climatic_mass_balance=1000.0*smb" $PISMVERSION $PISMVERSION
           45 # Note: The RACMO field smb has value 0 as a missing value, unfortunately,
           46 # everywhere the ice thickness is zero.  Here we replace with 1 m a-1 ablation.
           47 # This is a *choice* of the model of surface mass balance in thk==0 areas.
           48 ncap2 -O -s "where(thk <= 0.0){climatic_mass_balance=-1000.0;}" $PISMVERSION $PISMVERSION
           49 ncatted -O -a standard_name,climatic_mass_balance,m,c,"land_ice_surface_specific_mass_balance_flux" $PISMVERSION
           50 ncatted -O -a units,climatic_mass_balance,m,c,"kg m-2 year-1" $PISMVERSION
           51 # de-clutter by only keeping vars we want
           52 ncks -O -v mapping,lat,lon,bheatflx,topg,thk,precipitation,ice_surface_temp,climatic_mass_balance \
           53   $PISMVERSION $PISMVERSION
           54 # add projection information
           55 ncatted -O -a proj,global,c,c,"+proj=stere +lat_0=90 +lat_ts=71 +lon_0=-39 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" $PISMVERSION
           56 ncap2 -A \
           57       -s 'land_ice_area_fraction_retreat=0 * thk' \
           58       -s 'where(thk > 0 || topg > 0) land_ice_area_fraction_retreat=1' \
           59       -s 'land_ice_area_fraction_retreat@units="1"' \
           60       $PISMVERSION $PISMVERSION
           61 ncatted -a standard_name,land_ice_area_fraction_retreat,d,, $PISMVERSION
           62 
           63 echo "done."
           64 echo
           65 
           66 # extract paleo-climate time series into files suitable for option
           67 # -atmosphere ...,delta_T
           68 TEMPSERIES=pism_dT.nc
           69 echo -n "creating paleo-temperature file $TEMPSERIES from $DATANAME ... "
           70 ncks -O -v oisotopestimes,temp_time_series $DATANAME $TEMPSERIES
           71 ncrename -O -d oisotopestimes,time      $TEMPSERIES
           72 ncrename -O -v temp_time_series,delta_T $TEMPSERIES
           73 ncrename -O -v oisotopestimes,time      $TEMPSERIES
           74 # reverse time dimension
           75 ncpdq -O --rdr=-time $TEMPSERIES $TEMPSERIES
           76 # make times follow same convention as PISM
           77 ncap2 -O -s "time=-time" $TEMPSERIES $TEMPSERIES
           78 ncatted -O -a units,time,m,c,"years since 1-1-1" $TEMPSERIES
           79 ncatted -O -a calendar,time,c,c,"365_day" $TEMPSERIES
           80 ncatted -O -a units,delta_T,m,c,"Kelvin" $TEMPSERIES
           81 echo "done."
           82 echo
           83 
           84 # extract paleo-climate time series into files suitable for option
           85 # -sea_level ...,delta_SL
           86 SLSERIES=pism_dSL.nc
           87 echo -n "creating paleo-sea-level file $SLSERIES from $DATANAME ... "
           88 ncks -O -v sealeveltimes,sealevel_time_series $DATANAME $SLSERIES
           89 ncrename -O -d sealeveltimes,time $SLSERIES
           90 ncrename -O -v sealeveltimes,time $SLSERIES
           91 ncrename -O -v sealevel_time_series,delta_SL $SLSERIES
           92 # reverse time dimension
           93 ncpdq -O --rdr=-time $SLSERIES $SLSERIES
           94 # make times follow same convention as PISM
           95 ncap2 -O -s "time=-time" $SLSERIES $SLSERIES
           96 ncatted -O -a units,time,m,c,"years since 1-1-1" $SLSERIES
           97 ncatted -O -a calendar,time,c,c,"365_day" $SLSERIES
           98 echo "done."
           99 echo
          100