htmie

Optical properties of water droplets
git clone git://git.meso-star.fr/htmie.git
Log | Files | Refs | README | LICENSE

dump_netcdf_data.sh (1294B)


      1 #!/bin/sh -e
      2 
      3 # Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com)
      4 # Copyright (C) 2018 Centre National de la Recherche Scientifique
      5 # Copyright (C) 2018 Université Paul Sabatier
      6 #
      7 # This program is free software: you can redistribute it and/or modify
      8 # it under the terms of the GNU General Public License as published by
      9 # the Free Software Foundation, either version 3 of the License, or
     10 # (at your option) any later version.
     11 #
     12 # This program is distributed in the hope that it will be useful,
     13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     15 # GNU General Public License for more details.
     16 #
     17 # You should have received a copy of the GNU General Public License
     18 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
     19 
     20 if [ $# -lt 2 ]; then
     21   printf "usage: %s variable netcdf\n" "${0##*/}" >&2
     22   exit 1
     23 fi
     24 
     25 if [ ! -f "$2" ]; then
     26   printf "\"%s\" is not a valid file\n" "$2"
     27   exit 1
     28 fi
     29 
     30 name=${2##*/}
     31 name=${name%.*}
     32 
     33 blanks="[[:space:]]\{0,\}"
     34 
     35 ncdump -v "$1" "$2" \
     36   | sed -n "/^${blanks}data:${blanks}/,\$p" \
     37   | sed -n "/^${blanks}$1${blanks}=/,\$p" \
     38   | sed "s/^${blanks}$1${blanks}=${blanks}//g" \
     39   | sed "s/[;} ]//g" \
     40   | sed "s/,/\n/g" \
     41   | sed "/^${blanks}$/d"
     42