@@ -559,22 +559,34 @@ def __init__(self, classid="0", components=None, comments=None):
559559 self .components = components
560560 self .comments = comments
561561
562- @staticmethod
563- def from_grid (grid , type = None , typequote = '"' , ** kwargs ):
562+ @classmethod
563+ def from_grid (cls , grid , type = None , typequote = '"' , ** kwargs ):
564564 """Create OpenDX field from Grid.
565565
566566 Parameters
567567 ----------
568568 grid : Grid
569+ Grid object to convert
569570 type : str, optional
571+ for DX, set the output DX array type, e.g., "double" or "float".
572+ By default (``None``), the DX type is determined from the numpy
573+ dtype of the array of the grid (and this will typically result in
574+ "double").
570575 typequote : str, optional
576+ For DX, set the character used to quote the type string;
577+ by default this is a double-quote character, '"'.
578+ Custom parsers like the one from NAMD-GridForces (backend for MDFF)
579+ expect no quotes, and typequote='' may be used to appease them.
571580 **kwargs
572581 Additional keyword arguments (currently unused)
573582
574583 Returns
575584 -------
576585 field
577586 OpenDX field wrapper
587+
588+
589+ .. versionadded:: 1.2.0
578590 """
579591 comments = [
580592 "OpenDX density file written by gridDataFormats.Grid.export()" ,
@@ -594,12 +606,18 @@ def from_grid(grid, type=None, typequote='"', **kwargs):
594606 connections = gridconnections (2 , grid .grid .shape ),
595607 data = array (3 , grid .grid , type = type , typequote = typequote ),
596608 )
597- dx_field = field ("density" , components = components , comments = comments )
609+ dx_field = cls ("density" , components = components , comments = comments )
598610 return dx_field
599611
600612 @property
601613 def native (self ):
602- """Return native object"""
614+ """Return native object
615+
616+ The "native" object is the :class:gridData.OpenDX.field itself.
617+
618+
619+ .. versionadded:: 1.2.0
620+ """
603621 return self
604622
605623 def _openfile_writing (self , filename ):
0 commit comments