Changeset 7572


Ignore:
Timestamp:
Nov 26, 2009, 2:02:35 PM (14 years ago)
Author:
jgriffin
Message:

Now calculates differences in area and writes to file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/new_south_wales/batemans_bay/compare_inundation_areas.py

    r7570 r7572  
    1313from os.path import join
    1414from collections import defaultdict
     15import csv
     16
     17
     18
    1519# Create the Geoprocessor object
    1620gp = arcgisscripting.create(9.3)
     
    3034boundary_path = "N:\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\boundaries\\"
    3135boundary_file_name = 'wave_energy_summary.csv'
     36out_file_name = 'area_comparisons.csv'
     37#figure = 'area_comparisons.png'
     38
    3239boundary_file = join(boundary_path,boundary_file_name)
     40out_file = join(boundary_path, out_file_name)
     41#figure_path = join(boundary_path, 'figures',figure)
     42plot = True
    3343
    3444event_dict = {'Event1_MSL':58346,
    35               'Event1_HAT':58346,
    36 ##              'Event2_MSL':51204,
     45##              'Event1_HAT':58346,
     46              'Event2_MSL':51204,
    3747##              'Event2_HAT':51204,
    38               'Event3_MSL':58284}#,
     48              'Event3_MSL':58284,#,
    3949##              'Event3_HAT':58284,
    40 ##              'Puysegur_200yr':58129,
    41 ##              'Puysegur_500yr':58115,
    42 ##              'Puysegur_1000yr':58226,
    43 ##              'Puysegur_5000yr':58286,
    44 ##              'Puysegur_15000yr':58272,
    45 ##              'New_Hebrides_200yr':51077,
    46 ##              'New_Hebrides_500yr':51378,
    47 ##              'New_Hebrides_1000yr':51347,
    48 ##              'New_Hebrides_2000yr':51292,
    49 ##              'New_Hebrides_5000yr':51424,}
    50 
    51 # Dictionary for storing area comparison
     50              'Puysegur_200yr':58129,
     51              'Puysegur_500yr':58115,
     52              'Puysegur_1000yr':58226,
     53              'Puysegur_5000yr':58286,
     54              'Puysegur_15000yr':58272,
     55              'New_Hebrides_200yr':51077,
     56              'New_Hebrides_500yr':51378,
     57              'New_Hebrides_1000yr':51347,
     58              'New_Hebrides_2000yr':51292,
     59              'New_Hebrides_5000yr':51424,}
     60
     61# Dictionaries for storing area comparison
    5262area_comp = defaultdict(list)
     63area_percent = defaultdict(list)
    5364
    5465boundaries = file(boundary_file,'r')
     
    236247
    237248    for key in anuga_area_dict:
     249        if not key in analytical_area_dict:
     250            analytical_area_dict[key] = 0.
    238251        diff = anuga_area_dict[key]-analytical_area_dict[key]
     252        percent_diff = 100*diff/anuga_area_dict[key]
    239253        area_comp[key].append(diff)
    240     print 'area_comp', area_comp
    241    
     254        area_percent[key].append(percent_diff)
     255print 'area_comp', area_comp
     256print 'area_percent', area_percent
     257
     258##csv_dict = csv.DictWriter(open(out_file,'w'),[1,2,3,4,5,6,7,8,9])
     259##csv_dict.writerow(dict(zip([1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9])))
     260##csv_dict.writerow(area_percent)
     261
     262csv_out = csv.writer(open(out_file,'w'))
     263csv_out.writerow([1,2,3,4,5,6,7,8,9])
     264for i in range(len(area_percent[1])):
     265    value_list =[]
     266    for key in area_percent:
     267        value_list.append(area_percent[key][i])
     268    csv_out.writerow(value_list)
     269     
     270out_file.close()   
     271##for key, value in area_percent:
     272##    key_list = []
     273##    for val in value:
     274##        key_list.append(key)
     275##    pylab.scatter(key_list,value)
     276       
     277
     278
     279
     280
    242281boundaries.close()
     282
     283
Note: See TracChangeset for help on using the changeset viewer.