Created
March 17, 2014 23:16
-
-
Save edouard-lopez/9610352 to your computer and use it in GitHub Desktop.
GRIB2 installation of environnement and conversion to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env make | |
# DESCRIPTION | |
# GRIB2 installation of environnement and conversion | |
# see: https://gis.stackexchange.com/questions/26356/conversion-of-grib-and-netcdf-to-my-database | |
# | |
# USAGE | |
# make extract-data | |
# | |
# @author: Édouard Lopez <dev+mec@edouard-lopez.com> | |
gribFile=FranceHD10-grib2.grb | |
csvFile=FranceHD10-grib2.csv | |
csvFilteredFile=FranceHD10-grib2.light.csv | |
binDir=wgrib2-v0.1.9.4/bin | |
binFile=${binDir}/wgrib2 | |
default: extract-data | |
# alias | |
install: wgrib2-v0.1.9.4/bin/wgrib2 | |
get-data: ${gribFile} | |
convert2csv: ${csvFile} | |
extract-data: ${csvFilteredFile} | |
# @alias: extract-data | |
# Select only interesting data (considerably reduce file size) | |
${csvFilteredFile}: ${csvFile} | |
@echo "Select only interesting data (considerably reduce file size)" | |
@awk 'BEGIN {FS=OFS=","} {print $$3,$$5,$$6,$$7}' ${csvFile} > ${csvFilteredFile} | |
# @alias: convert2csv | |
# Convert GRIB2 file to CSV | |
${csvFile}: ${binFile} ${gribFile} | |
@echo "Convert GRIB2 file to CSV" | |
wgrib2 ${gribFile} -csv ${csvFile} | |
# @alias: get-data | |
# Get GRIB2 file dynamically | |
${gribFile}: | |
@echo "Get GRIB2 file dynamically" | |
@echo "add a curl/wget command here" | |
# @alias: install | |
# Install executable if missing | |
${binFile}: | |
@echo "Install executable if missing" | |
@wget --quiet http://freefr.dl.sourceforge.net/project/opengrads/wgrib2/0.1.9.4/wgrib2-v0.1.9.4-bin-i686-glib2.5-linux-gnu.tar.gz | |
@tar xvzf wgrib2-v0.1.9.4-bin-i686-glib2.5-linux-gnu.tar.gz | |
clean: | |
rm -rf ${csvFile} ${csvFilteredFile} ${binDir}/* | |
# @clear | |
echo "Cleaning Environment" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear Edouard,
Do you know any way or script that can convert a GRIB file to CSV file ?
Thank you for your kind help