def ba_multiyear_histogram(years, ba_template, ind_template, ind_names, outfile=None, bins=10, minmaxyears=None, day_range=None, geog_box=None): """computes multiyear histograms and stores in a netcdf file.""" # open netcdf files bafiles = [] indfiles = [] for y in years: bafiles.append(nc.Dataset(ba_template % y)) indfiles.append(nc.Dataset(ind_template % y)) # compute min/max if minmaxyears is None: minmax = oi.multifile_minmax(indfiles, ind_names, day_range=day_range, geog_box=geog_box) else: minmax = oi.multifile_minmax(ind_template, ind_names, years=minmaxyears, day_range=day_range, geog_box=geog_box) if not ('__iter__' in dir(bins)): bins = [bins] * len(ind_names) minmax = zip(minmax[0], minmax[1], bins) # compute histogram histos = ba_multifile_histograms(bafiles, indfiles, ind_names, minmax, day_range, geog_box) # write output if outfile is not None: write_multiyear_histogram_file(outfile, histos, ind_names, minmax, day_range, geog_box) # close netcdf files for i_files in range(len(years)): bafiles[i_files].close() indfiles[i_files].close() return histos
def ba_multiyear_ratios(years, ba_template, ind_template, ind_names, histo_outfile=None, ratio_outfile=None, bins=10, minmaxyears=None): """computes multiyear histograms and stores in a netcdf file.""" # open netcdf files bafiles = [] indfiles = [] for y in years: bafiles.append(nc.Dataset(ba_template % y)) indfiles.append(nc.Dataset(ind_template % y)) # compute min/max if minmaxyears is None: minmax = oi.multifile_minmax(indfiles, ind_names) else: minmax = oi.multifile_minmax(ind_template, ind_names, years=minmaxyears) if not ('__iter__' in dir(bins)): bins = [bins] * len(ind_names) minmax = zip(minmax[0], minmax[1], bins) # compute histogram ratios, halfdeg_counts, histo = ba_ratio_histograms( bafiles, indfiles, ind_names, minmax) # write output if histo_outfile is not None: ah.save_sparse_histos(histo, histo_outfile) if ratio_outfile is not None: write_raw_ratio_file(ratio_outfile, ratios, halfdeg_counts, ind_names, minmax) # close netcdf files for i_files in range(len(years)): bafiles[i_files].close() indfiles[i_files].close() return ratios, histo
def ba_multiyear_histogram(years, ba_template, ind_template, ind_names, outfile=None, bins=10, minmaxyears=None, day_range=None, geog_box=None) : """computes multiyear histograms and stores in a netcdf file.""" # open netcdf files bafiles = [ ] indfiles = [ ] for y in years : bafiles.append(nc.Dataset(ba_template % y)) indfiles.append(nc.Dataset(ind_template % y)) # compute min/max if minmaxyears is None : minmax = oi.multifile_minmax(indfiles, ind_names, day_range=day_range, geog_box=geog_box) else : minmax = oi.multifile_minmax(ind_template, ind_names, years=minmaxyears, day_range=day_range, geog_box=geog_box) if not ('__iter__' in dir(bins)) : bins = [ bins ] * len(ind_names) minmax = zip(minmax[0], minmax[1], bins) # compute histogram histos = ba_multifile_histograms(bafiles, indfiles, ind_names, minmax, day_range, geog_box) # write output if outfile is not None : write_multiyear_histogram_file(outfile, histos, ind_names, minmax, day_range, geog_box) # close netcdf files for i_files in range(len(years)) : bafiles[i_files].close() indfiles[i_files].close() return histos
def ba_multiyear_ratios(years, ba_template, ind_template, ind_names, histo_outfile=None, ratio_outfile=None, bins=10, minmaxyears=None) : """computes multiyear histograms and stores in a netcdf file.""" # open netcdf files bafiles = [ ] indfiles = [ ] for y in years : bafiles.append(nc.Dataset(ba_template % y)) indfiles.append(nc.Dataset(ind_template % y)) # compute min/max if minmaxyears is None : minmax = oi.multifile_minmax(indfiles, ind_names) else : minmax = oi.multifile_minmax(ind_template, ind_names, years=minmaxyears) if not ('__iter__' in dir(bins)) : bins = [ bins ] * len(ind_names) minmax = zip(minmax[0], minmax[1], bins) # compute histogram ratios, halfdeg_counts, histo = ba_ratio_histograms(bafiles, indfiles, ind_names, minmax) # write output if histo_outfile is not None : ah.save_sparse_histos(histo, histo_outfile) if ratio_outfile is not None: write_raw_ratio_file(ratio_outfile, ratios, halfdeg_counts, ind_names, minmax) # close netcdf files for i_files in range(len(years)) : bafiles[i_files].close() indfiles[i_files].close() return ratios, histo