/*NP*/ short temp_to_pix (float temp, float pres) /*************************************************************/ /* TEMP_TO_PIX */ /* John Hart NSSFC KCMO */ /* */ /* Converts given temperature (c) to an X coordinate on */ /* Thermodynamic diagram. */ /* */ /* Depending on (skv.type), relationship is for (1) Pseudo- */ /* Adiabatic or (2) Skew-T/Log P diagram. */ /* */ /* Skew: 90c spread across the bottom of chart. */ /* 120c spread up-and-down the chart. */ /* Temp at BR of chart = 50c */ /*************************************************************/ { float scl1, scl2; if (skv.type == 1) { scl1 = (float) skv.brtemp - ((((float) skv.bry - (float) pres_to_pix (pres)) / ((float) skv.bry - (float) skv.tly)) * (float) skv.vspread); } else { scl1 = (float) skv.brtemp; } scl2 = skv.brx - (((scl1 - temp) / skv.hspread) * (skv.brx - skv.tlx)); return (short) scl2; }
void trace_dwpt2 (short width) /*************************************************************/ /* TRACE_DWPT2 */ /* John Hart NSSFC KCMO */ /* */ /* Plots environmental Dew Point trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0, numlvl2; numlvl2 = sndgp->ovrlev; setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); setlinestyle (1, width); for (i = 0; i < numlvl2; i++) { if (sndgp->ovrl[i].dwpt > -200) { xold = x; yold = y; x = temp_to_pix (sndgp->ovrl[i].dwpt, sndgp->ovrl[i].pres); y = pres_to_pix (sndgp->ovrl[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
void trace_temp (struct sndg_struct *sp, short width) /*************************************************************/ /* TRACE_TEMP */ /* John Hart NSSFC KCMO */ /* */ /* Plots environmental temperature trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0; setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); setlinestyle (1, width); for (i = 0; i < sp->numlev; i++) { if (sp->sndg[i].temp > -200) { xold = x; yold = y; x = temp_to_pix (sndgp->sndg[i].temp, sndgp->sndg[i].pres); y = pres_to_pix (sndgp->sndg[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
void trace_vtmp (short width) /*************************************************************/ /* TRACE_VTMP */ /* John Hart NSSFC KCMO */ /* */ /* Plots virtual temperature trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0; setlinestyle (3, width); for (i = 0; i < sndgp->numlev; i++) { if (qc (sndgp->sndg[i].temp) && qc (sndgp->sndg[i].dwpt)) { xold = x; yold = y; x = temp_to_pix (i_vtmp (sndgp->sndg[i].pres), sndgp->sndg[i].pres); y = pres_to_pix (sndgp->sndg[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
/*NP*/ void plot_barbs (void) /*************************************************************/ /* PLOT_BARBS */ /* John Hart NSSFC KCMO */ /* */ /* Plots wind barbs along side of thermo diagram. */ /*************************************************************/ { short ii, xx, yy; float lastpres; setcliprgn (1, 1, xwdth, xhght, draw_reg, gc); lastpres = 1100; for (ii = 0; ii < sndgp->numlev; ii++) { if (qc (sndgp->sndg[ii].drct)) { yy = pres_to_pix (sndgp->sndg[ii].pres); xx = skv.brx - 40; if ((sndgp->sndg[ii].hght - i_hght (lastpres)) > 400) { wind_barb (sndgp->sndg[ii].drct, sndgp->sndg[ii].sped, xx, yy, 4); lastpres = sndgp->sndg[ii].pres; } } } }
void isobar (float pres, short flag) /*************************************************************/ /* ISOBAR */ /* John Hart NSSFC KCMO */ /* */ /* Draws pressure lines (pres, mb) on SkewT graphic. */ /* */ /* flag = 0 Draw complete horizontal line */ /* = 1 Draw small tick marks along sides of chart */ /*************************************************************/ { short y; char st[10]; setcliprgn (1, 1, xwdth, xhght, draw_reg, gc); y = pres_to_pix (pres); if (flag == 0) { moveto (skv.tlx, y); itoa ((short) pres, st, 10); outgtext (st, skv.tlx - getgtextextent (st) - 2, y - 5); setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); moveto (skv.tlx, y); lineto (skv.brx, y); } else { moveto (skv.tlx, y); lineto (skv.tlx + 5, y); moveto (skv.brx, y); lineto (skv.brx - 5, y); } }
/*NP*/ void trace_parcel (float pres, float temp, float dwpt) /*************************************************************/ /* TRACE_PARCEL */ /* John Hart NSSFC KCMO */ /* */ /* Plots parcel(pres, temp, dwpt) trajectory on SkewT */ /* graphic. */ /* */ /* pres - Pressure of initial parcel(mb) */ /* temp - Temperature of initial parcel (c) */ /* dwpt - Dew Point of initial parcel (c) */ /*************************************************************/ { float i, p2, t2, t3; short x, y; if (!qc (pres) || !qc (temp) || !qc (dwpt)) return; setcolor (31, draw_reg, gc); setlinestyle (4, 1); x = temp_to_pix (virtemp (pres, temp, dwpt), pres); y = pres_to_pix (pres); moveto (x, y); drylift (pres, temp, dwpt, &p2, &t2); x = temp_to_pix (virtemp (p2, t2, t2), p2); y = pres_to_pix (p2); lineto (x, y); for (i = p2 - 50; i >= 100; i = i - 50) { t3 = wetlift (p2, t2, i); x = temp_to_pix (virtemp (i, t3, t3), i); y = pres_to_pix (i); lineto (x, y); } t3 = wetlift (p2, t2, 100); x = temp_to_pix (virtemp (100, t3, t3), 100); y = pres_to_pix (100); lineto (x, y); }
void vvel_profile (void) /*************************************************************/ /* VVEL_PROFILE */ /* John Hart NSSFC KCMO */ /* */ /* Plots vertical velocity profile */ /*************************************************************/ { short i, x1, x2, y, avail, leng; avail = 0; setcliprgn (1, 1, xwdth, xhght, draw_reg, gc); for (i = 0; i < sndgp->numlev; i++) { if (qc (sndgp->sndg[i].omega) && (sndgp->sndg[i].omega < 1)) { avail++; y = pres_to_pix (sndgp->sndg[i].pres); x1 = skv.tlx + 40; leng = (sndgp->sndg[i].omega * 1000); /* Convert to Mbs/sec */ x2 = x1 - (leng * 2); /* Determine screen scale */ setcolor (25, draw_reg, gc); if (sndgp->sndg[i].omega < 0) setcolor (12, draw_reg, gc); moveto (x1, y); lineto (x2, y); } } /* ----- Draw Scales ----- */ if (avail > 5) { setcolor (7, draw_reg, gc); x1 = skv.tlx + 40; moveto (x1, skv.tly + 40); lineto (x1, skv.bry - 10); setlinestyle (3, 1); x1 = skv.tlx + 20; moveto (x1, skv.tly + 40); lineto (x1, skv.bry - 10); x1 = skv.tlx + 60; moveto (x1, skv.tly + 40); lineto (x1, skv.bry - 10); set_font (2); outgtext ("OMEGA", skv.tlx + 18, skv.tlx); outgtext ("+10", skv.tlx + 3, skv.tlx + 15); outgtext ("-10", skv.tlx + 43, skv.tlx + 15); } }
void trace_wetbulb (short width) /*************************************************************/ /* TRACE_WETBULB */ /* John Hart NSSFC KCMO */ /* */ /* Plots environmental Wetbulb trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0; float t1; setlinestyle (1, width); for (i = 0; i < sndgp->numlev; i++) { if (sndgp->sndg[i].dwpt > -200) { xold = x; yold = y; t1 = wetbulb (sndgp->sndg[i].pres, sndgp->sndg[i].temp, sndgp->sndg[i].dwpt); x = temp_to_pix (t1, sndgp->sndg[i].pres); y = pres_to_pix (sndgp->sndg[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
void isobar_nolabel (float pres) /*************************************************************/ /* OPC MODIFICATION - J. Morgan 5/12/05 */ /* ISOBAR_NOLABEL - New function */ /* */ /* ISOBAR_NOLABEL */ /* J. Morgan OPC */ /* */ /* Modification of void isobar() to draw pressure (pres) */ /* without a label on SkewT graphic */ /* */ /* Called by xwvid1.c: draw_skewt() */ /*************************************************************/ { short y; setcliprgn (1, 1, xwdth, xhght, draw_reg, gc); y = pres_to_pix (pres); moveto (skv.tlx, y); setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); moveto (skv.tlx, y); lineto (skv.brx, y); }
void dry_adiabat (float thta) /*************************************************************/ /* DRY_ADIABAT */ /* John Hart NSSFC KCMO */ /* */ /* Draws dry adiabat of theta (thta, c) on SkewT graphic. */ /*************************************************************/ { float pres, temp; short x, y; setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); for (pres = 1050; pres >= 100; pres = pres - 50) { temp = (float) ((((double) thta + 273.15) / pow (1000.0 / (double) pres, ROCP)) - 273.15); x = temp_to_pix (temp, pres); y = pres_to_pix (pres); /* if( pres <= 200) { printf( "%f %f %d\n", pres, temp, x);} */ if (pres == 1050) { moveto (x, y); } else { lineto (x, y); } } }
/*NP*/ void plot_windspeedprofile(void) /*************************************************************/ /* PLOT_WINDSPEEDPROFILE */ /* John Hart SPC Norman */ /* */ /* Plots vertical profile of Wind Speeds */ /*************************************************************/ { float lasthght; float bothgt, tophgt, h, wsp; short x1, y1, x2, y2, i, tlx, tly, wid, hgt; short pIndex, zIndex, wsIndex, wdIndex; char st[10]; pIndex = getParmIndex("PRES"); zIndex = getParmIndex("HGHT"); wsIndex = getParmIndex("SPED"); if (!sndg || pIndex == -1 || zIndex == -1 || wsIndex == -1) return; tlx = skv.brx; tly = skv.tly; wid = 93; hgt = skv.bry - skv.tly; setcliprgn(tlx, tly, tlx+wid, tly+hgt+15); setcolor(0); setlinestyle( 1, 1 ); rectangle(1,tlx, tly, tlx+wid, tly+hgt); setcolor(1); rectangle(0, tlx, tly, tlx+wid, tly+hgt); /* Plot scale */ setlinestyle(2, 1); set_font(5); for (i=20;i<=120;i+=20) { setcolor(8); x1 = tlx + (i/1.5); x2 = x1; y1 = tly + 1; y2 = tly + hgt; moveto(x1, y1); lineto(x2, y2); setcolor(1); sprintf( st, "%d", i); outgtext(st, x1-3, y2+2); } /* ----- Plot Label ----- */ setcolor(1); set_font(5); outgtext("Wind Speed (kt)", tlx+5, tly+3); outgtext("vs Height", tlx+5, tly+15); /* color code to match hodograph layers */ lasthght = 0; setlinestyle(1, 1); for (i=0; i<numlvl; i++) { if ((lasthght >= 0) && (lasthght < 3000)) { if (qc(sndg[i][wsIndex])) { wsp = sndg[i][wsIndex]; x1 = tlx; x2 = tlx + (short)(wsp / 1.5); y2 = pres_to_pix(sndg[i][pIndex]); y1 = y2; setcolor(2); moveto(x1, y1); lineto(x2, y2); lasthght = agl(sndg[i][zIndex]); } } if ((lasthght >= 3000) && (lasthght < 6000)) { if (qc(sndg[i][wsIndex])) { wsp = sndg[i][wsIndex]; x1 = tlx; x2 = tlx + (short)(wsp / 1.5); y2 = pres_to_pix(sndg[i][pIndex]); y1 = y2; setcolor(3); moveto(x1, y1); lineto(x2, y2); lasthght = agl(sndg[i][zIndex]); } } if ((lasthght >= 6000) && (lasthght < 9000)) { if (qc(sndg[i][wsIndex])) { wsp = sndg[i][wsIndex]; x1 = tlx; x2 = tlx + (short)(wsp / 1.5); y2 = pres_to_pix(sndg[i][pIndex]); y1 = y2; setcolor(5); moveto(x1, y1); lineto(x2, y2); lasthght = agl(sndg[i][zIndex]); } } if ((lasthght >= 9000) && (lasthght < 12000)) { if (qc(sndg[i][wsIndex])) { wsp = sndg[i][wsIndex]; x1 = tlx; x2 = tlx + (short)(wsp / 1.5); y2 = pres_to_pix(sndg[i][pIndex]); y1 = y2; setcolor(6); moveto(x1, y1); lineto(x2, y2); lasthght = agl(sndg[i][zIndex]); } } if (lasthght >= 12000) { if (qc(sndg[i][wsIndex])) { wsp = sndg[i][wsIndex]; x1 = tlx; x2 = tlx + (short)(wsp / 1.5); y2 = pres_to_pix(sndg[i][pIndex]); y1 = y2; setcolor(29); moveto(x1, y1); lineto(x2, y2); lasthght = agl(sndg[i][zIndex]); } } } setcliprgn(1, 1, xwdth, xhght); copytodisplay(); }
/*NP*/ void plot_advectionprofile(void) /*************************************************************/ /* PLOT_ADVECTIONPROFILE */ /* John Hart SPC Norman */ /* */ /* Plots vertical profile of Wind Speeds */ /*************************************************************/ { float bothgt, tophgt, h, wsp, advt, ix1, z; short x1, y1, x2, y2, x3, i, tlx, tly, wid, hgt; short pIndex, zIndex, wsIndex, wdIndex; char st[10]; pIndex = getParmIndex("PRES"); zIndex = getParmIndex("HGHT"); wsIndex = getParmIndex("SPED"); if (!sndg || pIndex == -1 || zIndex == -1 || wsIndex == -1) return; tlx = skv.brx + 93; tly = skv.tly; wid = 67; hgt = skv.bry - skv.tly; setcliprgn(tlx, tly, tlx+wid, tly+hgt+15); setcolor(0); setlinestyle( 1, 1 ); rectangle(1,tlx, tly, tlx+wid, tly+hgt); setcolor(1); rectangle(0, tlx, tly, tlx+wid, tly+hgt); /* Draw centerline */ setlinestyle( 2, 1 ); moveto( tlx + (wid/2), tly); lineto(tlx + (wid/2), tly + hgt); set_font(4); setlinestyle( 1, 1 ); for (h=sndg[sfc()][pIndex]; h>=200; h-=100) { advt = advection_layer(&ix1, h, h - 100); /* Draw tick marks x1 = tlx + (wid/2) + 5; x2 = tlx + (wid/2) - 5; y2 = pres_to_pix(h); y1 = pres_to_pix(h - 100); setcolor(1); moveto( x1, y1); lineto(x2, y1); moveto( x1, y2); lineto(x2, y2); */ x1 = tlx + (wid/2); x2 = tlx + (wid/2) + (advt*2.5); y2 = pres_to_pix(h); y1 = pres_to_pix(h - 100); setcolor(1); moveto( x1, y1); lineto(x2, y1); moveto( x1, y2); lineto(x2, y2); setcolor(26); if (advt > 0) setcolor(13); sprintf( st, "%.1f", advt); if(advt > 0) rectangle(0, x1, y1, x2, y2); else rectangle(0, x2, y1, x1, y2); if (advt > 0) { x3 = x2 + 3; if (advt > 2) x3 = x1 + 3; } else { x3 = x2 - getgtextextent(st); if (advt < -2) x3 = x1 - getgtextextent(st); } if (advt > -999) outgtext( st, x3, ((y1+y2)/2)-4); } /* ----- Plot Label ----- */ setcolor(1); set_font(5); outgtext("Inferred", tlx+5, tly+3); outgtext("Temp Advection", tlx+5, tly+13); outgtext("(C / hr)", tlx+5, tly+23); setcliprgn(1, 1, xwdth, xhght); copytodisplay(); }