@@ -585,7 +585,44 @@ def pi(SSTC,MSL,P,TC,R,CKCD=0.9,ascent_flag=0,diss_flag=1,V_reduc=0.8,ptop=50,mi
585
585
# if the CAPE function tripped a flag, set the output IFL to it
586
586
if (IFLAG != 1 ):
587
587
IFL = int (IFLAG )
588
+
589
+ CAPEM , CAPEMS , RAT , TVAV , IFL , TO , OTL = pmin_loop (SSTK ,MSL ,P ,T ,R ,CAPEA ,ES0 ,NK ,CKCD ,ascent_flag ,diss_flag ,ptop ,miss_handle )
590
+ #
591
+ # *** If the routine does not converge, set IFL=0 and return missing PI ***
592
+ #
593
+ if IFL == 0 :
594
+ VMAX = np .nan
595
+ PMIN = np .nan
596
+ IFL = 0
597
+ TO = np .nan
598
+ OTL = np .nan
599
+ return (VMAX ,PMIN ,IFL ,TO ,OTL )
600
+
601
+ # Once converged, set potential intensity at the radius of maximum winds
602
+ CATFAC = 0.5 * (1. + 1 / constants .b )
603
+ CAT = (CAPEM - CAPEA )+ CKCD * RAT * CATFAC * (CAPEMS - CAPEM )
604
+ CAT = max ([CAT ,0.0 ])
588
605
606
+ # Calculate the minimum pressure at the eye of the storm
607
+ # BE02 EQN. 4
608
+ PMIN = MSL * np .exp (- CAT / (constants .RD * TVAV ))
609
+
610
+ # Calculate the potential intensity at the radius of maximum winds
611
+ # BE02 EQN. 3, reduced by some fraction (default 20%) to account for the reduction
612
+ # of 10-m winds from gradient wind speeds (Emanuel 2000, Powell 1980)
613
+ FAC = max ([0.0 ,(CAPEMS - CAPEM )])
614
+ VMAX = V_reduc * np .sqrt (CKCD * RAT * FAC )
615
+
616
+ # Return the calculated outputs to the above program level
617
+ return (VMAX ,PMIN ,IFL ,TO ,OTL )
618
+
619
+
620
+ @njit ()
621
+ def pmin_loop (SSTK ,MSL ,P ,T ,R ,CAPEA ,ES0 ,NK ,CKCD = 0.9 ,ascent_flag = 0 ,diss_flag = 1 ,ptop = 50 ,miss_handle = 1 ):
622
+ """
623
+ Calculate quantities associated with the minimum pressure at the eye of the storm
624
+ """
625
+
589
626
#
590
627
# *** Begin iteration to find mimimum pressure ***
591
628
#
@@ -660,31 +697,9 @@ def pi(SSTC,MSL,P,TC,R,CKCD=0.9,ascent_flag=0,diss_flag=1,V_reduc=0.8,ptop=50,mi
660
697
# increase iteration count in the loop
661
698
NP += 1
662
699
663
- #
664
- # *** If the routine does not converge, set IFL=0 and return missing PI ***
665
- #
700
+ # if the routine does not converge, set IFL=0 and return nan
666
701
if (NP > 200 ) or (PM < 400 ):
667
- VMAX = np .nan
668
- PMIN = np .nan
669
702
IFL = 0
670
- TO = np .nan
671
- OTL = np .nan
672
- return (VMAX ,PMIN ,IFL ,TO ,OTL )
673
-
674
- # Once converged, set potential intensity at the radius of maximum winds
675
- CATFAC = 0.5 * (1. + 1 / constants .b )
676
- CAT = (CAPEM - CAPEA )+ CKCD * RAT * CATFAC * (CAPEMS - CAPEM )
677
- CAT = max ([CAT ,0.0 ])
678
-
679
- # Calculate the minimum pressure at the eye of the storm
680
- # BE02 EQN. 4
681
- PMIN = MSL * np .exp (- CAT / (constants .RD * TVAV ))
682
-
683
- # Calculate the potential intensity at the radius of maximum winds
684
- # BE02 EQN. 3, reduced by some fraction (default 20%) to account for the reduction
685
- # of 10-m winds from gradient wind speeds (Emanuel 2000, Powell 1980)
686
- FAC = max ([0.0 ,(CAPEMS - CAPEM )])
687
- VMAX = V_reduc * np .sqrt (CKCD * RAT * FAC )
688
-
689
- # Return the calculated outputs to the above program level
690
- return (VMAX ,PMIN ,IFL ,TO ,OTL )
703
+ return (np .nan , np .nan , np .nan , np .nan , IFL , np .nan , np .nan )
704
+
705
+ return CAPEM , CAPEMS , RAT , TVAV , IFL , TO , OTL
0 commit comments