Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F119983088
average.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 1, 01:28
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Jul 3, 01:28 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27121315
Attached To
R8798 MoTUS_analysis
average.py
View Options
# coding: utf-8
# In[1]:
from
py7zr
import
unpack_7zarchive
import
shutil
import
os
import
pandas
as
pd
import
numpy
as
np
from
IPython.core
import
display
as
ICD
import
glob
# In[2]:
time_int
=
'5min'
DATA_FOLDER
=
r'/mnt/motus_raw/'
AVERAGE_RES_FOLDER
=
r'average_data/'
TEMP
=
r'temp_data/'
zip_folders
=
os
.
listdir
(
DATA_FOLDER
)
items_anem
=
np
.
arange
(
4
,
5
)
columns_anem
=
[
1
,
2
,
3
,
6
,
7
]
time_stp_position_anem
=-
1
#Respect to columns_anem
# In[4]:
#computing average and saving in CSV file
temp_files
=
os
.
listdir
(
TEMP
)
df_wind
=
pd
.
DataFrame
()
print
(
'Averaging data'
)
for
temp_file
in
temp_files
:
df_temp
=
pd
.
read_csv
(
'temp_data/'
+
temp_file
,
header
=
None
,
comment
=
','
,
error_bad_lines
=
False
,
sep
=
','
,
keep_default_na
=
False
,
na_values
=
[
' '
],
usecols
=
columns_anem
,
index_col
=
time_stp_position_anem
,
low_memory
=
False
)
df_temp
.
index
=
pd
.
to_datetime
(
df_temp
.
index
,
format
=
'
%d
.%m.%Y %H:%M:%S'
,
errors
=
'coerce'
)
df_temp
=
df_temp
.
apply
(
pd
.
to_numeric
,
errors
=
'coerce'
)
.
fillna
(
0
)
df_temp
=
df_temp
.
resample
(
time_int
)
.
mean
()[:
-
1
]
df_wind
=
df_wind
.
append
(
df_temp
)
df_temp
=
[]
print
(
'Saving file'
)
df_wind
.
to_csv
(
AVERAGE_RES_FOLDER
+
'anem'
+
str
(
i
)
+
'.csv'
,
header
=
None
,
index
=
True
,
sep
=
','
,
mode
=
'a'
)
print
(
'Done'
)
Event Timeline
Log In to Comment