Repository: Qiskit/qiskit

Issue:
Pulse results schema
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?
Pulse experiments will return different `memory` data arrays for a given experiment depending on the `meas_level` and `meas_return`. The schemas should be updated to handle this along with terra postprocessing code. Note the arxiv specification version is currently out of date with respect to the internal version of the returned `memory` array shapes that shall be implemented as below.

| `meas_level` | `meas_return`  | external format                                                                                           | internal format                                                                                                                        | implemented |
|--------------|----------------|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|-------------|
| 0            | `single`       | Nested `List` of shape [shots, memory_slots, memory_slot_size, 2]                                         | `np.array` of dtype `np.dtype.complex32`  with shape [shots, memory_slots, memory_slot_size]                                           |     [ ]     |
| 0            | `avg`          | Nested `List` of shape  [memory_slots, memory_slot_size, 2]                                               | `np.array` of dtype `np.dtype.complex32`  with shape [memory_slots, memory_slot_size]                                                  |     [ ]     |
| 1            | `single`       | Nested `List` of shape [shots, memory_slots, 2]                                                           | `np.array` of dtype `np.dtype.complex32`  with shape [shots, memory_slots]                                                             |     [ ]     |
| 1            | `avg`          | Nested `List` of shape [memory_slots, 2]                                                                  | `np.array` of dtype `np.dtype.complex32` with shape [memory_slots]                                                                     |     [ ]     |
| 2            | `memory=True`  | `List` of length `shots` where each element is the little-endian hex measurement for the respective shot. | `np.array` of length `shots` where each element is the register assigned little-endian bitstring measurement  for the respective shot. |     [x]     |
| 2            | `memory=False` | Dictionary of binned counts  identified by string hex of measurement result.                              | Dictionary of binned counts identified by register assigned  bitstring of measurement result.                                          |     [x]     |

 




Discussion:

Resolving patch:
diff --git a/qiskit/result/models.py b/qiskit/result/models.py
--- a/qiskit/result/models.py
+++ b/qiskit/result/models.py
@@ -13,6 +13,7 @@
 from qiskit.validation.fields import Complex, ByType
 from qiskit.validation.fields import Boolean, DateTime, Integer, List, Nested, Raw, String
 from qiskit.validation.validate import PatternProperties
+from qiskit.qobj.utils import MeasReturnType
 
 
 class ExperimentResultDataSchema(BaseSchema):
@@ -44,7 +45,9 @@ class ExperimentResultSchema(BaseSchema):
     # Optional fields.
     status = String()
     seed = Integer()
-    meas_return = String(validate=OneOf(['single', 'avg']))
+    meas_level = Integer(validate=Range(min=0, max=2))
+    meas_return = String(validate=OneOf(choices=(MeasReturnType.AVERAGE,
+                                                 MeasReturnType.SINGLE)))
     header = Nested(ObjSchema)
 
 
@@ -88,11 +91,13 @@ class ExperimentResult(BaseModel):
         shots (int or tuple): the starting and ending shot for this data.
         success (bool): if true, we can trust results for this experiment.
         data (ExperimentResultData): results information.
+        meas_level (int): Measurement result level.
     """
 
-    def __init__(self, shots, success, data, **kwargs):
+    def __init__(self, shots, success, data, meas_level=2, **kwargs):
         self.shots = shots
         self.success = success
         self.data = data
+        self.meas_level = meas_level
 
         super().__init__(**kwargs)


Test patch: