Skip to content

Instantly share code, notes, and snippets.

@drj11
Created September 22, 2012 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drj11/3766130 to your computer and use it in GitHub Desktop.
Save drj11/3766130 to your computer and use it in GitHub Desktop.
#!/bin/sh
# execute with:
# curl https://raw.github.com/gist/3766130/ccc-gistemp-ushcn-minmax | sh
set -e
REVISION=1019
D=r${REVISION}-ccc-gistemp
svn co -r $REVISION https://ccc-gistemp.googlecode.com/svn/trunk $D
cd $D
mkdir -p input
export METADATA=input/ushcn_proxy_metadata.csv
if ! test -f "$METADATA"
then
echo "Please download $METADATA and try again"
exit 4
fi
# to get data and metadata
tool/fetch.py min.ushcnv2 max.ushcnv2 ushcn-v2-stations.txt
# Convert metadata file to form suitable for ccc-gistemp:
python -c 'import csv, os
f=csv.reader(open(os.environ["METADATA"], "U"));f.next()
for row in f: row[0]="%06d" % int(row[0]); print "%s,%s"%(row[0],row[16])' > input/bright
dorun () {
# do a run
if ! [ "$1" ]
then
return 4
fi
python tool/run.py -p "augment_metadata=input/bright=uid,nightlight;USHCN_convert_id=false;data_sources=$1.ushcnv2;USHCN_meta=ushcn-v2-stations.txt;work_file_format=v3;rural_designator=nightlight <= 14" -s0-2
mv log $1-log
mv work $1-work
mv result $1-result
}
dorun min
dorun max
awk '/action.*rural/{print $1}' max-log/step2.log > rural.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment