Skip to content

Commit

Permalink
Added optional frost point trace. Turned off by default, press F to t…
Browse files Browse the repository at this point in the history
…urn on.
  • Loading branch information
a-urq committed Nov 1, 2023
1 parent 1b75520 commit b1ccf3a
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 145 deletions.
Binary file modified bin/com/ameliaWx/soundingViewer/Sounding.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/com/ameliaWx/soundingViewer/SoundingFrame.class
Binary file not shown.
4 changes: 4 additions & 0 deletions bin/com/ameliaWx/soundingViewer/res/controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ <h2>Controls</h2>
<td>E</td>
<td>Toggles whether parcels and convective readouts consider entrainment. Entrainment is an approximation of <a href="https://arxiv.org/pdf/2301.04712.pdf">Peters et. al. 2023</a>, but not exactly what the paper describes.</td>
</tr>
<tr>
<td>F</td>
<td>Toggles whether the frost point trace (dashed line, bluish-green) is shown. Off by default. Computed according to formula in <a href="https://journals.ametsoc.org/view/journals/mwre/116/11/1520-0493_1988_116_2172_tswrpa_2_0_co_2.xml?tab_body=pdf">Huffman and Norman 1988, Appendix B</a>.</td>
</tr>
<tr>
<td>P</td>
<td>Shows a dialog where the user can choose the convective parcel path displayed on the Skew-T diagram.</td>
Expand Down
Binary file modified bin/com/ameliaWx/soundingViewer/unixTool/RadiosondeWrapper.class
Binary file not shown.
20 changes: 20 additions & 0 deletions src/com/ameliaWx/soundingViewer/Sounding.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class Sounding {
private double[] temperature;
private double[] wetbulb;
private double[] dewpoint;
private double[] frostPoint;
private double[] height;
private double[] uWind;
private double[] vWind;
Expand All @@ -19,6 +20,7 @@ public Sounding(double[] pressureLevels, double[] temperature, double[] dewpoint

public Sounding(double[] pressureLevels, double[] temperature, double[] dewpoint, double[] height,
double[] uWind, double[] vWind, double[] wWind) {
// System.out.println("entering constructor");
this.pressureLevels = pressureLevels;
this.temperature = temperature;
this.dewpoint = dewpoint;
Expand All @@ -32,6 +34,13 @@ public Sounding(double[] pressureLevels, double[] temperature, double[] dewpoint
for(int i = 0; i < wetbulb.length; i++) {
wetbulb[i] = WeatherUtils.wetBulbTemperature(temperature[i], dewpoint[i], pressureLevels[i]);
}

frostPoint = new double[dewpoint.length];

for(int i = 0; i < frostPoint.length; i++) {
frostPoint[i] = WeatherUtils.frostPointFromDewpoint(dewpoint[i]);
// System.out.println("assigning frost points");
}
}

public Sounding(float[] pressureLevels, float[] temperature, float[] dewpoint, float[] height,
Expand All @@ -54,6 +63,13 @@ public Sounding(float[] pressureLevels, float[] temperature, float[] dewpoint, f
for(int i = 0; i < wetbulb.length; i++) {
wetbulb[i] = WeatherUtils.wetBulbTemperature(temperature[i], dewpoint[i], pressureLevels[i]);
}

frostPoint = new double[dewpoint.length];

for(int i = 0; i < frostPoint.length; i++) {
frostPoint[i] = WeatherUtils.frostPointFromDewpoint(dewpoint[i]);
// System.out.println("assigning frost points");
}
}

private double[] convFloatToDouble(float[] arr) {
Expand Down Expand Up @@ -82,6 +98,10 @@ public double[] getDewpoint() {
return dewpoint;
}

public double[] getFrostPoint() {
return frostPoint;
}

public double[] getHeight() {
return height;
}
Expand Down
23 changes: 22 additions & 1 deletion src/com/ameliaWx/soundingViewer/SoundingFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
import com.ameliaWx.weatherUtils.WeatherUtils;

public class SoundingFrame extends JFrame {
// IMPLEMENT WHENEVER YOU HAVE TIME
private void outputAsCM1Sounding() {
// MAKE GUI DIRECTORY SELECTOR
}

private static final long serialVersionUID = 396540838404275479L;

public static String dataFolder = System.getProperty("user.home") + "/Documents/SoundingViewer/data/";
Expand All @@ -68,6 +73,7 @@ public class SoundingFrame extends JFrame {
private ParcelPath pathType = ParcelPath.INFLOW_LAYER;

private boolean showEntrainment = false;
private boolean showFrostPoint = false;

private boolean parcelPathVisible = true;
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -889,7 +895,7 @@ private BufferedImage drawSoundingChart(int width, int height) {
g.setFont(normalFont);
}

drawCenteredString(timeString(time), g, (int) ((1750 * scale * (i + 1)) / 4), (int) (25 * scale));
drawCenteredString(timeString(time), g, (int) ((1850 * scale * (i + 1)) / 4), (int) (25 * scale));
}
}

Expand All @@ -913,6 +919,7 @@ private BufferedImage drawSkewT(double scale, ParcelPath pathType) {
double[] temperature = activeSounding.getTemperature();
double[] wetbulb = activeSounding.getWetbulb();
double[] dewpoint = activeSounding.getDewpoint();
double[] frostPoint = activeSounding.getFrostPoint();

double[] virtTemp = new double[dewpoint.length];

Expand Down Expand Up @@ -1095,6 +1102,16 @@ private BufferedImage drawSkewT(double scale, ParcelPath pathType) {
g.drawLine((int) ((x1W + skew1) * scale), (int) (y1 * scale), (int) ((x2W + skew2) * scale),
(int) (y2 * scale));

if(showFrostPoint) {
g.setStroke(thickStroke);
g.setColor(new Color(0, 196, 128));
double x1F = linScale(223.15, 323.15, 0, 800, frostPoint[i]);
double x2F = linScale(223.15, 323.15, 0, 800, frostPoint[i + 1]);

drawDashedLine(g, (int) ((x1F + skew1) * scale), (int) (y1 * scale), (int) ((x2F + skew2) * scale),
(int) (y2 * scale), 10);
}

g.setStroke(thickStroke);
g.setColor(new Color(0, 255, 0));
double x1D = linScale(223.15, 323.15, 0, 800, dewpoint[i]);
Expand Down Expand Up @@ -2729,6 +2746,10 @@ public void keyPressed(KeyEvent e) {
showEntrainment = !showEntrainment;
sg.repaint();
break;
case KeyEvent.VK_F:
showFrostPoint = !showFrostPoint;
sg.repaint();
break;
case KeyEvent.VK_P:
selectParcelPathType();
sg.repaint();
Expand Down
4 changes: 4 additions & 0 deletions src/com/ameliaWx/soundingViewer/res/controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ <h2>Controls</h2>
<td>E</td>
<td>Toggles whether parcels and convective readouts consider entrainment. Entrainment is an approximation of <a href="https://arxiv.org/pdf/2301.04712.pdf">Peters et. al. 2023</a>, but not exactly what the paper describes.</td>
</tr>
<tr>
<td>F</td>
<td>Toggles whether the frost point trace (dashed line, bluish-green) is shown. Off by default. Computed according to formula in <a href="https://journals.ametsoc.org/view/journals/mwre/116/11/1520-0493_1988_116_2172_tswrpa_2_0_co_2.xml?tab_body=pdf">Huffman and Norman 1988, Appendix B</a>.</td>
</tr>
<tr>
<td>P</td>
<td>Shows a dialog where the user can choose the convective parcel path displayed on the Skew-T diagram.</td>
Expand Down
Loading

0 comments on commit b1ccf3a

Please sign in to comment.