Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary format subclass methods #76

Merged
merged 3 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions format/FormatBruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from builtins import range
from dxtbx.format.Format import Format
from dxtbx import IncorrectFormatError


class FormatBruker(Format):
Expand Down Expand Up @@ -92,12 +93,9 @@ def understand(image_file):
def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

Format.__init__(self, image_file, **kwargs)
super(FormatBruker, self).__init__(str(image_file), **kwargs)

def detectorbase_start(self):
pass
Expand Down
12 changes: 0 additions & 12 deletions format/FormatBrukerFixedChi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ def understand(image_file):

return True

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment. Easy from Rigaku Saturn images as
they contain everything pretty much we need..."""
from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

self._image_file = image_file
FormatBruker.__init__(self, image_file, **kwargs)

def _start(self):
self.header_dict = {}
header_text = open(self._image_file).read().split("......")[0]
Expand Down
11 changes: 0 additions & 11 deletions format/FormatBrukerPhotonII.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ def understand(image_file):

return True

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment. Easy from Rigaku Saturn images as
they contain everything pretty much we need..."""

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

self._image_file = image_file
FormatBruker.__init__(self, image_file, **kwargs)

def _start(self):

try:
Expand Down
7 changes: 2 additions & 5 deletions format/FormatCBF.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import six
from dxtbx.format.Format import Format
from dxtbx import IncorrectFormatError


class FormatCBF(Format):
Expand Down Expand Up @@ -58,12 +59,10 @@ def get_cbf_header(image_file):
def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

Format.__init__(self, image_file, **kwargs)
super(FormatCBF, self).__init__(str(image_file), **kwargs)

@staticmethod
def _parse_cbf_header(cbf_header):
Expand Down Expand Up @@ -97,8 +96,6 @@ def _start(self):
"""Open the image file, read the image header, copy it into memory
for future inspection."""

Format._start(self)

self._cif_header = FormatCBF.get_cbf_header(self._image_file)

self._mime_header = ""
Expand Down
14 changes: 1 addition & 13 deletions format/FormatCBFFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,12 @@ def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

# It appears Pycbf can not handle unicode filenames (see dials/dials#256)
image_file = str(image_file)
from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBF.__init__(self, image_file, **kwargs)
self._raw_data = None
super(FormatCBFFull, self).__init__(str(image_file), **kwargs)

def __del__(self):
self._cbf_handle.__swig_destroy__(self._cbf_handle)

def _start(self):
"""Open the image file as a cbf file handle, and keep this somewhere
safe."""

FormatCBF._start(self)

def _get_cbf_handle(self):
try:
return self._cbf_handle
Expand Down
18 changes: 0 additions & 18 deletions format/FormatCBFFullPilatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFFull.__init__(self, image_file, **kwargs)

self._raw_data = None

def _start(self):
"""Open the image file as a cbf file handle, and keep this somewhere
safe."""

FormatCBFFull._start(self)

def _beam(self):
"""Return a working beam instance. Override polarization to be 0.999."""

Expand Down
5 changes: 1 addition & 4 deletions format/FormatCBFFullPilatusDLS300KSN104.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ def has_dynamic_shadowing(**kwargs):

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

assert self.understand(image_file)

self._dynamic_shadowing = self.has_dynamic_shadowing(**kwargs)
FormatCBFFullPilatus.__init__(self, image_file, **kwargs)
super(FormatCBFFullPilatusDLS300KSN104, self).__init__(image_file, **kwargs)

def get_mask(self, goniometer=None):
mask = super(FormatCBFFullPilatusDLS300KSN104, self).get_mask()
Expand Down
6 changes: 1 addition & 5 deletions format/FormatCBFFullPilatusDLS6MSN100.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ def has_dynamic_shadowing(**kwargs):

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""
from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

self._dynamic_shadowing = self.has_dynamic_shadowing(**kwargs)
FormatCBFFullPilatus.__init__(self, image_file, **kwargs)
super(FormatCBFFullPilatusDLS6MSN100, self).__init__(image_file, **kwargs)

def get_mask(self, goniometer=None):
mask = super(FormatCBFFullPilatusDLS6MSN100, self).get_mask()
Expand Down
6 changes: 1 addition & 5 deletions format/FormatCBFFullPilatusDLS6MSN126.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ def has_dynamic_shadowing(**kwargs):

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""
from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

self._dynamic_shadowing = self.has_dynamic_shadowing(**kwargs)
FormatCBFFullPilatus.__init__(self, image_file, **kwargs)
super(FormatCBFFullPilatusDLS6MSN126, self).__init__(image_file, **kwargs)

def get_mask(self, goniometer=None):
mask = super(FormatCBFFullPilatusDLS6MSN126, self).get_mask()
Expand Down
11 changes: 2 additions & 9 deletions format/FormatCBFMini.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,14 @@ def one_of_these_in(record):
def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBF.__init__(self, image_file, **kwargs)

self._raw_data = None
super(FormatCBFMini, self).__init__(image_file, **kwargs)

def _start(self):
"""Open the image file, read the image header, copy it into a
dictionary for future reference."""

FormatCBF._start(self)

super(FormatCBFMini, self)._start()
cif_header = FormatCBF.get_cbf_header(self._image_file)

self._cif_header_dictionary = {}
Expand Down
16 changes: 0 additions & 16 deletions format/FormatCBFMiniADSCHF4M.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMini.__init__(self, image_file, **kwargs)

self._raw_data = None

def _start(self):
FormatCBFMini._start(self)

def _detector(self):
"""Return a model for a simple detector, presuming no one has
one of these on a two-theta stage. Assert that the beam centre is
Expand Down
16 changes: 0 additions & 16 deletions format/FormatCBFMiniEiger.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMini.__init__(self, image_file, **kwargs)

self._raw_data = None

def _start(self):
FormatCBFMini._start(self)

def _detector(self):
distance = float(self._cif_header_dictionary["Detector_distance"].split()[0])

Expand Down
4 changes: 0 additions & 4 deletions format/FormatCBFMiniEigerDLS16MSN160.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ def has_dynamic_shadowing(**kwargs):

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file."""
from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

self._dynamic_shadowing = self.has_dynamic_shadowing(**kwargs)
super(FormatCBFMiniEigerDLS16MSN160, self).__init__(image_file, **kwargs)
Expand Down
13 changes: 0 additions & 13 deletions format/FormatCBFMiniEigerPetraP14.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMiniEiger.__init__(self, image_file, **kwargs)

self._raw_data = None

def _goniometer(self):
return self._goniometer_factory.known_axis((0, 1, 0))

Expand Down
16 changes: 0 additions & 16 deletions format/FormatCBFMiniEigerPhotonFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ def understand(image_file):
return True
return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMini.__init__(self, image_file, **kwargs)

return

def _start(self):
FormatCBFMini._start(self)

def _goniometer(self):
return self._goniometer_factory.make_goniometer(
(1, 0, 0), (1, 0, 0, 0, 1, 0, 0, 0, 1)
Expand Down
16 changes: 0 additions & 16 deletions format/FormatCBFMiniPilatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMini.__init__(self, image_file, **kwargs)

return

def _start(self):
FormatCBFMini._start(self)

def _detector(self):
"""Return a model for a simple detector, presuming no one has
one of these on a two-theta stage. Assert that the beam centre is
Expand Down
13 changes: 0 additions & 13 deletions format/FormatCBFMiniPilatus3APS19ID6MSN132.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMiniPilatus.__init__(self, image_file, **kwargs)

return

def _goniometer(self):
"""19ID has reversed goniometer"""

Expand Down
13 changes: 0 additions & 13 deletions format/FormatCBFMiniPilatusCHESS_6MSN127.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ def understand(image_file):

return False

def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

FormatCBFMiniPilatus.__init__(self, image_file, **kwargs)

return

def _goniometer(self):
"""Return a model for a simple single-axis reversed direction goniometer."""

Expand Down
9 changes: 1 addition & 8 deletions format/FormatCBFMiniPilatusDLS12M.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,13 @@ def __init__(self, image_file, **kwargs):
"""Initialise the image structure from the given file, including a
proper model of the experiment."""

from dxtbx import IncorrectFormatError

if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)

# if multi_panel == False, then interpret data as 24 panels, where each
# row of 5 panels is grouped as one "panel"
# elif multi_panel == True, then interpret data as 120 panels,
# 24 rows * 5 columns
self._dynamic_shadowing = self.has_dynamic_shadowing(**kwargs)
self._multi_panel = kwargs.get("multi_panel", False)
FormatCBFMiniPilatus.__init__(self, image_file, **kwargs)

self._raw_data = None
super(FormatCBFMiniPilatusDLS12M, self).__init__(image_file, **kwargs)

def _detector(self):

Expand Down
Loading