Ignore:
Timestamp:
Feb 3, 2009, 11:51:59 AM (10 years ago)
Author:
ole
Message:

Looped elevation data conversions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/busselton/standardised_version/build_busselton.py

    r6254 r6261  
    1414
    1515# Standard modules
    16 from os import sep
    17 from os.path import dirname, basename
     16from os.path import dirname
    1817from os import mkdir, access, F_OK
    19 from shutil import copy
    20 import time
    21 import sys
    2218
    2319# Related major packages
     
    3531#------------------------------------------------------------------------------
    3632
    37 copy_code_files(project.output_build_time_dir,__file__,
    38                dirname(project.__file__)+sep+ project.__name__+'.py' )
     33#copy_code_files(project.output_build_time_dir,__file__,
     34#               dirname(project.__file__)+os.sep+ project.__name__+'.py' )
     35#start_screen_catcher(project.output_build_time_dir)
    3936
    40 start_screen_catcher(project.output_build_time_dir)
    41 
    42 print 'USER:    ', project.user
    4337
    4438#-------------------------------------------------------------------------------
     
    5044#-------------------------------------------------------------------------------
    5145
    52 # FIXME(Ole): Here's the Shark Bay way.
     46print 'project.poly_all', project.poly_all
     47print 'project.combined_dir_name', project.combined_dir_name
    5348
    54 ## FIXME (Ole): Clip data by interior regions if possible
     49# input elevation directory filenames
     50#onshore_in_dir_name = project.onshore_in_dir_name
     51#coast_in_dir_name = project.coast_in_dir_name
     52#coast_in_dir_name1 = project.coast_in_dir_name1
     53#offshore_in_dir_name = project.offshore_in_dir_name
     54#offshore_in_dir_name1 = project.offshore_in_dir_name1
     55#offshore_in_dir_name2 = project.offshore_in_dir_name2
     56#offshore_in_dir_name3 = project.offshore_in_dir_name3
     57#offshore_in_dir_name4 = project.offshore_in_dir_name4
     58#offshore_in_dir_name5 = project.offshore_in_dir_name5
     59
     60# output elevation directory filenames
     61#onshore_dir_name = project.onshore_dir_name
     62#coast_dir_name = project.coast_dir_name
     63#coast_dir_name1 = project.coast_dir_name1
     64#offshore_dir_name = project.offshore_dir_name
     65#offshore_dir_name1 = project.offshore_dir_name1
     66#offshore_dir_name2 = project.offshore_dir_name2
     67#offshore_dir_name3 = project.offshore_dir_name3
     68#offshore_dir_name4 = project.offshore_dir_name4
     69#offshore_dir_name5 = project.offshore_dir_name5
     70
     71
     72# Create Geospatial data from ASCII files
     73geospatial_data = {}
     74for filename in project.ascii_grid_filenames:
     75    absolute_filename = project.topographies_in_dir + filename
     76    convert_dem_from_ascii2netcdf(absolute_filename,
     77                                  basename_out=absolute_filename,
     78                                  use_cache=True,
     79                                  verbose=True)
     80    dem2pts(absolute_filename, use_cache=True, verbose=True)
     81
     82    geospatial_data[filename] = Geospatial_data(file_name=absolute_filename+'.pts',
     83                                                verbose=True)
     84
     85# Create Geospatial data from TXT files
     86for filename in project.point_filenames:
     87    absolute_filename = project.topographies_in_dir + filename
     88    geospatial_data[filename] = Geospatial_data(file_name=absolute_filename,
     89                                                verbose=True)
     90
     91
     92#print "creates DEMs from asc data"
     93#print onshore_in_dir_name, onshore_dir_name
     94#print offshore_in_dir_name5, offshore_dir_name5
    5595#
    56 #print 'creating geospatial data objects from asc data (via dem and pts formats)'
    57 #for filename in project.ascii_grid_filenames:
    58 #    convert_dem_from_ascii2netcdf(filename,
    59 #                                  basename_out=filename,
    60 #                                  use_cache=True, verbose=True)
    61 #    dem2pts(filename, use_cache=True, verbose=True)#
     96#convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
    6297#
    63 #    geospatial_data += Geospatial_data(file_name=filename + '.pts',
    64 #                                       verbose=True)
     98#convert_dem_from_ascii2netcdf(offshore_in_dir_name5, basename_out=offshore_dir_name5, use_cache=True, verbose=True)#
    6599##
    66100#
    67 #print 'creating geospatial data objects from txt data'
    68 #for filename in project.point_filenames:
    69 #    geospatial_data += Geospatial_data(file_name=filename + '.txt',
    70 #                                       verbose=True)
    71 #
    72 #
    73 #print 'clip combined geospatial object by bounding polygon'
    74 #G = geospatial_data.clip(project.bounding_polygon)
    75 #
    76 #
    77 #print 'export combined geospatial data'
    78 #if access(project.topographies_dir, F_OK) == 0:
    79 #    mkdir (project.topographies_dir)
    80 #G.export_points_file(project.combined_dir_name + '.pts')
    81 
    82 
    83 
    84 print "project.poly_all", project.poly_all
    85 print "project.combined_dir_name", project.combined_dir_name
    86 
    87 # input elevation directory filenames
    88 onshore_in_dir_name = project.onshore_in_dir_name
    89 coast_in_dir_name = project.coast_in_dir_name
    90 coast_in_dir_name1 = project.coast_in_dir_name1
    91 offshore_in_dir_name = project.offshore_in_dir_name
    92 offshore_in_dir_name1 = project.offshore_in_dir_name1
    93 offshore_in_dir_name2 = project.offshore_in_dir_name2
    94 offshore_in_dir_name3 = project.offshore_in_dir_name3
    95 offshore_in_dir_name4 = project.offshore_in_dir_name4
    96 offshore_in_dir_name5 = project.offshore_in_dir_name5
    97 
    98 # output elevation directory filenames
    99 onshore_dir_name = project.onshore_dir_name
    100 coast_dir_name = project.coast_dir_name
    101 coast_dir_name1 = project.coast_dir_name1
    102 offshore_dir_name = project.offshore_dir_name
    103 offshore_dir_name1 = project.offshore_dir_name1
    104 offshore_dir_name2 = project.offshore_dir_name2
    105 offshore_dir_name3 = project.offshore_dir_name3
    106 offshore_dir_name4 = project.offshore_dir_name4
    107 offshore_dir_name5 = project.offshore_dir_name5
    108 # creates DEM from asc data
    109 print "creates DEMs from asc data"
    110 convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
    111 convert_dem_from_ascii2netcdf(offshore_in_dir_name5, basename_out=offshore_dir_name5, use_cache=True, verbose=True)
    112 
    113101# creates pts file for onshore DEM
    114 print "creates pts file for onshore DEM"
    115 dem2pts(onshore_dir_name ,use_cache=True,verbose=True)
    116 dem2pts(offshore_dir_name5 ,use_cache=True,verbose=True)
     102#print "creates pts file for onshore DEM"
     103#dem2pts(onshore_dir_name ,use_cache=True,verbose=True)
     104#dem2pts(offshore_dir_name5 ,use_cache=True,verbose=True)
    117105
    118106# create onshore pts files
    119 print'create Geospatial data1 objects from topographies'
    120 G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
     107#print'create Geospatial data1 objects from topographies'
     108#G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
    121109
    122110# create coastal and offshore pts files
    123 print'create Geospatial data2 objects from topographies'
    124 G2 = Geospatial_data(file_name = coast_in_dir_name)
    125 print'create Geospatial data3 objects from topographies'
    126 G3 = Geospatial_data(file_name = coast_in_dir_name1)
    127 print'create Geospatial data4 objects from topographies'
    128 G_off = Geospatial_data(file_name = offshore_in_dir_name)
    129 print'create Geospatial data5 objects from topographies'
    130 G_off1 = Geospatial_data(file_name = offshore_in_dir_name1)
    131 print'create Geospatial data6 objects from topographies'
    132 G_off2 = Geospatial_data(file_name = offshore_in_dir_name2)
    133 print'create Geospatial data7 objects from topographies'
    134 G_off3 = Geospatial_data(file_name = offshore_in_dir_name3)
    135 print'create Geospatial data8 objects from topographies'
    136 G_off4 = Geospatial_data(file_name = offshore_in_dir_name4)
    137 print'create Geospatial data9 objects from topographies'
    138 G_off5 = Geospatial_data(file_name = offshore_dir_name5 + '.pts')
     111#print'create Geospatial data2 objects from topographies'
     112#G2 = Geospatial_data(file_name = coast_in_dir_name)
     113#print'create Geospatial data3 objects from topographies'
     114#G3 = Geospatial_data(file_name = coast_in_dir_name1)
     115#print'create Geospatial data4 objects from topographies'
     116#G_off = Geospatial_data(file_name = offshore_in_dir_name)
     117#print'create Geospatial data5 objects from topographies'
     118#G_off1 = Geospatial_data(file_name = offshore_in_dir_name1)
     119#print'create Geospatial data6 objects from topographies'
     120#G_off2 = Geospatial_data(file_name = offshore_in_dir_name2)
     121#print'create Geospatial data7 objects from topographies'
     122#G_off3 = Geospatial_data(file_name = offshore_in_dir_name3)
     123#print'create Geospatial data8 objects from topographies'
     124#G_off4 = Geospatial_data(file_name = offshore_in_dir_name4)
     125#print'create Geospatial data9 objects from topographies'
     126#G_off5 = Geospatial_data(file_name = offshore_dir_name5 + '.pts')
    139127
    140128
     
    143131#-------------------------------------------------------------------------------
    144132
    145 print'add all geospatial objects'
    146 G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4
     133#print'add all geospatial objects'
     134#G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4
    147135
    148 print'clip combined geospatial object by bounding polygon'
     136print 'Add geospatial objects except', project.offshore_name5
     137print geospatial_data.keys()
     138G = None
     139for key in geospatial_data:
     140    if key != project.offshore_name5:
     141        G += geospatial_data[key]
     142       
     143print 'Clip (outside) combined geospatial object except %s by area of interest.'
    149144G_clip = G.clip_outside(project.poly_aoi1)
    150 G_all = G_clip + G_off5
     145
     146print 'Clip combined geospatial object by bounding polygon'
     147G_all = G_clip + geospatial_data[project.offshore_name5]   # G_off5
    151148G_clipped = G_all.clip(project.poly_all)
    152149
    153 print'export combined DEM file'
    154 if access(project.topographies_dir,F_OK) == 0:
    155     mkdir (project.topographies_dir)
     150print 'Export combined DEM file'
     151#if access(project.topographies_dir,F_OK) == 0:
     152#    mkdir (project.topographies_dir)
    156153G_clipped.export_points_file(project.combined_dir_name + '.pts')
    157 G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC
     154print 'Do txt version too'
     155G_clipped.export_points_file(project.combined_dir_name + '.txt') # Use for comparision in ARC
    158156
Note: See TracChangeset for help on using the changeset viewer.