Commit 7c913438 authored by abuddenberg's avatar abuddenberg
Browse files

Full support for all health assessment metadata (probably)

parent 9658bdbe
......@@ -100,7 +100,7 @@ def populate_activity(mthd_json):
except Exception, e:
warning('Activity exception: ', e)
return act, mthd_json['image_name'], mthd_json['dataset']
return act, mthd_json['image_name'], mthd_json['dataset'].strip() if mthd_json['dataset'] else None
def populate_parent(pub_json):
......
__author__ = 'abuddenberg'
from gcis_clients.domain import Person
DATASET_IDS = {
'U.S. Climate Divisional Dataset Version 2': 'nca3-cddv2-r1',
'World Climate Research Program\'s (WCRP\'s) Coupled Model Intercomparison Project phase 5 (CMIP5) multi-model ensemble': 'nca3-cmip5-r1',
'World Climate Research Program\'s (WCRP\'s) Coupled Model Intercomparison Project phase 5 (CMIP5) multi-model ensemble': 'nca3-cmip5-r1'
'World Climate Research Program\'s (WCRP\'s) Coupled Model Intercomparison Project phase 5 (CMIP5) multi-model ensemble': 'nca3-cmip5-r1',
'ArboNet': 'cdc-arbonet',
'U.S. Natural Hazard Statistics': 'noaa-nws-us-natural-hazard-statistics',
'Billion-Dollar Weather and Climate Disasters': 'noaa-ncdc-billion-dollar-weather-climate-disasters',
'ESRI USA10 dataset (ArcGIS version 10.0)': 'esri-arcgis-v10-0'
}
COPYRIGHT_TRANSLATIONS = {
......@@ -37,7 +43,30 @@ PARENT_PUBTYPE_MAP = {
'Web Page': 'webpage'
}
PARENT_SEARCH_HINTS = {}
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'
},
'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',
'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'
},
'webpage': {
'Screenshot of: Social Vulnerability Index (SVI) Mapping Dashboard': '6d0ccc19-cdcc-4d56-acb7-d62f12611333'
},
'book': {
'Assessing Health Vulnerability to Climate Change: A Guide for Health Departments': ('report', 'assessing-health-vulnerability-to-climate-change-a-guide-for-health-departments')
}
}
ORG_IDS = {
'NOAA NCDC/CICS-NC': 'cooperative-institute-climate-satellites-nc',
......@@ -66,41 +95,77 @@ ORG_IDS = {
'Susanne Moser Research & Consulting': 'susanne-moser-research-consulting',
'NEMAC': 'national-environmental-modeling-analysis-center',
'LBNL': 'lawrence-berkeley-national-laboratory',
'Texas Tech University': 'texas-tech-university'
'Texas Tech University': 'texas-tech-university',
'Centers for Disease Control and Prevention / National Center for Atmospheric Research': 'centers-disease-control-and-prevention',
'Stratus Consulting Inc.': 'stratus-consulting'
}
# host
# point_of_contact
# editor
# analyst
# principal_author
# secondary_author
# data_producer
# author
# scientist
# coordinator
# manager
# convening_lead_author
# lead_author
# contributor
# lead_agency
# publisher
# executive_editor
# distributor
# engineer
# primary_author
# graphic_artist
# coordinating_lead_author
# contributing_editor
# funding_agency
# contributing_author
# data_archive
# advisor
# contributing_agency
PERSON_TRANSLATIONS = {
'Alexis Juliana': Person({'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'}),
'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'}),
}
CONTRIB_ROLES = {
'Kenneth Kunkel': 'scientist',
'Xungang Yin': 'scientist',
'Nina Bednarsek': 'scientist',
'Henry Schwartz': 'scientist',
'Jessicca Griffin': 'graphic_artist',
'James Youtz': 'scientist',
'Chris Fenimore': 'scientist',
'Deb Misch': 'graphic_artist',
'James Galloway': 'scientist',
'Laura Stevens': 'scientist',
'Nichole Hefty': 'point_of_contact',
'Mike Squires': 'scientist',
'Peter Thorne': 'scientist',
'Donald Wuebbles': 'scientist',
'Felix Landerer': 'scientist',
'David Wuertz': 'scientist',
'Russell Vose': 'scientist',
'Gregg Garfin': 'scientist',
'Jeremy Littell': 'scientist',
'Emily Cloyd': 'contributing_author',
'F. Chapin': 'scientist',
' Chapin': 'scientist',
'Andrew Buddenberg': 'analyst',
'Jerry Hatfield': 'author',
'George Luber': 'lead_author',
'Kathy Hibbard': 'lead_author',
'Susanne Moser': 'convening_lead_author',
'Bull Bennett': 'convening_lead_author',
'Ernesto Weil': 'scientist',
'William Elder': 'scientist',
'Greg Dobson': 'analyst',
'Michael Wehner': 'scientist',
'Katharine Hayhoe': 'scientist'
'Kenneth Kunkel': ('cooperative-institute-climate-satellites-nc', 'scientist'),
'Allison Crimmins': ('us-environmental-protection-agency', 'point_of_contact'),
'Micah Hahn': ('centers-disease-control-and-prevention', 'scientist'),
'Jada Garofalo': ('centers-disease-control-and-prevention', 'point_of_contact'),
'Ben Beard': ('centers-disease-control-and-prevention', 'scientist'),
'Dave Mills': ('stratus-consulting', 'analyst'),
'David Mills': ('stratus-consulting', 'analyst'),
'Alexis Juliana': ('stratus-consulting', 'analyst'),
'Neal Fann': ('us-environmental-protection-agency', 'analyst'),
'Pat Dolwick': ('us-environmental-protection-agency', 'scientist'),
'Lewis Ziska': ('us-department-agriculture', 'scientist'),
'Juli Trtanj': ('national-oceanic-atmospheric-administration', 'point_of_contact'),
'Alan Joyner': ('university-north-carolina-chapel-hill', 'graphic_artist'),
'Jeanette Thurston': ('us-department-agriculture', 'scientist'),
'Richard Streeter': ('stratus-consulting', 'analyst'),
'Stephanie Moore': ('national-oceanic-atmospheric-administration', 'scientist'),
'Steve Kibler': ('national-oceanic-atmospheric-administration', 'scientist'),
'Jesse Bell': ('national-oceanic-atmospheric-administration', 'scientist'),
'Lesley Jantarasami': ('us-environmental-protection-agency', 'analyst'),
'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')
}
from __future__ import print_function
__author__ = 'abuddenberg'
from os.path import exists
import sys
def warning(*objs):
print("WARNING: ", *objs, file=sys.stderr)
#This function is for adding images to existing figures
def move_images_to_gcis(webform_client, gcis_client, webform_url, gcis_id, report_id, subset_images=None):
......@@ -19,7 +23,7 @@ def move_images_to_gcis(webform_client, gcis_client, webform_url, gcis_id, repor
raise Exception('Local file missing ' + image.local_path)
if not gcis_client.image_exists(image.identifier):
print 'Creating image: {img}'.format(img=image.identifier)
print('Creating image: {img}'.format(img=image.identifier))
gcis_client.create_image(image, report_id=report_id, figure_id=figure.identifier)
......@@ -34,32 +38,28 @@ def realize_contributors(gcis_client, contributors):
person = cont.person
org = cont.organization
#Hack for F. Chapin
if '.' in person.first_name:
person.first_name = ''
name_matches = gcis_client.lookup_person(person.first_name + ' ' + person.last_name)
if len(name_matches) == 1:
person.id = name_matches[0][0]
elif len(name_matches) == 0:
print '\t', 'No ID found for ' + person.first_name + ' ' + person.last_name
warning('No ID found for ' + person.first_name + ' ' + person.last_name)
else:
print '\t', 'Ambiguous results for ' + person.first_name + ' ' + person.last_name
print '\t\t', name_matches
warning('Ambiguous results for ' + person.first_name + ' ' + person.last_name)
warning(name_matches)
if org.identifier in (None, '') and org.name not in (None, ''):
print 'No ID found for ' + org.name
if org and org.identifier in (None, '') and org.name not in (None, ''):
warning('No ID found for ' + org.name)
#Check if we missed any organizations in our hardcoding...
if not all(map(lambda c: c.organization.identifier is not None, contributors)):
print 'Missing organizations: ', contributors
if not all(map(lambda c: c.organization is None or c.organization.identifier is not None, contributors)):
warning('Missing organizations: ', contributors)
def realize_parents(gcis_client, parents):
for parent in parents:
# print parent.publication_type_identifier, parent.label
if parent.url:
print '\t', ' '.join(('Using hint for', parent.publication_type_identifier, parent.label))
print(' '.join(('Using hint for', parent.publication_type_identifier, parent.label)))
continue
parent_matches = gcis_client.lookup_publication(parent.publication_type_identifier, parent.label)
......@@ -67,7 +67,7 @@ def realize_parents(gcis_client, parents):
if len(parent_matches) == 1:
parent.url = '/{type}/{id}'.format(type=parent.publication_type_identifier, id=parent_matches[0][0])
elif len(parent_matches) == 0:
print '\t', ' '.join(('No ID found for', parent.publication_type_identifier, parent.label))
warning(' '.join(('No ID found for', parent.publication_type_identifier, parent.label)))
else:
print '\t', ' '.join(('Ambiguous results for', parent.publication_type_identifier, parent.label))
print '\t\t', parent_matches
\ No newline at end of file
warning(' '.join(('Ambiguous results for', parent.publication_type_identifier, parent.label)))
warning(parent_matches)
__author__ = 'abuddenberg'
from gcis_clients import GcisClient, SurveyClient, survey_token, gcis_dev_auth
from gcis_clients import GcisClient, SurveyClient, survey_token, gcis_dev_auth, gcis_stage_auth
from gcis_clients.domain import Report, Chapter
from sync_utils import realize_parents, realize_contributors
from collections import OrderedDict
import pickle
import sys
gcis = GcisClient('http://data.gcis-dev-front.joss.ucar.edu', *gcis_dev_auth)
# gcis = GcisClient('https://data-review.globalchange.gov', *gcis_stage_auth)
surveys = SurveyClient('https://healthresources.globalchange.gov', survey_token)
sync_metadata_tree = {
'usgcrp-climate-and-health-assessment-draft': OrderedDict([
# ('executive-summary', []),
# ('climate-change-and-human-health', [
# ('/metadata/figures/3698', 'major_u_s__climate_trends'), #1.1 #climate-change-and-human-health
# ('/metadata/figures/3632', 'percent_changes_in_the_annual_number_of_extreme_precipitation_events_'), #1.2 #climate-change-and-human-health
# ('/metadata/figures/3635', 'projected_changes_in_temperature_and_precipitation_by_mid_century'), #1.3 #climate-change-and-human-health
# ('/metadata/figures/3633', 'projected_changes_in_the_hottest_coldest_and_wettest_driest_day_of_the_year'), #1.4 #climate-change-and-human-health
# ('/metadata/figures/3757', 'climate_change_and_health'), #1.5 #climate-change-and-human-health
# ]),
# ('temperature-related-death-and-illness', [
# ('/metadata/figures/3811', 'climate_change_and_health__extreme_heat'), #2.1 #temperature-related-death-and-illness
# ('/metadata/figures/3585', 'heat_related_deaths_during_the_1995_chicago_heat_wave'), #2.2 #temperature-related-death-and-illness
# ('/metadata/figures/3643', 'projected_net_changes_in_extreme_temperature_related_deaths'), #2.3 #temperature-related-death-and-illness
# ('/metadata/figures/3653', 'projected_changes_in_deaths_in_u_s__cities_by_season'), #2.4 #temperature-related-death-and-illness
# ]),
# ('air-quality-impacts', [
# ('/metadata/figures/3812', 'climate_change_and_health__outdoor_air_quality'), #3.1 #air-quality-impacts
# ('/metadata/figures/3647', 'projected_change_in_average_daily_maximum_temperature__seasonal_average_maximum_daily_8_hr_ozone__and_ozone_related_premature_deaths_in_2013'), #3.2 #air-quality-impacts
# ('/metadata/figures/3649', 'projected_change_in_ozone_related_premature_deaths'), #3.3 #air-quality-impacts
# ('/metadata/figures/3650', 'ragweed_pollen_season_lengthens'), #3.4 #air-quality-impacts
# ]),
# ('vectorborne-diseases', [
# ('/metadata/figures/3807', 'climate_change_and_health__lyme_disease'), #4.1 #vectorborne-diseases
# ('/metadata/figures/3659', 'changes_in_lyme_disease_case_report_distribution'), #4.2 #vectorborne-diseases
# ('/metadata/figures/3658', 'life_cycle_of_blacklegged_ticks__ixodes_scapularis'), #4.3 #vectorborne-diseases
# ('/metadata/figures/3747', 'lyme_disease_onset_week_modeling_scenarios'), #4.4 #vectorborne-diseases
# ('/metadata/figures/3674', 'incidence_of_west_nile_neuroinvasive_disease_in_the_united_states'), #4.5 #vectorborne-diseases
# ('/metadata/figures/3675', 'climate_impacts_on_west_nile_virus_transmission'), #4.6 #vectorborne-diseases
# ]),
# ('water-related-illnesses', [
# ('/metadata/figures/3824', 'climate_change_and_health___vibrio'), #5.1 #water-related-illnesses
# ('/metadata/figures/3700', 'links_between_climate_change__water_quantity_and_quality__and_human_exposure_to_water_related_illness'), #5.2 #water-related-illnesses
# ('/metadata/figures/3671', 'locations_of_livestock_and_projections_of_heavy_precipitation'), #5.3 #water-related-illnesses
# # ('/metadata/figures/3673', 'potential_routes_of_manure_borne_microbial_contaminants_to_ground_and_surface_water_supplies_'), #5.3 #water-related-illnesses UNUSED?
# ('/metadata/figures/3709', 'projections_of_vibrio_occurrence_and_abundance_in_chesapeake_bay'), #5.4 #water-related-illnesses
# ('/metadata/figures/3704', 'changes_in_suitable_coastal_vibrio_habitat_in_alaska'), #5.5 #water-related-illnesses
# ('/metadata/figures/3734', 'projected_changes_in_caribbean_gambierdiscus_species'), #5.6 #water-related-illnesses
# ('/metadata/figures/3712', 'projections_of_growth_of_alexandrium_fundyense_in_puget_sound'), #5.7 #water-related-illnesses
# ]),
# ('food-safety--nutrition--and-distribution', [
# ('/metadata/figures/3579', 'farm_to_table'), #6.1 #food-safety--nutrition--and-distribution
# # ('/metadata/figures/3600', 'mycotoxin_in_corn'), #6.1 #food-safety--nutrition--and-distribution BOX 1?
# ('/metadata/figures/3809', 'climate_change_and_health__salmonella'), #6.2 #food-safety--nutrition--and-distribution
# ('/metadata/figures/3748', 'seasonality_of_human_illnesses_associated_with_foodborne_pathogens'), #6.3 #food-safety--nutrition--and-distribution
# ('/metadata/figures/3688', 'effects_of_carbon_dioxide_on_protein_and_minerals'), #6.4 #food-safety--nutrition--and-distribution
# ('/metadata/figures/3597', 'mississippi_river_level_at_st__louis__missouri'), #6.5 #food-safety--nutrition--and-distribution
# ]),
# ('extreme-weather', [
# ('/metadata/figures/3810', 'estimated_deaths_and_billion_dollar_losses_from_extreme_weather_events_in_the_u_s__2004_2013'), #7.1 #extreme-weather
# # ('/metadata/figures/3772', 'trends_in_flood_magnitude'), #7.2 #extreme-weather NOT USED
# ('/metadata/figures/3808', 'climate_change_and_health__flooding'), #7.2 #extreme-weather
# ('/metadata/figures/3760', 'hurricane_induced_flood_effects_in_eastern_and_central_united_states'), #7.3 #extreme-weather
# ]),
# ('mental-health-and-well-being', [
# ('/metadata/figures/3789', 'climate_change_and_mental_health'), #8.1 #mental-health-and-well-being
# ('/metadata/figures/3722', 'the_impact_of_climate_change_on_physical__mental__and_community_health'), #8.2 #mental-health-and-well-being
# ]),
('executive-summary', []),
('climate-change-and-human-health', [
('/metadata/figures/3698', 'major_u_s__climate_trends'), #1.1 #climate-change-and-human-health
('/metadata/figures/3632', 'percent_changes_in_the_annual_number_of_extreme_precipitation_events_'), #1.2 #climate-change-and-human-health
('/metadata/figures/3635', 'projected_changes_in_temperature_and_precipitation_by_mid_century'), #1.3 #climate-change-and-human-health
('/metadata/figures/3633', 'projected_changes_in_the_hottest_coldest_and_wettest_driest_day_of_the_year'), #1.4 #climate-change-and-human-health
('/metadata/figures/3757', 'climate_change_and_health'), #1.5 #climate-change-and-human-health
]),
('temperature-related-death-and-illness', [
('/metadata/figures/3811', 'climate_change_and_health__extreme_heat'), #2.1 #temperature-related-death-and-illness
('/metadata/figures/3585', 'heat_related_deaths_during_the_1995_chicago_heat_wave'), #2.2 #temperature-related-death-and-illness
('/metadata/figures/3643', 'projected_net_changes_in_extreme_temperature_related_deaths'), #2.3 #temperature-related-death-and-illness
('/metadata/figures/3653', 'projected_changes_in_deaths_in_u_s__cities_by_season'), #2.4 #temperature-related-death-and-illness
]),
('air-quality-impacts', [
('/metadata/figures/3812', 'climate_change_and_health__outdoor_air_quality'), #3.1 #air-quality-impacts
('/metadata/figures/3647', 'projected_change_in_average_daily_maximum_temperature__seasonal_average_maximum_daily_8_hr_ozone__and_ozone_related_premature_deaths_in_2013'), #3.2 #air-quality-impacts
('/metadata/figures/3649', 'projected_change_in_ozone_related_premature_deaths'), #3.3 #air-quality-impacts
('/metadata/figures/3650', 'ragweed_pollen_season_lengthens'), #3.4 #air-quality-impacts
]),
('vectorborne-diseases', [
('/metadata/figures/3807', 'climate_change_and_health__lyme_disease'), #4.1 #vectorborne-diseases
('/metadata/figures/3659', 'changes_in_lyme_disease_case_report_distribution'), #4.2 #vectorborne-diseases
('/metadata/figures/3658', 'life_cycle_of_blacklegged_ticks__ixodes_scapularis'), #4.3 #vectorborne-diseases
('/metadata/figures/3747', 'lyme_disease_onset_week_modeling_scenarios'), #4.4 #vectorborne-diseases
('/metadata/figures/3674', 'incidence_of_west_nile_neuroinvasive_disease_in_the_united_states'), #4.5 #vectorborne-diseases
('/metadata/figures/3675', 'climate_impacts_on_west_nile_virus_transmission'), #4.6 #vectorborne-diseases
]),
('water-related-illnesses', [
('/metadata/figures/3824', 'climate_change_and_health___vibrio'), #5.1 #water-related-illnesses
('/metadata/figures/3700', 'links_between_climate_change__water_quantity_and_quality__and_human_exposure_to_water_related_illness'), #5.2 #water-related-illnesses #TOO BIG
('/metadata/figures/3671', 'locations_of_livestock_and_projections_of_heavy_precipitation'), #5.3 #water-related-illnesses #TOO BIG
('/metadata/figures/3673', 'potential_routes_of_manure_borne_microbial_contaminants_to_ground_and_surface_water_supplies_'), #5.3 #water-related-illnesses UNUSED?
('/metadata/figures/3709', 'projections_of_vibrio_occurrence_and_abundance_in_chesapeake_bay'), #5.4 #water-related-illnesses
('/metadata/figures/3704', 'changes_in_suitable_coastal_vibrio_habitat_in_alaska'), #5.5 #water-related-illnesses
('/metadata/figures/3734', 'projected_changes_in_caribbean_gambierdiscus_species'), #5.6 #water-related-illnesses
('/metadata/figures/3712', 'projections_of_growth_of_alexandrium_fundyense_in_puget_sound'), #5.7 #water-related-illnesses
]),
('food-safety--nutrition--and-distribution', [
('/metadata/figures/3579', 'farm_to_table'), #6.1 #food-safety--nutrition--and-distribution
## ('/metadata/figures/3600', 'mycotoxin_in_corn'), #6.1 #food-safety--nutrition--and-distribution BOX 1?
('/metadata/figures/3809', 'climate_change_and_health__salmonella'), #6.2 #food-safety--nutrition--and-distribution
('/metadata/figures/3748', 'seasonality_of_human_illnesses_associated_with_foodborne_pathogens'), #6.3 #food-safety--nutrition--and-distribution
('/metadata/figures/3688', 'effects_of_carbon_dioxide_on_protein_and_minerals'), #6.4 #food-safety--nutrition--and-distribution
('/metadata/figures/3597', 'mississippi_river_level_at_st__louis__missouri'), #6.5 #food-safety--nutrition--and-distribution
]),
('extreme-weather', [
('/metadata/figures/3810', 'estimated_deaths_and_billion_dollar_losses_from_extreme_weather_events_in_the_u_s__2004_2013'), #7.1 #extreme-weather #Has Activities
## ('/metadata/figures/3772', 'trends_in_flood_magnitude'), #7.2 #extreme-weather NOT USED
('/metadata/figures/3808', 'climate_change_and_health__flooding'), #7.2 #extreme-weather
('/metadata/figures/3760', 'hurricane_induced_flood_effects_in_eastern_and_central_united_states'), #7.3 #extreme-weather
]),
('mental-health-and-well-being', [
('/metadata/figures/3789', 'climate_change_and_mental_health'), #8.1 #mental-health-and-well-being
('/metadata/figures/3722', 'the_impact_of_climate_change_on_physical__mental__and_community_health'), #8.2 #mental-health-and-well-being
]),
('populations-of-concern', [
# ('/metadata/figures/3696', 'determinants_of_vulnerability'), #9.1 #populations-of-concern
('/metadata/figures/3696', 'determinants_of_vulnerability'), #9.1 #populations-of-concern
('/metadata/figures/3694', 'social_determinants_of_health'), #9.2 #populations-of-concern
# ('/metadata/figures/3758', 'children_at_different_lifestages_experience_unique_vulnerabilities_to_climate_change'), #9.3 #populations-of-concern
# ('/metadata/figures/3714', 'mapping_social_vulnerability'), #9.4 #populations-of-concern
# ('/metadata/figures/3717', 'mapping_communities_vulnerable_to_heat_in_georgia'), #9.5 #populations-of-concern
('/metadata/figures/3758', 'children_at_different_lifestages_experience_unique_vulnerabilities_to_climate_change'), #9.3 #populations-of-concern
('/metadata/figures/3714', 'mapping_social_vulnerability'), #9.4 #populations-of-concern
('/metadata/figures/3717', 'mapping_communities_vulnerable_to_heat_in_georgia'), #9.5 #populations-of-concern
]),
# ('appendix-1--technical-support-document', [
# ('/metadata/figures/3623', 'emissions_levels_determine_temperature_rises'), #1.1 #climate-change-and-human-health
# ('/metadata/figures/3759', 'the_shared_socioeconomic_pathways'), #1.2 #climate-change-and-human-health
# ('/metadata/figures/3726', 'example_spatial_resolution_of_climate_models'), #1.3 #climate-change-and-human-health
# ('/metadata/figures/3638', 'sensitivity_analysis_of_differences_in_modeling_approaches'), #1.4 #climate-change-and-human-health
# ])
('appendix-1--technical-support-document', [
('/metadata/figures/3623', 'emissions_levels_determine_temperature_rises'), #1.1 #climate-change-and-human-health
('/metadata/figures/3759', 'the_shared_socioeconomic_pathways'), #1.2 #climate-change-and-human-health
('/metadata/figures/3726', 'example_spatial_resolution_of_climate_models'), #1.3 #climate-change-and-human-health
('/metadata/figures/3638', 'sensitivity_analysis_of_differences_in_modeling_approaches'), #1.4 #climate-change-and-human-health
])
])
}
def main():
print gcis.test_login()
# regenerate_image_id_map()
image_id_map = pickle.load(open('image_id_cache.pk1', 'r'))
# create_health_report()
for report_id in sync_metadata_tree:
for chapter_id in sync_metadata_tree[report_id]:
for survey_url, figure_id in sync_metadata_tree[report_id][chapter_id]:
print survey_url
print survey_url, gen_edit_link(survey_url)
s = surveys.get_survey(survey_url, do_download=False)
print s.contributors
print s.parents
print s.usage_limits
figure, datasets = surveys.get_survey(survey_url, do_download=True)
realize_parents(gcis, figure.parents)
realize_contributors(gcis, figure.contributors)
# for i in s.images:
# i.identifier = image_id_map[i.identifier]
#
# print i.contributors
# print i.parents
#
# for ds in i.datasets:
# if ds.activity and ds.activity.identifier is None:
# ds.activity.identifier = generate_activity_id(i, ds)
# print ds
print 'Contributors: ', figure.contributors
print 'Parents: ', figure.parents
for ds in [p for p in figure.parents if p.publication_type_identifier == 'dataset']:
# Assign synthetic activity identifier to for datasets associated with figure
if ds.activity and ds.activity.identifier is None:
ds.activity.identifier = generate_activity_id(figure, ds.publication)
print 'Dataset: ', ds.activity
# realize_parents(gcis, s.parents)
# realize_contributors(gcis, s.contributors)
#Create the figure in GCIS
# print 'Creating figure... ', gcis.create_figure(report_id, chapter_id, figure, skip_images=True)
print 'Updating figure... ', gcis.update_figure(report_id, chapter_id, figure, skip_images=True)
for i in figure.images:
i.identifier = image_id_map[i.identifier]
print '\t', i
realize_parents(gcis, i.parents)
realize_contributors(gcis, i.contributors)
# for i in s.images:
# i.identifier = image_id_map[i.identifier]
# i.datasets = []
# print gcis.create_image(i, report_id=report_id, figure_id=figure_id)
print '\t\tContributors: ', i.contributors
print '\t\tParents: ', i.parents
for ds in [p for p in i.parents if p.publication_type_identifier == 'dataset']:
# Assign synthetic activity identifier to for datasets associated with images
if ds.activity and ds.activity.identifier is None:
ds.activity.identifier = generate_activity_id(i, ds.publication)
print '\t\tDataset: ', ds, ds.activity
#Create image in GCIS
# print 'Creating image... ', gcis.create_image(i, report_id=report_id, figure_id=figure_id)
print 'Updating image... ', gcis.update_image(i)
def gen_edit_link(survey_id):
node_id = survey_id.split('/')[-1]
return 'https://healthresources.globalchange.gov/node/' + node_id
def generate_activity_id(image, dataset):
return '-'.join([image.identifier.split('-')[0], dataset.identifier, '-process'])
try:
return '-'.join([image.identifier.split('-')[0], dataset.identifier, '-process'])
except Exception, e:
sys.stderr.write('WARNING: Activity identifier generation failed\n')
def regenerate_image_id_map(existing=None):
from uuid import uuid4
......@@ -169,20 +190,21 @@ def gen_survey_list():
def create_health_report():
hr = Report({})
hr.identifier = 'usgcrp-climate-and-health-assessment-draft'
hr.report_type_identifier = 'assessment'
hr.title = 'Impacts of Climate Change on Human Health in the United States: A Scientific Assessment'
hr.url = 'http://www.globalchange.gov/health-assessment'
hr.publication_year = '2015'
hr.contact_email = 'healthreport@usgcrp.gov'
hr = Report({
'identifier': 'usgcrp-climate-and-health-assessment-draft',
'report_type_identifier': 'assessment',
'title': 'Impacts of Climate Change on Human Health in the United States: A Scientific Assessment',
'url': 'http://www.globalchange.gov/health-assessment',
'publication_year': '2015',
'contact_email': 'healthreport@usgcrp.gov'
})
# ['report_identifier', 'identifier', 'number', 'title', 'url']
chapters = [
('executive-summary', None, 'Executive Summary'),
('climate-change-and-human-health', 1, 'Climate Change and Human Health'),
('temperature-related-death-and-illness', 2, 'Temperature-Related Death and Illness'),
('air-quality-impacts', 3, 'Air Quality Impacts '),
('air-quality-impacts', 3, 'Air Quality Impacts'),
('vectorborne-diseases', 4, 'Vectorborne Diseases'),
('water-related-illnesses', 5, 'Climate Impacts on Water-Related Illnesses'),
('food-safety--nutrition--and-distribution', 6, 'Food Safety, Nutrition, and Distribution'),
......@@ -192,15 +214,49 @@ def create_health_report():
('appendix-1--technical-support-document', None, 'Appendix 1: Technical Support Document')
]
# print gcis.create_report(hr)
print gcis.create_report(hr)
for id, num, title in chapters:
ch = Chapter({})
ch.identifier = id
ch.number = num
ch.title = title
ch.report_identifier = hr.identifier
ch = Chapter({
'identifier': id,
'number': num,
'title': title,
'report_identifier': hr.identifier
})
print gcis.create_chapter(hr.identifier, ch)
def create_cmip5_report():
cmip = Report({
'identifier': 'noaa-techreport-nesdis-144',
'report_type_identifier': 'report',
'title': 'Regional Surface Climate Conditions in CMIP3 and CMIP5 for the United States: Differences, Similarities, and Implications for the U.S. National Climate Assessment',
'publication_year': '2015'
})
print gcis.create_report(cmip)
chapters = [
('introduction', 1, 'Introduction'),
('data', 2, 'Data'),
('methods', 3, 'Methods'),
('temperature', 4, 'Temperature'),
('precipitation', 5, 'Precipitation'),
('summary', 6, 'Summary'),
('appendix', None, 'Appendix'),
('references', None, 'References'),
('acknowledgements', None, 'Acknowledgements'),
]
for id, num, title in chapters:
ch = Chapter({
'identifier': id,
'number': num,
'title': title,
'report_identifier': cmip.identifier
})
print gcis.create_chapter(cmip.identifier, ch)
main()
\ No newline at end of file
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