示例#1
0
/*NP*/
float ptype1( void )
/*************************************************************/
/*  PTYPE1                                                   */
/*  John Hart  NSSFC KCMO                                    */
/*                                                           */
/*  Determines precipitation type using same method as       */
/*  MESOETA model.                                           */
/*                                                           */
/*************************************************************/
{
	short i, IWX;
	float pmid, T[50], P[50], Q[50], PINT[50], LMH;
	float TD[50], TWET[50], LM, PPT;
	short pIndex;

	pIndex = getParmIndex("PRES");

	if (!sndg || pIndex == -1)
	  return RMISSD;

	for (i=0;i<numlvl-1;i++) {
	  pmid = (sndg[i][pIndex] + sndg[i+1][pIndex]) / 2;
	  P[i] = pmid;
	  T[i] = i_temp(pmid, I_PRES);
	  Q[i] = mixratio(pmid, i_dwpt(pmid, I_PRES)); 
	  PINT[i] = sndg[i][pIndex] - sndg[i+1][pIndex];
	}

	LMH = numlvl;


/* Call M.Baldwin FORTRAN routine to actually compute this stuff */
/* CALWXT(T, Q, P, PINT, TD, TWET, LMH, LM, PPT, IWX); */
	printf( "IWX = %d\n", IWX );
}
示例#2
0
float i_vtmp ( float pres )
/*************************************************************/
/*  I_VTMP                                                   */
/*  John Hart  NSSFC KCMO                                    */
/*                                                           */
/*  Calculates the virtual temperature (C) at pressure       */
/*  level (pres).                                            */
/*                                                           */
/*  pres             - Level(mb) to compute a virtual temp.  */
/*************************************************************/
{
	double cta, eps, tk, w;

	if( !qc(i_dwpt( pres )))
	   {
	   if( !qc( i_temp( pres ))) { return -999.0F; }
	   return i_temp( pres );
	   }

	cta = 273.15;
	eps = .62197;

	tk = (double)i_temp(pres) + cta;
	w = .001 * (double) mixratio( pres, i_dwpt(pres));
	return (float)(tk * (1 + w / eps) / (1 + w) - cta);
	}
示例#3
0
float virtemp ( float pres, float temp, float dwpt )
/*************************************************************/
/*  VIRTEMP                                                  */
/*  John Hart  NSSFC KCMO                                    */
/*                                                           */
/*  Calculates the virtual temperature (C) of parcel         */
/*  (pres, temp, dwpt).                                      */
/*                                                           */
/*  pres             - Level(mb) to compute a virtual temp.  */
/*  temp             - Temperature(c).                       */
/*  dwpt             - Dew point(c).                         */
/*************************************************************/
{
	double cta, eps, tk, w;

	if( !qc(dwpt) ) { return temp; }

	cta = 273.15;
	eps = .62197;

	tk = temp + cta;
	w = .001 * mixratio( pres, dwpt);
	return (float)(tk * (1 + w / eps) / (1 + w) - cta);
	}
示例#4
0
/*NP*/
char *init_phase(float *plevel, short *phase)
/*************************************************************/
/*  INIT_PHASE                                               */
/*************************************************************/
{
	short       i, ok, avail;
	short       pIndex, zIndex, tIndex, tdIndex, oIndex;
	float       rh, p1, pbegin, pos, neg, p, w1;
	float       p_pres, p_phase, ptop, pbot;
	static char st[80];
	char        pt[80];

	*plevel = 0;
	*phase = -1;

	pIndex  = getParmIndex("PRES");
	zIndex  = getParmIndex("HGHT");
	tIndex  = getParmIndex("TEMP");
	tdIndex = getParmIndex("DWPT");
	oIndex  = getParmIndex("OMEG");

	if (!sndg || pIndex == -1 || zIndex == -1 || tIndex == -1 || 
	    tdIndex == -1) {
	  strcpy(st, "N/A");
	  return st;
	}

	/* First, determine whether VVELS are available.  If they are,   */
	/* use them to determine level where precipitation will develop. */
	avail=0;
	if (oIndex != -1) {
          for( i = 0; i < numlvl; i++) {
	    if (qc(sndg[i][oIndex]) && (sndg[i][oIndex] < 1)) avail++;
	  }
	}

	if (avail< 5) {
	   /* No VVELS...must look for saturated level */

	   /* ----- Find the highest near-saturated 50mb 
	      layer blo 5km agl ---- */
	   for(i=numlvl-1;i>0;i--) {
	      ok = 0;
	      pbegin = -999;
	      if (agl(sndg[i][zIndex]) < 5000.0) {
		  rh = mixratio(sndg[i][pIndex], sndg[i][tdIndex]) / 
	               mixratio(sndg[i][pIndex], sndg[i][tIndex]);
		  if (rh > 0.8) {
		    p1 = sndg[i][pIndex]+50;
		     if ((mixratio(p1, i_dwpt(p1, I_PRES)) / 
	                 mixratio(p1, i_temp(p1, I_PRES))) > 0.8) {
				ok = 1;
				pbegin = p1-25.0;
				break;
		     }
		}
	      }
	   }
	}
	else {
		/* ----- Find the highest near-saturated layer with UVV in 
	           the lowest 5km ----- */
	        for(i=numlvl-1;i>0;i--) {
			ok=0;
			pbegin=-999;
			if ((agl(sndg[i][zIndex])<5000) && 
	                    (sndg[i][oIndex] <= 0)) {
		  		rh = mixratio(sndg[i][pIndex], 
	                                      sndg[i][tdIndex]) / 
	                             mixratio(sndg[i][pIndex], sndg[i][tIndex]);
		  		if (rh > 0.8) {
					p1 = sndg[i][pIndex]+50;
				if ((mixratio(p1, i_dwpt(p1, I_PRES)) / 
	                             mixratio(p1, i_temp(p1, I_PRES))) > 0.8) {
						ok = 1;
						pbegin = p1-25;
						break;
				}
				}
				}
			}
	      }	

	if (!ok) {
	   *plevel =  0;
	   *phase  = -1;
	   strcpy(st, "N/A");
	   return st;
	}

	p1 = i_temp(pbegin, I_PRES);
	if(p1>0) {p_phase=0; strcpy(pt, "Rain"); }
	if((p1<=0) && (p1 > -5)) {p_phase=1; strcpy(pt, "Freezing Rain"); }
	if((p1<=-5) && (p1 > -9)) {p_phase=1; strcpy(pt, "ZR/S Mix" ); }
	if(p1 <= -9) {p_phase=3; strcpy(pt, "Snow"); }
	*plevel = pbegin;
	*phase = p_phase;
	return pt;
}
示例#5
0
        /* NP */
short ww_type(short *wwtype, short *dcp)
        /********************************************************************/
        /*      Watch type guidance                                         */
        /*      A decision tree to help with ww issuance                    */
        /*                                                                  */
        /*      Rich Thompson SPC OUN                                       */
        /********************************************************************/
        {
        float ix1, ix2, ix3, ix4, lr75, shr6, t500, fzlh, mumixr, lowrh, midrh, low_mid_rh;
        float mucn, mlcn, mlcp, sbcp, mucp, lr1, lr3, shr6_dir, sr46_dir, sr46_spd, shr6_sr46_diff, mmp;
        float sig_tor, sig_tor_winter, sighail, wind_dmg, rm_scp, cbsig, dncp, srh1, sblcl, mllcl;
        float oldlplpres, pres, pbot, ptop, shr8, bot, top, esrh, lm_scp;
        short oldlplchoice, ww_choice;
        short pIndex, tIndex, zIndex, tdIndex;
        short x1, y1, x2, y2, tlx, tly, wid;
        struct _parcel pcl;
        char st[40];

        tlx = hov.tlx + 409;
        tly = hov.bry;
        wid = 119;

        setcliprgn( tlx+2, tly+2, tlx+wid+24, tly+wid+1);
        setcolor(0);
        setlinestyle( 1, 1 );
        rectangle( 1,tlx, tly, tlx+wid+27, tly+wid+1);
        setcolor(1);
        rectangle( 0, tlx, tly, tlx+wid+27, tly+wid+1);
        setlinestyle( 1, 1 );
        moveto( tlx + 2, tly + 18);
	lineto(tlx + wid + 27, tly + 18);


        /* ----- Plot Label ----- */
        set_font(6);
        setcolor(1);
        outgtext( "Psbl Watch Type", tlx + 20, tly + 3 );

	*wwtype = 0;
	*dcp = 0;

        oldlplchoice = lplvals.flag;

        tIndex = getParmIndex("TEMP");
        pIndex = getParmIndex("PRES");
        zIndex = getParmIndex("HGHT");
        tdIndex = getParmIndex("DWPT");

/* 24 Mar 2008 */
/*        effective_inflow_layer(100, -250, &pbot, &ptop);*/

	/* sb parcel */
        define_parcel(1,0);
        ix1 = parcel(-1, -1, lplvals.pres, lplvals.temp, lplvals.dwpt, &pcl);
        sbcp = pcl.bplus;
        sblcl = agl(i_hght(pcl.lclpres, I_PRES));
        sig_tor_winter = sigtorn_fixed(st_dir, st_spd);

	/* ml parcel */
        define_parcel(4,100);
        ix1 = parcel(-1, -1, lplvals.pres, lplvals.temp, lplvals.dwpt, &pcl);
        mlcn = pcl.bminus;
        mlcp = pcl.bplus;
        mllcl = agl(i_hght(pcl.lclpres, I_PRES));
        sig_tor = sigtorn_cin(st_dir, st_spd);

	/* mu parcel */
        define_parcel(3,400);
        mucp = parcel(-1, -1, lplvals.pres, lplvals.temp, lplvals.dwpt, &pcl);
        mucn = pcl.bminus;

	dncp = dcape(&ix1, &ix2);

	/* sighail ingredients */
        lr75 = lapse_rate(&ix1, 700, 500);
        wind_shear(sndg[sfc()][pIndex], i_pres(msl(6000)), &ix1, &ix2, &ix3, &ix4);
        shr6 = ix4;
        shr6_dir = ix3;
        wind_shear(sndg[sfc()][pIndex], i_pres(msl(8000)), &ix1, &ix2, &ix3, &ix4);
	shr8 = ix4;
        mumixr = mixratio(lplvals.pres, lplvals.dwpt);
        t500 =  i_temp(500, I_PRES);
        fzlh = mtof(agl(i_hght(temp_lvl(0, &ix1), I_PRES)));
        sighail = sig_hail(pcl.bplus, mumixr, lr75, t500, kt_to_mps(shr6), fzlh, pcl.bminus, 0, 0, 25, mlcp);

        rm_scp = scp(st_dir, st_spd);
        wind_dmg = damaging_wind();

        sr_wind( i_pres(msl(4000)), i_pres(msl(6000)), st_dir, st_spd, &ix1, &ix2, &ix3, &ix4);
        sr46_dir = ix3;
        sr46_spd = ix4;
        shr6_sr46_diff = (shr6_dir - sr46_dir);
	srh1 = helicity(0, 1000, st_dir, st_spd, &ix1, &ix2);
	bot = agl(i_hght(p_bot, I_PRES));
	top = agl(i_hght(p_top, I_PRES));	
	esrh = helicity(bot, top, st_dir, st_spd, &ix1, &ix2);

        lapse_rate(&ix2, sndg[sfc()][pIndex], i_pres(sndg[sfc()][zIndex]+1000));
        lr1 = ix2;
        lapse_rate(&ix2, sndg[sfc()][pIndex], i_pres(sndg[sfc()][zIndex]+3000));
        lr3 = ix2;

        mean_relhum(&ix1, sndg[sfc()][pIndex]-150, sndg[sfc()][pIndex]-350);
        midrh = ix1;
        mean_relhum(&ix1, sndg[sfc()][pIndex], sndg[sfc()][pIndex]-150);
        lowrh = ix1;
        low_mid_rh = ((lowrh + midrh)/2);
        mmp = coniglio1();
        cbsig = (mlcp * kt_to_mps(shr6));

/* 24 Mar 2008 */
/* all "p_bot" below were changed from "pbot" */

/* Decision tree below is identical to the operational "ww_type" flow chart documentation 9/23/09 RLT */
        if ((sig_tor >= 3.0) && (sig_tor_winter >= 3.0) && (srh1 >= 150) && (esrh >= 150) && (sr46_spd >= 15.0) && (shr8 >= 40.0) && (sblcl < 1000) && (mllcl < 1100) && (lr1 >= 5.0) && (bot == 0.0)) {
		*dcp = 1;
		*wwtype = 5;
                ww_choice = 5;
        	/*printf("\n dcp (in PDS) = %d", *dcp);*/
        	set_font(6);
        	setcolor(7);
        	outgtext( "PDS TOR", tlx + 45, tly + 60 );
                }

/*        else
        if ((sig_tor_winter >= 4.0) && (sr46_spd >= 15.0) && (shr8 >= 40.0) && (sblcl < 1000) && (lr1 >= 5.0) && (bot == 0.0)) {
                *dcp = 2;
                *wwtype = 5;
                ww_choice = 5;
                set_font(6);
                setcolor(7);
                outgtext( "PDS TOR", tlx + 45, tly + 60 );
                }
*/	
        else
        if (((sig_tor >= 3.0) || (sig_tor_winter >= 4.0)) && (bot == 0.0)) {
                *dcp = 3;
                *wwtype = 4;
                ww_choice = 4;
                /*printf("\n dcp (in TOR) = %d", *dcp);*/
                set_font(6);
                setcolor(2);
                outgtext( "TOR", tlx + 45, tly + 60 );
                }
	
        else
        if (((sig_tor >= 1.0) || (sig_tor_winter >= 1.0)) && ((sr46_spd >= 15.0) || (shr8 >= 40.0)) && (bot == 0.0)) {
                *dcp = 4;
                *wwtype = 4;
                ww_choice = 4;
                /*printf("\n dcp (in TOR) = %d", *dcp);*/
                set_font(6);
                setcolor(2);
                outgtext( "TOR", tlx + 45, tly + 60 );
                }

        else
        if (((sig_tor >= 1.0) || (sig_tor_winter >= 1.0)) && (low_mid_rh >= 60) && (lr1 >= 5.0) && (bot == 0.0)) {
                *dcp = 5;
                *wwtype = 4;
                ww_choice = 4;
                /*printf("\n dcp (in TOR) = %d", *dcp);*/
                set_font(6);
                setcolor(2);
                outgtext( "TOR", tlx + 45, tly + 60 );
                }

        else
        if ((( sig_tor >= 1.0) || (sig_tor_winter >= 1.0)) && (bot == 0.0)) {
                *dcp = 6;
                *wwtype = 3;	
                ww_choice = 3; 
                /*printf("\n dcp (in mrgl TOR) = %d", *dcp);*/
	        set_font(6);
                setcolor(2);
                outgtext( "mrgl TOR", tlx + 40, tly + 60 );
                }

        else
        if (((( sig_tor >= 0.5) && (esrh >= 150)) || ((sig_tor_winter >= 0.5) && (srh1 >= 150))) && (bot == 0.0)) {
                *dcp = 7;
                *wwtype = 3;	
                ww_choice = 3;
                /*printf("\n dcp (in mrgl TOR) = %d", *dcp);*/
                set_font(6);
                setcolor(2);
                outgtext( "mrgl TOR", tlx + 40, tly + 60 );
                }

        else
        if ((( sig_tor_winter >= 1.0) || (rm_scp >= 4.0) || (sig_tor >= 1.0)) && (mucn >= -50.0)) {
                *dcp = 8;
                *wwtype = 2;
                ww_choice = 2;
                /*printf("\n dcp (in SVR) = %d", *dcp);*/
	        set_font(6);
                setcolor(6);
                outgtext( "SVR",  tlx + 60, tly + 60 );
                }

        else
        if ((rm_scp >= 2.0) && ((sighail >= 1.0) || (dncp >= 750)) && (mucn >= -50.0)) {
                *dcp = 9;
                *wwtype = 2;
                ww_choice = 2;
                /*printf("\n dcp (in SVR) = %d", *dcp);*/
                set_font(6);
                setcolor(6);
                outgtext( "SVR",  tlx + 60, tly + 60 );
                }

        else
        if ((cbsig >= 30000) && (mmp >= 0.6) && (mucn >= -50.0)) {
                *dcp = 10;
                *wwtype = 2;
                ww_choice = 2;
                /*printf("\n dcp (in SVR) = %d", *dcp);*/
                set_font(6);
                setcolor(6);
                outgtext( "SVR",  tlx + 60, tly + 60 );
                }
        
	else
        if ((mucn >= -75.0) && ((wind_dmg >= 0.5) || (sighail >= 0.5) || (rm_scp >= 0.5)))  {
                *dcp = 11;
                *wwtype = 1;
                ww_choice = 1;
                /*printf("\n dcp (in mrgl SVR) = %d", *dcp);*/
	        set_font(6);
                setcolor(26);
                outgtext( "MRGL SVR",  tlx + 40, tly + 60 );
                }
        else    {
                *dcp = 0;
                /*printf("\n dcp (after logic checks) = %d", *dcp);*/
                *wwtype = 0;
                ww_choice = 0;
		}

        if (*wwtype == 0) {
                set_font(6);
                setcolor(19);
                outgtext( "NONE",  tlx + 50, tly + 60 );
                }
    	//printf("sig_tor=%f sig_tor_winter=%f srh1=%f esrh=%f sr46_spd=%f shr8=%f sblcl=%f\n mllcl=%f lr1=%f bot=%f low_mid_rh=%f rm_scp=%f\n mucn=%f dncp=%f sighail=%f cbsig=%f wind_dmg=%f",
    	//		sig_tor,sig_tor_winter,srh1,esrh,sr46_spd,shr8, sblcl, mllcl, lr1, bot, low_mid_rh, rm_scp,mucn, dncp, sighail, cbsig, wind_dmg);

/*      define_parcel(oldlplchoice, oldlplpres); */
        
        /* set parcel back to user selection */
        if (oldlplchoice == 1)
          pres = 0;
        else if (oldlplchoice == 2)
          pres = 0;
        else if (oldlplchoice == 3)
          pres = mu_layer;
        else if (oldlplchoice == 4)
          pres = mml_layer;
        else if (oldlplchoice == 5)
          pres = user_level;
        else if (oldlplchoice == 6)
          pres = mu_layer;
        define_parcel(oldlplchoice, pres);

        return ww_choice;

        }