Skip to content
Snippets Groups Projects

[EPIX][CORR] Optimize histograms and plots

Merged Nuno Duarte requested to merge feat/epix_CorrectionNB_plots into master

Description

Optimization of plots in ePix Correction Notebook, as stated in https://git.xfel.eu/calibration/planning/-/issues/167

How Has This Been Tested?

Run 55 from p003346 (EPIX-1 and EPIX-2).

Relevant Documents (optional)

Comparision between the generated reports before/after this MR, where the histpgrams are optimized and the plots now show meaningfull information:

OLD: MID_EXP_EPIX-1_correct_003346_r55_230330_195859.pdf

NEW:EPIX100CORRECTCalibration_new.pdf

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Specifically:

  • Using np.histogram instead of xcal.HistogramCalculator to calculate histograms
  • Using extra_geom instead of xana.heatmapPlot
  • Dynamic colorbar limits, replacing the fixed ones
  • Added additional plot for cluster corrected data
  • Added meaningfull titles to the plots

Reviewers

@ahmedk

Edited by Nuno Duarte

Merge request reports

Checking pipeline status.

Approval is optional

Merged by Karim AhmedKarim Ahmed 1 year ago (Jul 10, 2023 7:59am UTC)

Merge details

  • Changes merged into master with e6df7b77.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • assigned to @duarten

  • Nuno Duarte added 1 commit

    added 1 commit

    • 9c6e5dfb - improve plots and histograms

    Compare with previous version

  • Nuno Duarte changed the description

    changed the description

  • Nuno Duarte changed title from Draft: [EPIX][CORR] to Draft: [EPIX][CORR] Optimize histograms and plots

    changed title from Draft: [EPIX][CORR] to Draft: [EPIX][CORR] Optimize histograms and plots

  • Nuno Duarte marked this merge request as ready

    marked this merge request as ready

  • Nuno Duarte mentioned in merge request !834 (merged)

    mentioned in merge request !834 (merged)

  • Nuno Duarte added 1 commit

    added 1 commit

    Compare with previous version

  • Author Maintainer

    New commit to solve the same issue as in !834 (merged). Ready for review again

  • Nuno Duarte resolved all threads

    resolved all threads

  • Nuno Duarte added 1 commit

    added 1 commit

    Compare with previous version

  • Karim Ahmed changed milestone to %3.11.0

    changed milestone to %3.11.0

  • LGTM.

    Note for later deployment tests: This MR leads to changing the values for patterns and pixels_classified. The reason is that gain_cnst value is computed differently now

    Edited by Karim Ahmed
  • Hello Nuno, Could you document here the changes fro gain_cnst? It is not mentioned in the MR description and it is important to have the reason for such change documented somewhere as this affects the data values.

  • Karim Ahmed removed milestone %3.11.0

    removed milestone %3.11.0

  • Karim Ahmed changed milestone to %3.11.1

    changed milestone to %3.11.1

  • Karim Ahmed changed milestone to %3.11.0

    changed milestone to %3.11.0

    • Author Maintainer
      Resolved by Karim Ahmed

      Of course.

      It was not mentioned in the description of this MR, but it's mentioned in the comments in the code above the line where gain_cnst is defined:

      # gain constant is given by the mode of the gain map because all bad pixels are masked using this value

      Up until now, we have been calculating gain_cnst by looking the median of the gain map.

      However, the actual gain constant value is calculated in the FF analysis notebook (!750 (merged), which is still not merged to pycalibration), and is not directly outputed, since this NB only injects to the DB the relative gain map after all the processing steps. However, because this map is actually an absolute gain map, and because during its processing the bad pixels are masked with the calculated gain constant, it's value can be found by looking at the bad pixels.

      And this is slightly different from the median value of the map. The difference is not great:

      >>> gain_cnst = np.median(const_data)
      >>> print(f'Old gain constant: {1/gain_cnst:.3f} ADU/keV')
      Old gain constant: 16.079 ADU/keV
      >>>
      >>> _vals,_counts = np.unique(const_data, return_counts=True)
      >>> gain_cnst = _vals[np.argmax(_counts)]
      >>> print(f'New gain constant: {1/gain_cnst:.3f} ADU/keV')
      New gain constant: 16.032 ADU/keV

      But since it is virtually effortless, we should use the most accurate value.

      So I just find the most commom value of the map, which will for sure correspond to the value passed to the bad pixels. In fact, it's the only value that ever repeats:

      >>> np.sort(_counts)
      array([   1,    1,    1, ...,    1,    1, 4596])

      I understand this change is out of the scope of this MR. Should I suggest it in a seperate MR and keep this as was in here?

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading