Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uwb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlas
uwb
Commits
5db02cb9
Commit
5db02cb9
authored
2 years ago
by
Adriaens, Ines
Browse files
Options
Downloads
Patches
Plain Diff
exploration script
parent
033e6a8d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exploration.py
+83
-0
83 additions, 0 deletions
exploration.py
with
83 additions
and
0 deletions
exploration.py
0 → 100644
+
83
−
0
View file @
5db02cb9
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 2 13:51:49 2023
@author: adria036
"""
import
os
os
.
chdir
(
r
"
C:\Users\adria036\OneDrive - Wageningen University & Research\iAdriaens_doc\Projects\cKamphuis\nlas\scripts\uwb
"
)
#%% import modules
from
datetime
import
date
,
timedelta
,
datetime
import
pandas
as
pd
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
seaborn
as
sns
#%% set paths and constants and load data
# path to per barn directories
path
=
os
.
path
.
join
(
"
W:
"
,
"
\ASG
"
,
"
WLR_Dataopslag
"
,
"
DairyCampus
"
,
"
3406_Nlas
"
,
"
uwb_processed
"
)
# settings
settings
=
{
'
barn
'
:
[
60
,
61
,
62
,
70
,
71
,
72
,
73
],
'
startdate
'
:
date
(
2022
,
10
,
5
),
'
enddate
'
:
date
(
2022
,
12
,
30
),
'
cows
'
:
[
1790
],
# or specific cow number
}
# files that comply with settings
fn
=
[]
for
b
in
range
(
0
,
len
(
settings
[
"
barn
"
])):
print
(
"
barn =
"
+
str
(
settings
[
"
barn
"
][
b
]))
if
settings
[
"
cows
"
]
==
0
:
fbarn
=
[
f
for
f
in
os
.
listdir
(
path
+
"
/barn
"
+
str
(
settings
[
"
barn
"
][
b
]))
\
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
"
barn
"
+
str
(
settings
[
"
barn
"
][
b
]),
f
))
\
and
(
datetime
.
strptime
(
f
[
5
:
13
],
'
%Y%m%d
'
).
date
()
>=
settings
[
"
startdate
"
])
\
and
(
datetime
.
strptime
(
f
[
5
:
13
],
'
%Y%m%d
'
).
date
()
<=
settings
[
"
enddate
"
])]
fbarn
.
sort
()
else
:
fbarn
=
[
f
for
f
in
os
.
listdir
(
path
+
"
/barn
"
+
str
(
settings
[
"
barn
"
][
b
]))
\
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
"
barn
"
+
str
(
settings
[
"
barn
"
][
b
]),
f
))
\
and
(
int
(
f
[
26
:
-
4
])
in
settings
[
"
cows
"
])
\
and
(
datetime
.
strptime
(
f
[
5
:
13
],
'
%Y%m%d
'
).
date
()
>=
settings
[
"
startdate
"
])
\
and
(
datetime
.
strptime
(
f
[
5
:
13
],
'
%Y%m%d
'
).
date
()
<=
settings
[
"
enddate
"
])]
fbarn
.
sort
()
fn
.
extend
(
fbarn
)
fn
.
sort
()
# find unique cows
cows
=
list
(
set
([
int
(
f
[
26
:
-
4
])
for
f
in
fn
]))
# read data
data
=
pd
.
DataFrame
([])
for
f
in
fn
:
barn
=
f
[
19
:
21
]
sub
=
pd
.
read_csv
(
path
+
"
/barn
"
+
barn
+
"
/
"
+
f
,
usecols
=
[
"
cowid
"
,
"
barn
"
,
"
date
"
,
"
t
"
,
"
xnew
"
,
"
ynew
"
,
"
area
"
,
"
zone
"
],
dtype
=
{
"
cowid
"
:
"
int64
"
,
"
barn
"
:
"
int64
"
,
"
date
"
:
"
object
"
,
"
t
"
:
"
int64
"
,
"
xnew
"
:
"
float64
"
,
"
ynew
"
:
"
float64
"
,
"
area
"
:
"
object
"
,
"
zone
"
:
"
float64
"
})
sub
[
"
date
"
]
=
pd
.
to_datetime
(
sub
[
"
date
"
],
format
=
"
%Y-%m-%d
"
)
data
=
pd
.
concat
([
data
,
sub
])
data
=
data
.
sort_values
(
by
=
[
"
cowid
"
,
"
date
"
,
"
t
"
])
#%% data exploration and visualisation
#TODO
"""
- explore the number of cows with data on each day
- explore when no areas are assigned and so, wrong barn is entered
- explore gaps and gapsize
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment