def makeHistogram (paramIndex): filename = "sites-" + ambient.parameterNames [paramIndex].translate (str.maketrans (" ", "-")) + ".histogram.pdf" filename = filename.lower () title = "Normalized " + ambient.parameterNames [paramIndex] #get a list of seeing days, 1 Days object for each site sites = [] for siteRange in args.indirs: sites.append (ambient.Days (os.path.join (siteRange.path, ambient.parameterBasenames [paramIndex] + ".orig"), args.start_date, args.stop_date)) pages = PdfPages (os.path.join (args.outdir, filename)) fig = plt.figure () ax = fig.add_subplot (1, 1, 1) ax.set_color_cycle (['b','r','g','m','c','y']) datasets = [] labels = [] #for each site, add a list of values to "datasets" #also make a corresponding list of labels based on site dir names for site, siteRange in zip (sites, [siteRange for siteRange in args.indirs]): labels.append (siteRange) datasets.append ([]) dayList = ambient.dayListFromRange (site, siteRange.startDate, siteRange.stopDate) for day in dayList: if day: func = day.periodFilter (args.start_minutes * 60, args.stop_minutes * 60, args.past_midnight) filtered = filter (func, day.measurements) datasets [-1].extend ([m [1] for m in filtered]) ax.hist (datasets, bins=args.num_bins, label=labels, normed=1) ax.set_title (title.title ()) ax.set_xlabel (ambient.paramLabel (paramIndex)) ax.legend () pages.savefig (fig) plt.close (fig) pages.close ()
return True # set fig, im, and lines to call draw_frame repeatedly with fig = plt.figure(figsize=(8, 6)) ax = fig.add_subplot(111) im = ax.imshow([[], []], cmap=plt.cm.gist_earth_r, extent=[xmin, xmax, ymin, ymax], aspect="auto") lines, = ax.plot([], [], "k.", markersize=2) ax.set_title( "Kernel Density Estimation \n {} - {}".format(os.path.basename(args.indir), startDate.strftime("%m/%d/%Y")) ) ax.set_xlim([xmin, xmax]) ax.set_ylim([ymin, ymax]) ax.set_xlabel(ambient.paramLabel(args.vars[0])) ax.set_ylabel(ambient.paramLabel(args.vars[1])) # the script's big switch, either we have 1 date and we make a pdf or its a date range # and we are making an mp4 if args.date: pdf = PdfPages( os.path.join( args.outdir, "kde_{}_{}_{}.pdf".format( args.date.strftime("%m_%d_%Y"), ambient.parameterBasenames[args.vars[0]], ambient.parameterBasenames[args.vars[1]], ), ) )