Changeset 4348


Ignore:
Timestamp:
Apr 3, 2007, 2:36:58 PM (17 years ago)
Author:
duncan
Message:

Changing the definition of a mux file. South is now the positive axis, not North.

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4326 r4348  
    40404040        """
    40414041        self.quantity_name = quantity_name
    4042         quantity_units= {'HA':'CENTIMETERS',
     4042        quantity_units = {'HA':'CENTIMETERS',
    40434043                              'UA':'CENTIMETERS/SECOND',
    4044                               'VA':'CENTIMETERS/SECOND'}
     4044                              'VA':'CENTIMETERS/SECOND'}       
     4045       
     4046        multiplier_dic = {'HA':100.0, # To convert from m to cm
     4047                              'UA':100.0,  #  m/s to cm/sec
     4048                              'VA':-100.0}  # MUX files have positve x in the
     4049        # Southern direction.  This corrects for it, when writing nc files.
     4050       
     4051        self.quantity_multiplier =  multiplier_dic[self.quantity_name]
    40454052       
    40464053        #self.file_name = file_name
     
    40734080    def store_timestep(self, quantity_slice):
    40744081        """
     4082        Write a time slice of quantity info
    40754083        quantity_slice is the data to be stored at this time step
    40764084        """
     
    40864094        #Store time
    40874095        time[i] = i*self.time_step #self.domain.time
    4088         quantity[i,:] = quantity_slice*100 # To convert from m to cm
    4089                                            # And m/s to cm/sec
     4096        quantity[i,:] = quantity_slice* self.quantity_multiplier
    40904097       
    40914098    def close(self):
     
    47124719        swwname = basename_out + '.sww'
    47134720
     4721    if verbose: print 'Output to ', swwname
    47144722    outfile = NetCDFFile(swwname, 'w')
    47154723    # For a different way of doing this, check out tsh2sww
     
    48744882        h = w - elevation
    48754883        xmomentum[j] = ua*h
    4876         ymomentum[j] = va*h
     4884        ymomentum[j] = -1*va*h  #  -1 since in mux files south is positive.
    48774885        j += 1
    48784886
     
    48894897    h = w - elevation
    48904898    xmomentum[slice_index] = ua*h
    4891     ymomentum[slice_index] = va*h
     4899    ymomentum[slice_index] = -1*va*h # -1 since in mux files south is positive.
    48924900
    48934901def urs2txt(basename_in, location_index=None):
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4326 r4348  
    47594759            # Write quantity info
    47604760            for time in  range(time_step_count):
    4761                 for i in range(points_num):
    4762                     f.write(pack('f',q_time[time,i]))
     4761                for point_i in range(points_num):
     4762                    f.write(pack('f',q_time[time,point_i]))
     4763                    #print " mux_names[i]", mux_names[i]
     4764                    #print "f.write(pack('f',q_time[time,i]))", q_time[time,point_i]
    47634765            f.close()
    47644766        return base_name, files
     
    48374839            # Write quantity info
    48384840            for time in  range(time_step_count):
    4839                 for i in range(points_num):
    4840                     f.write(pack('f',q_time[time,i]))
     4841                for point_i in range(points_num):
     4842                    f.write(pack('f',q_time[time,point_i]))
     4843                    #print " mux_names[i]", mux_names[i]
     4844                    #print "f.write(pack('f',q_time[time,i]))", q_time[time,point_i]
    48414845            f.close()
    48424846        return base_name, files
     
    49134917        #Check that first coordinate is correctly represented       
    49144918        #Work out the UTM coordinates for first point
    4915         zone, e, n = redfearn(-34.5, 150.66667)       
     4919        zone, e, n = redfearn(-34.5, 150.66667)
    49164920       
    49174921        assert allclose(geo_reference.get_absolute([[x[0],y[0]]]), [e,n])
     
    49324936        #Check the momentums - ua
    49334937        #momentum = velocity*(stage-elevation)
    4934         #momentum = velocity*(stage+elevation)
     4938        # elevation = - depth
     4939        #momentum = velocity_ua *(stage+depth)
     4940        # = n*(e+tide+n) based on how I'm writing these files
     4941        #
     4942        answer_x = n*(e+tide+n)
     4943        actual_x = xmomentum[0,0]
     4944        #print "answer_x",answer_x
     4945        #print "actual_x",actual_x
     4946        assert allclose(answer_x, actual_x)  #Meters
     4947
     4948        #Check the momentums - va
     4949        #momentum = velocity*(stage-elevation)
    49354950        # -(-elevation) since elevation is inverted in mux files
    4936         # = n*(e+tide+n) based on how I'm writing these files
    4937         answer = n*(e+tide+n)
    4938         actual = xmomentum[0,0]
    4939         assert allclose(answer, actual)  #Meters
    4940 
     4951        #momentum = velocity_va *(stage+elevation)
     4952        # = e*(e+tide+n) based on how I'm writing these files
     4953        answer_y = e*(e+tide+n) * -1 # talking into account mux file format
     4954        actual_y = ymomentum[0,0]
     4955        #print "answer_y",answer_y
     4956        #print "actual_y",actual_y
     4957        assert allclose(answer_y, actual_y)  #Meters
     4958       
     4959        assert allclose(answer_x, actual_x)  #Meters
     4960       
    49414961        # check the stage values, first time step.
    49424962        # These arrays are equal since the Easting values were used as
     
    49644984        ha=2
    49654985        ua=5
    4966         va=10
     4986        va=-10 #-ve added to take into account mux file format where south
     4987               # is positive.
    49674988        base_name, files = self.write_mux(lat_long_points,
    49684989                                          time_step_count, time_step,
     
    50085029        answer = 230
    50095030        actual = ymomentum[0,0]
     5031        #print "answer",answer
     5032        #print "actual",actual
    50105033        assert allclose(answer, actual)  #Meters^2/ sec
    50115034
     
    53815404        assert allclose(stage[0,0], e +tide)  #Meters
    53825405
     5406
    53835407        #Check the momentums - ua
    53845408        #momentum = velocity*(stage-elevation)
    5385         #momentum = velocity*(stage+elevation)
    5386         # -(-elevation) since elevation is inverted in mux files
     5409        # elevation = - depth
     5410        #momentum = velocity_ua *(stage+depth)
    53875411        # = n*(e+tide+n) based on how I'm writing these files
    5388         answer = n*(e+tide+n)
    5389         actual = xmomentum[0,0]
    5390         assert allclose(answer, actual)  #Meters
     5412        #
     5413        answer_x = n*(e+tide+n)
     5414        actual_x = xmomentum[0,0]
     5415        #print "answer_x",answer_x
     5416        #print "actual_x",actual_x
     5417        assert allclose(answer_x, actual_x)  #Meters
     5418       
     5419        #Check the momentums - va
     5420        #momentum = velocity*(stage-elevation)
     5421        # elevation = - depth
     5422        #momentum = velocity_va *(stage+depth)
     5423        # = e*(e+tide+n) based on how I'm writing these files
     5424        #
     5425        answer_y = -1*e*(e+tide+n)
     5426        actual_y = ymomentum[0,0]
     5427        #print "answer_y",answer_y
     5428        #print "actual_y",actual_y
     5429        assert allclose(answer_y, actual_y)  #Meters
    53915430
    53925431        # check the stage values, first time step.
     
    54585497        #Check the momentums - ua
    54595498        #momentum = velocity*(stage-elevation)
    5460         #momentum = velocity*(stage+elevation)
    5461         # -(-elevation) since elevation is inverted in mux files
     5499        # elevation = - depth
     5500        #momentum = velocity_ua *(stage+depth)
    54625501        # = n*(e+tide+n) based on how I'm writing these files
    5463         answer = n*(e+tide+n)
    5464         actual = xmomentum[0,0]
    5465         assert allclose(answer, actual)  #Meters
     5502        #
     5503        answer_x = n*(e+tide+n)
     5504        actual_x = xmomentum[0,0]
     5505        #print "answer_x",answer_x
     5506        #print "actual_x",actual_x
     5507        assert allclose(answer_x, actual_x)  #Meters
     5508       
     5509        #Check the momentums - va
     5510        #momentum = velocity*(stage-elevation)
     5511        # elevation = - depth
     5512        #momentum = velocity_va *(stage+depth)
     5513        # = e*(e+tide+n) based on how I'm writing these files
     5514        #
     5515        answer_y = -1*e*(e+tide+n)
     5516        actual_y = ymomentum[0,0]
     5517        #print "answer_y",answer_y
     5518        #print "actual_y",actual_y
     5519        assert allclose(answer_y, actual_y)  #Meters
    54665520
    54675521        # check the stage values, first time step.
     
    55325586        #Check the momentums - ua
    55335587        #momentum = velocity*(stage-elevation)
    5534         #momentum = velocity*(stage+elevation)
    5535         # -(-elevation) since elevation is inverted in mux files
     5588        # elevation = - depth
     5589        #momentum = velocity_ua *(stage+depth)
    55365590        # = n*(e+tide+n) based on how I'm writing these files
    5537         answer = n*(e+tide+n)
    5538         actual = xmomentum[0,0]
    5539         assert allclose(answer, actual)  #Meters
     5591        #
     5592        answer_x = n*(e+tide+n)
     5593        actual_x = xmomentum[0,0]
     5594        #print "answer_x",answer_x
     5595        #print "actual_x",actual_x
     5596        assert allclose(answer_x, actual_x)  #Meters
     5597       
     5598        #Check the momentums - va
     5599        #momentum = velocity*(stage-elevation)
     5600        # elevation = - depth
     5601        #momentum = velocity_va *(stage+depth)
     5602        # = e*(e+tide+n) based on how I'm writing these files
     5603        #
     5604        answer_y = -1*e*(e+tide+n)
     5605        actual_y = ymomentum[0,0]
     5606        #print "answer_y",answer_y
     5607        #print "actual_y",actual_y
     5608        assert allclose(answer_y, actual_y)  #Meters
    55405609
    55415610        # check the stage values, first time step.
     
    56055674        #Check the momentums - ua
    56065675        #momentum = velocity*(stage-elevation)
    5607         #momentum = velocity*(stage+elevation)
    5608         # -(-elevation) since elevation is inverted in mux files
     5676        # elevation = - depth
     5677        #momentum = velocity_ua *(stage+depth)
    56095678        # = n*(e+tide+n) based on how I'm writing these files
    5610         answer = n*(e+tide+n)
    5611         actual = xmomentum[0,0]
    5612         assert allclose(answer, actual)  #Meters
     5679        #
     5680        answer_x = n*(e+tide+n)
     5681        actual_x = xmomentum[0,0]
     5682        #print "answer_x",answer_x
     5683        #print "actual_x",actual_x
     5684        assert allclose(answer_x, actual_x)  #Meters
     5685       
     5686        #Check the momentums - va
     5687        #momentum = velocity*(stage-elevation)
     5688        # elevation = - depth
     5689        #momentum = velocity_va *(stage+depth)
     5690        # = e*(e+tide+n) based on how I'm writing these files
     5691        #
     5692        answer_y = -1*e*(e+tide+n)
     5693        actual_y = ymomentum[0,0]
     5694        #print "answer_y",answer_y
     5695        #print "actual_y",actual_y
     5696        assert allclose(answer_y, actual_y)  #Meters
    56135697
    56145698        # check the stage values, first time step.
     
    58265910#-------------------------------------------------------------
    58275911if __name__ == "__main__":
    5828     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2txt')
     5912    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sww')
    58295913    #suite = unittest.makeSuite(Test_Data_Manager,'cache_test_URS_points_needed_and_urs_ungridded2sww')
    58305914    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sww_momentum')
Note: See TracChangeset for help on using the changeset viewer.