Forráskód Böngészése

update repository photos;
fix sudden Smith chart options reset

ricet8ur 2 éve
szülő
commit
7f5f3f897a

+ 4 - 6
TODO.md

@@ -5,12 +5,12 @@
     * What is Q circle?
     * What data formats are supported?
 2. [x] Demo
-3. Support .snp
+3. [x]Support .snp
     * .s3p and more
 4. [x] Add button to copy choosen fragment to compare with other programs.
 5. [x] Advanced output options (only frontend):
     * Option to choose output values precision
-6. Add approximation for second chart (abs(S) from f)
+6. [x] Add approximation for second chart (abs(S) from f)
 7. [x] Add impedance input option (Z)
     * additional field for omega | from .snp
     * convertion to reflection coeffitient (explanation: <https://radioprog.ru/post/195>)
@@ -23,12 +23,10 @@
     * mp.dps = ~50 or something else.
     * make sure that result' ~ result
     * increase mp.dps while 7 digits after dot are not stable
+    * Don't do it, it is already taking ~3 seconds for 30000 input lines
 10. [x] Advanced file loading:
     * Show file preview
     * Options to skip first and last lines
-11. Advanced file preview: highlight choosen data fragments
+11. [x] Advanced file preview: highlight choosen data fragments
 12. [x] Make charts more interactive
-13. Make an option to pass the whole program to .html site via iframe? - It works, but where to host?
-14. Add support lines for smith chart?
 <!-- Add direct support for output files from different vna models? Supported formats: .snp, .csv or similar -->
-<!-- Do we need to calculate systematic errors? - yes, if its not too hard. After some considerations... Rather not -->

BIN
resource/repository/readme_img1.png


BIN
resource/repository/readme_img2.png


+ 33 - 28
source/frontend/front.py

@@ -11,23 +11,34 @@ from .data_parsing_utils import parse_snp_header, read_data, count_columns, prep
 
 
 def plot_smith(r, i, g, r_cut, i_cut):
-    show_excluded_points = True
-    show_Abs_S_gridlines = False
-    show_Re_Z_gridlines = False
-    show_Im_Z_gridlines = False
-    show_grid = True
+    # maintaining state again (remember options for this session)
+    if 'smith_options' not in st.session_state:
+        st.session_state.smith_options = (True, True, False, False, False)
     with st.expander("Smith chart options"):
-        show_excluded_points = st.checkbox("Show excluded points",
-                                           value=show_excluded_points)
-        show_grid = st.checkbox("Show grid", value=show_grid)
-
-        show_Abs_S_gridlines = st.checkbox("Show |S| gridlines",
-                                       value=show_Abs_S_gridlines)
-        show_Re_Z_gridlines = st.checkbox("Show Re(Z) gridlines",
-                                      value=show_Re_Z_gridlines)
-        show_Im_Z_gridlines = st.checkbox("Show Im(Z) gridlines",
-                                      value=show_Im_Z_gridlines)
 
+        smith_options_input = (st.checkbox(
+            "Show excluded points",
+            value=st.session_state.smith_options[0]),
+                               st.checkbox("Show grid",
+                                           st.session_state.smith_options[1]),
+                               st.checkbox(
+                                   "Show |S| gridlines",
+                                   value=st.session_state.smith_options[2],
+                               ),
+                               st.checkbox(
+                                   "Show Re(Z) gridlines",
+                                   value=st.session_state.smith_options[3],
+                               ),
+                               st.checkbox(
+                                   "Show Im(Z) gridlines",
+                                   value=st.session_state.smith_options[4],
+                               ))
+        if st.session_state.smith_options != smith_options_input:
+            st.session_state.smith_options = smith_options_input
+            st.experimental_rerun()
+
+    (show_excluded_points, show_grid, show_Abs_S_gridlines,
+     show_Re_Z_gridlines, show_Im_Z_gridlines) = st.session_state.smith_options
     fig = plt.figure(figsize=(10, 10))
     ax = fig.add_subplot()
     ax.axis('equal')
@@ -81,23 +92,18 @@ def plot_abs_vs_f(f, r, i, fitted_mag_s):
     fig = plt.figure(figsize=(10, 10))
     s = np.abs(np.array(r) + 1j * np.array(i))
     if st.session_state.legendselection == '|S| (dB)':
-        m = np.min(np.where(s==0, np.inf, s))
-        s = list(20*np.where(s==0, np.log10(m), np.log10(s)))
-        m = np.min(np.where(s==0, np.inf, fitted_mag_s))
-        fitted_mag_s = list(20*np.where(s==0, np.log10(m), np.log10(fitted_mag_s)))
+        m = np.min(np.where(s == 0, np.inf, s))
+        s = list(20 * np.where(s == 0, np.log10(m), np.log10(s)))
+        m = np.min(np.where(s == 0, np.inf, fitted_mag_s))
+        fitted_mag_s = list(
+            20 * np.where(s == 0, np.log10(m), np.log10(fitted_mag_s)))
     s = list(s)
     min_f = min(f)
     max_f = max(f)
-    xlim = [
-        min_f - abs(max_f - min_f) * 0.1,
-        max_f + abs(max_f - min_f) * 0.1
-    ]
+    xlim = [min_f - abs(max_f - min_f) * 0.1, max_f + abs(max_f - min_f) * 0.1]
     min_s = min(s)
     max_s = max(s)
-    ylim = [
-        min_s - abs(max_s - min_s) * 0.5,
-        max_s + abs(max_s - min_s) * 0.5
-    ]
+    ylim = [min_s - abs(max_s - min_s) * 0.5, max_s + abs(max_s - min_s) * 0.5]
     ax = fig.add_subplot()
     ax.set_xlim(xlim)
     ax.set_ylim(ylim)
@@ -366,4 +372,3 @@ def run(calc_function):
             plot_abs_vs_f(f_cut, r_cut, i_cut, fitted_mag_s)
 
         plot_smith(r, i, circle_params, r_cut, i_cut)
-

+ 0 - 0
source/other/article_research/plan.drawio.svg → source/other/article_research/plan(old).drawio.svg