Skip to content

Instantly share code, notes, and snippets.

View cynici's full-sized avatar

Cheewai cynici

View GitHub Profile
@cynici
cynici / gist:2249169
Created March 30, 2012 08:00
Directory watcher as a Windows service using ActivePython
# Adapted from http://pypi.python.org/pypi/watchdog
import sys, os, re
import time
import logging
from optparse import OptionParser
import subprocess
from watchdog.observers import Observer
import watchdog.events
import pythoncom
@cynici
cynici / modis_dedup_firms_csv.py
Last active April 12, 2018 05:47
De-duplicate MODIS fire pixels in CSV format downloaded from FIRMS
#!/usr/bin/env python
import sys, os, re
import datetime, time
import csv
import psycopg2, psycopg2.extras
import logging
logger = logging.getLogger(__name__)
help_text = """De-duplicate MODIS fire downloaded from FIRMS in CSV format.
@cynici
cynici / mod14hdf4_to_fireloc.py
Last active October 7, 2015 20:50
Convert MODIS MOD14 active fire HDFv4 to CSV
#!/usr/bin/env python
#
# Author: [email protected]
# Version: 20130307c
# Source: https://gist.github.com/cynici/3223681
# Requires: pyHDF
#
# To install pyHDF on Ubuntu 11+, adapt these instructions accordingly:
# https://gist.github.com/1408088
@cynici
cynici / .gitignore
Last active October 12, 2015 19:38
Monitor directories and take action on new files, for Python 2.7+
.pyc
@cynici
cynici / optparse_formatter.py
Created November 16, 2012 05:46
Python optparse custom description formatter
'''
optparse offers IndentedHelpFormatter() and TitledHelpFormatter() but they don't honor the newlines embedded in the description string.
author: Tim Chase
source: https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/bfbmtUGhW8I
usage: parser = OptionParser(description=help_text, formatter=IndentedHelpFormatterWithNL())
'''
from optparse import OptionParser, IndentedHelpFormatter, textwrap
@cynici
cynici / run_user.bash
Created November 23, 2012 05:52
MODIS dbvm user script to run mod14hdf4_to_fireloc.py
#!/bin/bash
#
# Sample Script for User Defined Processing in DBVM
# [email protected]
# Place this file in $DBVM_HOME/user/
#
echo
echo "Creating User Defined Products; started at "$(date -u)
@cynici
cynici / urllist
Last active October 13, 2015 03:47
MODIS: Files to download into $DBVM_HOME/tarfiles/ using aria2c
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/AIRS_linux_v5.2.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/AIRS_store_v5.2.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/DEM30ARC.tar
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/STD30ARC.tar
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/AIRS_anc_avhrr.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/AIRS/v5524/AIRS_anc_myd11.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/MODIS/hidden/modisl2_v2.2/IMAPP_MODISL2_V2.2.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/MODIS/hidden/modisl2_v2.1/IMAPP_MODISL2_V2.1_MOD06OD_COEFF.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/MODIS/hidden/dbge/dbge_v1.2/dbge_v1.2.tar.gz
ftp://ftp.ssec.wisc.edu/pub/IMAPP/MODIS/hidden/destripe/destripe_v1.1/DESTRIPE_V1.1.tar.gz
@cynici
cynici / wunderground-harvest-stations.py
Last active October 13, 2015 13:27
Harvest Wunderground.com weather stations in a specific country
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
from optparse import OptionParser
import string
import urllib2
import simplejson
import logging
help_text = """usage: %prog [options] ISO_country_code ...
@cynici
cynici / http-get-wunderground.py
Created December 5, 2012 05:44
Get weather data from Wunderground stations listed in input JSON and output to a CSV file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
from optparse import OptionParser
import string
import urllib2
import simplejson
import logging
from datetime import datetime
import time
@cynici
cynici / run_drl.sh
Created December 6, 2012 13:09
NPP: Run DRL software for NPP raw data to produce truecolor GeoTiff image
#! /bin/bash
#
# Use DRL software suite to process NPP data and produce
# geolocated truecolor GeoTiff image
#
if [ $# -lt 1 ] || [ ! -f "$1" ]; then
echo "usage: $0 NPP_DAT" >&2
exit 1