Add --file argument to render SPC outlook file
This commit is contained in:
parent
f8f44fa798
commit
2cf511472c
1 changed files with 18 additions and 5 deletions
|
@ -25,7 +25,10 @@ def render_categorical(db: Database,
|
|||
|
||||
conus.draw_base_map_from_file(cr, assets['conus'])
|
||||
conus.draw_categories(cr, outlook)
|
||||
|
||||
if args.cities:
|
||||
conus.draw_cities(cr, db)
|
||||
|
||||
conus.draw_logo(cr, assets['logo'])
|
||||
conus.draw_legend(cr, SPCOutlookType.CATEGORICAL)
|
||||
|
||||
|
@ -50,7 +53,10 @@ def render_probabilistic(db: Database,
|
|||
|
||||
conus.draw_base_map_from_file(cr, assets['conus'])
|
||||
conus.draw_probabilities(cr, outlook, hazard.upper())
|
||||
|
||||
if args.cities:
|
||||
conus.draw_cities(cr, db)
|
||||
|
||||
conus.draw_logo(cr, assets['logo'])
|
||||
conus.draw_legend(cr, SPCOutlookType.PROBABILISTIC)
|
||||
|
||||
|
@ -63,6 +69,8 @@ def render_probabilistic(db: Database,
|
|||
|
||||
argparser = argparse.ArgumentParser(description='Render graphical SPC outlooks from text file')
|
||||
argparser.add_argument('--dark', action='store_true', help='Output dark mode graphics')
|
||||
argparser.add_argument('--cities', action='store_true', help='Render major cities')
|
||||
argparser.add_argument('--file', type=str, help='Load outlook from file, not database')
|
||||
argparser.add_argument('--valid', type=str, help='Timestamp on or after most recent outlook')
|
||||
argparser.add_argument('--day', type=int, help='Number of days from issuance outlook applies to')
|
||||
argparser.add_argument('--categorical', type=str, help='Output categorical risk graphic file')
|
||||
|
@ -76,10 +84,15 @@ args = argparser.parse_args()
|
|||
config = Config.load()
|
||||
db = Database.from_config(config)
|
||||
|
||||
parser = SPCOutlookParser()
|
||||
conus = SPCOutlookMap()
|
||||
|
||||
if args.file is None:
|
||||
outlook = SPCOutlook.for_timestamp(db, args.valid, args.day)
|
||||
else:
|
||||
with open(args.file, 'r') as fh:
|
||||
parser = SPCOutlookParser()
|
||||
|
||||
outlook = parser.parse(fh.read())
|
||||
|
||||
if args.categorical is not None:
|
||||
render_categorical(db, conus, outlook, args)
|
||||
|
|
Loading…
Add table
Reference in a new issue