dafekt1ve / d3-skewt-and-indices

A fork of rsobash's d3-skewt. This new version is meant to replace COMET's MetEd Flash resource, Interactive Skew-T Log P diagram.
MIT License
1 stars 2 forks source link

Problems with CAPE calculation and LFC location #2

Open Begio opened 3 years ago

Begio commented 3 years ago

Hello, I'm quite interested in the development of this library and I've found some bugs.

1. CAPE calculation

I've got experience with Mepty and Sharppy libreries. I've verified the CAPE value and it returns a very different value compared to the one from these libraries. Then I looked for the issue and I think I've found the solution:

At the following line:
dt1 = temp_t - tlinetest[0][0][i+1].temp;// pcl temp - obs temp at level above

temp_t refers to temp_t = findTC(thetae_lcl, tlinetest[0][0][i].press); And its value is kept in parcel_temp_array[i]

Then, if we write dt1 = parcel_temp_array[i+1] - tlinetest[0][0][i+1].temp; The value is very close to the one from the rest of python libreries.

2. LFC location

My personal thoughts are that the level free convection (LFC) should be calculated from the equilibrium level (EL) in order to avoid the issue with the inversions at low layers. For this, the following could be added at line 2522:

var p_ob=[], t_ob=[], pcl_t=[]

for (i=start_index; i<tlinetest[0][0].length-1; i++){
    p_ob[i] = tlinetest[0][0][i].press; // Observed Pressure
    t_ob[i] = tlinetest[0][0][i].temp; // Observed Temperature
    pcl_t[i] = findTC(thetae_lcl, p_ob[i]); // Parcel Temperature
}
var k = p_ob.findIndex((element) => element <= 300); //LFC height more than 300 hPa
var j = 0;
for (i=k; i>start_index; i--){ // start from 300 hPa and go down until LCL level. Firts point is LCL , change then j to 1.
    if((t_ob[i] >= pcl_t[i])&&(j==0)){start_index = i; j=1;}
}

I've also found a slight bug when changing sounding in the hodograph. Spots are coloured in black.

I hope this proves helpful for you. Should you have questions about this, please let me know.

Kind regards,

Sergio

dafekt1ve commented 3 years ago

Sergio, I have updated a whole bunch of the code in the codebase with the most recent version of the interactive Skew-T and a similar interactive Tephigram. I may not have fixed your CAPE calculation issue, but did fix some other things around it and would appreciate if you tested it again to see if this is different or not either in Skew-T or Tephigram versions.

This project was meant to bring the Flash version of the Skew-T and Tephigram from meted.ucar.edu up to date with d3. Because of this, we have kept the code the same from one to the other in terms of calculating the LFC from the bottom up in our case. There are a lot of considerations within the LFC calculation that make me wonder which way it is supposed to be calculated. I have examples of soundings where I could say calculating the LFC from the EL downward would be better, but then others where if you calculated them from top down, you would miss an entire section of the sounding below an inversion that was convectively unstable. So I left the calculation as is for now and think there is room for this to grow.

Feel free to test both the Skew-T and Tephigram freely either by making your own local version or by testing it on https://www.meted.ucar.edu/mesoprim/skewtd3/ OR https://www.meted.ucar.edu/mesoprim/tephid3/.

Let me know if you find anything else that you think needs to be modified. Thanks for your interest in this project.

Bryan