figdir = '/home/jthom/public_html/images/lostcreek/' # OPERATIONAL ------------------------------------------------------------------------ import matplotlib.pyplot as plt from matplotlib.dates import HourLocator, DateFormatter import numpy as np import pandas as pd import xray from record2xray import record2xray today = datetime.now() tminus5 = today - timedelta(5) TsliceE = today.strftime('%Y-%m-%d') TsliceB = tminus5.strftime('%Y-%m-%d') filename = today.strftime( 'http://flux.aos.wisc.edu/data/lcreek-raw/%Y/flux/lcreek%Y_flux.txt') flptr = urllib2.urlopen(filename) data = flux_read(flptr) flptr.close() datax = record2xray(data) for var in plotvars: fig, ax = plt.subplots() datax.sel(varname=var, time=slice(TsliceB, TsliceE)).plot(marker='.') ax.xaxis.set_major_formatter(DateFormatter("%m/%d-%H")) plt.savefig(figdir + var + '.png', dpi=100) plt.close()
import xray from dataread import * from record2xray import record2xray # get files for the last two days of data data=[] for i in range(2,-1,-1): datesearch=today-timedelta(days=i) filesearch=datesearch.strftime('*met_data*%Y_%m_%d*.dat') files=glob(datadir + filesearch) for fn in files: filedata=toa5head(fn) data.extend(filedata) datax=record2xray(data) for i,xvar in enumerate(plotvars): fig,ax=plt.subplots() for var in xvar: try: datax.sel(varname=var).plot(marker='.',label=var) except: print var ax.xaxis.set_major_formatter(DateFormatter("%m/%d-%H")) plt.title(plotname[i]) ax.legend(loc='best',fontsize='x-small') plt.savefig(figdir + plotname[i] + '.png', dpi=100) plt.close(fig)