Skip to content

Instantly share code, notes, and snippets.

Avatar

Cheewai cynici

  • Takealot
  • Pretoria, South Africa
View GitHub Profile
@cynici
cynici / gist:2249169
Created Mar 30, 2012
Directory watcher as a Windows service using ActivePython
View gist:2249169
# 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 Apr 12, 2018
De-duplicate MODIS fire pixels in CSV format downloaded from FIRMS
View modis_dedup_firms_csv.py
#!/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 Oct 7, 2015
Convert MODIS MOD14 active fire HDFv4 to CSV
View mod14hdf4_to_fireloc.py
#!/usr/bin/env python
#
# Author: cheewai.lai@gmail.com
# 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 Oct 12, 2015
Monitor directories and take action on new files, for Python 2.7+
@cynici
cynici / optparse_formatter.py
Created Nov 16, 2012
Python optparse custom description formatter
View optparse_formatter.py
'''
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 Nov 23, 2012
MODIS dbvm user script to run mod14hdf4_to_fireloc.py
View run_user.bash
#!/bin/bash
#
# Sample Script for User Defined Processing in DBVM
# Liam.Gumley@ssec.wisc.edu
# Place this file in $DBVM_HOME/user/
#
echo
echo "Creating User Defined Products; started at "$(date -u)
@cynici
cynici / urllist
Last active Oct 13, 2015
MODIS: Files to download into $DBVM_HOME/tarfiles/ using aria2c
View urllist
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 Oct 13, 2015
Harvest Wunderground.com weather stations in a specific country
View wunderground-harvest-stations.py
#!/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 Dec 5, 2012
Get weather data from Wunderground stations listed in input JSON and output to a CSV file
View http-get-wunderground.py
#!/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 Dec 6, 2012
NPP: Run DRL software for NPP raw data to produce truecolor GeoTiff image
View run_drl.sh
#! /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