def get_nei(options, d1, d2, area): if options.neiconfig: logger.info('NEI file in configuration file') nei = svnei.NeiSummary(options.tdir + 'neifiles/' + options.neiconfig) else: logger.info('NEI file not in configuration file') nei = svnei.NeiData(options.ndir) nei.load() if not options.neiconfig: fname = options.tdir + options.tag + '.nei.csv' logger.info('writing NEI file ' + fname) nei.filter(area) nei.write_summary(options.tdir, options.tag + '.nei.csv') return nei
def make_hexbin(): # TO DO - this was split off from main. # create 2d distributions of wind direction and so2 measurements. meto.fignum = obs.fignum + 1 if options.neiconfig: nei = svnei.NeiSummary() nei.load(options.tdir + 'neifiles/' + options.neiconfig) meto.add_nei_data(nei.df) else: logger.info("No neiconfig file found in configuration file") # plot 2d histograms of SO2 measurements and measured wind speeds. make_hexbin(options, meto) plt.show()
def options_nei(options, d1, d2, source_chunks, tcmrun=False): ns = nei.NeiSummary() logger.info('writing EIS control and setup files for NEI data') sss = SourceSummary(fname=options.tag + '.source_summary.csv') neidf = ns.load(fname=options.tdir + '/neifiles/' + options.neiconfig) ns.remove_cems(sss.sumdf) ns.print(fname=options.tdir + '/neifiles/CONFIG.NEWNEI') neidf = ns.df nei_runlist = svhy.nei_controls(options.tdir, options.hdir, neidf, d1, d2, source_chunks, options.metfmt, units=options.cunits, tcm=tcmrun)
oldrunlist = False runlist = [] if oldrunlist: from sverify.svhy import create_controls from sverify.svhy import create_vmix_controls from sverify.svhy import RunScript from sverify.svhy import VmixScript from sverify.svhy import DatemScript from sverify.svcems import SourceSummary with open(logfile, 'a') as fid: fid.write('creating CONTROL files\n') if options.neiconfig: from sverify import nei from sverify.svhy import nei_controls ns = nei.NeiSummary() print('WRITING EIS CONTROLS') sss = SourceSummary(fname=options.tag + '.source_summary.csv') neidf = ns.load(fname=options.tdir + '/neifiles/' + options.neiconfig) #ns.remove_cems(sss.sumdf) #ns.print(fname = options.tdir + '/neifiles/CONFIG.NEWNEI') neidf = ns.df nei_runlist = nei_controls(options.tdir, options.hdir, neidf, d1, d2, source_chunks, options.metfmt, units=options.cunits,
def main(): parser = OptionParser() # parser.add_option( # "-a", type="string", dest="state", default="ND", help="two letter state code (ND)" # ) parser.add_option( "-i", type="string", dest="configfile", default="CONFIG.S", help="Name of configuration file", ) parser.add_option( "-c", action="store_true", dest="check_cdump", default=False, help= "Only write command to run HYSPLIT if the cdump file does not exist.", ) parser.add_option( "-p", action="store_true", dest="print_help", default=False, help="Print help for configuration file", ) parser.add_option( "--datem", action="store_true", dest="datem", default=False, help="create bash scripts to run datem", ) parser.add_option( "--vmix", action="store_true", dest="vmix", default=False, help="create bash scripts to run vmixing", ) parser.add_option( "--run", action="store_true", dest="run", default=False, help="create bash scripts to run HYSPLIT", ) parser.add_option( "--nei", action="store_true", dest="nei", default=False, help="create bash scripts to run datem or HYSPLIT for the data\ found in the confignei file", ) parser.add_option( "--ens", action="store_true", dest="ens", default=False, help="create bash scripts to ensemble. not completely working.") parser.add_option( "--debug", action="store_true", dest="debug", default=False, help="Print messages for debugging", ) parser.add_option("--quiet", action="store_false", dest="verbose", default=True, help="Don't print messages") (opts, args) = parser.parse_args() if opts.check_cdump: wstr = '-c option set ' + str(opts.check_cdump) wstr += 'lines to run HYSPLIT when cdump files exist will be' wstr += 'commented out' if not opts.check_cdump: wstr = '-c option not set ' + str(opts.check_cdump) wstr += 'cdump files may be overwritten if script is run' logger.warning(wstr) if opts.print_help: print("-------------------------------------------------------------") print("Configuration file options (key words are not case sensitive)") print("-------------------------------------------------------------") print(options.print_help(order=options.lorder)) sys.exit() options = svconfig.ConfigFile(opts.configfile) # options.fileread is a boolean attribute of ConfigFile class. if not options.fileread: print("configuration file " + opts.configfile + " not found.\ngoodbye") sys.exit() ##------------------------------------------------------## ##------------------------------------------------------## # Process some of the options to create new parameters. ##------------------------------------------------------## ##------------------------------------------------------## svp = options_process.main(options) # TO DO - may pass svp rather than individual attributes to functions. d1 = svp.d1 d2 = svp.d2 area = svp.area source_chunks = svp.source_chunks datem_chunks = svp.datem_chunks tcmrun = svp.tcmrun run_duration = svp.run_duration rfignum = 1 # FILES created # bash scripts to run c2datem on the results. if opts.nei: from sverify import nei ns = nei.NeiSummary() #print(options.tdir, options.neiconfig) neidf = ns.load(fname=options.tdir + '/neifiles/' + options.neiconfig) #ns.remove_cems(sss.sumdf) #ns.print(fname = options.tdir + '/neifiles/CONFIG.NEWNEI') neidf = ns.df nei_runlist = create_nei_runlist(options.tdir, options.hdir, neidf, d1, d2, source_chunks) if opts.run: fname = options.tag + "nei.sh" logger.info('Making bash script for NEI HYSPLIT runs ' + fname) rs = RunScript(fname, nei_runlist, options.tdir, check=opts.check_cdump) if opts.datem: fname = options.tag + "_nei_datem.sh" logger.info('Making DATEM script for NEI sources :' + fname) rs = DatemScript(fname, nei_runlist, options.tdir, options.cunits, poll=1) if opts.vmix and not opts.ens: runlist = create_vmix_controls(options.vdir, options.hdir, d1, d2, source_chunks, metfmt='None', write=False) fname = options.tag + '.vmix.sh' logger.info('writing script to run vmix ' + fname) rs = VmixScript(fname, runlist, options.tdir) elif opts.vmix and opts.ens: logger.warning('Ensemble option set ') logger.info('writing script to run ensemble vmix ') runlist = create_ensemble_vmix_controls(options.tdir, options.hdir, d1, d2, source_chunks, options.metfmt) svens.create_ensemble_vmix(options, d1, d2, source_chunks) # create ensemble scripts for running. if opts.run and not opts.nei and opts.ens: logger.warning('Ensemble option set ') svens.create_ensemble_scripts(options, d1, d2, source_chunks, opts.check_cdump) if opts.datem and not opts.nei and opts.ens: logger.warning('Ensemble option set ') svens.create_ensemble_datem_scripts(options, d1, d2, source_chunks) if opts.run and not opts.nei and not opts.ens: runlist = create_runlist(options.tdir, options.hdir, d1, d2, source_chunks) fname = options.tag + ".sh" logger.info('writing script to run HYSPLIT for CEMS sources: ' + fname) rs = RunScript(fname, runlist, options.tdir, check=opts.check_cdump) if opts.datem and not opts.nei and not opts.ens: runlist = create_runlist(options.tdir, options.hdir, d1, d2, source_chunks) logger.info( 'writing scripts to create datemfiles for CEMS hysplit runs') logger.info('p1datem_' + options.tag + ".sh") logger.info('p2datem_' + options.tag + ".sh") logger.info('p3datem_' + options.tag + ".sh") rs = DatemScript("p1datem_" + options.tag + ".sh", runlist, options.tdir, options.cunits, poll=1) rs = DatemScript("p2datem_" + options.tag + ".sh", runlist, options.tdir, options.cunits, poll=2) rs = DatemScript("p3datem_" + options.tag + ".sh", runlist, options.tdir, options.cunits, poll=3)