Skip to content

Functions for statistical quantities calculation and averaging techniques for gleaner#1

Open
Achu1707 wants to merge 1 commit intoapes-suite:mainfrom
Achu1707:main
Open

Functions for statistical quantities calculation and averaging techniques for gleaner#1
Achu1707 wants to merge 1 commit intoapes-suite:mainfrom
Achu1707:main

Conversation

@Achu1707
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member

@haraldkl haraldkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Achu1707. The interactive parts should be separated from the actual computation itself. Maybe those should even go into an executable of its own.

Comment thread gleaner.py
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does dbname under each table mean?

Comment thread gleaner.py
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', '')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcoded replacement of part of the file name seems dangerous to me, what is the intent?

Comment thread gleaner.py
indv_file = indv_file.replace('_p00000', '')
all_tab_names.append(indv_file)
try:
if os.path.isfile(dbname):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems unnecessary to me, as the sqlite3.connect above should either ensure that the database exists or fail.

Comment thread gleaner.py
Comment on lines +599 to +601
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread gleaner.py
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gleaner.py


################# Simple moving averages and variances calculation and creation of plots #############################
def simple_moving_avg_var_calc(sqlcon, all_tab_names):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interactive parts should be split out of the actual computation routine.

Comment thread gleaner.py
Comment on lines +1936 to +1937
print(f'Plots are stored in the folder: Sma_{table}')
print('-------------------------------------------------------------------------------------------------------')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the logger...

Comment thread gleaner.py
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,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code.

Comment thread gleaner.py


# Use this function for calculation of fourier means and variances
def fourier_mean_var_calc(sqlcon, all_tab_names):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interactive part should be moved out of this function.

Comment thread gleaner.py
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')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the logger for these outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants