Changeset 3035


Ignore:
Timestamp:
May 31, 2006, 5:03:59 PM (19 years ago)
Author:
ole
Message:

Working with Suresh at ACFR

Location:
development/stochastic_study
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • development/stochastic_study/create_realisations.py

    r2979 r3035  
    7272                        use_cache = False)
    7373
    74         print V.shape
    75         print V[:2,:]
    7674        Z = None
    7775
  • development/stochastic_study/plot_spread.py

    r3011 r3035  
    1515# Initialise
    1616# Read in all realisations-timeseries
    17 study = 'cyclone1'
    18 study = 'cyclone3'
    19 #study = 'nautilus3'
     17
     18#study = 'nautilus1' #~70 realisations, blocks of 100, sequential, stddev= 0.0006
     19#study = 'nautilus3' #~100 realisations, blocks of 10, sequential, stddev= 0.0013
     20study = 'cyclone1' #~4000 realisations, blocks of 100, parallel, stddev= 0.0006
     21#study = 'cyclone3' #~120 realisations, blocks of 10, parallel, stddev= 0.0013
    2022
    2123time, data, filenames = read_realisations(study,
    2224                                          #max_realisations = 200,
    23                                           gauge_number=2,
    24                                           use_cache=False)
     25                                          gauge_number=0,
     26                                          sorting='randomised',
     27                                          #sorting='numerical',
     28                                          verbose=True,
     29                                          use_cache=True)
    2530number_of_realisations = data.shape[1]
     31number_of_timesteps = data.shape[0]
    2632print 'Read %d realisations' %number_of_realisations
     33
    2734
    2835# Plot
     
    3441
    3542
    36 for j in range(20):
     43for j in range(1):
    3744    #print j, filenames[j]
    3845    plot(time, data[:,j], 'k-')
     
    4552          %(study, shortname, j, number_of_realisations-1))
    4653   
    47     #title('Study %s: timeseries for %s (realisation %d of %d)'\
    48     #      %(study, filenames[j], j, number_of_realisations-1))   
    49     raw_input('Next')
     54    #raw_input('Next')
     55
     56
     57raw_input('Stats')   
    5058 
    5159
     
    5361hold(False)
    5462# Plot spread of stage values for each timestep
    55 for i in range(300,320): #project.number_of_timesteps):
     63for i in range(0,project.number_of_timesteps):
    5664    # Plot histogram#
    5765
     
    6270    title('Study %s: spread at timestep %d of %d (t=%.2f)'\
    6371          %(study, i, project.number_of_timesteps-1, time[i]))       
    64     raw_input('Next')
     72raw_input('Next')
    6573
     74show()
     75import sys; sys.exit()
    6676
    6777hold(False)
  • development/stochastic_study/project.py

    r3011 r3035  
    2727
    2828# Stats (Suresh ?)
    29 number_of_realisations = 1
     29number_of_realisations = 2
    3030
    3131#number_of_realisations = 16000
    3232
    33 #std_dev = 0.0026  #Range is 26.035 cm
    34 std_dev = 0.0013  #Range is 26.035 cm   (simulation 3)
    35 #std_dev = 0.0006  #Range is 26.035 cm  (simulation 1)
     33std_dev = 0.0013 #m  #Range is 26.035 cm   (simulation 3)
     34#std_dev = 0.0006  #m  #Range is 26.035 cm  (simulation 1)
    3635mean = 0.0
    3736blocksize = 100 #How many realisations to fit at a time
  • development/stochastic_study/read_realisations.py

    r3006 r3035  
    55import project
    66from Numeric import Float, zeros
     7from RandomArray import randint
    78from caching import cache
    89
    910def read_realisations(subdir, max_realisations = None, gauge_number=0,
    10                       exclude=None, use_cache=False, verbose=True):
     11                      exclude=None,
     12                      sorting=None,
     13                      use_cache=False,
     14                      verbose=True):
    1115    """Read realisations
    1216    """
     
    1721                       {'max_realisations': max_realisations,
    1822                        'gauge_number': gauge_number,
    19                         'exclude': exclude},
     23                        'exclude': exclude,
     24                        'sorting': sorting},
    2025                       verbose=verbose)
    2126    else:
     
    2328                                    max_realisations = max_realisations,
    2429                                    gauge_number=gauge_number,
    25                                     exclude=exclude)
     30                                    exclude=exclude,
     31                                    sorting=sorting)
    2632
    2733    return result
    2834
     35
    2936def _read_realisations(subdir, max_realisations = None, gauge_number=0,
    30                        exclude=None, use_cache=False, verbose=True):
     37                       exclude=None, sorting=None,
     38                       use_cache=False, verbose=True):
    3139    """Read realisations
    3240    """
     
    5260    time = zeros(project.number_of_timesteps, Float)
    5361    data = zeros((project.number_of_timesteps, len(filenames)), Float)
    54    
     62
     63    if sorting is None:
     64        pass
     65    elif sorting == 'numerical':
     66        filenames = sort_numerically(filenames)
     67    elif sorting == 'randomised':   
     68        filenames = randomise(filenames)
     69    else:
     70        print 'Invalid value for sorting: %s' %sorting
     71        import sys; sys.exit()
     72
     73
    5574    # Read data       
    5675
     
    6887
    6988    return time, data, filenames
     89
     90
     91def sort_numerically(filenames):
     92    """Sort filenames numerically
     93    simulation_realisation_n_ch.... (sort by n)
     94    """
     95
     96    print 'Sorting'
     97    sorted_filenames = []
     98
     99    numbers = []
     100    for filename in filenames:
     101        fields = filename.split('_')
     102        n = int(fields[2])
     103        numbers.append(n)
     104
     105    A = zip(numbers, filenames)
     106    A.sort()
     107   
     108    sorted_filenames = [a[1] for a in A]   
     109   
     110    return sorted_filenames
     111
     112
     113def randomise(filenames):
     114    """Randomise filenames
     115    """
     116
     117    print 'Randomising'
     118    randomised_filenames = []
     119
     120
     121    while len(filenames) > 0:
     122        n = randint(0, len(filenames))
     123        filename = filenames[n]
     124        del filenames[n]
     125        randomised_filenames.append(filename)
     126     
     127    return randomised_filenames
  • development/stochastic_study/run_model.py

    r3009 r3035  
    134134                                       finaltime = finaltime):
    135135                    pass
    136                     #domain.write_time()
     136                    domain.write_time()
    137137                   
    138138       
Note: See TracChangeset for help on using the changeset viewer.