BCDA-APS / apstools

various tools for use with Bluesky at the APS
https://bcda-aps.github.io/apstools/latest/
Other
16 stars 9 forks source link

DiffractometerMixin: needs wh() report #397

Closed prjemian closed 4 years ago

prjemian commented 4 years ago

Need a report like SPEC provides:

1117.KAPPA29ID_sim> wh
H K L =  0  0  1.7345
Alpha = 20  Beta = 20  Azimuth = 90
Omega = 32.952  Lambda = 1.54
  Two Theta       Theta         Chi         Phi     K_Theta       Kappa       K_Phi
  40.000000   20.000000   90.000000   57.048500   77.044988  134.755995  114.093455

also report the sample name

Thanks, @rodolakis, for the suggestion.

prjemian commented 4 years ago

maybe sample does not fit into this context, could be an option

prjemian commented 4 years ago

prototype:


def wh(diffractometer):
    """
    1117.KAPPA29ID_sim> wh
    H K L =  0  0  1.7345
    Alpha = 20  Beta = 20  Azimuth = 90
    Omega = 32.952  Lambda = 1.54
    Two Theta       Theta         Chi         Phi     K_Theta       Kappa       K_Phi
    40.000000   20.000000   90.000000   57.048500   77.044988  134.755995  114.093455

    https://certif.com/downloads/css_docs/spec_manA4.pdf
    """
    self = diffractometer
    table = pyRestTable.Table()
    table.labels = "term value".split()
    table.addRow(("diffractometer", self.name))
    table.addRow(("wavelength (angstrom)", self.calc.wavelength))
    # TODO: Alpha   angle of incidence with sample surface
    # TODO: Beta    angle of reflection with sample surface
    # TODO: Azimuth ??
    # TODO: Omega   ??

    # table.addRow(("sample name", self.calc.sample.name))
    # for item in "a b c".split():
    #     table.addRow((f"{item} (angstrom)", getattr(self.calc.sample.lattice, item)))
    # for item in "alpha beta gamma".split():
    #     table.addRow((f"{item} (degrees)", getattr(self.calc.sample.lattice, item)))

    for item in "h k l".split():
        table.addRow((item, getattr(self, item).position))

    for item in self.real_positioners:
        table.addRow((item.attr_name, item.position))
    print(table)

example:

In [89]: wh(sixc)                                                                                                                                        
===================== =====
term                  value
===================== =====
diffractometer        sixc 
wavelength (angstrom) 1.54 
h                     0.0  
k                     0.0  
l                     0.0  
mu                    0.0  
omega                 0    
chi                   0    
phi                   0    
gamma                 0    
delta                 0    
===================== =====
prjemian commented 4 years ago

Make it easier to subclass. Add printing=True kwarg and return the table object. A subclass that overrides could call table = super().wh(printing=False), then call table.addRow() as desired.