diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py
index 2ee5802ffd80e359f2e3d4ece908252fc48d0820..297cb900c9211c7e46f803c73bb05deeccf446c4 100644
--- a/src/toolbox_scs/detectors/hrixs.py
+++ b/src/toolbox_scs/detectors/hrixs.py
@@ -553,6 +553,55 @@ class hRIXS:
         data['spectrum'] = (("trainId", "energy"), ret)
         return data
 
+    def fit_elastic(self, data, fit_hw=10, plot=False):
+        """Fits elastic line in each spectum found in data. Returns fit params
+        and integrated area of RIXS spectrum.
+
+        data - xarray containing hRIXS data that has already been centroided
+               or integrated
+        fit_hw - half width of the fitting window (in bins) around the elastic
+               line 
+        plot - plot each individual fit 
+        
+        Example
+        -------
+
+            data = h.centroid(data)
+            p, int = h.fit_elastic(data)
+
+        """
+        #if data["spectrum"] == None:
+        #    print("No spectrum found in data structure. "+ 
+        #           "Centroid or integrate images first.")
+        #    return
+
+        if self.ENERGY_SLOPE == None:
+            energy = np.arange(self.Y_RANGE.start, self.Y_RANGE.stop)
+        else:
+            energy = (np.arange(self.Y_RANGE.start, self.Y_RANGE.stop) *
+                      self.ENERGY_SLOPE+self.ENERGY_INTERCEPT)
+
+        
+
+        fit_param = []
+        data_int = []
+        for spec in data["spectrum"].data:
+            x0 = np.argmax(spec)
+            fit_start = x0-fit_hw
+            fit_end = x0+fit_hw
+            fit_result = gaussian_fit(energy[fit_start:fit_end], 
+                                      spec[fit_start:fit_end])
+            fit_param.append(fit_result)
+            data_int.append(np.trapz(spec))
+            if plot:
+                plt.figure()
+                plt.plot(energy, spec)
+                plt.plot(energy, gauss1d(energy, *fit_result))
+
+
+        return np.array(fit_param), data_int
+
+
     aggregators = dict(
         hRIXS_det=lambda x, dim: x.sum(dim=dim),
         Delay=lambda x, dim: x.mean(dim=dim),