Changeset 2835


Ignore:
Timestamp:
May 16, 2017 4:02:31 PM (6 years ago)
Author:
vondreele
Message:

add self.scriptable=False to ImportBaseClass?
set it True in various PWDR readers
when selecting points for image calibration, shift key forces selection at cursor
Status bar text changes to reflect this

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r2826 r2835  
    319319       
    320320def GetDetectorXY(dsp,azm,data):
    321     'Needs a doc string'
    322    
     321    '''Get detector x,y position from d-spacing (dsp), azimuth (azm,deg)
     322    & image controls dictionary (data)
     323    it seems to be only used in plotting
     324    '''   
    323325    elcent,phi,radii = GetEllipse(dsp,data)
    324326    phi = data['rotation']-90.          #to give rotation of major axis
     
    363365def GetDetXYfromThAzm(Th,Azm,data):
    364366    '''Computes a detector position from a 2theta angle and an azimultal
    365     angle (both in degrees)
     367    angle (both in degrees) - apparently not used!
    366368    '''
    367369    dsp = data['wavelength']/(2.0*npsind(Th))   
  • trunk/GSASIIimgGUI.py

    r2828 r2835  
    173173           
    174174    def OnCalibrate(event):
    175         G2frame.dataFrame.GetStatusBar().SetStatusText('Select > 4 points on 1st used ring; LB to pick, RB on point to delete else RB to finish')
     175        G2frame.dataFrame.GetStatusBar().SetStatusText('Select > 4 points on 1st used ring; LB to pick (shift key to force pick), RB on point to delete else RB to finish')
    176176        G2frame.ifGetRing = True
    177177               
  • trunk/GSASIIobj.py

    r2820 r2835  
    18041804        self.repeatcount = 0
    18051805        self.readfilename = '?'
     1806        self.scriptable = False
    18061807        #print 'created',self.__class__
    18071808
  • trunk/GSASIIplot.py

    r2829 r2835  
    44894489                ypix = int(ypos*scaley)
    44904490                Int = 0
    4491                 if (0 <= xpix < sizexy[1]) and (0 <= ypix < sizexy[0]):
     4491                if (0 <= xpix < sizexy[0]) and (0 <= ypix < sizexy[1]):
    44924492                    Int = G2frame.ImageZ[ypix][xpix]
    44934493                tth,azm,D,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
     
    45714571            elif event.key in ['y',]:
    45724572                Data['invert_y'] = not Data['invert_y']
     4573            else:
     4574                return
    45734575            wx.CallAfter(PlotImage,G2frame,newPlot=True)
    45744576           
     
    48384840                    Xpix = Xpos*scalex
    48394841                    Ypix = Ypos*scaley
    4840                     xpos,ypos,I,J = G2img.ImageLocalMax(G2frame.ImageZ,pixLimit,Xpix,Ypix)
     4842                    if event.key == 'shift':                #force selection at cursor position
     4843                        xpos = Xpix
     4844                        ypos = Ypix
     4845                        I = J = 10
     4846                    else:
     4847                        xpos,ypos,I,J = G2img.ImageLocalMax(G2frame.ImageZ,pixLimit,Xpix,Ypix)
    48414848                    if I and J:
    48424849                        xpos += .5                              #shift to pixel center
  • trunk/GSASIIscriptable.py

    r2825 r2835  
    115115                for a PWDR entry in  GSASII data tree.       
    116116    '''
    117     readerlist = ['G2pwd_fxye','G2pwd_xye','G2pwd_BrukerRAW','G2pwd_csv','G2pwd_FP',
    118         'G2pwd_Panalytical','G2pwd_rigaku']
    119     if reader not in readerlist:
    120         print '**** ERROR: unrecognized reader ',reader
     117    if not reader.scriptable:
     118        print '**** ERROR: not a scriptable reader ',reader
    121119        return None
    122120    rdfile,rdpath,descr = imp.find_module(reader)
  • trunk/imports/G2img_1TIF.py

    r2829 r2835  
    2424import numpy as np
    2525import time
    26 DEBUG = False
     26DEBUG = True
    2727GSASIIpath.SetVersionNumber("$Revision$")
    2828class TIF_ReaderClass(G2obj.ImportImage):
     
    4040            longFormatName = 'Various .tif and pseudo-TIF formats'
    4141            )
     42        self.scriptable = True
    4243
    4344    def ContentsValidator(self, filepointer):
     
    184185                return lines,0,0,0
    185186        tifType = 'CheMin'
    186         pixy = [40,40]
     187        pixy = [40.,40.]
    187188        image = np.flipud(np.array(Im.open(filename)))*10.
    188189        distance = 18.0
     
    196197            tifType = 'Pilatus'
    197198            dataType = 0
    198             pixy = [172,172]
     199            pixy = [172.,172.]
    199200            File.seek(4096)
    200201            print 'Read Pilatus tiff file: ',filename
     
    204205            if IFD[258][2][0] == 16:
    205206                tifType = 'GE'
    206                 pixy = [200,200]
     207                pixy = [200.,200.]
    207208                File.seek(8)
    208209                print 'Read GE-detector tiff file: ',filename
     
    212213            elif IFD[258][2][0] == 32:
    213214                tifType = 'CHESS'
    214                 pixy = [200,200]
     215                pixy = [200.,200.]
    215216                File.seek(8)
    216217                print 'Read CHESS-detector tiff file: ',filename
     
    222223            tifType = 'ImageJ'
    223224            dataType = 0
    224             pixy = [200,200]*IFD[277][2][0]
     225            pixy = [200.,200.]*IFD[277][2][0]
    225226            File.seek(IFD[273][2][0])
    226227            print 'Read ImageJ tiff file: ',filename
    227228#            image = ar.array('H',File.read(2*Npix))
    228229#            image = File.read(2*Npix,dtype=np.uint16)
    229             image = File.read(4*Npix)
     230            if IFD[258][2][0] == 32:
     231                image = File.read(4*Npix)
     232                image = np.array(np.frombuffer(image,dtype=byteOrd+'i4'),dtype=np.int32)
     233            elif IFD[258][2][0] == 16:
     234                image = File.read(2*Npix)
     235                pixy = [109.92,109.92]      #for LCLS ImageJ tif files
     236                image = np.array(np.frombuffer(image,dtype=byteOrd+'u2'),dtype=np.int32)
    230237#            if '>' in byteOrd:
    231238#                image.byteswap()
    232             image = np.array(np.frombuffer(image,dtype=np.int),dtype=np.int32)
    233239#            image = np.array(np.frombuffer(image),dtype=np.int32)
    234240#            image = np.array(np.asarray(image,dtype='H'),dtype=np.int32)           
    235241    elif 262 in IFD and IFD[262][2][0] > 4:
    236242        tifType = 'DND'
    237         pixy = [158,158]
     243        pixy = [158.,158.]
    238244        File.seek(512)
    239245        print 'Read DND SAX/WAX-detector tiff file: ',filename
     
    243249    elif sizexy == [1536,1536]:
    244250        tifType = 'APS Gold'
    245         pixy = [150,150]
     251        pixy = [150.,150.]
    246252        File.seek(64)
    247253        print 'Read Gold tiff file:',filename
     
    253259            if IFD[258][2][0] == 32:
    254260                tifType = 'PE'
    255                 pixy = [200,200]
     261                pixy = [200.,200.]
    256262                File.seek(8)
    257263                print 'Read APS PE-detector tiff file: ',filename
     
    274280        elif IFD[273][2][0] == 4096:
    275281            if sizexy[0] == 3072:
    276                 pixy =  [73,73]
     282                pixy =  [73.,73.]
    277283                tifType = 'MAR225'           
    278284            else:
    279                 pixy = [158,158]
     285                pixy = [158.,158.]
    280286                tifType = 'MAR325'           
    281287            File.seek(4096)
     
    286292        elif IFD[273][2][0] == 512:
    287293            tifType = '11-ID-C'
    288             pixy = [200,200]
     294            pixy = [200.,200.]
    289295            File.seek(512)
    290296            print 'Read 11-ID-C tiff file: ',filename
     
    296302            if IFD[258][2][0] == 16:
    297303                tifType = 'scanCCD'
    298                 pixy = [9,9]
     304                pixy = [9.,9.]
    299305                File.seek(8)
    300306                print 'Read APS scanCCD tiff file: ',filename
     
    302308            elif IFD[258][2][0] == 32:
    303309                tifType = 'PE4k'
    304                 pixy = [100,100]
     310                pixy = [100.,100.]
    305311                File.seek(8)
    306312                print 'Read PE 4Kx4K tiff file: ',filename
  • trunk/imports/G2img_CheMin.py

    r2817 r2835  
    4141        '''
    4242        import scipy.misc
    43         self.Image = scipy.misc.imread(filename,flatten=True).T
     43        self.Image = scipy.misc.imread(filename,flatten=True)
    4444        self.Npix = self.Image.size
    4545        if self.Npix == 0:
     
    4949            self.Comments = ['no metadata']
    5050            pixy = list(self.Image.shape)
    51             sizexy = [40,40]
     51            sizexy = [40.,40.]
    5252            self.Data = {'wavelength': 1.78892, 'pixelSize': sizexy, 'distance': 18.0,'size':pixy}
    5353            self.Data['center'] = [pixy[0]*sizexy[0]/1000.,pixy[1]*sizexy[1]/2000.]
  • trunk/imports/G2pwd_BrukerRAW.py

    r2817 r2835  
    3131            longFormatName = 'Bruker .RAW powder data file'
    3232            )
     33        self.scriptable = True
    3334
    3435    # Validate the contents -- make sure we only have valid lines
  • trunk/imports/G2pwd_FP.py

    r2817 r2835  
    3030            longFormatName = 'FullProf 1-10 column .dat powder data file'
    3131            )
     32        self.scriptable = True
    3233
    3334    # Validate the contents -- make sure we only have valid lines
  • trunk/imports/G2pwd_Panalytical.py

    r2817 r2835  
    2525            longFormatName = 'Panalytical powder data as *.xrdml'
    2626            )
     27        self.scriptable = True
    2728        self.vals = None
    2829        self.stepsize = None
  • trunk/imports/G2pwd_csv.py

    r2817 r2835  
    3030            longFormatName = 'Worksheet-type .csv powder data file'
    3131            )
     32        self.scriptable = True
    3233
    3334    # Validate the contents -- make sure we only have valid lines
  • trunk/imports/G2pwd_rigaku.py

    r2817 r2835  
    2929            longFormatName = 'Rigaku powder data exported as .txt'
    3030            )
     31        self.scriptable = True
    3132        self.vals = None
    3233        self.stepsize = None
  • trunk/imports/G2pwd_xye.py

    r2817 r2835  
    2929            longFormatName = 'Topas .xye or 2th Fit2D .chi powder data file'
    3030            )
     31        self.scriptable = True
    3132
    3233    # Validate the contents -- make sure we only have valid lines
Note: See TracChangeset for help on using the changeset viewer.