Skip to content

Commit

Permalink
chore: correct use of generalized lorentzian
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Oct 13, 2024
1 parent 5e6622b commit 7a4c39d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
18 changes: 17 additions & 1 deletion src/component/modal/EditPeakShapeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function getKindDefaultValues(kind: Kind) {
return {
kind,
fwhm: 500,
...(kind === 'pseudoVoigt' && { mu: 0.5 }),
...(kind === 'pseudoVoigt'
? { mu: 0.5 }
: kind === 'generalizedLorentzian' && { gamma: 0.5 }),
};
}
function getValues(peak: Peak1D, kind: Kind): Shape {
Expand Down Expand Up @@ -60,6 +62,10 @@ const KINDS: Array<{ label: string; value: Kind }> = [
value: 'pseudoVoigt',
label: 'PseudoVoigt',
},
{
value: 'generalizedLorentzian',
label: 'Generalized Lorentzian',
},
];

const labelStyle: LabelStyle = {
Expand Down Expand Up @@ -147,6 +153,16 @@ function InnerEditPeakShapeModal(props: Required<EditPeakShapeModalProps>) {
<NumberInput2Controller min={0} control={control} name="mu" />
</Label>
)}
{kind === 'generalizedLorentzian' && (
<Label title="Gamma:" style={labelStyle}>
<NumberInput2Controller
min={-1}
max={2}
control={control}
name="gamma"
/>
</Label>
)}
</>
</DialogBody>
<DialogFooter>
Expand Down
6 changes: 6 additions & 0 deletions src/component/panels/PeaksPanel/PeaksPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const formatFields: NucleusPreferenceField[] = [
checkFieldName: 'mu.show',
formatFieldName: 'mu.format',
},
{
id: 11,
label: 'gamma :',
checkFieldName: 'gamma.show',
formatFieldName: 'gamma.format',
},
{
id: 9,
label: 'Delete action :',
Expand Down
17 changes: 17 additions & 0 deletions src/component/panels/PeaksPanel/PeaksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ function PeaksTable({ activeTab, data, info }: PeaksTableProps) {
return '';
},
},
{
showWhen: 'gamma.show',
index: 9,
Header: 'gamma',
accessor: (row) =>
(row?.shape?.kind === 'generalizedLorentzian' && row?.shape?.gamma) ||
'',
Cell: ({ row }) => {
const gamma =
row.original?.shape?.kind === 'generalizedLorentzian' &&
row.original?.shape?.gamma;
if (gamma) {
return formatNumber(gamma, peaksPreferences.gamma.format);
}
return '';
},
},
{
showWhen: 'showEditPeakShapeAction',
...createActionColumn<PeakRecord>({
Expand Down
6 changes: 3 additions & 3 deletions src/component/reducer/actions/PeaksActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function handleAddPeak(draft: Draft<State>, action: AddPeakAction) {
originalX: candidatePeak.x - shiftX,
x: candidatePeak.x,
y: candidatePeak.y,
width: 0.001,
width: 1,
shape: {
kind: 'generalizedLorentzian',
fwhm: 1,
Expand Down Expand Up @@ -123,10 +123,10 @@ function handleAddPeaks(draft: Draft<State>, action: AddPeaksAction) {
originalX: peak.x - shiftX,
x: peak.x,
y: peak.y,
width: 0,
width: 1,
shape: {
kind: 'generalizedLorentzian',
fwhm: 0.001,
fwhm: 1,
gamma: 0.5,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const getPeaksDefaultValues = (
intensity: { show: true, format: '0.00' },
fwhm: { show: true, format: '0.00000' },
mu: { show: false, format: '0.00000' },
gamma: { show: false, format: '0.000' },
showDeleteAction: true,
showEditPeakShapeAction: true,
showKind: true,
Expand Down

0 comments on commit 7a4c39d

Please sign in to comment.