Functions for statistical quantities calculation and averaging techniques for gleaner#1
Functions for statistical quantities calculation and averaging techniques for gleaner#1Achu1707 wants to merge 1 commit intoapes-suite:mainfrom
Conversation
| def tracking_multiple_data_to_db(dbname, input_files): | ||
| """ (string, string or list of strings) | ||
| input_files are ASCII files containing instantaneous velocities which are tracked to the | ||
| database: dbname under each table for each ASCII file. |
There was a problem hiding this comment.
What does dbname under each table mean?
| sqlcon = sqlite3.connect(dbname) | ||
| for file, i in zip(input_files, range(len(input_files))): | ||
| indv_file = Path(file).stem | ||
| indv_file = indv_file.replace('_p00000', '') |
There was a problem hiding this comment.
This hardcoded replacement of part of the file name seems dangerous to me, what is the intent?
| indv_file = indv_file.replace('_p00000', '') | ||
| all_tab_names.append(indv_file) | ||
| try: | ||
| if os.path.isfile(dbname): |
There was a problem hiding this comment.
This check seems unnecessary to me, as the sqlite3.connect above should either ensure that the database exists or fail.
| Read data with 'columns' from 'sqlcon' under the table 'tabname' and | ||
| reduce those columns along 'reduce_coord_column'. Reduced columns are written | ||
| into 'sqlcon' under the table 'tabname'_red. |
There was a problem hiding this comment.
This explanation is hard to understand.
Please explicitly state what the purpose of each argument is. (It isn't quite clear what columns is meant to be here).
| input_files are ASCII files containing instantaneous velocities which are tracked to the | ||
| database: dbname under each table for each ASCII file. | ||
|
|
||
| Returns sqlcon (a sqlite3.Connection) to the database: dbname and all_tab_names |
There was a problem hiding this comment.
The description should point out that this function will drop pre-existing data in the given database and replace it with the new found in the provided files.
|
|
||
|
|
||
| ################# Simple moving averages and variances calculation and creation of plots ############################# | ||
| def simple_moving_avg_var_calc(sqlcon, all_tab_names): |
There was a problem hiding this comment.
Interactive parts should be split out of the actual computation routine.
| print(f'Plots are stored in the folder: Sma_{table}') | ||
| print('-------------------------------------------------------------------------------------------------------') |
| ak_list_W.append(ak_W) | ||
| bk_list_W.append(bk_W) | ||
|
|
||
| # print ak_list_U, bk_list_U, ak_list_V, bk_list_V, ak_list_W, bk_list_W, |
|
|
||
|
|
||
| # Use this function for calculation of fourier means and variances | ||
| def fourier_mean_var_calc(sqlcon, all_tab_names): |
There was a problem hiding this comment.
The interactive part should be moved out of this function.
| data_folder_ind = f"Fourier_{table}" | ||
| if not os.path.exists(f'{data_folder_ind}'): | ||
| os.makedirs(f'{data_folder_ind}') | ||
| print(f'\n{data_folder_ind} folder created') |
There was a problem hiding this comment.
We can use the logger for these outputs.
Hello,
I added the functions for the the calculation of statistical quantities and various averaging techniques in gleaner as these are the part of my Master thesis. I also added the function, spatial reduction from 3D data to 2D data in database. Let me know if there are any mistakes. Merge the changes if everything is right.
Regards
Achuthan