Skip to content

Commit

Permalink
small changes to data entry
Browse files Browse the repository at this point in the history
  • Loading branch information
tizayi committed Oct 27, 2023
1 parent 578b365 commit 9d6c9d4
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],

// // Uncomment the next line to run commands after the container is created.
// // "postCreateCommand": "cat /etc/os-release",

// "initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
// "runArgs": [
// "--net=host",
// "--security-opt=label=disable"
// ],
// "mounts": [
// "source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
// "source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind"
// ],
// // make the workspace folder the same inside and outside of the container
// "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
// "workspaceFolder": "${localWorkspaceFolder}"
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dedi-web</title>
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --port 3000",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview --port 3000",
Expand Down
Binary file added public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/data-entry/dataSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function DataSideBar(): JSX.Element {
</Typography>
<Stack direction="row">
<Typography flexGrow={2}>
Pixel size: {pixelSize.height}x{pixelSize.width}{" "}
Pixel size: {pixelSize.height} x {pixelSize.width}{" "}
</Typography>
<FormControl>
<InputLabel>units</InputLabel>
Expand Down
55 changes: 54 additions & 1 deletion src/utils/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export enum AngleUnits {
degrees = "deg",
}

/**
* An interface to keep track of all units in the app
*/
export interface UnitConfig {
pixelSizeUnits: DistanceUnits;
beamEnergyUnits: EnergyUnits;
Expand All @@ -41,7 +44,7 @@ export const PLANCK = 6.62607015e-34;
/**
* Converts energy in kilo elctronvolts to wavelength in nm
* @param energy energy in keV
* @returns wave length in nm
* @returns - wavelength in nm
*/
export const energy2WavelengthConverter = (energy: number): number => {
return metres2nanometres((PLANCK * CSPEED) / (kiloElectronVolt2Joule(energy)));
Expand All @@ -56,42 +59,92 @@ export const wavelength2EnergyConverter = (wavelength: number): number => {
return joule2KiloElectronVolt((PLANCK * CSPEED) / (nanometres2metres(wavelength))) ;
};

/**
* Converts joules to keV
* @param input value in joules
* @returns output in keV
*/
export const joule2KiloElectronVolt = (input: number): number => {
return input/ 1.602e-16
}

/**
* Converts keV to joules
* @param input value in keV
* @returns output in joules
*/
export const kiloElectronVolt2Joule = (input: number): number => {
return input* 1.602e-16
}

/**
* Converts meters into nanometeres
* @param input value in metres
* @returns output in nanometeres
*/
const metres2nanometres = (input: number): number => {
return input *1e9;
}

/**
* Converts nanometres to metres
* @param input value in nanometres
* @returns output in metres
*/
const nanometres2metres = (input: number): number => {
return input *1e-9;
}

/**
* Converts millimetres to micrometres
* @param input value in nillimetres
* @returns output in micrometres
*/
export const millimetre2Micrometre = (input: number): number => {
return 1000 * input;
};

/**
* Converts micrometres to millimetres
* @param input values in micrometres
* @returns output in millimetres
*/
export const micrometre2Milimetre = (input: number): number => {
return input / 1000;
};

/**
* Converts nanometres to Angstroms
* @param input value in nanometres
* @returns output in angstroms
*/
export const nanometres2Angstroms = (input: number): number => {
return input * 10;
};

/**
* Converts angstrom to nm
* @param input value in angstrom
* @returns output in nanometres
*/
export const angstroms2Nanometres = (input: number): number => {
return input / 10;
};

/**
* Converts keV to eV
* @param input value in keV
* @returns output in eV
*/
export const kiloElectronVolts2ElectronVots = (input: number): number => {
return input * 1000;
};

/**
* Converts eV to keV
* @param input value in eV
* @returns output in keV
*/
export const electronVots2KiloElectronVolts = (input: number): number => {
return input / 1000;
};

0 comments on commit 9d6c9d4

Please sign in to comment.