Ignore:
Timestamp:
Apr 3, 2013, 12:17:16 PM (12 years ago)
Author:
tnavarro
Message:

UTIL PYTHON planetoplot_v2. corrected case: mean_x+free_y free_x+mean_y mean_x+mean_y now correctly accounts for limited intervals. inspiration for improvements of getindexhori with bool arrays.

File:
1 edited

Legend:

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

    r925 r926  
    12481248                self.method_y = "fixed"
    12491249                if self.verbose: print "**** OK. no y dimension."
    1250         ## CASE 0 above, this is just for continuity.
     1250        ## CASE 0 above, this is just for continuity for free.
     1251        ## ... for comp we have to select bounds.
     1252        ## ... TBD: take the bool array strategy for what follows!
    12511253        if self.method_x in ["free","comp"] and self.method_y in ["free","comp"]:
     1254            ### ref1_dirty_hack
     1255            ### ... for the moment this is a hack. but actually this is more powerful.
     1256            if self.method_x == "comp":
     1257                yeah = (self.field_x >= dalistx[indx][0])*(self.field_x <= dalistx[indx][1])
     1258                self.index_x = yeah[0,:]
     1259            if self.method_y == "comp":
     1260                yeah = (self.field_y >= dalisty[indy][0]) * (self.field_y <= dalisty[indy][1])
     1261                self.index_y = yeah[:,0]
    12521262            self.index_x2d = self.index_x
    12531263            self.index_y2d = self.index_y
     
    13411351        # NB: ... always 4D array but possibly with "size 1" dimensions
    13421352        #     ... if one dimension is missing because 1D 2D or 3D requests, make it appear again
    1343         self.field = np.reshape(self.field,(nt,nz,ny,nx))
     1353        try:
     1354            self.field = np.reshape(self.field,(nt,nz,ny,nx))
     1355        except:
     1356            # dirty hack (AS) ref1_dirty_hack
     1357            # waiting for more fundamental modifications. case when self.index_y is a bool array.
     1358            # ... be careful if no point...
     1359            nx = np.sum(self.index_x) ## gives the size of the True part!
     1360            ny = np.sum(self.index_y)
     1361            self.field = np.reshape(self.field,(nt,nz,ny,nx))
    13441362        if self.verbose: print "**** OK. I got %7.1e values. This took me %6.4f seconds" % (nx*ny*nz*nt,timelib.time() - time0)
    13451363        if self.verbose: print "**** OK. I got var "+self.var+" with shape",self.field.shape
Note: See TracChangeset for help on using the changeset viewer.