8 Commits 7f5f3f897a ... 3e3ab089d3

Author SHA1 Message Date
  ricet8ur 3e3ab089d3 Update requirements.txt 2 years ago
  ricet8ur 2be0e5043e Correct requirements and fix input errors 2 years ago
  ricet8ur dc4f14794f Merge branch 'main' of github.com:ricet8ur/calc-factor-of-vna into docked 2 years ago
  ricet8ur d43158f8a5 correct info 2 years ago
  MikhailPolikarpov 43f69cc13e Merge pull request #23 from ricet8ur/docked 2 years ago
  ricet8ur a840ed3b0b Merge pull request #22 from ricet8ur/todoing 2 years ago
  Egor f9eb70cf18 description redacted 2 years ago
  MikhailPolikarpov 1fa7d278d2 Merge pull request #21 from ricet8ur/docked 2 years ago
4 changed files with 38 additions and 27 deletions
  1. 1 1
      README.md
  2. 1 1
      requirements.txt
  3. 32 24
      source/frontend/front.py
  4. 4 1
      source/frontend/info.md

+ 1 - 1
README.md

@@ -33,7 +33,7 @@ streamlit run source/main.py
 The measurements made by a vector network analyzer (set of frequencies and corresponding network parameters).
 Main supported file format is .snp, but similar formats are accepted too. Noise data is not supported.
 
-* Supported network parameters: S, Z
+* Supported network parameters: reflection coefficient (S), impedance (Z)
 * Supported parameters representations:
 real and imaginary; magnitude and angle; db and angle
 

+ 1 - 1
requirements.txt

@@ -5,4 +5,4 @@ numpy
 
 streamlit_echarts
 streamlit-ace
-sigfig
+sigfig

+ 32 - 24
source/frontend/front.py

@@ -84,7 +84,10 @@ def plot_smith(r, i, g, r_cut, i_cut):
     YLIM = [-1.3, 1.3]
     ax.set_xlim(XLIM)
     ax.set_ylim(YLIM)
-    st.pyplot(fig)
+    try:
+        st.pyplot(fig)
+    except:
+        st.write('Unexpected plot error')
 
 
 # plot abs(S) vs f chart with pyplot
@@ -121,12 +124,12 @@ def plot_abs_vs_f(f, r, i, fitted_mag_s):
 
     ax.plot(f, fitted_mag_s, '-', linewidth=3, color='#FF8400')
 
-    st.pyplot(fig)
-
+    try:
+        st.pyplot(fig)
+    except:
+        st.write('Unexpected plot error')
 
 def run(calc_function):
-
-
     # info
     with st.expander("Info"):
         # streamlit.markdown does not support footnotes
@@ -214,6 +217,8 @@ def run(calc_function):
                                     min_value=1,
                                     max_value=len(data),
                                     value=len(data)))
+                if input_end_line < input_start_line:
+                    input_end_line=input_start_line
                 data = data[input_start_line - 1:input_end_line]
 
             # Ace editor to show choosen data columns and rows
@@ -290,25 +295,28 @@ def run(calc_function):
 
     st.write("Use range slider to choose best suitable data interval")
 
-    # make accessible a specific range of numerical data choosen with interactive plot
-    # line id, line id
-    interval_start, interval_end = plot_interact_abs_from_f(f,r,i)
-
-    f_cut, r_cut, i_cut = [], [], []
-    if validator_status == "data parsed":
-        f_cut, r_cut, i_cut = (x[interval_start:interval_end]
-                               for x in (f, r, i))
-        with st.expander("Selected data interval as .s1p"):
-            st_ace(value="# Hz S RI R 50\n" +
-                   ''.join(f'{f_cut[x]} {r_cut[x]} {i_cut[x]}\n'
-                           for x in range(len(f_cut))),
-                   readonly=True,
-                   auto_update=True,
-                   placeholder="Selection is empty",
-                   height="150px")
-
-        if len(f_cut) < 3:
-            validator_status = "Choosen interval is too small, add more points"
+    if len(f)==0:
+        validator_status = 'data unpacking error: empty data'
+    else:
+        # make accessible a specific range of numerical data choosen with interactive plot
+        # line id, line id
+        interval_start, interval_end = plot_interact_abs_from_f(f,r,i)
+    
+        f_cut, r_cut, i_cut = [], [], []
+        if validator_status == "data parsed":
+            f_cut, r_cut, i_cut = (x[interval_start:interval_end]
+                                   for x in (f, r, i))
+            with st.expander("Selected data interval as .s1p"):
+                st_ace(value="# Hz S RI R 50\n" +
+                       ''.join(f'{f_cut[x]} {r_cut[x]} {i_cut[x]}\n'
+                               for x in range(len(f_cut))),
+                       readonly=True,
+                       auto_update=True,
+                       placeholder="Selection is empty",
+                       height="150px")
+    
+            if len(f_cut) < 3:
+                validator_status = "Choosen interval is too small, add more points"
 
     st.write("Status: " + validator_status)
 

+ 4 - 1
source/frontend/info.md

@@ -41,4 +41,7 @@ Correction for coupling loss is implemented according to [3].
 ##### Alternatives
 
 * http://scikit-rf.org/
-* https://people.engineering.olemiss.edu/darko-kajfez/software/
+* https://people.engineering.olemiss.edu/darko-kajfez/software/
+
+##### Terms of use
+This program comes with ABSOLUTELY NO WARRANTY