Changeset 4552


Ignore:
Timestamp:
Jun 20, 2007, 6:34:21 PM (18 years ago)
Author:
ole
Message:

Got the shark bay scenario to build

Location:
anuga_work/production/shark_bay_2007
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/shark_bay_2007/build_shark_bay.py

    r4505 r4552  
    33Source data such as elevation and boundary data is assumed to be available in
    44directories specified by project_urs.py
    5 The output sww file is stored in project_urs.output_time_dir
     5The output sww file is stored in project.output_time_dir
    66
    77The scenario is defined by a triangular mesh created from project_urs.polygon,
     
    3131from anuga.pmesh.mesh_interface import create_mesh_from_regions
    3232from anuga.geospatial_data.geospatial_data import Geospatial_data
    33 from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
     33from anuga.shallow_water.data_manager import start_screen_catcher
     34from anuga.shallow_water.data_manager import copy_code_files
     35
    3436from anuga_parallel.parallel_abstraction import get_processor_name
    3537
    3638# Application specific imports
    37 import project_urs   # Definition of file names and polygons
     39import project   # Definition of file names and polygons
     40
    3841
    3942#------------------------------------------------------------------------------
     
    4245#------------------------------------------------------------------------------
    4346
    44 copy_code_files(project_urs.output_build_time_dir,__file__,
    45                dirname(project_urs.__file__)+sep+ project_urs.__name__+'.py' )
     47copy_code_files(project.output_build_time_dir,__file__,
     48               dirname(project.__file__)+sep+ project.__name__+'.py' )
    4649
    47 start_screen_catcher(project_urs.output_build_time_dir)
     50start_screen_catcher(project.output_build_time_dir)
    4851
    49 print "Processor Name:",get_processor_name()
    50 print 'USER: ', project_urs.user
     52print 'Processor Name:', get_processor_name()
     53print 'User: ', project.user
     54
    5155
    5256#-------------------------------------------------------------------------------
     
    5761# Fine pts file to be clipped to area of interest
    5862#-------------------------------------------------------------------------------
    59 print"project_urs.combined_dir_name",project_urs.combined_dir_name
    60 '''
    61 # topography directory filenames
    62 onshore_in_dir_name = project_urs.onshore_in_dir_name
    63 coast_in_dir_name = project_urs.coast_in_dir_name
    64 offshore_in_dir_name = project_urs.offshore_in_dir_name
    65 offshore1_in_dir_name = project_urs.offshore1_in_dir_name
    66 offshore2_in_dir_name = project_urs.offshore2_in_dir_name
    6763
    68 onshore_dir_name = project_urs.onshore_dir_name
    69 coast_dir_name = project_urs.coast_dir_name
    70 offshore_dir_name = project_urs.offshore_dir_name
    71 offshore1_dir_name = project_urs.offshore1_dir_name
    72 offshore2_dir_name = project_urs.offshore2_dir_name
     64print 'project.combined_dir_name', project.combined_dir_name
    7365
    74 # creates DEM from asc data
    75 print "creates DEMs from asc data"
    76 convert_dem_from_ascii2netcdf(onshore_in_dir_name,
    77                               basename_out=onshore_dir_name,
    78                               use_cache=True, verbose=True)
    79 #creates pts file for onshore DEM
    80 print "creates pts file for onshore DEM"
    81 dem2pts(onshore_dir_name, use_cache=True, verbose=True)
    8266
    83 print'create Geospatial onshore objects from topographies'
    84 G = Geospatial_data(file_name = onshore_dir_name + '.pts') +\
    85     Geospatial_data(file_name = coast_in_dir_name + '.txt') +\
    86     Geospatial_data(file_name = offshore_in_dir_name + '.txt')
    87 #    +\
    88 #    Geospatial_data(file_name = offshore1_dir_name + '.pts') +\
    89 #    Geospatial_data(file_name = offshore2_dir_name + '.pts')
    90      
     67geospatial_data = None
     68# create DEMs from asc data
     69print 'creating geospatial data objects from asc data (via dem and pts formats)'
     70for filename in project.ascii_grid_filenames:
     71    convert_dem_from_ascii2netcdf(filename,
     72                                  basename_out=filename,
     73                                  use_cache=True, verbose=True)
     74    dem2pts(filename, use_cache=True, verbose=True)
    9175
    92 print'clip combined geospatial object by bounding polygon'
    93 G_clipped = G.clip(project_urs.poly_all)
     76    geospatial_data += Geospatial_data(file_name = filename + '.pts', verbose=True)
    9477
    95 print'export combined DEM file'
    96 if access(project_urs.topographies_dir,F_OK) == 0:
    97     mkdir (project_urs.topographies_dir)
    98 G.export_points_file(project_urs.combined_dir_name + '.txt')
    9978
    100 print'split combined data set'
    101 G_small, G_other = G_clipped.split(0.1, True)
     79print 'creating geospatial data objects from txt data'
     80for filename in project.point_filenames:
     81    geospatial_data += Geospatial_data(file_name = filename + '.txt', verbose=True)
    10282
    103 print'export split DEM file'
    104 G_small.export_points_file(project_urs.combined_dir_name + '_small' + '.txt')
    105 #G_other.export_points_file(project_urs.combined_dir_name + '_other' + '.pts')
    10683
    107 '''
    108 print 'start reading:',project_urs.combined_dir_name + '.txt'
    109 G = Geospatial_data(file_name = (project_urs.combined_dir_name + '.txt'))
    110 G_clipped = G.clip(project_urs.poly_topo_clip)
     84print 'clip combined geospatial object by bounding polygon'
     85G = geospatial_data.clip(project.poly_all)
    11186
    112 print 'start split'
    113 #G_smallest, G_other = G.split(0.1,True)
    11487
    115 print 'start export',project_urs.combined_smallest_dir_name + '.txt'
    116 #G.export_points_file(project_urs.combined_smaller_dir_name + '.txt')
    117 G_clipped.export_points_file(project_urs.combined_smallest_dir_name + '.txt')
     88print 'export combined geospatial data'
     89if access(project.topographies_dir, F_OK) == 0:
     90    mkdir (project.topographies_dir)
     91G.export_points_file(project.combined_dir_name + '.txt')
    11892
     93
     94#print 'split combined data set'
     95#G_small, _ = G.split(0.1, True)
     96#
     97#print 'export sub sampled DEM file'
     98#G_small.export_points_file(project.combined_dir_name + '_small' + '.txt')
     99
     100
     101 
    119102#-------------------------------------------------------------------------
    120103# Convert URS to SWW file for boundary conditions
    121104#-------------------------------------------------------------------------
    122 print 'starting to create boundary conditions'
    123 #boundaries_in_dir_name = project_urs.boundaries_in_dir_name
     105print 'converting boundary conditions to sww format'
     106#boundaries_in_dir_name = project.boundaries_in_dir_name
    124107
    125 #print 'minlat=project_urs.north_boundary, maxlat=project_urs.south_boundary',project_urs.north_boundary, project_urs.south_boundary
    126 #print 'minlon= project_urs.west_boundary, maxlon=project_urs.east_boundary',project_urs.west_boundary, project_urs.east_boundary
    127 '''       
     108#print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
     109#print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
     110       
    128111from anuga.shallow_water.data_manager import urs_ungridded2sww
    129112
    130 print 'boundaries_in_dir_name',project_urs.boundaries_in_dir_name
    131 print 'project.boundaries_dir_name',project_urs.boundaries_dir_name
     113print 'boundaries_dir', project.boundaries_dir
     114print 'project.boundaries_name', project.boundaries_name
    132115
    133 urs_ungridded2sww(project_urs.boundaries_in_dir_name, project_urs.boundaries_dir_name,
     116urs_ungridded2sww(project.boundaries_name,
    134117                  verbose=True, mint=5000, maxt=35000, zscale=1)
    135 '''
    136118
    137119
     120print 'Finished building the %s scenario' %project.scenario_name
    138121
    139122
  • anuga_work/production/shark_bay_2007/project.py

    r4505 r4552  
    11"""Common filenames and locations for topographic data, meshes and outputs.
    22Also includes origin for slump scenario.
     3
     4All filenames are given without extension
    35"""
    46
    5 from os import sep, environ, getenv, getcwd,umask
    6 from os.path import expanduser, basename
     7from os import sep, environ, getenv, getcwd, umask
     8from os.path import expanduser, basename, join
    79from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon, number_mesh_triangles
    810import sys
     
    1113from anuga.utilities.system_tools import get_user_name, get_host_name
    1214
    13 codename = 'project.py'
     15codename = 'project.py' # FIXME can be obtained automatically as __file__
    1416
    15 home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent dir   
     17home = join(getenv('INUNDATIONHOME'), 'data') # Location of Data   
    1618user = get_user_name()
    1719host = get_host_name()
     
    2224state = 'western_australia'
    2325scenario_name = 'shark_bay'
    24 scenario = 'shark_bay_tsunami_scenario_2006'
     26scenario = 'shark_bay_tsunami_scenario'
    2527
    2628#time stuff
     
    3941starttime=3600
    4042setup='final'
    41 
    42 #dir_comment='_trial_'+str(tide)+'_'+str(user)
    43 #dir_comment='_final_'+str(tide)+'_'+str(user)
    44 #time_thinning=4
    45 #yieldstep=60
    46 #res_factor = 1
     43source='shark_bay'
    4744
    4845if setup =='trial':
     
    6360
    6461
    65 dir_comment='_'+setup+'_'+str(tide)+'_'+str(user)
     62dir_comment='_'+setup+'_'+str(tide)+'_'+str(source)+'_'+str(user)
    6663
    67 # onshore data from 30m DTED level 2
    68 onshore_name = 'dli_dem' # get from Neil/Ingo (DEM or topo data)
    69 offshore_name = 'pt_hedland_bathy_edit'
    70 offshore1_name = '1'
    71 offshore2_name = '2'
    72 coast_name = 'Coastline'
     64# elevation data filenames
     65ascii_grid_filenames = ['10m_dem_without_survey', '50m_dem_without_10m_dem']
     66point_filenames = ['field_survey_north', 'field_survey_south',
     67                   'clipped_bathymetry_final', 'coast_points_final']
    7368
    7469#final topo name
    75 combined_name ='pt_hedland_combined_elevation'
    76 combined_small_name = 'pt_hedland_combined_elevation_small'
    77 combined_smallest_name = 'pt_hedland_export'
     70combined_name ='shark_bay_combined_elevation'
     71combined_small_name = 'shark_bay_combined_elevation_small'
    7872
    79 anuga_dir = home+state+sep+scenario+sep+'anuga'+sep
    8073
    81 topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'20070416'+sep+'points'+sep
    82 topographies_dir = anuga_dir+'topographies'+sep
     74anuga_dir = join(home, state, scenario, 'anuga')
    8375
    84 # input topo file location
    85 onshore_in_dir_name = topographies_in_dir + onshore_name
    86 coast_in_dir_name = topographies_in_dir + coast_name
    87 offshore_in_dir_name = topographies_in_dir + offshore_name
    88 offshore1_in_dir_name = topographies_in_dir + offshore1_name
    89 offshore2_in_dir_name = topographies_in_dir + offshore2_name
     76topographies_in_dir = join(home, state, scenario, 'elevation_final', 'test_area')
     77topographies_dir = join(anuga_dir, 'topographies') # Output dir for ANUGA
    9078
    91 onshore_dir_name = topographies_dir + onshore_name
    92 coast_dir_name = topographies_dir + coast_name
    93 offshore_dir_name = topographies_dir + offshore_name
    94 offshore1_dir_name = topographies_dir + offshore1_name
    95 offshore2_dir_name = topographies_dir + offshore2_name
     79# Convert topo file locations into absolute pathnames
     80for filename_list in [ascii_grid_filenames, point_filenames]:
     81    for i, filename in enumerate(filename_list):
     82        filename_list[i] = join(topographies_in_dir, filename)
    9683
    9784#final topo files
    98 combined_dir_name = topographies_dir + combined_name
    99 #combined_time_dir_name = topographies_time_dir + combined_name
    100 combined_small_dir_name = topographies_dir + combined_small_name
    101 combined_smallest_dir_name = topographies_dir + combined_smallest_name
     85combined_dir_name = join(topographies_dir, combined_name)
     86combined_small_dir_name = join(topographies_dir, combined_small_name)
    10287
    103 meshes_dir = anuga_dir+'meshes'+sep
    104 meshes_dir_name = meshes_dir + scenario_name
    10588
    106 polygons_dir = anuga_dir+'polygons'+sep
    107 tide_dir = anuga_dir+'tide_data'+sep
     89meshes_dir = join(anuga_dir, 'meshes')
     90meshes_dir_name = join(meshes_dir, scenario_name)
    10891
    109 #boundaries locations
    110 boundaries_name = 'shark_bay'
    11192
    112 boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'1_10000'+sep
    113 boundaries_in_dir_name = boundaries_in_dir + boundaries_name
    114 boundaries_dir = anuga_dir+'boundaries'+sep
    115 boundaries_dir_name = boundaries_dir + boundaries_name
     93polygons_dir = join(anuga_dir, 'polygons') # Created with ArcGIS (csv files)
     94tide_dir = join(anuga_dir, 'tide_data')
     95
     96
     97# locations for boundary conditions
     98if source=='shark_bay':
     99    boundaries_file_name = 'shark_bay_3867_18052007'
     100    boundaries_dir = join(anuga_dir, 'boundaries', 'shark_bay', '1_10000')
     101
     102boundaries_name = join(boundaries_dir, boundaries_file_name)
    116103
    117104#output locations
    118 output_dir = anuga_dir+'outputs'+sep
     105output_dir = join(anuga_dir, 'outputs')
    119106output_build_time_dir = output_dir+build_time+sep
    120107output_run_time_dir = output_dir +run_time+dir_comment+sep
     
    122109
    123110#gauges
    124 gauge_name = 'gauge_location_port_hedland.csv'
    125 gauge_name_test = 'gauge_checking_test.csv'
    126 gauges_dir = anuga_dir+'gauges'+sep
    127 gauges_dir_name = gauges_dir + gauge_name
    128 gauges_dir_name_test = gauges_dir + gauge_name_test
     111#gauge_name = 'gauge_location_port_hedland.csv'
     112#gauge_name_test = 'gauge_checking_test.csv'
     113#gauges_dir = anuga_dir+'gauges'+sep
     114#gauges_dir_name = gauges_dir + gauge_name
     115#gauges_dir_name_test = gauges_dir + gauge_name_test
    129116
    130 tide_dir = anuga_dir+'tide_data'+sep
     117#tide_dir = anuga_dir+'tide_data'+sep
    131118
    132 buildings_filename = gauges_dir + 'pt_hedland_res.csv'
    133 buildings_filename_out = 'pt_hedland_res_modified.csv'
    134 buildings_filename_damage_out = 'pt_hedland_res_modified_damage.csv'
    135 tidal_filename = tide_dir + 'pt_hedland_tide.txt'
    136 community_filename = gauges_dir + 'CHINS_v2.csv'
    137 community_scenario = gauges_dir + 'community_pt_hedland.csv'
     119#buildings_filename = gauges_dir + 'pt_hedland_res.csv'
     120#buildings_filename_out = 'pt_hedland_res_modified.csv'
     121#buildings_filename_damage_out = 'pt_hedland_res_modified_damage.csv'
     122#tidal_filename = tide_dir + 'pt_hedland_tide.txt'
     123#community_filename = gauges_dir + 'CHINS_v2.csv'
     124#community_scenario = gauges_dir + 'community_pt_hedland.csv'
    138125
    139126# clipping region to make DEM (pts file) from onshore data
    140 eastingmin = 594000
    141 eastingmax = 715000
    142 northingmin = 7720000
    143 northingmax = 7880000
     127#eastingmin = 594000
     128#eastingmax = 715000
     129#northingmin = 7720000
     130#northingmax = 7880000
    144131
    145132# for ferret2sww
     
    150137
    151138# region to export (used from export_results.py)
    152 e_min_area = 648000
    153 e_max_area = 675000
    154 n_min_area = 7745000
    155 n_max_area = 7761000
     139#e_min_area = 648000   # Eastings min
     140#e_max_area = 675000
     141#n_min_area = 7745000
     142#n_max_area = 7761000
    156143
    157 export_region = [[e_min_area,n_min_area],[e_min_area,n_max_area],
    158                  [e_max_area,n_max_area],[e_max_area,n_min_area]]
     144#export_region = [[e_min_area,n_min_area],[e_min_area,n_max_area],
     145#                 [e_max_area,n_max_area],[e_max_area,n_min_area]]
    159146                 
    160 refzone = 50
    161147
    162148#from anuga.coordinate_transforms.redfearn import redfearn
    163 poly_all = read_polygon(polygons_dir+'boundary_extent.csv')
     149poly_all = read_polygon(join(polygons_dir, 'boundary_extent.csv'))
    164150res_poly_all = 250000*res_factor
    165151
    166 #Interior region - Pt Hedland town
    167 i0 = [668000, 7757000]
    168 i1 = [659000, 7755000]
    169 i2 = [660000, 7749000]
    170 i3 = [667000, 7746000]
    171 i4 = [678000, 7751000]
     152#Interior regions
     153poly_inundated_area = read_polygon(join(polygons_dir, 'inundated_area.csv'))
     154res_inundated_area = 50000*res_factor
    172155
    173 poly_pt_hedland = [i0, i1, i2, i3, i4]
    174 res_pt_hedland=500*res_factor
     156poly_bay_area = read_polygon(join(polygons_dir, 'bay_area.csv'))                                   
     157res_bay_area = 100000*res_factor                                   
    175158
    176 #Are there other significant features?
    177 j0 = [670000, 7760000]
    178 j1 = [633000, 7745000]
    179 j2 = [665000, 7743000]
    180 j3 = [690000, 7755000]
    181 
    182 poly_region = [j0, j1, j2, j3]
    183 res_region = 50000*res_factor
    184 
    185 #poly_mainland = read_polygon(polygons_dir+'Initial_Condition.csv')
    186 
    187 poly_topo_clip = [[664000,7752000],[664000,7754000],
    188                   [666000,7754000],[666000,7752000]]
    189 
    190 interior_regions = [[poly_pt_hedland,res_pt_hedland],[poly_region,res_region]
    191 #                    ,[poly_region,res_region]
    192                     ]
     159interior_regions = [[poly_bay_area, res_bay_area], [poly_inundated_area, res_inundated_area]]
    193160
    194161trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all)
Note: See TracChangeset for help on using the changeset viewer.