Repository: sunpy/sunpy

Issue:
GOES XRS observatory attribute not parsing correctly
### Describe the bug

another GOES/XRS issue ...

For the GOES 13,14, 15, from what I can tell the meta information within the netcdf file does not include the GOES Satellite Number but rather gives 'GOES 1-15 X-ray Irradiance Sensor (XRS)'. The way we are parsing out the `observatory` attribute is just to read this as GOES-15 but this is the same for GOES 13 and 14. 

Hence if you read in the GOES 13 or 14 data the `observatory` attribute will give you `GOES-15`.
This is an issue for the temperature/emission measure calculation (that will very soon be PR'd to sunkit-instruments) needs to know the satellite to use the correct response. 

(not an issue for GOES 16 and 17).

### To Reproduce


```python
>>> goes_15 = ts.TimeSeries("sci_gxrs-l2-irrad_g15_d20190301_v0-0-0.nc")
>>> goes_14 = ts.TimeSeries("sci_gxrs-l2-irrad_g14_d20190301_v0-0-0.nc")


>>> goes_15.observatory
'GOES-15'
>>> goes_14.observatory 
'GOES-15'
```

I think the only way to go around this is to take the satellite number from the file name itself (for GOES 13, 14, 15).




Discussion:
nabobalis: Do we not check for this in our source tests for GOES?
hayesla: so yes there is a test - the issue was that for GOES 13, 14 is said it was GOES-15 and the[ test uses the GOES-15 data](https://github.com/sunpy/sunpy/blob/main/sunpy/timeseries/sources/tests/test_goes.py#L48).
there's also a test for GOES-17. So we could add one, but would need to add another test file
hayesla: actually this also needed to be fixed for the 1minute average data, which I've now also added. I'll get on making a test for this
nabobalis: I think this will need rebasing due to the new GOES test files? 

Patch:
diff --git a/changelog/6451.bugfix.rst b/changelog/6451.bugfix.rst
new file mode 100644
index 000000000..69fed84a0
--- /dev/null
+++ b/changelog/6451.bugfix.rst
@@ -0,0 +1,1 @@
+Fix a bug to parse the GOES "observatory" number in `~.XRSTimeSeries` for GOES 13, 14, 15 and for the 1 minute GOES-R data.
diff --git a/sunpy/data/test/goes_truncated_test_goes13.nc b/sunpy/data/test/sci_gxrs-l2-irrad_g13_d20170901_truncated.nc
similarity index 100%
rename from sunpy/data/test/goes_truncated_test_goes13.nc
rename to sunpy/data/test/sci_gxrs-l2-irrad_g13_d20170901_truncated.nc
diff --git a/sunpy/data/test/goes_truncated_test_goes15.nc b/sunpy/data/test/sci_gxrs-l2-irrad_g15_d20131028_truncated.nc
similarity index 100%
rename from sunpy/data/test/goes_truncated_test_goes15.nc
rename to sunpy/data/test/sci_gxrs-l2-irrad_g15_d20131028_truncated.nc
diff --git a/sunpy/data/test/goes_truncated_test_1m_avg_goes15.nc b/sunpy/data/test/sci_xrsf-l2-avg1m_g15_d20190102_truncated.nc
similarity index 100%
rename from sunpy/data/test/goes_truncated_test_1m_avg_goes15.nc
rename to sunpy/data/test/sci_xrsf-l2-avg1m_g15_d20190102_truncated.nc
diff --git a/sunpy/data/test/goes_truncated_test_1m_avg_goes16.nc b/sunpy/data/test/sci_xrsf-l2-avg1m_g16_d20210101_truncated.nc
similarity index 100%
rename from sunpy/data/test/goes_truncated_test_1m_avg_goes16.nc
rename to sunpy/data/test/sci_xrsf-l2-avg1m_g16_d20210101_truncated.nc
diff --git a/sunpy/data/test/goes_truncated_test_goes17.nc b/sunpy/data/test/sci_xrsf-l2-flx1s_g17_d20201016_truncated.nc
similarity index 100%
rename from sunpy/data/test/goes_truncated_test_goes17.nc
rename to sunpy/data/test/sci_xrsf-l2-flx1s_g17_d20201016_truncated.nc
diff --git a/sunpy/timeseries/sources/goes.py b/sunpy/timeseries/sources/goes.py
index d27653c88..2a1940e9f 100644
--- a/sunpy/timeseries/sources/goes.py
+++ b/sunpy/timeseries/sources/goes.py
@@ -123,12 +123,14 @@ class XRSTimeSeries(GenericTimeSeries):
         pattern_new = ("sci_gxrs-l2-irrad_g{SatelliteNumber:02d}_d{year:4d}{month:2d}{day:2d}_{}.nc")
         pattern_old = ("go{SatelliteNumber:02d}{}{month:2d}{day:2d}.fits")
         pattern_r = ("sci_xrsf-l2-flx1s_g{SatelliteNumber:02d}_d{year:4d}{month:2d}{day:2d}_{}.nc")
+        pattern_1m = ("sci_xrsf-l2-avg1m_g{SatelliteNumber:02d}_d{year:4d}{month:2d}{day:2d}_{}.nc")
         pattern_telescop = ("GOES {SatelliteNumber:02d}")
         # The ordering of where we get the metadata from is important.
         # We alway want to check ID first as that will most likely have the correct information.
         # The other fields are fallback and sometimes have data in them that is "useless".
         id = (
             self.meta.metas[0].get("id", "").strip()
+            or self.meta.metas[0].get("filename_id", "").strip()
             or self.meta.metas[0].get("TELESCOP", "").strip()
             or self.meta.metas[0].get("Instrument", "").strip()
         )
@@ -138,7 +140,7 @@ class XRSTimeSeries(GenericTimeSeries):
         if id is None:
             log.debug("Unable to get a satellite number from 'Instrument', 'TELESCOP' or 'id' ")
             return None
-        for pattern in [pattern_inst, pattern_new, pattern_old, pattern_r, pattern_telescop]:
+        for pattern in [pattern_inst, pattern_new, pattern_old, pattern_r, pattern_1m, pattern_telescop]:
             parsed = parse(pattern, id)
             if parsed is not None:
                 return f"GOES-{parsed['SatelliteNumber']}"
@@ -228,6 +230,8 @@ class XRSTimeSeries(GenericTimeSeries):
         """
         with h5netcdf.File(filepath, mode="r", **XRSTimeSeries._netcdf_read_kw) as h5nc:
             header = MetaDict(OrderedDict(h5nc.attrs))
+            if len(header["id"].strip()) == 0:  # needed to get observatory number if 'id' empty.
+                header.update({"filename_id": Path(filepath).name})
             flux_name = h5nc.variables.get("a_flux") or h5nc.variables.get("xrsa_flux")
             if flux_name is None:
                 raise ValueError(f"No flux data (either a_flux or xrsa_flux) found in file: {filepath}")


Test patch:
diff --git a/sunpy/timeseries/sources/tests/test_goes.py b/sunpy/timeseries/sources/tests/test_goes.py
index 093c5e149..b7f56b98d 100644
--- a/sunpy/timeseries/sources/tests/test_goes.py
+++ b/sunpy/timeseries/sources/tests/test_goes.py
@@ -9,11 +9,11 @@ from sunpy.tests.helpers import figure_test
 from sunpy.util.exceptions import SunpyUserWarning
 
 goes_fits_filepath_com = get_test_filepath('go1520120601.fits.gz')
-goes13_filepath_nc = get_test_filepath('goes_truncated_test_goes13.nc')
-goes15_filepath_nc = get_test_filepath('goes_truncated_test_goes15.nc')
-goes17_filepath_nc = get_test_filepath('goes_truncated_test_goes17.nc')
-goes15_1m_avg_filepath = get_test_filepath('goes_truncated_test_1m_avg_goes15.nc')
-goes16_1m_avg_filepath = get_test_filepath('goes_truncated_test_1m_avg_goes16.nc')
+goes13_filepath_nc = get_test_filepath('sci_gxrs-l2-irrad_g13_d20170901_truncated.nc')
+goes15_filepath_nc = get_test_filepath('sci_gxrs-l2-irrad_g15_d20131028_truncated.nc')
+goes17_filepath_nc = get_test_filepath('sci_xrsf-l2-flx1s_g17_d20201016_truncated.nc')
+goes15_1m_avg_filepath = get_test_filepath('sci_xrsf-l2-avg1m_g15_d20190102_truncated.nc')
+goes16_1m_avg_filepath = get_test_filepath('sci_xrsf-l2-avg1m_g16_d20210101_truncated.nc')
 goes13_leap_second_filepath = get_test_filepath('goes_13_leap_second.nc')
 
 
@@ -37,7 +37,6 @@ def test_implicit_goes(goes_nc_files):
                           (goes17_filepath_nc, 'GOES-17'),
                           (goes15_1m_avg_filepath, 'GOES-15'),
                           (goes16_1m_avg_filepath, 'GOES-16')])
-@pytest.mark.xfail
 def test_implicit_goes_satno(goes_nc_files, sat_no):
     # Test that satellite number is correctly parsed from files
     ts_goes = sunpy.timeseries.TimeSeries(goes_nc_files, source='XRS')