Changeset 5462


Ignore:
Timestamp:
Jan 2, 2023 5:14:08 PM (11 months ago)
Author:
toby
Message:

add Zoom/Pan? to status line; fix numpy 1.24.1 bug in NIST code

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r5461 r5462  
    863863
    864864
    865     # these routines are not currently in use, but there are probably good
    866     # places in the graphics to disable the zoom/pan to release the mouse bind
    867     #
    868     # use as Page.canvas.toolbar.reset_zoompan()
    869     #
    870865    def get_zoompan(self):
    871         """Return "ZOOM" if Zoom is active, , "PAN" if Pan is active,
     866        """Return "Zoom" if Zoom is active, "Pan" if Pan is active,
    872867        or None if neither
    873868        """
    874869        return self.GetActive()
    875870
    876     def reset_zoompan(self):
    877         '''Turns off Zoom or Pan mode, if on. Ignored if neither is set
    878         '''
    879         if self._active == 'ZOOM':
    880             self._active = None
    881             if self._idPress is not None:
    882                 self._idPress = self.canvas.mpl_disconnect(self._idPress)
    883                 self.mode = ''
    884 
    885             if self._idRelease is not None:
    886                 self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
    887                 self.mode = ''
    888             self.canvas.widgetlock.release(self)
    889             if hasattr(self,'_NTB2_ZOOM'):
    890                 self.ToggleTool(self._NTB2_ZOOM, False)
    891             elif hasattr(self,'wx_ids'):
    892                 self.ToggleTool(self.wx_ids['Zoom'], False)
    893             else:
    894                 print('Unable to reset Zoom button, please report this with matplotlib version')
    895         elif self._active == 'PAN':
    896             self._active = None
    897             if self._idPress is not None:
    898                 self._idPress = self.canvas.mpl_disconnect(self._idPress)
    899                 self.mode = ''
    900 
    901             if self._idRelease is not None:
    902                 self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
    903                 self.mode = ''
    904             self.canvas.widgetlock.release(self)
    905             if hasattr(self,'_NTB2_PAN'):
    906                 self.ToggleTool(self._NTB2_PAN, False)
    907             elif hasattr(self,'wx_ids'):
    908                 self.ToggleTool(self.wx_ids['Pan'], False)
    909             else:
    910                 print('Unable to reset Pan button, please report this with matplotlib version')
     871    # this routine is not currently in use, and needs to be updated
     872    # to match internals of lib/python3.x/site-packages/matplotlib/backend_bases.py
     873    # but there are probably good places in the graphics to disable the
     874    # zoom/pan and release the mouse bind
     875    #
     876    # def reset_zoompan(self):
     877    #     '''Turns off Zoom or Pan mode, if on. Ignored if neither is set.
     878    #     call as Page.toolbar.reset_zoompan()
     879    #     '''
     880    #     if self._active == 'ZOOM':
     881    #         self._active = None
     882    #         if self._idPress is not None:
     883    #             self._idPress = self.canvas.mpl_disconnect(self._idPress)
     884    #             self.mode = ''
     885
     886    #         if self._idRelease is not None:
     887    #             self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
     888    #             self.mode = ''
     889    #         self.canvas.widgetlock.release(self)
     890    #         if hasattr(self,'_NTB2_ZOOM'):
     891    #             self.ToggleTool(self._NTB2_ZOOM, False)
     892    #         elif hasattr(self,'wx_ids'):
     893    #             self.ToggleTool(self.wx_ids['Zoom'], False)
     894    #         else:
     895    #             print('Unable to reset Zoom button, please report this with matplotlib version')
     896    #     elif self._active == 'PAN':
     897    #         self._active = None
     898    #         if self._idPress is not None:
     899    #             self._idPress = self.canvas.mpl_disconnect(self._idPress)
     900    #             self.mode = ''
     901
     902    #         if self._idRelease is not None:
     903    #             self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
     904    #             self.mode = ''
     905    #         self.canvas.widgetlock.release(self)
     906    #         if hasattr(self,'_NTB2_PAN'):
     907    #             self.ToggleTool(self._NTB2_PAN, False)
     908    #         elif hasattr(self,'wx_ids'):
     909    #             self.ToggleTool(self.wx_ids['Pan'], False)
     910    #         else:
     911    #             print('Unable to reset Pan button, please report this with matplotlib version')
    911912               
    912913def SetCursor(page):
     
    23882389                dsp = G2lat.Pos2dsp(Parms,xpos)
    23892390                q = 2.*np.pi/dsp
     2391            statLine = ""
    23902392            if G2frame.Contour: #PWDR only
    23912393                try:
    23922394                    if 'T' in Parms['Type'][0]:
    2393                         G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d=%9.5f Q=%9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1]),1)
     2395                        statLine = 'TOF =%9.3f d=%9.5f Q=%9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1])
    23942396                    else:
    2395                         G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d=%9.5f Q= %9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1]),1)
     2397                        statLine = '2-theta =%9.3f d=%9.5f Q= %9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1])
    23962398                except IndexError:
    23972399                    pass
     
    23992401                if 'T' in Parms['Type'][0]:
    24002402                    if Page.plotStyle['sqrtPlot']:
    2401                         G2frame.G2plotNB.status.SetStatusText('TOF = %9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
     2403                        statLine = 'TOF = %9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos)
    24022404                    else:
    2403                         G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d=%9.5f Q=%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1)
     2405                        statLine = 'TOF =%9.3f d=%9.5f Q=%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos)
    24042406                elif 'E' in Parms['Type'][0]:
    2405                     G2frame.G2plotNB.status.SetStatusText('Energy =%9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
     2407                    statLine = 'Energy =%9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos)
    24062408                else:
    24072409                    if 'PWDR' in plottype:
     2410                        ytmp = ypos
    24082411                        if Page.plotStyle['sqrtPlot']:
    2409                             G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
    2410                         else:
    2411                             G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d=%9.5f Q=%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1)
     2412                            ytmp = ypos**2
     2413                        statLine = '2-theta=%.3f d=%.5f Q=%.4f Intensity=%.2f'%(xpos,dsp,q,ypos)
    24122414                    elif plottype == 'SASD':
    2413                         G2frame.G2plotNB.status.SetStatusText('q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp),1)
     2415                        statLine = 'q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp)
    24142416                    elif plottype == 'REFD':
    2415                         G2frame.G2plotNB.status.SetStatusText('q =%12.5g Reflectivity =%12.5g d =%9.1f'%(q,ypos,dsp),1)
     2417                        statLine = 'q =%12.5g Reflectivity =%12.5g d =%9.1f'%(q,ypos,dsp)
     2418            zoomstat = Page.toolbar.get_zoompan()
     2419            if zoomstat:
     2420                statLine = "[" + zoomstat + "] " + statLine
     2421            G2frame.G2plotNB.status.SetStatusText(statLine,1)
    24162422            s = ''
    24172423            if G2frame.PickId:
  • trunk/NIST_profile/profile_functions_class.py

    r3571 r5462  
    8585
    8686ft_factors.sort()
    87 ft_factors=numpy.array(ft_factors, numpy.int)
     87ft_factors=numpy.array(ft_factors, int)
    8888
    8989## @brief used for debugging moments from FP_profile.axial_helper().
     
    215215       
    216216        ## a real-format scratch buffer
    217         self._rb1=b(numpy.zeros(nn,numpy.float))
     217        self._rb1=b(numpy.zeros(nn,float))
    218218        ## a real-format scratch buffer
    219         self._rb2=b(numpy.zeros(nn,numpy.float))
     219        self._rb2=b(numpy.zeros(nn,float))
    220220        ## a real-format scratch buffer
    221         self._rb3=b(numpy.zeros(nn,numpy.float))
     221        self._rb3=b(numpy.zeros(nn,float))
    222222        ## a complex-format scratch buffer
    223223        self._cb1=b(numpy.zeros(nn,numpy.complex))
    224224        ## a scratch buffer used by the axial helper
    225         self._f0buf=b(numpy.zeros(self.oversampling*twotheta_output_points, numpy.float))
     225        self._f0buf=b(numpy.zeros(self.oversampling*twotheta_output_points, float))
    226226        ## a scratch buffer used for axial divergence
    227         self._epsb2=b(numpy.zeros(self.oversampling*twotheta_output_points, numpy.float))
     227        self._epsb2=b(numpy.zeros(self.oversampling*twotheta_output_points, float))
    228228        ## the I2+ buffer
    229         self._I2p=b(numpy.zeros(self.oversampling*twotheta_output_points, numpy.float))
     229        self._I2p=b(numpy.zeros(self.oversampling*twotheta_output_points, float))
    230230        ## the I2- buffer
    231         self._I2m=b(numpy.zeros(self.oversampling*twotheta_output_points, numpy.float))
     231        self._I2m=b(numpy.zeros(self.oversampling*twotheta_output_points, float))
    232232        ## another buffer used for axial divergence
    233         self._axial=b(numpy.zeros(self.oversampling*twotheta_output_points, numpy.float))
     233        self._axial=b(numpy.zeros(self.oversampling*twotheta_output_points, float))
    234234        ## the largest frequency in Fourier space
    235235        omega_max=self.n_omega_points*2*math.pi/window_fullwidth
     
    308308    #  cached copy is implicitly updated, so thsat the next time this is called with the same
    309309    #  parameters, it will return the previous array.
    310     def get_conv(self, name, key, format=numpy.float):
     310    def get_conv(self, name, key, format=float):
    311311        #either get an old buffer associated with key, with valid convolution kernel,
    312312        #or create a new, empty buffer. If we already have too many buffers, swap one out.
     
    811811        if width is None:
    812812            return #no convolver
    813         flag, conv = self.get_conv(name, width, numpy.float)
     813        flag, conv = self.get_conv(name, width, float)
    814814        if flag: return conv #already up to date
    815815        rb1=self._rb1
     
    10481048        kwargs.update(self.param_dicts["conv_global"])
    10491049
    1050         flag, conv = self.get_conv(me, kwargs, numpy.float)
     1050        flag, conv = self.get_conv(me, kwargs, float)
    10511051        if flag: return conv #already up to date
    10521052       
     
    10911091        if not self.output_gaussian_smoother_bins_sigma: return # no smoothing
    10921092        flag, buf=self.get_conv(me, self.output_gaussian_smoother_bins_sigma,
    1093             format=numpy.float)
     1093            format=float)
    10941094        if flag: return buf #already computed
    10951095        buf[:]=self.omega_vals
Note: See TracChangeset for help on using the changeset viewer.