From ae64e5dc7a47ee24ac34e959ba6068f0182d2ba7 Mon Sep 17 00:00:00 2001 From: Arashhs Date: Fri, 20 Oct 2023 21:17:58 -0700 Subject: [PATCH] removed unnecessary prints --- stream_sim.py | 1 + user.db | Bin 12288 -> 12288 bytes viz.py | 103 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 64 insertions(+), 40 deletions(-) diff --git a/stream_sim.py b/stream_sim.py index 9c6d504..622970d 100644 --- a/stream_sim.py +++ b/stream_sim.py @@ -289,6 +289,7 @@ def fetch_sensor_data(): data_loader = init_dataloader(inited=data_loader_inited,db_name=db_name) data_loader_inited = True df_dict = data_loader.get_next() + print(df_dict) res = {} for key, rows in df_dict.items(): rows_with_strftime = rows.copy() diff --git a/user.db b/user.db index 8390b35dfbc6a3e7f31674ee0fb8a635f9895e7b..4e3d1169cb31aa54625d23e4f1d2300d61fc26b1 100644 GIT binary patch delta 102 zcmZojXh@hKEvUr6z`zW|Fu*%e$Cy!RV?vnx!~ixMCq`CrA064ml-$fbF-^}MJC+2@ zxjplQ%+4_3pf^*zly`+yOU5T0wDV#8@aLs%fW+MXz0>=aYsIxU>)+n|L!Ltb0ATzg A2><{9 delta 105 zcmZojXh@hKEhxvpz`zW|Fu*-g$Cy!WV?vm`lP_4ziIG*@M@Kd>B{wtgR@m pd.DataFrame: df_coords = pd.DataFrame(data['coordinates']) df_coords['value'] = df_coords['value'].apply(lambda x: wkb.loads(bytes.fromhex(x))) df_coords = gpd.GeoDataFrame(df_coords, geometry='value') - print(df_coords) # df_hrate['timestamp'] = pd.to_datetime(df_hrate['timestamp']) # df_calories['timestamp'] = pd.to_datetime(df_calories['timestamp']) # df_coords['timestamp'] = pd.to_datetime(df_coords['timestamp']) @@ -128,7 +127,6 @@ def get_data(session=None, real_time=False) -> pd.DataFrame: df_calories.sort_values(by=['timestamp'], inplace=True) # query coordinates df_coords = gpd.read_postgis(f"SELECT * FROM {DB_COORDINATES_TABLE} WHERE Date(timestamp) >= Date(%s) AND Date(timestamp) <= Date(%s)", db_conn, params=[start_date, end_date], geom_col='value') - print(df_coords) df_coords.sort_values(by=['timestamp'], inplace=True) df_hrate['timestamp'] = pd.to_datetime(df_hrate['timestamp']) @@ -319,6 +317,7 @@ def input_page(garmin_df): # preparing data user_ids = garmin_df.subj_id.tolist() rank_options = garmin_df['rank'].unique().tolist() + state_of_residence_options = garmin_df['state'].unique().tolist() drop_type_options = garmin_df['drop_type'].unique().tolist() weight_min, weight_max = int(garmin_df.weight.min()), int(garmin_df.weight.max()) height_min, height_max = int(garmin_df.height.min()), int(garmin_df.height.max()) @@ -341,22 +340,33 @@ def input_page(garmin_df): selected_rank = [] selected_drop_type = [] + selected_state_of_residence = [] + selected_state_of_residence_control = [] selected_weight_range = [] selected_height_range = [] selected_age_range = [] if subject_selection_type == 'attribute': st.subheader("Select Subject(s) Attributes") - col1, col2, col3, col4, col5 = st.columns(spec=[1, 3, 3, 3, 1], gap='large') + col1, col2, col3, col4 = st.columns(spec=[2, 3, 3, 3], gap='large') + # col1, col2, col3, col4, col5 = st.columns(spec=[1, 3, 3, 3, 1], gap='large') # add radio selector for gender - selected_rank = col1.multiselect( - "Select military rank", - options=rank_options, - key='subject rank', - # index=session.get('selected_rank', 0) - default=session.get('selected_rank', []) + # selected_rank = col1.multiselect( + # "Select military rank", + # options=rank_options, + # key='subject rank', + # # index=session.get('selected_rank', 0) + # default=session.get('selected_rank', []) + # ) + # selected_rank = selected_rank if selected_rank else rank_options + + selected_state_of_residence = col1.multiselect( + "Select state of residence", + options=state_of_residence_options, + key='subject state of residence', + default=session.get('selected_state_of_residence', []) ) - selected_rank = selected_rank if selected_rank else rank_options + selected_state_of_residence = selected_state_of_residence if selected_state_of_residence else state_of_residence_options # add sliders for weight, height, age selected_age_range = col2.slider( @@ -384,13 +394,13 @@ def input_page(garmin_df): step=1, key='subject height') - selected_drop_type = col5.multiselect( - "Select drop type", - options=drop_type_options, - key='drop type', - default=session.get('selected_drop_type', []) - ) - selected_drop_type = selected_drop_type if selected_drop_type else drop_type_options + # selected_drop_type = col5.multiselect( + # "Select drop type", + # options=drop_type_options, + # key='drop type', + # default=session.get('selected_drop_type', []) + # ) + # selected_drop_type = selected_drop_type if selected_drop_type else drop_type_options # Selecting the control group @@ -410,6 +420,7 @@ def input_page(garmin_df): ) selected_rank_control = [] + selected_state_of_residence_control = [] selected_drop_type_control = [] selected_weight_range_control = [] selected_height_range_control = [] @@ -417,16 +428,24 @@ def input_page(garmin_df): if control_selection_type == 'attribute': st.subheader("Select Control Group Attributes") - col1, col2, col3, col4, col5 = st.columns(spec=[1, 3, 3, 3, 1], gap='large') + col1, col2, col3, col4 = st.columns(spec=[2, 3, 3, 3], gap='large') + # col1, col2, col3, col4, col5 = st.columns(spec=[1, 3, 3, 3, 1], gap='large') # add radio selector for gender - selected_rank_control = col1.multiselect( - "Select military rank", - options=rank_options, - key='control military rank', - # index=session.get('selected_rank_control', 0) - default=session.get('selected_rank_control', []) + # selected_rank_control = col1.multiselect( + # "Select military rank", + # options=rank_options, + # key='control military rank', + # # index=session.get('selected_rank_control', 0) + # default=session.get('selected_rank_control', []) + # ) + # selected_rank_control = selected_rank_control if selected_rank_control else rank_options + selected_state_of_residence_control = col1.multiselect( + "Select state of residence", + options=state_of_residence_options, + key='control state of residence', + default=session.get('selected_state_of_residence_control', []) ) - selected_rank_control = selected_rank_control if selected_rank_control else rank_options + selected_state_of_residence_control = selected_state_of_residence_control if selected_state_of_residence_control else state_of_residence_options # add sliders for weight, height, age selected_age_range_control = col2.slider( @@ -453,14 +472,14 @@ def input_page(garmin_df): step=1, key='control height') - selected_drop_type_control = col5.multiselect( - "Select drop type", - options=drop_type_options, - key='control drop type', - # index=session.get('selected_rank_control', 0) - default=session.get('selected_drop_type_control', []) - ) - selected_drop_type_control = selected_drop_type_control if selected_drop_type_control else drop_type_options + # selected_drop_type_control = col5.multiselect( + # "Select drop type", + # options=drop_type_options, + # key='control drop type', + # # index=session.get('selected_rank_control', 0) + # default=session.get('selected_drop_type_control', []) + # ) + # selected_drop_type_control = selected_drop_type_control if selected_drop_type_control else drop_type_options st.header("Visualization/Analysis Configuration") @@ -522,7 +541,7 @@ def input_page(garmin_df): if real_time_update: window_size = st.number_input('Window Size (seconds)', value=session.get("window_size", DEFAULT_WINDOW_SIZE), step=15) - TIMEOUT = st.number_input('Fast Forward (Every 1 Minute Equals How Many Seconds?)', value=session.get('timeout', float(TIMEOUT)), step=float(1), format="%.1f", min_value=0.1, max_value=float(100)) + TIMEOUT = st.number_input('Fast Forward (Every 1 Hour Equals How Many Seconds?)', value=session.get('timeout', float(TIMEOUT)), step=float(1), format="%.1f", min_value=0.1, max_value=float(100)) @@ -545,10 +564,12 @@ def input_page(garmin_df): session["real_time_update"] = real_time_update session['subject_selection_type'] = 0 if subject_selection_type == 'id' else 1 session['control_selection_type'] = 0 if control_selection_type == 'all' else 1 if control_selection_type == 'id' else 2 - session['selected_rank'] = selected_rank - session['selected_rank_control'] = selected_rank_control - session['selected_drop_type'] = selected_drop_type - session['selected_drop_type_control'] = selected_drop_type_control + # session['selected_rank'] = selected_rank + # session['selected_rank_control'] = selected_rank_control + session['selected_state_of_residence'] = selected_state_of_residence + session['selected_state_of_residence_control'] = selected_state_of_residence_control + # session['selected_drop_type'] = selected_drop_type + # session['selected_drop_type_control'] = selected_drop_type_control session['selected_age_range'] = selected_age_range session['selected_age_range_control'] = selected_age_range_control session['selected_weight_range'] = selected_weight_range @@ -564,7 +585,8 @@ def input_page(garmin_df): if subject_selection_type == 'id': subjects_df = garmin_df.query('subj_id in @selected_users') else: - subjects_df = garmin_df.query('rank == @selected_rank and drop_type == @selected_drop_type and weight >= @selected_weight_range[0] and weight <= @selected_weight_range[1] and height >= @selected_height_range[0] and height <= @selected_height_range[1] and age >= @selected_age_range[0] and age <= @selected_age_range[1]') + # subjects_df = garmin_df.query('rank == @selected_rank and drop_type == @selected_drop_type and weight >= @selected_weight_range[0] and weight <= @selected_weight_range[1] and height >= @selected_height_range[0] and height <= @selected_height_range[1] and age >= @selected_age_range[0] and age <= @selected_age_range[1]') + subjects_df = garmin_df.query('state in @selected_state_of_residence and weight >= @selected_weight_range[0] and weight <= @selected_weight_range[1] and height >= @selected_height_range[0] and height <= @selected_height_range[1] and age >= @selected_age_range[0] and age <= @selected_age_range[1]') # Filter the dataframe based on the selected criteria for control group if control_selection_type == 'all': @@ -572,7 +594,8 @@ def input_page(garmin_df): elif control_selection_type == 'id': control_df = garmin_df.query('user_id in @selected_users_control') else: - control_df = garmin_df.query('rank == @selected_rank_control and drop_type == @selected_drop_type_control and weight >= @selected_weight_range_control[0] and weight <= @selected_weight_range_control[1] and height >= @selected_height_range_control[0] and height <= @selected_height_range_control[1] and age >= @selected_age_range_control[0] and age <= @selected_age_range_control[1]') + # control_df = garmin_df.query('rank == @selected_rank_control and drop_type == @selected_drop_type_control and weight >= @selected_weight_range_control[0] and weight <= @selected_weight_range_control[1] and height >= @selected_height_range_control[0] and height <= @selected_height_range_control[1] and age >= @selected_age_range_control[0] and age <= @selected_age_range_control[1]') + control_df = garmin_df.query('state in @selected_state_of_residence_control and weight >= @selected_weight_range_control[0] and weight <= @selected_weight_range_control[1] and height >= @selected_height_range_control[0] and height <= @selected_height_range_control[1] and age >= @selected_age_range_control[0] and age <= @selected_age_range_control[1]') # Store the filtered dataframe in session state session['subjects_df'] = subjects_df