import matplotlib.pyplot as pyplot import scikits.hydroclimpy.plotlib as cpl # """ Importing the rainfall information ================================== Let's import the rainfall data for Athens, GA. As we already know from a previous :ref:`section <examples_wweatherdata>`, the COAPS identification code for this is 90435. The :func:`coaps.load_coaps_data` function returns a series with a structured dtype, but we only need to take the ``'rain'`` field. """ weatherdata = coaps.load_coaps_data(90435) rainfall = weatherdata['rain'] """ We can check the frequency of the series and its dates range: >>> print rainfall.freqstr 'D' >>> print rainfall.dates[[0,-1]] [13-Jan-1944 31-Dec-2007] """ print rainfall.freqstr print rainfall.dates[[0,-1]] """ Importing the streamflow information
import numpy as np import numpy.ma as ma import scikits.hydroclimpy as hydro import scikits.hydroclimpy.io.coaps as coaps import scikits.hydroclimpy.enso as enso stationdict = coaps.ids_bystate('GA') stationid = [v for (k, v) in stationdict.items() if 'Athens' in k.capitalize()] print stationid data = coaps.load_coaps_data(90435) rainfall = data['rain'] print rainfall.freqstr print rainfall.dates[[0,-1]] mrainfall = rainfall.convert('M',func=ma.sum) arainfall = mrainfall.convert('A') assert(arainfall.shape == (64, 12)) monthly_means = arainfall.mean(axis=0).round(1) print monthly_means """ [ 115.9 112.4 130.8 94.1 99.4 103.5 122.3 90.2 94.5 77.8 92.7 98.6]""" ONI = enso.load_oni() print ONI.dates[[0,-1]] """ [Jan-1950 Dec-2008]"""
(-82.82, 31.52, '92783', 'Douglas'), (-82.80, 31.02, '94429', 'Homerville'), ] COAPS_SW = [(-84.12, 31.52, '90140', 'Albany'), (-84.18, 31.79, '91500', 'Camilla'), (-84.77, 31.17, '92153', 'Colquitt'), (-84.77, 31.77, '92450', 'Cuthbert')] ndtype = np.dtype([('lon', float), ('lat', float), ('site_no', '|S5'), ('desc', '|S20')]) COAPS_SE = np.array(COAPS_SE, dtype=ndtype) COAPS_SW = np.array(COAPS_SW, dtype=ndtype) end_date = climpy.Date('D', '2009-02-28') COAPS_data = {} for site_no in itertools.chain(COAPS_SE['site_no'], COAPS_SW['site_no']): data = coaps.load_coaps_data(site_no)['rain'] data = data.fill_missing_dates() COAPS_data[site_no] = data.adjust_endpoints(end_date=end_date) table_template = [] csc = "*" separator = csc.join(['-'*7, '-'*21, '-'*12, '-'*6, '-'*6, '-'*9]) for region in (COAPS_SW, COAPS_SE): table_template.append("%s%s%s" % (csc, separator, csc)) for (site_no, desc) in zip(region['site_no'], region['desc']): data = COAPS_data[site_no] start_date = data.dates[0].strfmt("%m/%d/%Y") mdata = extras.accept_atmost_missing(data.convert('M'), 0.1) nbtotal = len(mdata) nbvalid = mdata.any(-1).filled(False).sum() row = csc.join([" %5s " % site_no, "%20s " % desc,
import matplotlib.pyplot as pyplot import scikits.hydroclimpy.plotlib as cpl # """ Importing the rainfall information ================================== Let's import the rainfall data for Athens, GA. As we already know from a previous :ref:`section <examples_wweatherdata>`, the COAPS identification code for this is 90435. The :func:`coaps.load_coaps_data` function returns a series with a structured dtype, but we only need to take the ``'rain'`` field. """ weatherdata = coaps.load_coaps_data(90435) rainfall = weatherdata['rain'] """ We can check the frequency of the series and its dates range: >>> print rainfall.freqstr 'D' >>> print rainfall.dates[[0,-1]] [13-Jan-1944 31-Dec-2007] """ print rainfall.freqstr print rainfall.dates[[0, -1]] """ Importing the streamflow information ====================================