コード例 #1
0
                        else :
                            dataset = dataset_override

                        portID = port['ID']
                        portname = port['name']
                        if portResult == 'failed' :
                            print 'Port %s %s simulation failed! h:%s w:%s' % (run_type,current_structure,h,w )
                        # Print status
                        ###print 'Port: %s Name: %s h:%s w:%s' % (portID,portname,h,w )
                        # Run model

                        # Start clock
                        start_time = time.time()

                        portResult = 'failed'
                        response,error = portprotector.optimize(portID,w,h,simulation_equation,dataset,run_type,current_structure,number_of_buckets,bucket_low,bucket_high)
                        portResult = 'success'

                        # Stop clock
                        end_time = time.time()

                        # Elapsed time
                        elapsed_time = end_time - start_time
                        total_time += elapsed_time
                        #print '%s %s simulation time: %f total: %f' % (current_structure, run_type, elapsed_time, total_time, )

                        # If error, print error message
                        if error == True:
                            # Output error message
                            print 'Error'
                            output = GeoUtils.Interface.uniForm.fullErrorMsgGen(response)
コード例 #2
0
ファイル: batchModelRun.py プロジェクト: ddnewell/sebastian
 for port in portdata:
     try:
         # Unpack parameters
         h = port['grid_height']
         w = port['grid_width']
         
         if h == 0:
             h = 0.25
         if w == 0:
             w = 0.25
         
         portID = port['ID']
         # Print status
         print 'Port: %s' % (portID,)
         # Run model
         response,error = portprotector.optimize(portID,h,w,GeoUtils.constants.Equations.BMASW,port['elev_data'])
         # If error, print error message
         if error == True:
             # Output error message
             output = GeoUtils.Interface.uniForm.fullErrorMsgGen(response)
             print output
         else:
             # Unpack response from optimization
             path,avg_elev,length,vol,dikeVol,coreVol,toeVol,foundVol,armorVol = response
             # Update database
             response,error = portprotector.updateDB('2ee9a2ec7ebffaecc61f8f011981852e',portID,path,avg_elev,length,vol,dikeVol,coreVol,toeVol,foundVol,armorVol,GeoUtils.constants.Equations.BMASW,port['elev_data'],GeoUtils.constants.computeCenter(),h,w)
             # Add entry to portdata as well
             updateq = 'UPDATE portdata SET defense_volume=%s WHERE ID=%s' % (vol,portID)
             response2,error2 = DBhandle.query(updateq)
     except:
         continue