def plot_jacobians(name_str, dir_name, plot_output_dir, overwrite=False): pd_files = ['control1/t_pd.dat', 'control1/aer_pd_species_1.dat', 'control1/alb_pd.dat', 'control1/alb_i_pd.dat', 'control1/cont_pd.dat', 'control1/disp_pd.dat', 'control1/mr_pd_species_1.dat', 'control1/mr_pd_species_3.dat', 'control1/mr_scaling_pd_species_1.dat', 'control1/mr_scaling_pd_species_3.dat', 'control1/press_pd.dat' ] for pd_partname in pd_files: pd_fullname = "%s/out/%s" % (dir_name, pd_partname) pd_basename = os.path.basename(pd_partname) plot_filename = "%s/%s-%s.pdf" % (plot_output_dir, name_str, pd_basename) if os.path.exists(pd_fullname): if os.path.exists(plot_filename) and not overwrite: print 'Skipping existing: %s' % plot_filename else: print 'Creating: %s' % plot_filename plot_tmp_files = plot_jacobians_util( (pd_fullname,) ) combine_pdfs(plot_tmp_files, plot_filename, remove_source_files=True)
def plot_jacobians(name_str, dir_name, plot_output_dir, overwrite=False): pd_files = [ "control1/t_pd.dat", "control1/aer_pd_species_1.dat", "control1/alb_pd.dat", "control1/alb_i_pd.dat", "control1/cont_pd.dat", "control1/disp_pd.dat", "control1/mr_pd_species_1.dat", "control1/mr_pd_species_3.dat", "control1/mr_scaling_pd_species_1.dat", "control1/mr_scaling_pd_species_3.dat", "control1/press_pd.dat", ] for pd_partname in pd_files: pd_fullname = "%s/out/%s" % (dir_name, pd_partname) pd_basename = os.path.basename(pd_partname) plot_filename = "%s/%s-%s.pdf" % (plot_output_dir, name_str, pd_basename) if os.path.exists(pd_fullname): if os.path.exists(plot_filename) and not overwrite: print "Skipping existing: %s" % plot_filename else: print "Creating: %s" % plot_filename plot_tmp_files = plot_jacobians_util((pd_fullname,)) combine_pdfs(plot_tmp_files, plot_filename, remove_source_files=True)
def plot_spectrum_residuals(name_str, dir_name, plot_output_dir, overwrite=False): meas_spec_file = os.path.join(dir_name, RAD_MEAS_FILENAME) sim_spec_file = os.path.join(dir_name, RAD_CONV_FILENAME) output_filename = os.path.join(plot_output_dir, SPEC_RESIDUAL_OUT_TMPL % name_str) if os.path.exists(output_filename) and not overwrite: print 'Skipping existing plot: %s' % output_filename else: print 'Creating: %s' % output_filename plot_tmp_files = plot_residuals_util((meas_spec_file, sim_spec_file,), name_str, bottom_notes=None, grid_name=SPEC_RESIDUAL_GRID_NAME, detail_size=SPEC_RESIDUAL_DETAIL_SIZE) combine_pdfs(plot_tmp_files, output_filename, remove_source_files=True)
def plot_spectrum_residuals(name_str, dir_name, plot_output_dir, overwrite=False): meas_spec_file = os.path.join(dir_name, RAD_MEAS_FILENAME) sim_spec_file = os.path.join(dir_name, RAD_CONV_FILENAME) output_filename = os.path.join(plot_output_dir, SPEC_RESIDUAL_OUT_TMPL % name_str) if os.path.exists(output_filename) and not overwrite: print "Skipping existing plot: %s" % output_filename else: print "Creating: %s" % output_filename plot_tmp_files = plot_residuals_util( (meas_spec_file, sim_spec_file), name_str, bottom_notes=None, grid_name=SPEC_RESIDUAL_GRID_NAME, detail_size=SPEC_RESIDUAL_DETAIL_SIZE, ) combine_pdfs(plot_tmp_files, output_filename, remove_source_files=True)
def standalone_main(): # Load command line options parser = OptionParser( usage= "usage: %prog [options] [measured_spec_file] [simulated_spec_file]...") parser.add_option("-d", "--detail", dest="detail", metavar='NUM', type="int", default=0, help="size in grid units of detail plots") parser.add_option("-c", "--data_column", dest="data_column", default=DEFAULT_DATA_COLUMN, help="data column to be used from files being compared") parser.add_option( "-y", "--resid_ylims", dest="resid_ylims", default=None, help="vertical limits on residual plot (-percent, percent)") parser.add_option("-g", "--grid", dest="grid", default=VALID_GRID_NAMES[0], help="grid type to use for x axis. valid values: %s" % VALID_GRID_NAMES) parser.add_option( "--no_force", dest="no_force_grid", default=True, action='store_false', help= "do not force measured and simulation grids to be equal, ie do not compare by pixel" ) parser.add_option("-o", "--out_file", dest="out_file", metavar='FILE', help="output filename") parser.add_option("-t", "--title", dest="title", metavar='TEXT', help="additional title text") parser.add_option( "-n", "--notes", dest="notes", metavar='TEXT', action="append", help= "additional notes for bottom of first plot, option can be specified multiple times" ) # Parse command line arguments (options, args) = parser.parse_args() if len(args) < 2: parser.error('Need measured and simulated spectra files specified') meas_spec = args[0] sim_spec = args[1] if options.out_file == None: meas_name = os.path.splitext(os.path.basename(meas_spec))[0] sim_name = os.path.splitext(os.path.basename(sim_spec))[0] options.out_file = '%s-%s.pdf' % (meas_name, sim_name) print 'Writing output to: %s' % options.out_file if options.resid_ylims != None: options.resid_ylims = [ float(f) for f in options.resid_ylims.split(",") ] bottom_notes = [ os.path.realpath(meas_spec), os.path.realpath(sim_spec), '%s version: %s' % (os.path.basename( sys.argv[0]), L2_Version_Util.get_svn_version(sys.argv[0])), ] if options.notes != None and len(options.notes) > 0: bottom_notes += options.notes plot_files = plot_spec_residuals((meas_spec, sim_spec), plot_title=options.title, bottom_notes=bottom_notes, grid_name=options.grid, detail_size=options.detail, data_column=options.data_column, force_grid_match=options.no_force_grid, resid_ylims=options.resid_ylims) if len(plot_files) != 0: combine_pdfs(plot_files, options.out_file, remove_source_files=True)
def standalone_main(): # Load command line options parser = OptionParser(usage="usage: %prog [options] [measured_spec_file] [simulated_spec_file]...") parser.add_option( "-d", "--detail", dest="detail", metavar='NUM', type="int", default=0, help="size in grid units of detail plots") parser.add_option( "-c", "--data_column", dest="data_column", default=DEFAULT_DATA_COLUMN, help="data column to be used from files being compared") parser.add_option( "-y", "--resid_ylims", dest="resid_ylims", default=None, help="vertical limits on residual plot (-percent, percent)") parser.add_option( "-g", "--grid", dest="grid", default=VALID_GRID_NAMES[0], help="grid type to use for x axis. valid values: %s" % VALID_GRID_NAMES) parser.add_option( "--no_force", dest="no_force_grid", default=True, action='store_false', help="do not force measured and simulation grids to be equal, ie do not compare by pixel") parser.add_option( "-o", "--out_file", dest="out_file", metavar='FILE', help="output filename") parser.add_option( "-t", "--title", dest="title", metavar='TEXT', help="additional title text") parser.add_option( "-n", "--notes", dest="notes", metavar='TEXT', action="append", help="additional notes for bottom of first plot, option can be specified multiple times") # Parse command line arguments (options, args) = parser.parse_args() if len(args) < 2: parser.error('Need measured and simulated spectra files specified') meas_spec = args[0] sim_spec = args[1] if options.out_file == None: meas_name = os.path.splitext(os.path.basename(meas_spec))[0] sim_name = os.path.splitext(os.path.basename(sim_spec))[0] options.out_file = '%s-%s.pdf' % (meas_name, sim_name) print 'Writing output to: %s' % options.out_file if options.resid_ylims != None: options.resid_ylims = [float(f) for f in options.resid_ylims.split(",")] bottom_notes = [os.path.realpath(meas_spec), os.path.realpath(sim_spec), '%s version: %s' % (os.path.basename(sys.argv[0]), L2_Version_Util.get_svn_version(sys.argv[0])), ] if options.notes != None and len(options.notes) > 0: bottom_notes += options.notes plot_files = plot_spec_residuals( (meas_spec, sim_spec), plot_title=options.title, bottom_notes=bottom_notes, grid_name=options.grid, detail_size=options.detail, data_column=options.data_column, force_grid_match=options.no_force_grid, resid_ylims = options.resid_ylims) if len(plot_files) != 0: combine_pdfs(plot_files, options.out_file, remove_source_files=True)