# ExternalArrayReference

class `asdf.``ExternalArrayReference`(fileuri, target, dtype, shape)

  Bases: `asdf.types.AsdfType`

  Store a reference to an array in an external File.

  This class is a simple way of referring to an array in another file. It provides no way to resolve these references, that is left to the user. It also performs no checking to see if any of the arguments are correct. e.g. if the file exits.

  Parameters:

  fileuri: `str`

  > The path to the path to be referenced. Can be relative to the file containing the reference.

  target: `object`

  > Some internal target to the data in the file. Examples may include a HDU index, a HDF path or an asdf fragment.

  dtype: `str`

  > The (numpy) dtype of the contained array.

  shape: `tuple`

  > The shape of the array to be loaded.

  Examples

      >>> import asdf
      >>> ref = asdf.ExternalArrayReference("myfitsfile.fits", 1, "float64", (100, 100))
      >>> tree = {'reference': ref}
      >>> with asdf.AsdfFile(tree) as ff:
      ...     ff.write_to("test.asdf")

  Attributes Summary

  `handle_dynamic_subclasses` |
  `has_required_modules` |
  `name` |
  `organization` |
  `requires` |
  `standard` |
  `supported_versions` |
  `types` |
  `validators` |
  `version` |
  `yaml_tag` |

  Methods Summary

  `from_tree`(tree, ctx) | Converts basic types representing YAML trees into custom types.
  `from_tree_tagged`(tree, ctx) | Converts from tagged tree into custom type.
  `incompatible_version`(version) | Indicates if given version is known to be incompatible with this type.
  `make_yaml_tag`(name[, versioned]) | Given the name of a type, returns a string representing its YAML tag.
  `names`() | Returns the name(s) represented by this tag type as a list.
  `subclass`(*args[, attribute]) | Decorator to enable serialization of a subclass of an existing type.
  `subclass_property`(attribute) | Decorator to enable serialization of custom subclass attributes.
  `tag_base`() | Returns the base of the YAML tag for types represented by this class.
  `to_tree`(data, ctx) | Converts instances of custom types into YAML representations.
  `to_tree_tagged`(node, ctx) | Converts instances of custom types into tagged objects.

  Attributes Documentation

  `handle_dynamic_subclasses` = False
  `has_required_modules` = True
  `name` = 'core/externalarray'
  `organization` = 'stsci.edu'
  `requires` = []
  `standard` = 'asdf'
  `supported_versions` = []
  `types` = []
  `validators` = {}
  `version` = AsdfVersion('1.0.0')
  `yaml_tag` = 'tag:stsci.edu:asdf/core/externalarray-1.0.0'

  Methods Documentation

  classmethod `from_tree`(tree, ctx)

    Converts basic types representing YAML trees into custom types.

    This method should be overridden by custom extension classes in order to define how custom types are deserialized from the YAML representation back into their original types. The method will return an instance of the original custom type.

    This method is called as part of the process of reading an ASDF file in order to construct an `AsdfFile` object. Whenever a YAML subtree is encountered that has a tag that corresponds to the `yaml_tag` property of this class, this method will be used to deserialize that tree back into an instance of the original custom type.

    Parameters:

    tree : `object` representing YAML tree

    > An instance of a basic Python type (possibly nested) that corresponds to a YAML subtree.

    ctx : `AsdfFile`

    > An instance of the `AsdfFile` object that is being constructed.

    Returns: | An instance of the custom type represented by this extension class.

  classmethod `from_tree_tagged`(tree, ctx)

    Converts from tagged tree into custom type.

    It is more common for extension classes to override `from_tree` instead of this method. This method should only be overridden if it is necessary to access the `_tag` property of the `Tagged` object directly.

    Parameters:

    tree : `asdf.tagged.Tagged` object representing YAML tree

    ctx : `AsdfFile`

    > An instance of the `AsdfFile` object that is being constructed.

    Returns: | An instance of the custom type represented by this extension class.

  classmethod `incompatible_version`(version)

    Indicates if given version is known to be incompatible with this type.

    If this tag class explicitly identifies compatible versions then this checks whether a given version is compatible or not (see `supported_versions`). Otherwise, all versions are assumed to be compatible.

    Child classes can override this method to affect how version compatiblity for this type is determined.

    Parameters:

    version : `str` or `AsdfVersion`

    > The version to test for compatibility.

  classmethod `make_yaml_tag`(name, versioned=True)

    Given the name of a type, returns a string representing its YAML tag.

    Parameters:

    name : str

    > The name of the type. In most cases this will correspond to the `name` attribute of the tag type. However, it is passed as a parameter since some tag types represent multiple custom types.

    versioned : bool

    > If `True`, the tag will be versioned. Otherwise, a YAML tag without a version will be returned.

    Returns: | `str` representing the YAML tag

  classmethod `names`()

    Returns the name(s) represented by this tag type as a list.

    While some tag types represent only a single custom type, others represent multiple types. In the latter case, the `name` attribute of the extension is actually a list, not simply a string. This method normalizes the value of `name` by returning a list in all cases.

    Returns: | `list` of names represented by this tag type

  classmethod `subclass`(*args, attribute='subclass')

    Decorator to enable serialization of a subclass of an existing type.

    Use this method to decorate subclasses of custom types that are already handled by an existing ASDF tag class. This enables subclasses of known types to be properly serialized without having to write an entirely separate tag class for the subclass.

    This feature can only be used for tagged types where the underlying YAML representation of the type is an object (i.e. a Python `dict`). It will not work for nodes that are basic types.

    The subclass metadata is stored in a new attribute of the YAML node. By default the attribute name is “subclass”, but it is customizable by using the optional `attribute` keyword argument of the decorator.

    The schema of the base custom type is used for validation. This feature will not work if the base schema disallows additional attributes.

    It is incumbent upon the user to avoid name conflicts with attributes that already exist in the representation of the base custom class. For example, a base class may use the attribute “subclass” for some other purpose, in which case it would be necessary to provide a different custom attribute name here.

    Parameters:

    attribute : `str`

    > Custom attribute name used to store subclass metadata in this node.

  classmethod `subclass_property`(attribute)

    Decorator to enable serialization of custom subclass attributes.

    Use this decorator to serialize attributes that are specific to a subclass of a custom type that is already handled by an existing ASDF tag class. This decorator will only work on subclasses that have been decorated with the `subclass` decorator.

    Methods that are decorated in this way are treated as properties (see `property`). The name of the property must correspond to a keyword argument of the subclass constructor.

    The property will be serialized as a YAML object attribute with the same name. Users are responsible for ensuring that any and all additional subclass properties conform to the schema of the base custom type and do not conflict with existing attributes.

  classmethod `tag_base`()

    Returns the base of the YAML tag for types represented by this class.

    This method returns the portion of the tag that represents the standard and the organization of any type represented by this class.

    Returns: | `str` representing the base of the YAML tag

  classmethod `to_tree`(data, ctx)

    Converts instances of custom types into YAML representations.

    This method should be overridden by custom extension classes in order to define how custom types are serialized into YAML. The method must return a single Python object corresponding to one of the basic YAML types (dict, list, str, or number). However, the types can be nested and combined in order to represent more complex custom types.

    This method is called as part of the process of writing an `AsdfFile` object. Whenever a custom type (or a subclass of that type) that is listed in the `types` attribute of this class is encountered, this method will be used to serialize that type.

    The name `to_tree` refers to the act of converting a custom type into part of a YAML object tree.

    Parameters:

    node : `object`

    > Instance of a custom type to be serialized. Will be an instance (or an instance of a subclass) of one of the types listed in the `types` attribute of this class.

    ctx : `AsdfFile`

    > An instance of the `AsdfFile` object that is being written out.

    Returns:

    A basic YAML type (`dict`, `list`, `str`, `int`, `float`, or

    > `complex`) representing the properties of the custom type to be serialized. These types can be nested in order to represent more complex custom types.

  classmethod `to_tree_tagged`(node, ctx)

    Converts instances of custom types into tagged objects.

    It is more common for custom tag types to override `to_tree` instead of this method. This method should only be overridden if it is necessary to modify the YAML tag that will be used to tag this object.

    Parameters:

    node : `object`

    > Instance of a custom type to be serialized. Will be an instance (or an instance of a subclass) of one of the types listed in the `types` attribute of this class.

    ctx : `AsdfFile`

    > An instance of the `AsdfFile` object that is being written out.

    Returns: | An instance of `asdf.tagged.Tagged`.