Repository: sunpy/sunpy

Issue:
XRT Maps do not include unit information
XRT maps, from any level (as far as I can tell), do not include a `BUNIT` keyword or any equivalent keyword to encode the unit information.

However, according to Table 1.1 in [the XRT analysis guide](https://xrt.cfa.harvard.edu/resources/documents/XAG/XAG.pdf), the units for the different levels are DN for level 0 and DN/s for level 1. However, there is also a note that level 1 can be DN or DN/s, depending on which options are passed to `xrt_prep`. When level 1 data is divided by the exposure time (to be put in units of DN/s), there is a tag added to the `HISTORY` that indicates that the data have been renormalized. When pulling in the data, the source could check for this tag and set the unit appropriately and otherwise fall back to DN.


Discussion:
I'd like to give this a shot! :cowboy_hat_face: 
Go ahead.
There is a question of whether depending on the `HISTORY` tag when setting a property is a good idea and whether that is reliable or not. I don't think we do that in any of the other map sources. Maybe it is better to have no unit information at all than assert a particular unit with some degree of uncertainty?
n.b. According to Section 2.11 of the XRT analysis guide, the tag added to `HISTORY` starts with "XRT_RENORMALIZE". 
>  Maybe it is better to have no unit information at all than assert a particular unit with some degree of uncertainty?

um this issue should be up for discussion at the moment, right?
> > Maybe it is better to have no unit information at all than assert a particular unit with some degree of uncertainty?
> 
> um this issue should be up for discussion at the moment, right?

I don't think so?
As I said in my previous comment, relying on particular words in the HISTORY key is perhaps questionable. Having no unit information forces the user to figure this out for themselves. ~~Notably, I don't think our test XRT header includes this entry~~. I lied. It does. 
I've been trying to work on this for a while and having a little bit of trouble figuring out how to approach it. My current understanding is that I need to make changes to [`map/sources/hinode.py`](https://github.com/sunpy/sunpy/blob/main/sunpy/map/sources/hinode.py#L51). There's a test XRT file [here](https://github.com/sunpy/sunpy/blob/main/sunpy/data/test/HinodeXRT.header) with the corresponding test [`test_xrt_source.py`](https://github.com/sunpy/sunpy/blob/main/sunpy/map/sources/tests/test_xrt_source.py). I've tried tracing through the code and think the following way to test my changes on the test file should work:
```
import sunpy.data.test
m = sunpy.data.test.get_dummy_map_from_header('HinodeXRT.header')
```

~~but before i debugged through the errors ^this is giving me I guess I just want to know if there was perhaps a much simpler way I could've gone about this / documentation that I might have overlooked...~~ nevermind, I think I got it :+1: 

Resolving patch:
diff --git a/sunpy/map/sources/hinode.py b/sunpy/map/sources/hinode.py
--- a/sunpy/map/sources/hinode.py
+++ b/sunpy/map/sources/hinode.py
@@ -98,6 +98,19 @@ def processing_level(self):
             return
         return int(lvl)
 
+    @property
+    def unit(self):
+        # XRT data values are in DN and are converted into DN/s if the data has been normalized.
+        # A tag starting with "XRT_RENORMALIZE" is added to the HISTORY tag in that case.
+        # See Table 1.1 and Section 2.11 of the XRT Analysis Guide.
+        unit = super().unit
+        if not unit:
+            unit = u.ct
+            history = self.meta.get('HISTORY', '')
+            if "xrt_renormalize" in history.lower():
+                unit = u.ct / u.second
+        return unit
+
     @classmethod
     def is_datasource_for(cls, data, header, **kwargs):
         """Determines if header corresponds to an XRT image"""


Test patch:
diff --git a/sunpy/map/sources/tests/test_xrt_source.py b/sunpy/map/sources/tests/test_xrt_source.py
--- a/sunpy/map/sources/tests/test_xrt_source.py
+++ b/sunpy/map/sources/tests/test_xrt_source.py
@@ -38,6 +38,11 @@ def test_measurement(xrt_map):
     assert xrt_map.measurement == 'Be thin-Open'
 
 
+def test_unit(xrt_map):
+    """Tests the unit property of the XRTMap object."""
+    assert xrt_map.unit == u.ct / u.second
+
+
 def test_level_number(xrt_map):
     assert xrt_map.processing_level == 1