Commit c56042ed authored by abuddenberg's avatar abuddenberg
Browse files

Support for all Health Assessment figures

parent 5e9c7ebe
This diff is collapsed.
......@@ -108,7 +108,7 @@ class GcisClient(object):
self.s.headers.update({'Accept': 'application/json'})
def create_figure(self, report_id, chapter_id, figure, skip_images=False):
def create_figure(self, report_id, chapter_id, figure, skip_images=False, skip_upload=False):
if figure.identifier in (None, ''):
raise Exception('Invalid figure identifier', figure.identifier)
......@@ -124,7 +124,7 @@ class GcisClient(object):
if resp.status_code != 200:
return resp
if figure.local_path is not None:
if not skip_upload and figure.local_path is not None:
self.upload_figure_file(report_id, chapter_id, figure.identifier, figure.local_path)
if skip_images is False:
......@@ -6,6 +6,7 @@ import requests
import re
from os.path import join, basename
import sys
import traceback
from gcis_clients.domain import Figure, Image, Dataset, Parent, Contributor, Person, Organization, Activity, Role
import survey_transforms as trans
......@@ -25,7 +26,7 @@ def get_credentials():
def parse_title(graphic_title):
match ='\d+\.\d+', graphic_title)
match ='\w+\.\d+', graphic_title)
if match:
return, graphic_title[match.end(0):].strip()
......@@ -35,7 +36,20 @@ def parse_title(graphic_title):
def populate_figure(fig_json):
f = Figure({})
f.figure_num, f.title = parse_title(fig_json['graphics_title'])
if fig_json['graphics_title'].startswith('ES'):
title_fields = fig_json['graphics_title'].split('. ')
title = ' '.join(title_fields[1:])
f.ordinal ='\d+', title_fields[0]).group(0)
figure_num, title = parse_title(fig_json['graphics_title'])
if figure_num and figure_num.startswith('TSD'):
f.ordinal = figure_num.split('.')[1]
f.figure_num = figure_num if figure_num else None
f.title = title
f.identifier = fig_json['figure_id'] if fig_json['figure_id'] else re.sub('\W', '_', f.title).lower()
f.create_dt = fig_json['graphics_create_date'].strip()
if any(fig_json['period_record']):
......@@ -43,7 +57,7 @@ def populate_figure(fig_json):
f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent']
except Exception, e:
warning('Figure exception: ', e)
return f
......@@ -47,21 +47,29 @@ PARENT_SEARCH_HINTS = {
'report': {
'Climate Change Impacts in the United States: The Third National Climate Assessment': 'nca3',
'Third National Climate Assessment': 'nca3',
'A conceptual framework for action on the social determinants of health': 'conceptual-framework-for-action-on-the-social-determinants-of-health'
'A conceptual framework for action on the social determinants of health': 'conceptual-framework-for-action-on-the-social-determinants-of-health',
'Regional Surface Climate Conditions in CMIP3 and CMIP5 for the United States: Differences, Similarities, and Implications for the U.S. National Climate Assessment.': 'noaa-techreport-nesdis-144',
'2012 Census of Agriculture': 'census-agriculture-2012'
'dataset': {
'Global Historical Climatology Network - Daily': 'noaa-ncdc-ghcn-daily'
'article': {
'Projections of future temperature-attributable deaths in 209 U.S. cities using a cluster based Poisson approach': 'projections-of-future-temperature-attributable-deaths-in-209-us-cities',
'Projections of future temperature-attributable deaths in 209 U.S. cities using a cluster based Poisson approach': '10.1186/s12940-015-0071-2',
'Projections of future temperature-attributable deaths in 209 U.S. cities 1 using a cluster-based Poisson approach': '10.1186/s12940-015-0071-2',
'A framework for examining climate driven changes to the seasonality and geographic range of coastal pathogens': '10.1016/j.crm.2015.03.002',
'Effects of Ocean Warming on Growth and Distribution of Five Ciguatera-Associated Dinoflagellates in the Caribbean and Implications for Ciguatera Fish Poisoning': 'potential-effects-of-climate-change-on-growth-and-distribution-of-five-caribbean-gambierdiscus-species',
'Effects of elevated CO2 on the protein concentration of food crops: a meta-analysis': '10.1111/j.1365-2486.2007.01511.x',
'A new scenario framework for climate change research: the concept of shared socio-economic pathways': '10.1007/s10584-013-0905-2',
'Climate Change influences on the annual onset of Lyme disease in the United States': '10.1016/j.ttbdis.2015.05.005'
'Climate Change influences on the annual onset of Lyme disease in the United States': '10.1016/j.ttbdis.2015.05.005',
'The roads ahead: Narratives for shared socioeconomic pathways describing world futures in the 21st century': '10.1016/j.gloenvcha.2015.01.004'
'webpage': {
'Screenshot of: Social Vulnerability Index (SVI) Mapping Dashboard': '6d0ccc19-cdcc-4d56-acb7-d62f12611333'
'Screenshot of: Social Vulnerability Index (SVI) Mapping Dashboard': '6d0ccc19-cdcc-4d56-acb7-d62f12611333',
'Lyme Disease: Data and Statistics: Maps': '7206f315-04be-4536-9e10-70155edfada0',
'Risk of very large fires could increase sixfold by mid-century in the US': 'af962cb2-dd38-44f6-9b4e-7bef8577b92c',
'Flickr account: User: TeamSaintLouis. Album: Low Water on the Mississippi River': '9853a51e-b7c2-42c5-a201-d2f5c8527f52',
'USDA Biological Control of Pests Research Unit': '950835c0-2088-4f06-a61a-a809387d4930'
'book': {
'Assessing Health Vulnerability to Climate Change: A Guide for Health Departments': ('report', 'assessing-health-vulnerability-to-climate-change-a-guide-for-health-departments')
......@@ -130,18 +138,28 @@ ORG_IDS = {
# contributing_agency
'Alexis Juliana': Person({'first_name': 'Alexis', 'last_name': 'St. Juliana'}),
'Alexis St. Juliana': Person({'id': 9934, 'first_name': 'Alexis', 'last_name': 'St. Juliana'}),
'Alexis Juliana': Person({'id': 9934, 'first_name': 'Alexis', 'last_name': 'St. Juliana'}),
'Pat Dolwick': Person({'first_name': 'Patrick', 'last_name': 'Dolwick'}),
'Alan Joyner': Person({'first_name': 'Alan', 'last_name': 'Joyner'}),
'Juli Trtanj': Person({'first_name': 'Juli M.', 'last_name': 'Trtanj'}),
'Stephanie Moore': Person({'first_name': 'Stephanie K.', 'last_name': 'Moore'}),
'Juli Trtanj': Person({'id': 1264, 'first_name': 'Juli M.', 'last_name': 'Trtanj'}),
'Juli M. Trtanj': Person({'id': 1264, 'first_name': 'Juli M.', 'last_name': 'Trtanj'}),
'Stephanie Moore': Person({'id': 9889, 'first_name': 'Stephanie K.', 'last_name': 'Moore'}),
'Stephanie K. Moore': Person({'id': 9889, 'first_name': 'Stephanie', 'last_name': 'Moore'}),
'Steve Kibler': Person({'first_name': 'Steven R.', 'last_name': 'Kibler'}),
'Jesse Bell': Person({'first_name': 'Jesse E.', 'last_name': 'Bell'}),
'Dave Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}),
'David Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}),
'Lesley Crimmins)': Person({'first_name': 'Lesley', 'last_name': 'Jantarasami'}),
'Allison Jantarasami)': Person({'first_name': 'Allison', 'last_name': 'Crimmins'}),
'Lewis Ziska': Person({'first_name': 'Lewis H.', 'last_name': 'Ziska'}),
'Lewis Ziska': Person({'id': 923, 'first_name': 'Lewis', 'last_name': 'Ziska'}),
'Jada Garofalo': Person({'id': 9885, 'first_name': 'Jada', 'last_name': 'F. Garofalo'}),
'Micah Hahn': Person({'id': 9886, 'first_name': 'Micah', 'last_name': 'Hahn'}),
'Jeanette Thurston': Person({'id': 9892, 'first_name': 'Jeanette', 'last_name': 'Thurston'}),
'Daniel Dodgen': Person({'id': 9908, 'first_name': 'Daniel', 'last_name': 'Dodgen'}),
'John Jacobs': Person({'id': 9888, 'first_name': 'John', 'last_name': 'Jacobs'}),
'Stephanie Herring': Person({'id': 8333, 'first_name': 'Stephanie', 'last_name': 'Herring'}),
'Tom Maycock': Person({'id': 10926, 'first_name': 'Tom', 'last_name': 'Maycock'})
......@@ -153,6 +171,7 @@ CONTRIB_ROLES = {
'Dave Mills': ('stratus-consulting', 'analyst'),
'David Mills': ('stratus-consulting', 'analyst'),
'Alexis Juliana': ('stratus-consulting', 'analyst'),
'Alexis St. Juliana': ('stratus-consulting', 'analyst'),
'Neal Fann': ('us-environmental-protection-agency', 'analyst'),
'Pat Dolwick': ('us-environmental-protection-agency', 'scientist'),
'Lewis Ziska': ('us-department-agriculture', 'scientist'),
......@@ -167,5 +186,8 @@ CONTRIB_ROLES = {
'Daniel Dodgen': ('us-department-health-human-services', 'point_of_contact'),
'Andrea Maguire': ('us-environmental-protection-agency', 'point_of_contact'),
'Lesley Crimmins)': ('us-environmental-protection-agency', 'analyst'),
'Allison Jantarasami)': ('us-environmental-protection-agency', 'point_of_contact')
'Allison Jantarasami)': ('us-environmental-protection-agency', 'point_of_contact'),
'John Jacobs': ('national-oceanic-atmospheric-administration', 'scientist'),
'Stephanie Herring': ('national-oceanic-atmospheric-administration', 'scientist'),
'Tom Maycock': ('cooperative-institute-climate-satellites-nc', 'point_of_contact'),
......@@ -38,6 +38,7 @@ def realize_contributors(gcis_client, contributors):
person = cont.person
org = cont.organization
if not
name_matches = gcis_client.lookup_person(person.first_name + ' ' + person.last_name)
if len(name_matches) == 1: = name_matches[0][0]
......@@ -19,7 +19,7 @@ class PyTest(TestCommand):
author='Andrew Buddenberg',
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment