ACIS XML-RPC Examples (Python)

Initialize connection

import xmlrpclib
serv = xmlrpclib.ServerProxy('http://acis-rpc-dev.dri.edu')

Get station metadata, in JSON

print serv.getMetaForStn('--stn 518422 --stntype coop')
{ "code": 200, 
  "data": 
    {"21904": 
	{
	"ucan_id": 21904,
	"gmt_offset": 10.0,
	"name": "PUUKOHOLA HEIAU 98.1",
	"lat": 20.02861,
	"lon": -155.82472,
	"elev": 133.0,
	"county": "Hawaii",
	"clim_div": "06",
	"id_type_key_seq": [2, 7],
	"postal": "HI" }
    }
}

Get station metadata with variable statistics "--varstats" (default: tmax, tmin, prcp)

print serv.getMetaForStn('--stn 518422 --stntype coop --varstats')
{
    "code": 200,
    "data":
	{"21904":
	    {
		"ucan_id": 21904, 
		"gmt_offset": 10.0, 
		"name": "PUUKOHOLA HEIAU 98.1", 
		"lat": 20.02861, 
		"lon": -155.82472, 
		"elev": 133.0, 
		"county": "Hawaii", 
		"clim_div": "06", 
		"id_type_key_seq": [2, 7], 
		"postal": "HI", 
		"prcp_total_count": 11839, 
		"prcp_valid_count": 11422, 
		"prcp_invalid_count": 417, 
		"prcp_largest_valid": 1267, 
		"prcp_largest_invalid": 291, 
		"prcp_valid_start": "1977/01/01", 
		"prcp_valid_end": "2009/06/01", 
		"tmax_total_count": 11839, 
		"tmax_valid_count": 10951, 
		"tmax_invalid_count": 888, 
		"tmax_largest_valid": 373, 
		"tmax_largest_invalid": 291, 
		"tmax_valid_start": "1977/01/01", 
		"tmax_valid_end": "2009/06/01",
		"tmin_total_count": 11839, 
		"tmin_valid_count": 10860, 
		"tmin_invalid_count": 979, 
		"tmin_largest_valid": 348, 
		"tmin_largest_invalid": 291, 
		"tmin_valid_start": "1977/01/01",
		"tmin_valid_end": "2009/06/01", 
	    }
	}
}

Get COOP data, tab-separated

print serv.getDailyData('--stn 518422 --stntype coop --var tmax,tmin,prcp --format tab --start 20010101 --end 20010111')
stn	stntype	date	tmax	tmax_flag	tmin	tmin_flag	prcp	prcp_flag
518422	coop	2001/01/01	76.0		64.0		0.00	
518422	coop	2001/01/02	78.0		64.0		0.01	
518422	coop	2001/01/03	77.0		64.0		0.04	
518422	coop	2001/01/04	78.0		64.0		0.05	
518422	coop	2001/01/05	76.0		60.0		0.00	
518422	coop	2001/01/06	78.0		61.0		0.00	
518422	coop	2001/01/07	78.0		61.0		0.00	
518422	coop	2001/01/08	78.0		61.0		0.00	
518422	coop	2001/01/09	77.0		64.0		0.00	
518422	coop	2001/01/10	78.0		65.0		0.00	

Get Multi-station data, in JSON

print serv.getDailyData('--stn SRKN2,266779 --stntype shef,coop --var tmax,tmin,prcp --format json')
{	"code": 200, 
	"data": {
	    "dates": [[2009, 3, 26], [2009, 3, 27], [2009, 3, 28], [2009, 3, 29], [2009, 3, 30], [2009, 3, 31], [2009, 4, 1]], 
	    "266779": {
		"code": 200, 
		"stntype": "coop", 
		"prcp_code": 200, 
		"prcp": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
		"prcp_flag": ["", "", "", "", "", "", ""], 
		"prcp_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
		"tmax_code": 200, 
		"tmax": [54.0, 63.0, 73.0, 54.0, 54.0, 64.0, 64.0], 
		"tmax_flag": ["", "", "", "", "", "", ""], 
		"tmax_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
		"tmin_code": 200
		"tmin": [38.0, 30.0, 33.0, 32.0, 26.0, 29.0, 39.0], 
		"tmin_flag": ["", "", "", "", "", "", ""], 
		"tmin_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
		}, 
	    "SRKN2": {
		"code": 200, 
		"stntype": "shef", 
		"prcp_code": 200, 
		"prcp": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
		"prcp_flag": ["", "", "", "", "", "", ""], 
		"prcp_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
		"tmax_code": 200, 
		"tmax": [61.0, 66.0, 72.0, 52.0, 52.0, 56.0, 63.0], 
		"tmax_flag": ["", "", "", "", "", "", ""], 
		"tmax_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
		"tmin_code": 200
		"tmin": [43.0, 26.0, 28.0, 34.0, 23.0, 26.0, 37.0], 
		"tmin_flag": ["", "", "", "", "", "", ""], 
		"tmin_valid_flag": [1, 1, 1, 1, 1, 1, 1], 
	    }
	}
    }

Get WRCC daily data, in CSV

print serv.getDailyData('--stn nnsc --stntype wrcc --var tmax,tmin,prcp --format csv')
stn,stntype,date,tmax,tmax_flag,tmin,tmin_flag,prcp,prcp_flag
nnsc,wrcc,2009/03/26,50.7,,35.5,,0.00,
nnsc,wrcc,2009/03/27,60.8,,33.2,,0.00,
nnsc,wrcc,2009/03/28,67.4,,35.4,,0.00,
nnsc,wrcc,2009/03/29,49.6,,28.6,,0.00,
nnsc,wrcc,2009/03/30,50.3,,24.7,,0.00,
nnsc,wrcc,2009/03/31,58.5,,31.3,,0.00,
nnsc,wrcc,2009/04/01,59.5,,35.4,,0.00,

GET WRCC CRN data

CRN data is summarized from 5-minute data. If any of the 5-minute data is missing, a missing value will be returned for the entire day. To override this behavior, use the --allow-incomplete option to ignore missing data values.

print serv.getDailyData('--stn rmrc --stntype wrcc --var tmax,tmin,prcp --format tab --start 20070101 --end 20070130')

stn	stntype	date	tmax	tmax_flag	tmin	tmin_flag	prcp	prcp_flag
rmrc	wrcc	2007/01/01	54.9		27.0		0.00	
rmrc	wrcc	2007/01/02	56.8		38.1		0.00	
rmrc	wrcc	2007/01/03	59.0		33.3		0.00	
rmrc	wrcc	2007/01/04	62.8		27.7		0.04	
rmrc	wrcc	2007/01/05	41.7		26.2		0.00	
rmrc	wrcc	2007/01/06	45.0		22.3		0.00	
rmrc	wrcc	2007/01/07	53.8		33.8		0.00	
rmrc	wrcc	2007/01/08	63.3		35.1		0.00	
rmrc	wrcc	2007/01/09	62.2		34.5		0.00	
rmrc	wrcc	2007/01/10	57.0		30.4		0.00	
rmrc	wrcc	2007/01/11	57.6		32.5		0.00	
rmrc	wrcc	2007/01/12	34.7		20.1		0.00	
rmrc	wrcc	2007/01/13	32.0		16.7		0.00	
rmrc	wrcc	2007/01/14	36.1		15.6		0.00	
rmrc	wrcc	2007/01/15	41.4		21.0		0.00	
rmrc	wrcc	2007/01/16	47.3		21.9		0.00	
rmrc	wrcc	2007/01/17	45.9		17.6		0.00	
rmrc	wrcc	2007/01/18	54.0		31.8		0.00	
rmrc	wrcc	2007/01/19	54.9		29.8		0.00	
rmrc	wrcc	2007/01/20	56.3		29.1		0.00	
rmrc	wrcc	2007/01/21	45.0		27.9		0.00	
rmrc	wrcc	2007/01/22	51.6		30.2		0.00	
rmrc	wrcc	2007/01/23	63.3		30.6		0.00	
rmrc	wrcc	2007/01/24	64.0		37.0		0.00	
rmrc	wrcc	2007/01/25	62.1		31.6		0.00	
rmrc	wrcc	2007/01/26	61.0		26.1		0.00	
rmrc	wrcc	2007/01/27	57.7		27.0		0.00	
rmrc	wrcc	2007/01/28	57.0		31.3		0.00	
rmrc	wrcc	2007/01/29	59.2		39.4		0.00