Changeset 640


Ignore:
Timestamp:
Apr 30, 2012, 1:09:03 PM (13 years ago)
Author:
tnavarro
Message:

Ls axtime for gcm files. Plot files without time axis (surface,etc ...). Histogram plot for difference between two files (--ope -)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot.py

    r638 r640  
    8181    from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
    8282    import matplotlib as mpl
    83     from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel, subplots_adjust, axes, clabel
     83    from matplotlib.pyplot import contour,contourf,hist, text,subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel, subplots_adjust, axes, clabel
    8484    from matplotlib.cm import get_cmap
    8585    #from mpl_toolkits.basemap import cm
     
    8787    from numpy.core.defchararray import find
    8888    from videosink import VideoSink
     89    from timestuff import sol2ls
    8990    import subprocess
    9091    #from singlet import singlet
     
    197198          elif "time" in nc.variables:          time = nc.variables["time"][:]
    198199          elif "time_counter" in nc.variables:  time = nc.variables["time_counter"][:]/86400. #### time counter cinverstion from s-> days
    199           else:                                 errormess("no time axis found.")
    200           if axtime in ["ls","sol"]:   errormess("not supported. should not be too difficult though.")
     200          else:                                 time = [0.] #errormess("no time axis found.")
     201          if axtime in ["ls"]:
     202              print "converting to Ls ..."
     203              for iii in range(len(time)):
     204                time[iii] = sol2ls(time[iii]) # to use with timestuff
     205                if iii > 0:
     206                  while abs(time[iii]-time[iii-1]) > 300:
     207                    time[iii] = time[iii]+360
    201208          # for 1D plots (no need for longitude computation):
    202209          if axtime in ["lt"]:
     
    572579                                             scale=20., factor=250., color=colorvec, key=key)
    573580                                                              #200.         ## or csmooth=stride
     581                        if ope == '-' and nplot == numplot: # this should work as long as ope is '-' guarantees 3 plots for 4 panels without contour
     582                            subplot(subv,subh,nplot+1)
     583                            latmin = -50.; latmax = 50. # latitude range for histogram of difference
     584                            if indexlat is None: # a bit dirty, if field is not reduced along latitude, we assume lat is along the y axis
     585                                zeindexlat = (lat<latmax)*(lat>latmin)
     586                                what_I_plot_frame = what_I_plot_frame[zeindexlat,:]
     587                            toplot = np.ravel(what_I_plot_frame[np.isnan(what_I_plot_frame)==False])
     588                            zebins = np.linspace(minop,maxop,num=30)
     589                            hist(toplot,bins=zebins,histtype='step',linewidth=2,color='k',normed=True)
     590                            zestd = np.std(toplot)
     591                            zemean = np.mean(toplot)
     592                            zebins = np.linspace(minop,maxop,num=300)
     593                            zegauss = (1./(zestd * np.sqrt(2 * np.pi)) * np.exp( - (zebins - zemean)**2 / (2 * zestd**2) ) )
     594                            text(zebins[2],np.max(zegauss),'mean: '+str(zemean)[0:5]+'\nstd: '+str(zestd)[0:5],fontsize = 12)
     595                            plot(zebins, zegauss, linewidth=1, color='r')
     596                            title("Histogram fig(1) "+ope+" fig(2)")
     597                            subplot(subv,subh,nplot) # go back to last plot for title of contour difference
     598
    574599                    elif which == "contour":
    575600                        zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame))
Note: See TracChangeset for help on using the changeset viewer.