Ignore:
Timestamp:
Sep 5, 2013, 2:28:49 PM (11 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2

  • added keywords nxticks nyticks xp yp missing for improved plot settings
  • added function to print contents of pp object
  • added to ppplot a function figureref to easily set a figure of given size
  • bug fix affecting .ppobj objects containing fields with missing values
  • bug fix when size of z coordinate do not match field
  • bug fix for Ls time coordinates (added changetime=correctls)
  • bug fix if not connected to internet
  • tidying up examples
File:
1 edited

Legend:

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

    r1027 r1029  
    187187# a function for predefined figure sizes
    188188def figuref(x=16,y=9):
    189     mpl.figure(figsize=(x,y))
     189    fig = mpl.figure(figsize=(x,y))
     190    return fig
    190191
    191192# a function to change color lines according to a color map (idea by A. Pottier)
     
    208209        subv, subh = subv_t[numplot],subh_t[numplot]
    209210    except:
    210         print "!! WARNING !! no preset found from set_multiplot.txt, or this setting file was not found."
     211        print "!! WARNING !! (ignore if superpose mode) no preset found from set_multiplot.txt, or this setting file was not found."
    211212        subv = 1 ; subh = numplot
    212213    return subv,subh
     
    355356                 xmax=None,\
    356357                 ymax=None,\
     358                 nxticks=10,\
     359                 nyticks=10,\
    357360                 title=""):
    358361        ## what could be defined by the user
     
    379382        self.xmax = xmax
    380383        self.ymax = ymax
     384        self.nxticks = nxticks
     385        self.nyticks = nyticks
    381386        ## other useful arguments
    382387        ## ... not used here in ppplot but need to be attached to plot object
     
    532537        ## set with .div the number of ticks. (is it better than automatic?)
    533538        if not self.logx:
    534             ax.xaxis.set_major_locator(MaxNLocator(self.div/2))
     539            ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) #TBD: with nxticks?
    535540        else:
    536541            print "!! WARNING. in logx mode, ticks are set automatically."
     
    684689            if self.ymin is not None: ax.set_ybound(lower=self.ymin)
    685690            if self.ymax is not None: ax.set_ybound(upper=self.ymax)
    686             # set the number of ticks (hardcoded)
    687             ax.xaxis.set_major_locator(MaxNLocator(10))
     691            # set the number of ticks
     692            if not self.logx:
     693                ax.xaxis.set_major_locator(MaxNLocator(self.nxticks))
     694            else:
     695                print "!! WARNING. in logx mode, ticks are set automatically."
    688696            ## specific modulo labels
    689697            if self.modx is not None:
     
    773781              if self.back in back.keys():
    774782                 print "**** info: loading a background, please wait.",self.back
    775                  if self.back not in ["coast","sea"]:   m.warpimage(back[self.back],scale=0.75)
    776                  elif self.back == "coast":             m.drawcoastlines()
    777                  elif self.back == "sea":               m.drawlsmask(land_color='white',ocean_color='aqua')
     783                 if self.back not in ["coast","sea"]:
     784                    try: m.warpimage(back[self.back],scale=0.75)
     785                    except: print "!! ERROR !! no background image could be loaded. probably not connected to the internet?"
     786                 elif self.back == "coast":
     787                    m.drawcoastlines()
     788                 elif self.back == "sea":
     789                    m.drawlsmask(land_color='white',ocean_color='aqua')
    778790              else:
    779791                 print "!! ERROR !! requested background not defined. change name or fill in set_back.txt" ; exit()
Note: See TracChangeset for help on using the changeset viewer.