Changeset 991 for trunk/UTIL


Ignore:
Timestamp:
Jun 14, 2013, 10:10:43 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. added --modx to produce a modulo on x labelling (e.g. for local time plots or Ls plots). thanks Tanguy for the request.

Location:
trunk/UTIL/PYTHON/planetoplot_v2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/pp.py

    r990 r991  
    8383parser.add_option('--xmax',action='append',dest='xmax',type="float",default=None,help="[1D] max bound x axis")
    8484parser.add_option('--ymax',action='append',dest='ymax',type="float",default=None,help="[1D] max bound y axis")
     85parser.add_option('--modx',action='append',dest='modx',type="float",default=None,help="[1D] change xticks with a modulo")
    8586# -- 2D plot
    8687parser.add_option('-C','--colorb',action='append',dest='colorb',type="string",default=None,help="[2D] colormap: http://micropore.files.wordpress.com/2010/06/colormaps.png")
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r990 r991  
    162162                      units=None,\
    163163                      savtxt=False,\
     164                      modx=None,\
    164165                      title=None):
    165166        self.request = None
     
    201202        self.changetime = changetime
    202203        self.savtxt = savtxt
     204        self.modx = modx
    203205        ## here are user-defined plot settings
    204206        ## -- if not None, valid on all plots in the pp() objects
     
    265267            self.changetime = other.changetime
    266268            self.savtxt = other.savtxt
     269            self.modx = other.modx
    267270        else:
    268271            print "!! ERROR !! argument must be a pp object." ; exit()
     
    797800                    if self.units is not None: plobj.units = self.units
    798801                    if self.colorb is not None: plobj.colorb = self.colorb
     802                    if self.modx is not None: plobj.modx = self.modx
    799803                    # -- 1D specific
    800804                    if dp == 1:
     
    11781182                try: self.p[iii].ymax = opt.ymax[0]
    11791183                except: pass
    1180 
     1184            ###
     1185            try: self.p[iii].modx = opt.modx[iii]
     1186            except:
     1187                try: self.p[iii].modx = opt.modx[0]
     1188                except: pass
    11811189
    11821190
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r990 r991  
    248248    return what_I_plot
    249249
     250# a function to change labels with modulo
     251# ---------------------------------------
     252def labelmodulo(ax,mod):
     253    mpl.draw()
     254    strtab = []
     255    for tick in ax.get_xaxis().get_ticklabels():
     256        num = float(tick.get_text())
     257        strtab.append(num % mod)
     258    ax.get_xaxis().set_ticklabels(strtab)
     259    return ax
     260
    250261# a function to output an ascii file
    251262# ----------------------------------
     
    265276        else:
    266277            print "!! WARNING !! Not printing the file, 2D fields not supported yet."
    267 #    mydata = np.transpose([absc,np.transpose(field)]) #tab
    268 #    for line in mydata:
    269 #        zeline = str(line)
    270 #        zeline = zeline.replace('[','')
    271 #        zeline = zeline.replace(']','')
    272 #        myfile.write(zeline + '\n')
    273278    return
    274279
     
    333338                 colorb="jet",\
    334339                 units="",\
     340                 modx=None,\
    335341                 title=""):
    336342        ## what could be defined by the user
     
    352358        self.units = units
    353359        self.colorb = colorb
     360        self.modx = modx
    354361        ## other useful arguments
    355362        ## ... not used here in ppplot but need to be attached to plot object
     
    505512        else:
    506513            print "!! WARNING. in logx mode, ticks are set automatically."
     514        ## specific modulo labels
     515        if self.modx is not None:
     516            ax = labelmodulo(ax,self.modx)
    507517
    508518################################
Note: See TracChangeset for help on using the changeset viewer.