prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  IRIS SJI maps call undefined header in self.wavelength
  ### Describe the bug
  
  When creating SJI maps by feeding data and header separately into a Map() and then doing a plot, this causes an error because it calls an undefined header.
  
  ### To Reproduce
  
  import glob
  from [astropy.io](http://astropy.io/) import fits
  from [sunpy.map](http://sunpy.map/) import Map
  
  data_file = glob.glob('IRIS/*_SJI_2832_*fits')
  data_file.sort()
  
  hdul = [fits.open](http://fits.open/)(data_file[0])
      
  header = hdul[0].header
  data = hdul[0].data
  
  Map(data[0], header).plot()
  
  ### What happened?
  
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  /tmp/ipykernel_73554/1651218312.py in <module>
        7 data = hdul[0].data
        8 
  ----> 9 Map(data[0], header).plot()
  
  ~/SunEnvironment/lib64/python3.8/site-packages/astropy/units/decorators.py in wrapper(*func_args, **func_kwargs)
      251             # Call the original function with any equivalencies in force.
      252             with add_enabled_equivalencies(self.equivalencies):
  --> 253                 return_ = wrapped_function(*func_args, **func_kwargs)
      254 
      255             valid_empty = (inspect.Signature.empty, None)
  
  ~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in plot(self, annotate, axes, title, autoalign, clip_interval, **imshow_kwargs)
     2406             plot_settings_title = plot_settings.pop('title')
     2407         else:
  -> 2408             plot_settings_title = self.latex_name
     2409 
     2410         # Anything left in plot_settings is given to imshow
  
  ~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in latex_name(self)
      735     def latex_name(self):
      736         """LaTeX formatted description of the Map."""
  --> 737         if isinstance(self.measurement, u.Quantity):
      738             return self._base_name().format(measurement=self.measurement._repr_latex_())
      739         else:
  
  ~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in measurement(self)
      898         defaults to dimensionless units.
      899         """
  --> 900         return self.wavelength
      901 
      902     @property
  
  ~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/sources/iris.py in wavelength(self)
       61         Taken from WAVELNTH, or if not present TWAVE1.
       62         """
  ---> 63         return header.get('wavelnth', header.get('twave1')) * self.waveunit
       64 
       65     @classmethod
  
  NameError: name 'header' is not defined
  
  
  ### Expected behavior
  
  _No response_
  
  ### Screenshots
  
  ![image](https://user-images.githubusercontent.com/62298880/158391132-38d632bf-7ef4-41ba-b0c0-639a6da7a026.png)
  
  
  ### System Details
  
  sunpy.__version__ : 3.1.3
  astropy.__version__: 4.3.1
  
  ### Installation method
  
  pip
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sunpy/map/sources/iris.py`
  Content:
  ```
  1 
  2 import astropy.units as u
  3 
  4 from sunpy.map.mapbase import GenericMap, SpatialPair
  5 
  6 __all__ = ['SJIMap']
  7 
  8 
  9 class SJIMap(GenericMap):
  10     """
  11     A 2D IRIS Slit Jaw Imager Map.
  12 
  13     The Interface Region Imaging Spectrograph (IRIS) small explorer spacecraft
  14     provides simultaneous spectra and images of the photosphere, chromosphere,
  15     transition region, and corona with 0.33 to 0.4 arcsec spatial resolution,
  16     2-second temporal resolution and 1 km/s velocity resolution over a
  17     field-of- view of up to 175 arcsec by 175 arcsec.  IRIS consists of a 19-cm
  18     UV telescope that feeds a slit-based dual-bandpass imaging spectrograph.
  19 
  20     Slit-jaw images in four different passbands (C ii 1330, Si iv 1400,
  21     Mg ii k 2796 and Mg ii wing 2830  A) can be taken simultaneously with
  22     spectral rasters that sample regions up to 130 arcsec by 175 arcsec at a
  23     variety of spatial samplings (from 0.33 arcsec and up).
  24     IRIS is sensitive to emission from plasma at temperatures between
  25     5000 K and 10 MK.
  26 
  27     IRIS was launched into a Sun-synchronous orbit on 27 June 2013.
  28 
  29     .. warning::
  30 
  31         This object can only handle level 1 SJI files.
  32 
  33     References
  34     ----------
  35     * `IRIS Mission Page <https://iris.lmsal.com>`_
  36     * `IRIS Analysis Guide <https://iris.lmsal.com/itn26/itn26.pdf>`_
  37     * `IRIS Instrument Paper <https://doi.org/10.1007/s11207-014-0485-y>`_
  38     """
  39     @property
  40     def detector(self):
  41         return "SJI"
  42 
  43     @property
  44     def spatial_units(self):
  45         """
  46         If not present in CUNIT{1,2} keywords, defaults to arcsec.
  47         """
  48         return SpatialPair(u.Unit(self.meta.get('cunit1', 'arcsec')),
  49                            u.Unit(self.meta.get('cunit2', 'arcsec')))
  50 
  51     @property
  52     def waveunit(self):
  53         """
  54         Taken from WAVEUNIT, or if not present defaults to Angstrom.
  55         """
  56         return u.Unit(header.get('waveunit', "Angstrom"))
  57 
  58     @property
  59     def wavelength(self):
  60         """
  61         Taken from WAVELNTH, or if not present TWAVE1.
  62         """
  63         return header.get('wavelnth', header.get('twave1')) * self.waveunit
  64 
  65     @classmethod
  66     def is_datasource_for(cls, data, header, **kwargs):
  67         """Determines if header corresponds to an IRIS SJI image"""
  68         tele = str(header.get('TELESCOP', '')).startswith('IRIS')
  69         obs = str(header.get('INSTRUME', '')).startswith('SJI')
  70         level = header.get('lvl_num') == 1
  71         return tele and obs
  72
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sunpy/map/sources/iris.py b/sunpy/map/sources/iris.py
  --- a/sunpy/map/sources/iris.py
  +++ b/sunpy/map/sources/iris.py
  @@ -26,10 +26,6 @@
   
       IRIS was launched into a Sun-synchronous orbit on 27 June 2013.
   
  -    .. warning::
  -
  -        This object can only handle level 1 SJI files.
  -
       References
       ----------
       * `IRIS Mission Page <https://iris.lmsal.com>`_
  @@ -53,19 +49,27 @@
           """
           Taken from WAVEUNIT, or if not present defaults to Angstrom.
           """
  -        return u.Unit(header.get('waveunit', "Angstrom"))
  +        return u.Unit(self.meta.get('waveunit', "Angstrom"))
   
       @property
       def wavelength(self):
           """
           Taken from WAVELNTH, or if not present TWAVE1.
           """
  -        return header.get('wavelnth', header.get('twave1')) * self.waveunit
  +        return self.meta.get('wavelnth', self.meta.get('twave1')) * self.waveunit
  +
  +    @property
  +    def unit(self):
  +        unit_str = self.meta.get('bunit', None)
  +        if unit_str is None:
  +            return
  +        # Remove "corrected" so that the unit can be parsed
  +        unit_str = unit_str.lower().replace('corrected', '').strip()
  +        return self._parse_fits_unit(unit_str)
   
       @classmethod
       def is_datasource_for(cls, data, header, **kwargs):
           """Determines if header corresponds to an IRIS SJI image"""
           tele = str(header.get('TELESCOP', '')).startswith('IRIS')
           obs = str(header.get('INSTRUME', '')).startswith('SJI')
  -        level = header.get('lvl_num') == 1
           return tele and obs
  
verification_info: {"golden_diff": "diff --git a/sunpy/map/sources/iris.py b/sunpy/map/sources/iris.py\n--- a/sunpy/map/sources/iris.py\n+++ b/sunpy/map/sources/iris.py\n@@ -26,10 +26,6 @@\n \n     IRIS was launched into a Sun-synchronous orbit on 27 June 2013.\n \n-    .. warning::\n-\n-        This object can only handle level 1 SJI files.\n-\n     References\n     ----------\n     * `IRIS Mission Page <https://iris.lmsal.com>`_\n@@ -53,19 +49,27 @@\n         \"\"\"\n         Taken from WAVEUNIT, or if not present defaults to Angstrom.\n         \"\"\"\n-        return u.Unit(header.get('waveunit', \"Angstrom\"))\n+        return u.Unit(self.meta.get('waveunit', \"Angstrom\"))\n \n     @property\n     def wavelength(self):\n         \"\"\"\n         Taken from WAVELNTH, or if not present TWAVE1.\n         \"\"\"\n-        return header.get('wavelnth', header.get('twave1')) * self.waveunit\n+        return self.meta.get('wavelnth', self.meta.get('twave1')) * self.waveunit\n+\n+    @property\n+    def unit(self):\n+        unit_str = self.meta.get('bunit', None)\n+        if unit_str is None:\n+            return\n+        # Remove \"corrected\" so that the unit can be parsed\n+        unit_str = unit_str.lower().replace('corrected', '').strip()\n+        return self._parse_fits_unit(unit_str)\n \n     @classmethod\n     def is_datasource_for(cls, data, header, **kwargs):\n         \"\"\"Determines if header corresponds to an IRIS SJI image\"\"\"\n         tele = str(header.get('TELESCOP', '')).startswith('IRIS')\n         obs = str(header.get('INSTRUME', '')).startswith('SJI')\n-        level = header.get('lvl_num') == 1\n         return tele and obs\n", "issue": "IRIS SJI maps call undefined header in self.wavelength\n### Describe the bug\n\nWhen creating SJI maps by feeding data and header separately into a Map() and then doing a plot, this causes an error because it calls an undefined header.\n\n### To Reproduce\n\nimport glob\r\nfrom [astropy.io](http://astropy.io/) import fits\r\nfrom [sunpy.map](http://sunpy.map/) import Map\r\n\r\ndata_file = glob.glob('IRIS/*_SJI_2832_*fits')\r\ndata_file.sort()\r\n\r\nhdul = [fits.open](http://fits.open/)(data_file[0])\r\n    \r\nheader = hdul[0].header\r\ndata = hdul[0].data\r\n\r\nMap(data[0], header).plot()\n\n### What happened?\n\n---------------------------------------------------------------------------\r\nNameError                                 Traceback (most recent call last)\r\n/tmp/ipykernel_73554/1651218312.py in <module>\r\n      7 data = hdul[0].data\r\n      8 \r\n----> 9 Map(data[0], header).plot()\r\n\r\n~/SunEnvironment/lib64/python3.8/site-packages/astropy/units/decorators.py in wrapper(*func_args, **func_kwargs)\r\n    251             # Call the original function with any equivalencies in force.\r\n    252             with add_enabled_equivalencies(self.equivalencies):\r\n--> 253                 return_ = wrapped_function(*func_args, **func_kwargs)\r\n    254 \r\n    255             valid_empty = (inspect.Signature.empty, None)\r\n\r\n~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in plot(self, annotate, axes, title, autoalign, clip_interval, **imshow_kwargs)\r\n   2406             plot_settings_title = plot_settings.pop('title')\r\n   2407         else:\r\n-> 2408             plot_settings_title = self.latex_name\r\n   2409 \r\n   2410         # Anything left in plot_settings is given to imshow\r\n\r\n~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in latex_name(self)\r\n    735     def latex_name(self):\r\n    736         \"\"\"LaTeX formatted description of the Map.\"\"\"\r\n--> 737         if isinstance(self.measurement, u.Quantity):\r\n    738             return self._base_name().format(measurement=self.measurement._repr_latex_())\r\n    739         else:\r\n\r\n~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/mapbase.py in measurement(self)\r\n    898         defaults to dimensionless units.\r\n    899         \"\"\"\r\n--> 900         return self.wavelength\r\n    901 \r\n    902     @property\r\n\r\n~/SunEnvironment/lib64/python3.8/site-packages/sunpy/map/sources/iris.py in wavelength(self)\r\n     61         Taken from WAVELNTH, or if not present TWAVE1.\r\n     62         \"\"\"\r\n---> 63         return header.get('wavelnth', header.get('twave1')) * self.waveunit\r\n     64 \r\n     65     @classmethod\r\n\r\nNameError: name 'header' is not defined\r\n\n\n### Expected behavior\n\n_No response_\n\n### Screenshots\n\n![image](https://user-images.githubusercontent.com/62298880/158391132-38d632bf-7ef4-41ba-b0c0-639a6da7a026.png)\r\n\n\n### System Details\n\nsunpy.__version__ : 3.1.3\r\nastropy.__version__: 4.3.1\n\n### Installation method\n\npip\n", "before_files": [{"content": "\nimport astropy.units as u\n\nfrom sunpy.map.mapbase import GenericMap, SpatialPair\n\n__all__ = ['SJIMap']\n\n\nclass SJIMap(GenericMap):\n    \"\"\"\n    A 2D IRIS Slit Jaw Imager Map.\n\n    The Interface Region Imaging Spectrograph (IRIS) small explorer spacecraft\n    provides simultaneous spectra and images of the photosphere, chromosphere,\n    transition region, and corona with 0.33 to 0.4 arcsec spatial resolution,\n    2-second temporal resolution and 1 km/s velocity resolution over a\n    field-of- view of up to 175 arcsec by 175 arcsec.  IRIS consists of a 19-cm\n    UV telescope that feeds a slit-based dual-bandpass imaging spectrograph.\n\n    Slit-jaw images in four different passbands (C ii 1330, Si iv 1400,\n    Mg ii k 2796 and Mg ii wing 2830  A) can be taken simultaneously with\n    spectral rasters that sample regions up to 130 arcsec by 175 arcsec at a\n    variety of spatial samplings (from 0.33 arcsec and up).\n    IRIS is sensitive to emission from plasma at temperatures between\n    5000 K and 10 MK.\n\n    IRIS was launched into a Sun-synchronous orbit on 27 June 2013.\n\n    .. warning::\n\n        This object can only handle level 1 SJI files.\n\n    References\n    ----------\n    * `IRIS Mission Page <https://iris.lmsal.com>`_\n    * `IRIS Analysis Guide <https://iris.lmsal.com/itn26/itn26.pdf>`_\n    * `IRIS Instrument Paper <https://doi.org/10.1007/s11207-014-0485-y>`_\n    \"\"\"\n    @property\n    def detector(self):\n        return \"SJI\"\n\n    @property\n    def spatial_units(self):\n        \"\"\"\n        If not present in CUNIT{1,2} keywords, defaults to arcsec.\n        \"\"\"\n        return SpatialPair(u.Unit(self.meta.get('cunit1', 'arcsec')),\n                           u.Unit(self.meta.get('cunit2', 'arcsec')))\n\n    @property\n    def waveunit(self):\n        \"\"\"\n        Taken from WAVEUNIT, or if not present defaults to Angstrom.\n        \"\"\"\n        return u.Unit(header.get('waveunit', \"Angstrom\"))\n\n    @property\n    def wavelength(self):\n        \"\"\"\n        Taken from WAVELNTH, or if not present TWAVE1.\n        \"\"\"\n        return header.get('wavelnth', header.get('twave1')) * self.waveunit\n\n    @classmethod\n    def is_datasource_for(cls, data, header, **kwargs):\n        \"\"\"Determines if header corresponds to an IRIS SJI image\"\"\"\n        tele = str(header.get('TELESCOP', '')).startswith('IRIS')\n        obs = str(header.get('INSTRUME', '')).startswith('SJI')\n        level = header.get('lvl_num') == 1\n        return tele and obs\n", "path": "sunpy/map/sources/iris.py"}], "after_files": [{"content": "\nimport astropy.units as u\n\nfrom sunpy.map.mapbase import GenericMap, SpatialPair\n\n__all__ = ['SJIMap']\n\n\nclass SJIMap(GenericMap):\n    \"\"\"\n    A 2D IRIS Slit Jaw Imager Map.\n\n    The Interface Region Imaging Spectrograph (IRIS) small explorer spacecraft\n    provides simultaneous spectra and images of the photosphere, chromosphere,\n    transition region, and corona with 0.33 to 0.4 arcsec spatial resolution,\n    2-second temporal resolution and 1 km/s velocity resolution over a\n    field-of- view of up to 175 arcsec by 175 arcsec.  IRIS consists of a 19-cm\n    UV telescope that feeds a slit-based dual-bandpass imaging spectrograph.\n\n    Slit-jaw images in four different passbands (C ii 1330, Si iv 1400,\n    Mg ii k 2796 and Mg ii wing 2830  A) can be taken simultaneously with\n    spectral rasters that sample regions up to 130 arcsec by 175 arcsec at a\n    variety of spatial samplings (from 0.33 arcsec and up).\n    IRIS is sensitive to emission from plasma at temperatures between\n    5000 K and 10 MK.\n\n    IRIS was launched into a Sun-synchronous orbit on 27 June 2013.\n\n    References\n    ----------\n    * `IRIS Mission Page <https://iris.lmsal.com>`_\n    * `IRIS Analysis Guide <https://iris.lmsal.com/itn26/itn26.pdf>`_\n    * `IRIS Instrument Paper <https://doi.org/10.1007/s11207-014-0485-y>`_\n    \"\"\"\n    @property\n    def detector(self):\n        return \"SJI\"\n\n    @property\n    def spatial_units(self):\n        \"\"\"\n        If not present in CUNIT{1,2} keywords, defaults to arcsec.\n        \"\"\"\n        return SpatialPair(u.Unit(self.meta.get('cunit1', 'arcsec')),\n                           u.Unit(self.meta.get('cunit2', 'arcsec')))\n\n    @property\n    def waveunit(self):\n        \"\"\"\n        Taken from WAVEUNIT, or if not present defaults to Angstrom.\n        \"\"\"\n        return u.Unit(self.meta.get('waveunit', \"Angstrom\"))\n\n    @property\n    def wavelength(self):\n        \"\"\"\n        Taken from WAVELNTH, or if not present TWAVE1.\n        \"\"\"\n        return self.meta.get('wavelnth', self.meta.get('twave1')) * self.waveunit\n\n    @property\n    def unit(self):\n        unit_str = self.meta.get('bunit', None)\n        if unit_str is None:\n            return\n        # Remove \"corrected\" so that the unit can be parsed\n        unit_str = unit_str.lower().replace('corrected', '').strip()\n        return self._parse_fits_unit(unit_str)\n\n    @classmethod\n    def is_datasource_for(cls, data, header, **kwargs):\n        \"\"\"Determines if header corresponds to an IRIS SJI image\"\"\"\n        tele = str(header.get('TELESCOP', '')).startswith('IRIS')\n        obs = str(header.get('INSTRUME', '')).startswith('SJI')\n        return tele and obs\n", "path": "sunpy/map/sources/iris.py"}]}