Skip to content
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

Add skew-T log-p diagrams #75

Merged
merged 22 commits into from
Nov 25, 2024
Merged

Add skew-T log-p diagrams #75

merged 22 commits into from
Nov 25, 2024

Conversation

Peter9192
Copy link
Member

@Peter9192 Peter9192 commented Oct 29, 2024

Porting https://github.com/rsobash/d3-skewt/ to solid.js

TODO:

  • Port example basic structure to solidjs
  • Add example profile
  • Add analysis card for thermodynamic diagram
  • Cycle colors and linestyles like in other plots
  • Generalize skewTData interface
  • Convert CLASS output to skewTData interface
    • Conversion of mixed-layer height to top and bottom pressure
    • Conversion of mixed-layer theta and q to temperature and dew-point temperature
    • Conversion of free troposphere lapse rate of theta and q to temperature and dew-point temperature
    • Conversion of temperature/q jump at top of mixed layer to temperature and dew-point temperature
    • Draw up a profile by calculating p, T, and Td incrementally
  • Add mouseover effect?
    • Highlight pair of lines on hover
    • Label shown using SVG title element (but label could still be improved)
    • Move hovered line to foreground (i.e. move DOM element to end of parent group)
    • Show values? But corresponding to which set of lines?
    • Highlight path nearest to mouse? Requires calculating mouse position to all paths (e.g. d3 voronoi example).
    • Continuation in Add/improve hover effect on plots #82
  • Fix axis label positioning
  • Same font props as other plots
  • Check Td calculation

image

@Peter9192 Peter9192 mentioned this pull request Oct 29, 2024
29 tasks
@Peter9192
Copy link
Member Author

Now with CLASS output, but dewpoint temperature looks a bit off.

image

@Peter9192
Copy link
Member Author

Now looks consistent with other figures:

image

Comment on lines +102 to +158
export function getThermodynamicProfiles(
output: ClassOutput | undefined,
config: PartialConfig,
t = -1,
) {
// Guard against undefined output
if (output === undefined) {
return [];
}

let theta = output.theta.slice(t)[0];
let q = output.q.slice(t)[0];
const dtheta = output.dtheta.slice(t)[0];
const dq = output.dq.slice(t)[0];
const h = output.h.slice(t)[0];
// TODO: ensure config contains gammatheta and gammaq
const gammaTheta = config.mixedLayer?.gammatheta ?? 0.006;
const gammaq = config.mixedLayer?.gammaq ?? 0;

const nz = 25;
let dz = h / nz;
const zArrayMixedLayer = [...Array(nz).keys()].map((i) => i * dz);

let p = 1000; // hPa??
let T = theta;
let Td = dewpoint(q, p);
const soundingData: { p: number; T: number; Td: number }[] = [{ p, T, Td }];

// Mixed layer
for (const z of zArrayMixedLayer) {
p += pressureDiff(T, q, p, dz);
T = thetaToT(theta, p);
Td = dewpoint(q, p);

soundingData.push({ p, T, Td });
}

// Inversion
theta += dtheta;
q += dq;
T = thetaToT(theta, p);
Td = dewpoint(q, p);
soundingData.push({ p, T, Td });

// Free troposphere
dz = 200;
while (p > 100) {
theta += dz * gammaTheta;
q += dz * gammaq;
p += pressureDiff(T, q, p, dz);
T = thetaToT(theta, p);
Td = dewpoint(q, p);

soundingData.push({ p, T, Td });
}

return { y: [], x: [] };
return soundingData;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chiil could you please check these calculations/this approach?

@Peter9192 Peter9192 marked this pull request as ready for review November 25, 2024 14:40
@Peter9192 Peter9192 mentioned this pull request Nov 25, 2024
@Peter9192
Copy link
Member Author

Peter9192 commented Nov 25, 2024

Agreed with Chiel to merge so it is easier for him to test it. Started refactoring and created #87 to continue.

@Peter9192 Peter9192 merged commit ec463bb into main Nov 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant