Changeset 5071


Ignore:
Timestamp:
Feb 22, 2008, 5:01:53 PM (17 years ago)
Author:
nick
Message:

Updates to csv2timeseries_graphs... please test it out :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r5069 r5071  
    18581858   
    18591859    i_max = len(directories_dic.keys())
    1860     legend_list_dic =[]
     1860    legend_list_dic={}
    18611861    legend_list =[]
    18621862    for i, directory in enumerate(directories_dic.keys()):
     
    18791879            attribute_dic, title_index_dic = csv2dict(directory+filename+'.csv')
    18801880            #get data from dict in to list
    1881 #            t = [float(x) for x in attribute_dic["time"]]
    1882 
    18831881            #do maths to list by changing to array
    1884 #            t=(array(t)+directory_start_time)/seconds_in_minutes
    18851882            t=(array(directory_quantity_value[directory][filename]['time'])+directory_start_time)/seconds_in_minutes
    18861883
     
    18961893                print "Note! Elevation changes in %s" %dir_filename
    18971894
    1898             #populates the legend_list_dic with dir_name and the elevation
    1899             if i==0:
    1900                 legend_list_dic.append({directory_name:round(max_ele,3)})
    1901             else:
    1902                 #print j,max_ele, directory_name, legend_list_dic
    1903                 legend_list_dic[j][directory_name]=round(max_ele,3)
    1904 
    1905             # creates a list for the legend after at "legend_dic" has been fully populated
     1895            # creates a dictionary with keys that is the filename and attributes are a list of
     1896            # lists containing 'directory_name' and 'elevation'. This is used to make the contents
     1897            # for the legends in the graphs, this is the name of the model and the elevation.
     1898            # All in this great one liner from DG. If the key 'filename' doesn't exist it creates the
     1899            # entry if the entry exist it appends to the key.
     1900           
     1901            legend_list_dic.setdefault(filename,[]).append([directory_name,round(max_ele,3)])
     1902
     1903            # creates a LIST for the legend on the last iteration of the directories
     1904            # which is when "legend_list_dic" has been fully populated. Creates a list of strings
     1905            # which is used in the legend
    19061906            # only runs on the last iteration for all the gauges(csv) files
    19071907            # empties the list before creating it
    19081908            if i==i_max-1:
    19091909                legend_list=[]
    1910                 for k, l in legend_list_dic[j].iteritems():
    1911                     legend_list.append('%s (elevation = %sm)'%(k,l))
    1912                     #print k,l, legend_list_dic[j]
     1910   
     1911                print 'DIC',legend_list_dic
     1912                for name_and_elevation in legend_list_dic[filename]:
     1913                    legend_list.append('%s (elevation = %sm)'%(name_and_elevation[0],name_and_elevation[1]))
    19131914           
    19141915            #print 'filename',filename, quantities
    1915             #remove time so it is not plotted!
     1916            #skip time and elevation so it is not plotted!
    19161917            for k, quantity in enumerate(quantities):
    19171918                if quantity != 'time' and quantity != 'elevation':
    1918                     #quantity_value[quantity] = [float(x) for x in attribute_dic[quantity]]
    1919                    
    1920                     #add tide to stage if provided
    1921 #                    if quantity == 'stage':
    1922 #                        quantity_value[quantity]=array(quantity_value[quantity])+directory_add_tide
    19231919                   
    19241920                    num=int(k*100+j)
    19251921                    pylab.figure(num)
    1926 #                    print directory,len(t),'LENgth',len(directory_quantity_value[directory]),directory_quantity_value[directory][filename][quantity][1:10]
    19271922                    pylab.ylabel(quantities_label[quantity])
    19281923                    pylab.plot(t, directory_quantity_value[directory][filename][quantity], c = cstr[i], linewidth=1)
     
    19301925                    pylab.axis(quantities_axis[quantity])
    19311926                    pylab.legend(legend_list,loc='upper right')
     1927                   
    19321928                    pylab.title('%s at %s gauge' %(quantity,filename[len(base_name):]))
    19331929                    if output_dir == '':
Note: See TracChangeset for help on using the changeset viewer.