-
Notifications
You must be signed in to change notification settings - Fork 29
Support scaling_factor and offset for axis #1944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,13 +19,14 @@ import { | |
| findTitleDataset, | ||
| getDatasetInfo, | ||
| getDefaultSlice, | ||
| getScalingInfo, | ||
| getSilxStyle, | ||
| } from './utils'; | ||
|
|
||
| export const useDefaultSlice = createMemo(getDefaultSlice); | ||
|
|
||
| export function useNxData(group: GroupWithChildren): NxData { | ||
| const { attrValuesStore } = useDataContext(); | ||
| const { attrValuesStore, valuesStore } = useDataContext(); | ||
|
|
||
| assertNxDataGroup(group, attrValuesStore); | ||
| const signalDataset = findSignalDataset(group, attrValuesStore); | ||
|
|
@@ -46,7 +47,10 @@ export function useNxData(group: GroupWithChildren): NxData { | |
| })), | ||
| axisDefs: axisDatasets.map( | ||
| (dataset) => | ||
| dataset && { dataset, ...getDatasetInfo(dataset, attrValuesStore) }, | ||
| dataset && { | ||
| dataset, | ||
| ...getAxisDef(group, dataset, attrValuesStore, valuesStore), | ||
| }, | ||
|
Comment on lines
+50
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe time to make a |
||
| ), | ||
| defaultSlice: useDefaultSlice(group, signalDataset.shape, attrValuesStore), | ||
| silxStyle: getSilxStyle(group, attrValuesStore), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,11 @@ export interface DatasetInfo { | |
| unit: string | undefined; | ||
| } | ||
|
|
||
| export interface ScalingInfo { | ||
| scalingFactor: number | undefined; | ||
| offset: number | undefined; | ||
| } | ||
|
|
||
| export interface DatasetDef< | ||
| T extends NumericLikeType | ComplexType = NumericLikeType | ComplexType, | ||
| > extends DatasetInfo { | ||
|
|
@@ -38,7 +43,7 @@ type WithError<T extends DatasetDef> = T & { | |
| errorDataset?: Dataset<ArrayShape, NumericType>; | ||
| }; | ||
|
|
||
| export type AxisDef = DatasetDef<NumericType>; | ||
| export type AxisDef = DatasetDef<NumericType> & ScalingInfo; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about: interface AxisDef extends DatasetDef<NumericType> {
scalingFactor: number | undefined;
offset: number | undefined;
}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, makes sense if we replace |
||
|
|
||
| export type DefaultSlice = (number | '.')[]; | ||
| export interface SilxStyle { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I'm just realising that the NeXus spec says this should be: 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oopsie-daisy ! Thanks for checking 😹