Changeset 2836


Ignore:
Timestamp:
May 8, 2006, 4:55:59 PM (19 years ago)
Author:
sexton
Message:

updates to sww2timeseries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/util.py

    r2808 r2836  
    574574    - if title_on = False then output latex file will be generated
    575575      in same directory as where script is run (usually production
    576       scenario direcotry. Name = latex_output_label_id.tex
     576      scenario direcotry. Name = latexoutpulabel_id.tex
    577577
    578578    Other important information:
     
    606606                    time_max = None,
    607607                    title_on = None,
    608                     verbose = False):
    609 
    610     from pylab import * #FIXME (Ole): List actual functions used rather than *
    611    
     608                    verbose = False):   
    612609
    613610    assert type(swwfile) == type(''),\
     
    677674
    678675    if verbose: print 'Inputs OK - going to generate figures'
     676
     677    # could try different approach for file_loc:
     678    # index = swwfile.find(basename.sww)
     679    # file_loc = swwfile[:index-1]
    679680   
    680681    return generate_figures(plot_quantity, file_loc, f, gauges, locations,
     
    739740
    740741    from math import sqrt, atan, degrees
    741     from os import sep, altsep
     742    from Numeric import ones
     743    from os import sep, altsep, getcwd, mkdir, access, F_OK, environ
     744    from os.path import expanduser
     745    from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, ylabel, title, close
    742746
    743747    filename = file_loc.split(sep)
     
    746750        #ext = '.eps'
    747751        ext = ''
    748         texfilename = 'latex_output_%s.tex' %(label_id.replace(sep,'_'))
     752        label_id1 = label_id.replace(sep,'')
     753        label_id2 = label_id1.replace('_','')
     754        texfile = 'latexoutput%s' %(label_id2)
     755        texfilename = texfile + '.tex'
    749756        if verbose: print '\n Latex output printed to %s \n' %texfilename
    750757        fid = open(texfilename, 'w')
     
    820827            figure(i+1, frameon = False)
    821828            if which_quantity == 'depth':
    822                 plot(model_time, depths, 'g-')
     829                plot(model_time, depths, '-')
    823830                units = 'm'
    824831            if which_quantity == 'stage':
    825                 plot(model_time, stages, 'g-')
     832                plot(model_time, stages, '-')
    826833                units = 'm'
    827834            if which_quantity == 'momentum':
    828                 plot(model_time, momenta, 'g-')
     835                plot(model_time, momenta, '-')
    829836                units = 'm^2 / sec'
    830837            if which_quantity == 'xmomentum':
    831                 plot(model_time, xmom, 'g-')
     838                plot(model_time, xmom, '-')
    832839                units = 'm^2 / sec'
    833840            if which_quantity == 'ymomentum':
    834                 plot(model_time, ymom, 'g-')
     841                plot(model_time, ymom, '-')
    835842                units = 'm^2 / sec'
    836843            if which_quantity == 'velocity':
    837                 plot(model_time, velocity, 'g-')
     844                plot(model_time, velocity, '-')
    838845                units = 'm / sec'
    839846            if which_quantity == 'bearing':
    840847                due_east = 90.0*ones([len(model_time)])
    841848                due_west = 270.0*ones([len(model_time)])
    842                 plot(model_time, bearings, 'r-', model_time, due_west, '-.g',
    843                      model_time, due_east, '-.b')
     849                plot(model_time, bearings, '-', model_time, due_west, '-.',
     850                     model_time, due_east, '-.')
    844851                units = 'degrees from North'
    845852                ax = axis([time_min, time_max, 0, 360])
     
    849856            ylabel('%s (%s)' %(which_quantity, units))
    850857
    851             gaugeloc1 = gaugeloc.replace(' ','_')
    852             graphname = '%sgauge_%s_%s%s' %(file_loc, gaugeloc1, which_quantity, ext)
    853             latex_file_loc = file_loc.replace(sep,altsep)
    854             graphname_latex = '%sgauge_%s_%s_report%s' %(latex_file_loc, gaugeloc1, which_quantity, ext)
    855 
     858            gaugeloc1 = gaugeloc.replace(' ','')
     859            graphname = '%sgauge%s_%s%s' %(file_loc, gaugeloc1, which_quantity, ext)
     860            figdir = getcwd()+sep+'report_figures'+sep
     861            if access(figdir,F_OK) == 0 :
     862                mkdir (figdir)
     863            latex_file_loc = figdir.replace(sep,altsep)
     864           
     865            graphname_latex = '%sgauge%s%s%s%s' %(latex_file_loc, gaugeloc1, which_quantity, label_id2, ext)
     866
     867            p = getcwd().split(sep)   
     868            scenario = p[len(p)-1]
     869            home = expanduser('~')
     870            report_fig_loc = '~'+altsep+'anuga'+altsep+'production'+altsep+scenario+altsep+'report_figures'+altsep
     871            graphname_report = '%sgauge%s%s%s%s' %('report_figures'+altsep, gaugeloc1, which_quantity, label_id2, ext)
     872           
    856873            if title_on == True:
    857874                title('%s scenario: %s at %s gauge'
     
    859876                savefig(graphname)
    860877            else:
    861                 label = '%s_%s_gauge_%s' %(label_id.replace(sep,'_'), which_quantity, gaugeloc1)
    862                 caption = 'Time series for %s' %(which_quantity)
    863                 s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width=75mm, height=75mm]{%s}} \n' %(graphname_latex)
     878                label = '%s%sgauge%s' %(label_id2, which_quantity, gaugeloc1)
     879                caption = 'Time series for %s at %s gauge location' %(which_quantity, gaugeloc)
     880                s = '\\begin{figure}[hbt] \n \\centerline{\includegraphics[width=100mm, height=75mm]{%s%s}} \n' %(graphname_report, '.png')
    864881                fid.write(s)
    865882                s = '\\caption{%s} \n \label{fig:%s} \n \end{figure} \n \n' %(caption, label)
     
    879896    close('all')
    880897   
    881     return texfilename
     898    return texfile
Note: See TracChangeset for help on using the changeset viewer.