コード例 #1
0
ファイル: make_geometry.py プロジェクト: noaa-oar-arl/sverify
def main():
    parser = OptionParser()

    parser.add_option(
        "-i",
        type="string",
        dest="configfile",
        default="CONFIG.S",
        help="Name of configuration file",
    )
    parser.add_option(
        "-p",
        action="store_true",
        dest="print_help",
        default=False,
        help="Print help for configuration file",
    )
    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()

    logger.info('Creates file with distance and direction from')
    logger.info('AQS measurement sites to CEMS and NEI sources.')
    options = svconfig.ConfigFile(opts.configfile)
    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
    #logfile = svp.logfile
    logfile = "None"
    source_chunks = svp.source_chunks
    datem_chunks = svp.datem_chunks
    tcmrun = svp.tcmrun
    run_duration = svp.run_duration
    rfignum = 1
    options_obs.options_geometry(options, d1, d2, area)
コード例 #2
0
ファイル: sverify2.py プロジェクト: noaa-oar-arl/sverify
    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
logfile = svp.logfile
source_chunks = svp.source_chunks
datem_chunks = svp.datem_chunks
tcmrun = svp.tcmrun
run_duration = svp.run_duration
rfignum = 1

# create an instance of the MetObs class.
vmet = MetObs()

##------------------------------------------------------##
コード例 #3
0
def main():
    parser = OptionParser()

    parser.add_option(
        "-i",
        type="string",
        dest="configfile",
        default="CONFIG.S",
        help="Name of configuration file",
    )
    parser.add_option(
        "-p",
        action="store_true",
        dest="print_help",
        default=False,
        help="Print help for configuration file",
    )
    parser.add_option(
        "--aqs",
        action="store_true",
        dest="aqs",
        default=False,
        help="Retrieve AQS data",
    )
    parser.add_option(
        "--plot",
        action="store_true",
        dest="plot",
        default=False,
        help="Create Plots. Map and time series plots.",
    )

    parser.add_option(
        "--cems",
        action="store_true",
        dest="cems",
        default=False,
        help="Retrieve CEMS data",
    )
    parser.add_option(
        "--ish",
        action="store_true",
        dest="ish",
        default=False,
        help="Retrieve ISH data. Not currently working",
    )
    parser.add_option(
        "--datem",
        action="store_true",
        dest="datem",
        default=False,
        help="Write datem files in the subdirectories",
    )
    parser.add_option(
        "--efiles",
        action="store_true",
        dest="efiles",
        default=False,
        help="Write EMIT TIMES files in subdiretories",
    )
    parser.add_option(
        "--nei",
        action="store_true",
        dest="nei",
        default=False,
        help="Retrieve NEI data.",
    )

    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 not opts.aqs and not opts.cems and not opts.ish and not opts.nei:
        opts.aqs = True
        opts.cems = True

    options = svconfig.ConfigFile(opts.configfile)
    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()


    opts.ish = 0
    if opts.ish: options.ish = 1
    else: options.ish = 0

    # 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
    #logfile = svp.logfile
    logfile = "None"
    source_chunks = svp.source_chunks
    datem_chunks = svp.datem_chunks
    tcmrun = svp.tcmrun
    run_duration = svp.run_duration
    rfignum = 1


    if opts.aqs: options.obs=True

    ##------------------------------------------------------##
    # Run a test
    ##------------------------------------------------------##

    runtest = False
    if runtest:
        options_obs.test(
            options,
            d1,
            d2,
            area,
            source_chunks,
            run_duration,
            logfile,
            rfignum,
            svp.ensemble,
        )
        sys.exit()

    ##------------------------------------------------------##
    ## Get the CEMS data.
    ##------------------------------------------------------##
    if opts.cems:
        # OUTPUTS
        # ef SEmissions object
        # rfignum integer
        # FILES CREATED
        # source_summary.csv
        from sverify import options_cems
        options_cems.options_cems_main(
            options, d1, d2, area, source_chunks, 
            svp.ensemble, opts.efiles, verbose=opts.debug,
            create_plots = opts.plot
        )
    ##------------------------------------------------------##
    ## Get ISH data
    ##------------------------------------------------------##
    if opts.ish:
       options_obs.get_ish(options,d1,d2,area)

    if opts.nei:
       nei = options_obs.get_nei(options,d1,d2,area)
    ##------------------------------------------------------##
    ## Get observational data
    ##------------------------------------------------------##
    if opts.aqs:
        # OUTPUTS
        # meto - MetObs object with met observations.
        # obs  - SObs object
        # FILES CREATED
        # datem files in subdirectories
        # geometry.csv file
        # PLOTS CREATED
        # time series of observations
        # map with obs, cems, ish
        # 2d distributions of so2 conc and wdir for sites with met data.
        meto, obs = options_obs.options_obs_main(
            options,
            d1,
            d2,
            area,
            source_chunks,
            run_duration,
            rfignum,
            svp.ensemble,
            datem = opts.datem,
            create_plots = opts.plot
        )
コード例 #4
0
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)
コード例 #5
0
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(
    "-p",
    action="store_true",
    dest="print_help",
    default=False,
    help="Print help for configuration file",
    )
    parser.add_option(
    "--defaults",
    action="store_true",
    dest="defaults",
    default=False,
    help="Write CONTROL.0 and SETUP.0 files in top level directory",
    )

    parser.add_option(
    "--vmix",
    action="store_true",
    dest="vmix",
    default=False,
    help="Write CONTROL and SETUP files for vmixing, \
          Locations are where there are AQS stations. \
          CONTROL.suffix, suffix is V+AQS station id.",
    )

    parser.add_option(
    "--nei",
    action="store_true",
    dest="nei",
    default=False,
    help="Write CONTROL and SETUP files for sources found in \
          the CONFIG.nei file.",
    )

    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()

    options = svconfig.ConfigFile(opts.configfile)
    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
    #logfile = svp.logfile
    source_chunks = svp.source_chunks
    datem_chunks = svp.datem_chunks
    tcmrun = svp.tcmrun
    run_duration = svp.run_duration
    rfignum = 1

    # create an instance of the MetObs class.
    # vmet = MetObs()

    ##------------------------------------------------------##
    # Run a test
    ##------------------------------------------------------##
    runtest=False
    if runtest:
        print('No test available')
        rval = 1
    ##------------------------------------------------------##
    # Create default CONTROL.0 and SETUP.0 files
    ##------------------------------------------------------##
    elif opts.defaults and not svp.ensemble:
        #with open(logfile, 'a') as fid:
        #    fid.write('Running  defaults\n')
        from sverify.svhy import default_setup
        from sverify.svhy import default_control
        logger.info("writing CONTROL.0 and SETUP.0")
        # if units='ppb' then ichem=6 is set to output mixing ratios.
        default_setup("SETUP.0", options.tdir, units=options.cunits)
        default_control("CONTROL.0", options.tdir, run_duration, d1, area=area)
        # if ensemble then copy CONTROL.0 and SETUP.0 to ensemble directories
    elif opts.defaults and svp.ensemble:
        from sverify.svens import ensemble_defaults
        ensemble_defaults(options.tdir)

    ##------------------------------------------------------##
    # Create CONTROL and SETUP files in subdirectories.
    ##------------------------------------------------------##
    # FILES created
    # CONTROL and SETUP and ASCDATA.CFG files in each subdirectory.
    # CONTROL files for vmixing. 
    elif not opts.defaults:
       tcmrun=False
       main = False
       vmix = opts.vmix
       neibool = opts.nei
       if not vmix and not neibool: main = True
       #logger.info('writing control files')
       options_run_main(options, d1, d2, source_chunks, 
                        tcmrun, main, vmix, neibool)
    return 1