Example #1
0
File: XSweep.py Project: xia2/xia2
 def to_dict(self):
   obj = {}
   obj['__id__'] = 'XSweep'
   import inspect
   attributes = inspect.getmembers(self, lambda m:not(inspect.isroutine(m)))
   for a in attributes:
     if a[0] in ('_indexer', '_refiner', '_integrater') and a[1] is not None:
       obj[a[0]] = a[1].to_dict()
     elif a[0] == '_imageset':
       from dxtbx.serialize.imageset import imageset_to_dict
       obj[a[0]] = imageset_to_dict(a[1])
     elif a[0] == '_input_imageset':
       from dxtbx.serialize.imageset import imageset_to_dict
       obj[a[0]] = imageset_to_dict(a[1])
     elif a[0] == '_wavelength':
       # don't serialize this since the parent xwavelength *should* contain
       # the reference to the child xsweep
       continue
     elif a[0] == '_sample':
       # don't serialize this since the parent xsample *should* contain
       # the reference to the child xsweep
       continue
     elif a[0].startswith('__'):
       continue
     else:
       obj[a[0]] = a[1]
   return obj
Example #2
0
    def to_dict(self):
        obj = {}
        obj["__id__"] = "XSweep"

        attributes = inspect.getmembers(self,
                                        lambda m: not (inspect.isroutine(m)))
        for a in attributes:
            if a[0] in ("_indexer", "_refiner",
                        "_integrater") and a[1] is not None:
                obj[a[0]] = a[1].to_dict()
            elif a[0] == "_imageset":
                from dxtbx.serialize.imageset import imageset_to_dict

                obj[a[0]] = imageset_to_dict(a[1])
            elif a[0] == "_input_imageset":
                from dxtbx.serialize.imageset import imageset_to_dict

                obj[a[0]] = imageset_to_dict(a[1])
            elif a[0] == "_wavelength":
                # don't serialize this since the parent xwavelength *should* contain
                # the reference to the child xsweep
                continue
            elif a[0] == "sample":
                # don't serialize this since the parent xsample *should* contain
                # the reference to the child xsweep
                continue
            elif a[0].startswith("__"):
                continue
            else:
                obj[a[0]] = a[1]
        return obj
Example #3
0
def imageset_to_string(obj, compact=False):
  ''' Dump the given object to string.

  Params:
      obj The imageset
      compact Write in compact representation

  Returns:
      The JSON string

  '''
  import json
  import textwrap
  from dxtbx.serialize.imageset import imageset_to_dict

  # Return as a JSON string
  if compact == False:
    string = json.dumps(imageset_to_dict(obj),
      indent=2, ensure_ascii=True)

    # Hack to make more readable
    #string = compact_simple_lists(string)

  else:
    string = json.dumps(imageset_to_dict(obj),
      separators=(',',':'), ensure_ascii=True)

  # Return the string
  return string
Example #4
0
File: Indexer.py Project: xia2/xia2
 def to_dict(self):
   obj = {}
   obj['__id__'] = 'Indexer'
   obj['__module__'] = self.__class__.__module__
   obj['__name__'] = self.__class__.__name__
   import inspect
   attributes = inspect.getmembers(self, lambda m:not(inspect.isroutine(m)))
   for a in attributes:
     if a[0] == '_indxr_helper' and a[1] is not None:
       lattice_cell_dict = {}
       lattice_list = a[1].get_all()
       for l, c in lattice_list:
         lattice_cell_dict[l] = c
       obj[a[0]] = lattice_cell_dict
     elif a[0] == '_indxr_experiment_list' and a[1] is not None:
       obj[a[0]] = a[1].to_dict()
     elif a[0] == '_indxr_imagesets':
       from dxtbx.serialize.imageset import imageset_to_dict
       obj[a[0]] = [imageset_to_dict(imgset) for imgset in a[1]]
     elif a[0] == '_indxr_sweeps':
       # XXX I guess we probably want this?
       continue
     elif (a[0].startswith('_indxr_') or
           a[0].startswith('_fp_')):
       obj[a[0]] = a[1]
   return obj
    def to_dict(self):
        obj = {}
        obj["__id__"] = "Indexer"
        obj["__module__"] = self.__class__.__module__
        obj["__name__"] = self.__class__.__name__

        attributes = inspect.getmembers(self, lambda m: not (inspect.isroutine(m)))
        for a in attributes:
            if a[0] == "_indxr_helper" and a[1] is not None:
                lattice_cell_dict = {}
                lattice_list = a[1].get_all()
                for l, c in lattice_list:
                    lattice_cell_dict[l] = c
                obj[a[0]] = lattice_cell_dict
            elif a[0] == "_indxr_experiment_list" and a[1] is not None:
                obj[a[0]] = a[1].to_dict()
            elif a[0] == "_indxr_imagesets":
                from dxtbx.serialize.imageset import imageset_to_dict

                obj[a[0]] = [imageset_to_dict(imgset) for imgset in a[1]]
            elif a[0] == "_indxr_sweeps":
                # XXX I guess we probably want this?
                continue
            elif a[0].startswith("_indxr_") or a[0].startswith("_fp_"):
                obj[a[0]] = a[1]
        return obj
Example #6
0
def imageset_to_string(obj, compact=False):
    """Dump the given object to string.

    Params:
        obj The imageset
        compact Write in compact representation

    Returns:
        The JSON string

    """
    if compact:
        return json.dumps(
            imageset_to_dict(obj), separators=(",", ":"), ensure_ascii=True
        )
    else:
        return json.dumps(imageset_to_dict(obj), indent=2, ensure_ascii=True)
Example #7
0
 def to_dict(self):
   obj = {}
   obj['__id__'] = 'Integrater'
   obj['__module__'] = self.__class__.__module__
   obj['__name__'] = self.__class__.__name__
   import inspect
   attributes = inspect.getmembers(self, lambda m:not(inspect.isroutine(m)))
   for a in attributes:
     if a[0] in ('_intgr_indexer', '_intgr_refiner') and a[1] is not None:
       obj[a[0]] = a[1].to_dict()
     elif a[0] == '_fp_imageset':
       from dxtbx.serialize.imageset import imageset_to_dict
       obj[a[0]] = imageset_to_dict(a[1])
     elif a[0] == '_intgr_sweep':
       # XXX I guess we probably want this?
       continue
     elif (a[0].startswith('_intgr_') or
           a[0].startswith('_fp_')):
       obj[a[0]] = a[1]
   return obj
Example #8
0
 def to_dict(self):
   obj = {}
   obj['__id__'] = 'Integrater'
   obj['__module__'] = self.__class__.__module__
   obj['__name__'] = self.__class__.__name__
   import inspect
   attributes = inspect.getmembers(self, lambda m:not(inspect.isroutine(m)))
   for a in attributes:
     if a[0] in ('_intgr_indexer', '_intgr_refiner') and a[1] is not None:
       obj[a[0]] = a[1].to_dict()
     elif a[0] == '_fp_imageset':
       from dxtbx.serialize.imageset import imageset_to_dict
       obj[a[0]] = imageset_to_dict(a[1])
     elif a[0] == '_intgr_sweep':
       # XXX I guess we probably want this?
       continue
     elif (a[0].startswith('_intgr_') or
           a[0].startswith('_fp_')):
       obj[a[0]] = a[1]
   return obj
Example #9
0
    def to_dict(self):
        obj = {}
        obj["__id__"] = "Integrater"
        obj["__module__"] = self.__class__.__module__
        obj["__name__"] = self.__class__.__name__

        attributes = inspect.getmembers(self,
                                        lambda m: not inspect.isroutine(m))
        for a in attributes:
            if a[0] in ("_intgr_indexer",
                        "_intgr_refiner") and a[1] is not None:
                obj[a[0]] = a[1].to_dict()
            elif a[0] == "_fp_imageset":
                from dxtbx.serialize.imageset import imageset_to_dict

                obj[a[0]] = imageset_to_dict(a[1])
            elif a[0] == "_intgr_sweep":
                # XXX I guess we probably want this?
                continue
            elif a[0].startswith("_intgr_") or a[0].startswith("_fp_"):
                obj[a[0]] = a[1]
        return obj