Draw cities on SPC outlook maps
This commit is contained in:
parent
8c4b93d50e
commit
ed7c5bf317
1 changed files with 8 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
|
from xmet.db import Database
|
||||||
from xmet.spc import SPCOutlookParser, SPCOutlook, SPCOutlookMap
|
from xmet.spc import SPCOutlookParser, SPCOutlook, SPCOutlookMap
|
||||||
|
|
||||||
ASSETS = {
|
ASSETS = {
|
||||||
|
@ -20,6 +21,8 @@ ASSETS = {
|
||||||
def render_categorical(conus: SPCOutlookMap,
|
def render_categorical(conus: SPCOutlookMap,
|
||||||
outlook: SPCOutlook,
|
outlook: SPCOutlook,
|
||||||
args):
|
args):
|
||||||
|
db = Database.connect(args.db)
|
||||||
|
|
||||||
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
||||||
|
|
||||||
with cairo.SVGSurface(args.categorical, conus.width, conus.height) as surface:
|
with cairo.SVGSurface(args.categorical, conus.width, conus.height) as surface:
|
||||||
|
@ -27,6 +30,7 @@ def render_categorical(conus: SPCOutlookMap,
|
||||||
|
|
||||||
conus.draw_base_map_from_file(cr, assets['map'])
|
conus.draw_base_map_from_file(cr, assets['map'])
|
||||||
conus.draw_categories(cr, outlook)
|
conus.draw_categories(cr, outlook)
|
||||||
|
conus.draw_cities(cr, db)
|
||||||
conus.draw_logo(cr, assets['logo'])
|
conus.draw_logo(cr, assets['logo'])
|
||||||
|
|
||||||
if args.dark:
|
if args.dark:
|
||||||
|
@ -39,6 +43,8 @@ def render_probabilistic(conus: SPCOutlookMap,
|
||||||
hazard: str,
|
hazard: str,
|
||||||
path: str,
|
path: str,
|
||||||
args):
|
args):
|
||||||
|
db = Database.connect(args.db)
|
||||||
|
|
||||||
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
assets = ASSETS['dark'] if args.dark else ASSETS['light']
|
||||||
|
|
||||||
with cairo.SVGSurface(path, conus.width, conus.height) as surface:
|
with cairo.SVGSurface(path, conus.width, conus.height) as surface:
|
||||||
|
@ -46,6 +52,7 @@ def render_probabilistic(conus: SPCOutlookMap,
|
||||||
|
|
||||||
conus.draw_base_map_from_file(cr, assets['map'])
|
conus.draw_base_map_from_file(cr, assets['map'])
|
||||||
conus.draw_probabilities(cr, outlook, hazard.upper())
|
conus.draw_probabilities(cr, outlook, hazard.upper())
|
||||||
|
conus.draw_cities(cr, db)
|
||||||
conus.draw_logo(cr, assets['logo'])
|
conus.draw_logo(cr, assets['logo'])
|
||||||
|
|
||||||
if args.dark:
|
if args.dark:
|
||||||
|
@ -54,6 +61,7 @@ def render_probabilistic(conus: SPCOutlookMap,
|
||||||
conus.draw_annotation(cr, f"Day {outlook.day} Probabilistic {hazard.lower().capitalize()} Risk")
|
conus.draw_annotation(cr, f"Day {outlook.day} Probabilistic {hazard.lower().capitalize()} Risk")
|
||||||
|
|
||||||
argparser = argparse.ArgumentParser(description='Render graphical SPC outlooks from text file')
|
argparser = argparse.ArgumentParser(description='Render graphical SPC outlooks from text file')
|
||||||
|
argparser.add_argument('db', help='Spatialite database file')
|
||||||
argparser.add_argument('--dark', action='store_true', help='Output dark mode graphics')
|
argparser.add_argument('--dark', action='store_true', help='Output dark mode graphics')
|
||||||
argparser.add_argument('--categorical', type=str, help='Output categorical risk graphic file')
|
argparser.add_argument('--categorical', type=str, help='Output categorical risk graphic file')
|
||||||
argparser.add_argument('--any-severe', type=str, help='Output probabilistic severe risk graphic file')
|
argparser.add_argument('--any-severe', type=str, help='Output probabilistic severe risk graphic file')
|
||||||
|
|
Loading…
Add table
Reference in a new issue