def obsolete_plot_hazard_map(indir, datafile, out_dir, output_file, save_file=None, title=None, np_posn=None, s_posn=None, cb_label=None, cb_steps=None, invert=False, colourmap=None, annotate=None): """Plot a hazard map from gridded data. indir input directory data name of the data file to plot (in indir) out_dir general output directory output_file name of map output file to create in 'out_dir' directory save_file name of map data output file to create in 'out_dir' directory title title to put on the graph np_posn place to put a north pointer symbol at s_posn place to put a length scale at cb_label label text to put on the colour bar (if not defined, no colour bar) cb_steps sequence of required values in colourbar colourmap the base colourmap to use annotate user annotations required """ if cb_steps is None: cb_steps = [0.1,0.15,0.20,0.30,0.40,0.50] data = cld.calc_load_data(datafile, invert=invert) pgxc.plot_gmt_xyz_contour(data, output_file, title=title, np_posn=np_posn, s_posn=s_posn, cb_label=cb_label, cb_steps=cb_steps, annotate=annotate)
def test_real_world(self, show_graph=False): outputdir = tempfile.mkdtemp(prefix='test_plot_hexbin_map_') # get data from the file data = cld.calc_load_data(DataFilename, invert=True) value_scale = 1.0e3 data[:,2] = data[:,2] / value_scale hexbin_args = {'gridsize': 100, 'reduce_C_function': scipy.sum, 'linewidth': 0.5, 'edgecolors': 'w', } # test the plot routine output_file = os.path.join(outputdir, 'plot_hexbin_map.png') phm.plot_hexbin_map(data, title='Test of plot_hexbin_map()\nsecond line', output_file=output_file, cblabel='Dollar loss (x %d)' % int(value_scale), cbformat='%.0f', colormap='hazmap', show_graph=show_graph, grid=True, np_posn='NW', hexbin_args=hexbin_args) # ensure file expected was generated self.failUnless(os.path.isfile(output_file)) # clean up shutil.rmtree(outputdir, ignore_errors=True)
def test_real_world(self, show_graph=False): outputdir = tempfile.mkdtemp(prefix='test_plot_hexbin_map_') # get data from the file data = cld.calc_load_data(DataFilename, invert=True) value_scale = 1.0e3 data[:, 2] = data[:, 2] / value_scale hexbin_args = { 'gridsize': 100, 'reduce_C_function': scipy.sum, 'linewidth': 0.5, 'edgecolors': 'w', } # test the plot routine output_file = os.path.join(outputdir, 'plot_hexbin_map.png') phm.plot_hexbin_map(data, title='Test of plot_hexbin_map()\nsecond line', output_file=output_file, cblabel='Dollar loss (x %d)' % int(value_scale), cbformat='%.0f', colormap='hazmap', show_graph=show_graph, grid=True, np_posn='NW', hexbin_args=hexbin_args) # ensure file expected was generated self.failUnless(os.path.isfile(output_file)) # clean up shutil.rmtree(outputdir, ignore_errors=True)
def do_example(datafile, outfile, invert=False): contours = [0.10, 0.15, 0.20, 0.30, 0.40, 0.50] data = cld.calc_load_data(datafile, invert=invert) pgxic.plot_gmt_xyz_image_contour(data, outfile, bin_sum=True, cb_label='Acceleration (g)', #cb_steps=contours, contours=contours, title='Bedrock Hazard, RP=?, RSA=?')
def do_example(datafile, outfile, invert=False): # ignore_value = 0.025 # annotations = [] # if ignore_value: # annotations.append(('text', (143.6,-37.10), # 'Values <= %.2f are ignored' % ignore_value)) data = cld.calc_load_data(datafile, invert=invert) # TODO : add call to calc_ignore pgxc.plot_gmt_xyz_contour(data, outfile, title='Bedrock Hazard, RP=?, RSA=?', np_posn='NE', s_posn='SE', cb_label='Acceleration (g)', cb_steps=[0.1,0.15,0.20,0.30,0.40,0.50], annotate=annotations, linewidth=0.0)
def do_example(datafile, outfile, invert=False): # ignore_value = 0.025 # annotations = [] # if ignore_value: # annotations.append(('text', (143.6,-37.10), # 'Values <= %.2f are ignored' % ignore_value)) data = cld.calc_load_data(datafile, invert=invert) # TODO : add call to calc_ignore pgxc.plot_gmt_xyz_contour(data, outfile, title='Bedrock Hazard, RP=?, RSA=?', np_posn='NE', s_posn='SE', cb_label='Acceleration (g)', cb_steps=[0.1, 0.15, 0.20, 0.30, 0.40, 0.50], annotate=annotations, linewidth=0.0)
plt.savefig(output_file, dpi=300) if show_graph: plt.show() plt.close() if __name__ == '__main__': import calc_load_data as cld # filename with test data filename = 'lat_long_eloss.csv.SAVE' #filename = 'lat_long_eloss.csv' # get data from the file result = cld.calc_load_data(filename, invert=True) # strip out values > 250,000,000 #result = result[scipy.nonzero(result[:,2] < 250000000), :][0] value_scale = 1.0e6 result[:,2] = result[:,2] / value_scale hexbin_args = {#'gridsize': 100, # 'reduce_C_function': scipy.sum, # 'linewidth': 0.5, 'edgecolors': None, # 'fill_color': 'r', 'bins': 100, } scale_args = ('se', 100)
plt.savefig(output_file, dpi=300) if show_graph: plt.show() plt.close() if __name__ == '__main__': import calc_load_data as cld # filename with test data filename = 'lat_long_eloss.csv.SAVE' #filename = 'lat_long_eloss.csv' # get data from the file result = cld.calc_load_data(filename, invert=True) # strip out values > 250,000,000 #result = result[scipy.nonzero(result[:,2] < 250000000), :][0] value_scale = 1.0e6 result[:, 2] = result[:, 2] / value_scale hexbin_args = {#'gridsize': 100, # 'reduce_C_function': scipy.sum, # 'linewidth': 0.5, 'edgecolors': None, # 'fill_color': 'r', 'bins': 100, } scale_args = ('se', 100)