Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Learning Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Steinmann, Victor
Learning Python
Commits
2b7eca30
You need to sign in or sign up before continuing.
Commit
2b7eca30
authored
8 months ago
by
Steinmann
Browse files
Options
Downloads
Patches
Plain Diff
Ziele für die Woche aufgeschrieben
parent
17ef29b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Kennlinien_und_Fitting.ipynb
+8
-1
8 additions, 1 deletion
Kennlinien_und_Fitting.ipynb
with
8 additions
and
1 deletion
Kennlinien_und_Fitting.ipynb
+
8
−
1
View file @
2b7eca30
...
@@ -240,9 +240,16 @@
...
@@ -240,9 +240,16 @@
"```python\n",
"```python\n",
"X = numpy.array([df.loc[:,'Q']**3, df.loc[:,'Q']**2 * df.loc[:,'n']...)\n",
"X = numpy.array([df.loc[:,'Q']**3, df.loc[:,'Q']**2 * df.loc[:,'n']...)\n",
"```\n",
"```\n",
"anmelden Thesis\n",
"\n",
"\n",
"Ziel einen Fit mit n als zweite Variable\n",
"Ziel einen Fit mit n als zweite Variable\n",
"multiple linear REgression"
"multiple linear REgression\n",
"\n",
"Ziel2 den FST custom stil zum plotten des Kennfelds einbinden\n",
"\n",
"Ziel3 eine Präsi erstellen anhand des Leitfadens im studierende Starterpaket\n",
"\n",
"schritt 4 Profit "
]
]
},
},
{
{
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Pumpenkennlinien importieren und auf Pumpengleichung Fitten
Pumpenkennlinien importieren und auf Pumpengleichung Fitten
aus Webplotdigitizer .csv datei eines Plots extrahieren
aus Webplotdigitizer .csv datei eines Plots extrahieren
mit pandas read_csv importieren
mit pandas read_csv importieren
-> rechenspaß
-> rechenspaß
->Profit!!!
->Profit!!!
Q^2 -> Q_sq quit
Q^2 -> Q_sq quit
Multiple Linear Regression with Intercept
Multiple Linear Regression with Intercept
Q^3, Q^2
Q^3, Q^2
pandas -> read_csv
pandas -> read_csv
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
pip
install
pandas
%
pip
install
pandas
%
pip
install
numpy
%
pip
install
numpy
%
pip
install
matplotlib
%
pip
install
matplotlib
%
pip
install
scikit
-
learn
%
pip
install
scikit
-
learn
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Zusammenhänge der Pumpe:
Zusammenhänge der Pumpe:
$
\D
elta p=
\a
lpha_1
\c
dot Q^2+
\a
lpha_2
\c
dot Q
\c
dot n_{est}+
\a
lpha_3
\c
dot n_{est}^2$
$
\D
elta p=
\a
lpha_1
\c
dot Q^2+
\a
lpha_2
\c
dot Q
\c
dot n_{est}+
\a
lpha_3
\c
dot n_{est}^2$
$l_{est}=
\f
rac{
\D
elta p}{Q^2}$
$l_{est}=
\f
rac{
\D
elta p}{Q^2}$
Leistungsgleichung:
Leistungsgleichung:
$P_{est}=
\b
eta_1
\c
dot Q^3+
\b
eta_2 Q^2
\c
dot n_{est}+
\b
eta_3
\c
dot Qn_{est}^2+
\b
eta_4n^3+
\b
eta_5$
$P_{est}=
\b
eta_1
\c
dot Q^3+
\b
eta_2 Q^2
\c
dot n_{est}+
\b
eta_3
\c
dot Qn_{est}^2+
\b
eta_4n^3+
\b
eta_5$
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Implementierung des .csv zu DataFrame converters
#Implementierung des .csv zu DataFrame converters
import
pandas
as
pd
import
pandas
as
pd
def
csv_einlesen
(
y_Achse
,
drehzahl
):
def
csv_einlesen
(
y_Achse
,
drehzahl
):
with
open
(
'
{0}-Q_kennlinie_n_{1}.csv
'
.
format
(
y_Achse
,
drehzahl
))
as
kennlinie
:
with
open
(
'
{0}-Q_kennlinie_n_{1}.csv
'
.
format
(
y_Achse
,
drehzahl
))
as
kennlinie
:
dataframe
=
pd
.
read_csv
(
kennlinie
,
delimiter
=
'
;
'
)
dataframe
=
pd
.
read_csv
(
kennlinie
,
delimiter
=
'
;
'
)
dataframe
.
loc
[
-
1
]
=
dataframe
.
columns
dataframe
.
loc
[
-
1
]
=
dataframe
.
columns
dataframe
.
index
=
dataframe
.
index
+
1
dataframe
.
index
=
dataframe
.
index
+
1
dataframe
=
dataframe
.
sort_index
()
dataframe
=
dataframe
.
sort_index
()
sorted_set
=
dataframe
.
set_axis
([
'
Q
'
,
'
H
'
],
axis
=
'
columns
'
)
sorted_set
=
dataframe
.
set_axis
([
'
Q
'
,
'
H
'
],
axis
=
'
columns
'
)
#im Datensatz alle ',' durch '.' ersetzen und die String werte als Float Werte casten
#im Datensatz alle ',' durch '.' ersetzen und die String werte als Float Werte casten
for
x
in
sorted_set
.
index
:
for
x
in
sorted_set
.
index
:
for
y
in
sorted_set
.
columns
:
for
y
in
sorted_set
.
columns
:
sorted_set
.
loc
[
x
,[
y
]]
=
sorted_set
.
loc
[
x
,[
y
]].
str
.
replace
(
'
,
'
,
'
.
'
)
sorted_set
.
loc
[
x
,[
y
]]
=
sorted_set
.
loc
[
x
,[
y
]].
str
.
replace
(
'
,
'
,
'
.
'
)
sorted_set
.
loc
[
x
,[
y
]]
=
sorted_set
.
loc
[
x
,[
y
]].
astype
(
float
)
sorted_set
.
loc
[
x
,[
y
]]
=
sorted_set
.
loc
[
x
,[
y
]].
astype
(
float
)
#berechnen der Spalte Q^2, Q^3 n_relativ, n^2, n^3, Q*n, Q^2*n,Q*n^2
#berechnen der Spalte Q^2, Q^3 n_relativ, n^2, n^3, Q*n, Q^2*n,Q*n^2
sorted_set
[
'
Q^2
'
]
=
sorted_set
[
'
Q
'
]
**
2
sorted_set
[
'
Q^2
'
]
=
sorted_set
[
'
Q
'
]
**
2
sorted_set
[
'
Q^3
'
]
=
sorted_set
[
'
Q
'
]
**
3
sorted_set
[
'
Q^3
'
]
=
sorted_set
[
'
Q
'
]
**
3
sorted_set
[
'
n_rel
'
]
=
drehzahl
/
3600
sorted_set
[
'
n_rel
'
]
=
drehzahl
/
3600
sorted_set
[
'
n^2
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
**
2
sorted_set
[
'
n^2
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
**
2
sorted_set
[
'
n^3
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
**
3
sorted_set
[
'
n^3
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
**
3
sorted_set
[
'
Qn
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
*
sorted_set
[
'
Q
'
]
sorted_set
[
'
Qn
'
]
=
(
sorted_set
[
'
n_rel
'
]
*
3600
)
*
sorted_set
[
'
Q
'
]
sorted_set
[
'
Q^2n
'
]
=
sorted_set
[
'
Q^2
'
]
*
3600
*
sorted_set
[
'
n_rel
'
]
sorted_set
[
'
Q^2n
'
]
=
sorted_set
[
'
Q^2
'
]
*
3600
*
sorted_set
[
'
n_rel
'
]
sorted_set
[
'
Qn^2
'
]
=
sorted_set
[
'
Q
'
]
*
sorted_set
[
'
n^2
'
]
sorted_set
[
'
Qn^2
'
]
=
sorted_set
[
'
Q
'
]
*
sorted_set
[
'
n^2
'
]
return
sorted_set
return
sorted_set
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
def
combine_csvs
():
def
combine_csvs
():
for
i
in
os
.
listdir
(:
*
.
csv
):
for
i
in
os
.
listdir
(:
*
.
csv
):
pd
.
read_csv
(
i
)
pd
.
read_csv
(
i
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
print
(
csv_einlesen
(
'
h
'
,
750
))
print
(
csv_einlesen
(
'
h
'
,
750
))
```
```
%% Output
%% Output
Q h Q^2 Q^3 n_rel n^2 n^3 Qn \
Q h Q^2 Q^3 n_rel n^2 n^3 Qn \
0 0.0 0.363392 0.0 0.0 0.208333 562500.0 421875000.0 0.0
0 0.0 0.363392 0.0 0.0 0.208333 562500.0 421875000.0 0.0
1 0.5 0.398001 0.25 0.125 0.208333 562500.0 421875000.0 375.0
1 0.5 0.398001 0.25 0.125 0.208333 562500.0 421875000.0 375.0
2 1.0 0.397639 1.0 1.0 0.208333 562500.0 421875000.0 750.0
2 1.0 0.397639 1.0 1.0 0.208333 562500.0 421875000.0 750.0
3 1.5 0.328851 2.25 3.375 0.208333 562500.0 421875000.0 1125.0
3 1.5 0.328851 2.25 3.375 0.208333 562500.0 421875000.0 1125.0
4 2.0 0.27687 4.0 8.0 0.208333 562500.0 421875000.0 1500.0
4 2.0 0.27687 4.0 8.0 0.208333 562500.0 421875000.0 1500.0
5 2.5 0.207313 6.25 15.625 0.208333 562500.0 421875000.0 1875.0
5 2.5 0.207313 6.25 15.625 0.208333 562500.0 421875000.0 1875.0
Q^2n Qn^2
Q^2n Qn^2
0 0.0 0.0
0 0.0 0.0
1 187.5 281250.0
1 187.5 281250.0
2 750.0 562500.0
2 750.0 562500.0
3 1687.5 843750.0
3 1687.5 843750.0
4 3000.0 1125000.0
4 3000.0 1125000.0
5 4687.5 1406250.0
5 4687.5 1406250.0
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Fitting aus den Kurven mit sklearn
Fitting aus den Kurven mit sklearn
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
from
sklearn.linear_model
import
LinearRegression
from
sklearn.linear_model
import
LinearRegression
results
=
pd
.
DataFrame
()
results
=
pd
.
DataFrame
()
drehz
=
[
750
,
1150
,
1500
,
1850
,
2200
,
2550
,
2900
,
3250
,
3600
]
drehz
=
[
750
,
1150
,
1500
,
1850
,
2200
,
2550
,
2900
,
3250
,
3600
]
results
[
'
n
'
]
=
drehz
results
[
'
n
'
]
=
drehz
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
2
,
1
,
sharex
=
True
,
gridspec_kw
=
{
'
hspace
'
:
0
})
fig
,
(
ax1
,
ax2
)
=
plt
.
subplots
(
2
,
1
,
sharex
=
True
,
gridspec_kw
=
{
'
hspace
'
:
0
})
ax1
.
set_xticks
(
np
.
linspace
(
0
,
10
,
11
))
ax1
.
set_xticks
(
np
.
linspace
(
0
,
10
,
11
))
ax1
.
set_xticks
(
np
.
linspace
(
0
,
10
,
21
),
minor
=
True
)
ax1
.
set_xticks
(
np
.
linspace
(
0
,
10
,
21
),
minor
=
True
)
for
x
,
x2
in
zip
(
ax1
.
get_xgridlines
()
,
ax2
.
get_xgridlines
()):
for
x
,
x2
in
zip
(
ax1
.
get_xgridlines
()
,
ax2
.
get_xgridlines
()):
x
.
set_visible
(
True
)
x
.
set_visible
(
True
)
x2
.
set_visible
(
True
)
x2
.
set_visible
(
True
)
for
y
,
y2
in
zip
(
ax1
.
get_ygridlines
(),
ax2
.
get_ygridlines
()):
for
y
,
y2
in
zip
(
ax1
.
get_ygridlines
(),
ax2
.
get_ygridlines
()):
y
.
set_visible
(
True
)
y
.
set_visible
(
True
)
y2
.
set_visible
(
True
)
y2
.
set_visible
(
True
)
ax1
.
set_title
(
'
Förderhöhe Kennlinie
'
,
loc
=
'
center
'
)
ax1
.
set_title
(
'
Förderhöhe Kennlinie
'
,
loc
=
'
center
'
)
ax1
.
set_ylabel
(
'
$H$ in m
'
)
ax1
.
set_ylabel
(
'
$H$ in m
'
)
ax2
.
set_title
(
'
Leistungskennlinien
'
,
loc
=
'
center
'
,
y
=-
0.25
)
ax2
.
set_title
(
'
Leistungskennlinien
'
,
loc
=
'
center
'
,
y
=-
0.25
)
ax2
.
set_ylabel
(
'
$P$ in kW
'
)
ax2
.
set_ylabel
(
'
$P$ in kW
'
)
for
n
in
results
.
index
:
for
n
in
results
.
index
:
df
=
csv_einlesen
(
'
h
'
,
drehz
[
n
])
df
=
csv_einlesen
(
'
h
'
,
drehz
[
n
])
X
=
df
.
loc
[:,[
'
Q^2
'
,
'
Qn
'
,
'
n^2
'
]].
to_numpy
(
float
)
X
=
df
.
loc
[:,[
'
Q^2
'
,
'
Qn
'
,
'
n^2
'
]].
to_numpy
(
float
)
y
=
df
[
'
h
'
].
to_numpy
(
float
)
y
=
df
[
'
h
'
].
to_numpy
(
float
)
results
[
'
Q-h_fit
'
]
=
LinearRegression
(
fit_intercept
=
False
).
fit
(
X
,
y
)
results
[
'
Q-h_fit
'
]
=
LinearRegression
(
fit_intercept
=
False
).
fit
(
X
,
y
)
#plotten der Punkte und des Graphen
#plotten der Punkte und des Graphen
ax1
.
plot
(
df
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-h_fit
'
].
get
(
n
).
predict
(
X
))
ax1
.
plot
(
df
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-h_fit
'
].
get
(
n
).
predict
(
X
))
ax1
.
errorbar
(
df
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-h_fit
'
].
get
(
n
).
predict
(
X
),
fmt
=
'
b+
'
)
ax1
.
errorbar
(
df
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-h_fit
'
].
get
(
n
).
predict
(
X
),
fmt
=
'
b+
'
)
#regression aus den Werten für Q und P
#regression aus den Werten für Q und P
df2
=
csv_einlesen
(
'
P
'
,
drehz
[
n
])
df2
=
csv_einlesen
(
'
P
'
,
drehz
[
n
])
X2
=
df2
.
loc
[:,[
'
Q^3
'
,
'
Q^2n
'
,
'
Qn^2
'
,
'
n^3
'
]].
to_numpy
(
float
)
X2
=
df2
.
loc
[:,[
'
Q^3
'
,
'
Q^2n
'
,
'
Qn^2
'
,
'
n^3
'
]].
to_numpy
(
float
)
y2
=
df2
[
'
h
'
].
to_numpy
(
float
)
y2
=
df2
[
'
h
'
].
to_numpy
(
float
)
results
[
'
Q-P_fit
'
]
=
LinearRegression
().
fit
(
X2
,
y2
)
results
[
'
Q-P_fit
'
]
=
LinearRegression
().
fit
(
X2
,
y2
)
#plotten der Punkte und der gefundnen Funktion mit
#plotten der Punkte und der gefundnen Funktion mit
ax2
.
errorbar
(
df2
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-P_fit
'
].
get
(
n
).
predict
(
X2
),
fmt
=
'
b+
'
)
ax2
.
errorbar
(
df2
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-P_fit
'
].
get
(
n
).
predict
(
X2
),
fmt
=
'
b+
'
)
ax2
.
plot
(
df2
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-P_fit
'
].
get
(
n
).
predict
(
X2
))
ax2
.
plot
(
df2
[
'
Q
'
].
to_numpy
(),
results
[
'
Q-P_fit
'
].
get
(
n
).
predict
(
X2
))
print
(
results
[
'
Q-h_fit
'
].
get
(
n
).
coef_
)
print
(
results
[
'
Q-h_fit
'
].
get
(
n
).
coef_
)
print
(
f
'
R^2:
{
results
[
'
Q-h_fit
'
].
get
(
n
).
score
(
X
,
y
)
}
'
)
print
(
f
'
R^2:
{
results
[
'
Q-h_fit
'
].
get
(
n
).
score
(
X
,
y
)
}
'
)
#print(results['Q-P_fit'].get(n).coef_)
#print(results['Q-P_fit'].get(n).coef_)
```
```
%% Output
%% Output
[-4.32633175e-02 5.19623567e-05 6.74554837e-07]
[-4.32633175e-02 5.19623567e-05 6.74554837e-07]
R^2: 0.9993376472269206
R^2: 0.9993376472269206
[-4.42742552e-02 6.27325491e-05 6.53871635e-07]
[-4.42742552e-02 6.27325491e-05 6.53871635e-07]
R^2: 0.9996437866771651
R^2: 0.9996437866771651
[-4.55181410e-02 7.07998272e-05 6.44464225e-07]
[-4.55181410e-02 7.07998272e-05 6.44464225e-07]
R^2: 0.9996824413373676
R^2: 0.9996824413373676
[-4.33713318e-02 6.34156384e-05 6.49436305e-07]
[-4.33713318e-02 6.34156384e-05 6.49436305e-07]
R^2: 0.999760791662233
R^2: 0.999760791662233
[-4.48621316e-02 6.80680926e-05 6.46997640e-07]
[-4.48621316e-02 6.80680926e-05 6.46997640e-07]
R^2: 0.9995310406285615
R^2: 0.9995310406285615
[-4.56090785e-02 7.25278520e-05 6.45662549e-07]
[-4.56090785e-02 7.25278520e-05 6.45662549e-07]
R^2: 0.999203487869221
R^2: 0.999203487869221
[-5.30102486e-02 8.44703682e-05 6.42551789e-07]
[-5.30102486e-02 8.44703682e-05 6.42551789e-07]
R^2: 0.989680503933434
R^2: 0.989680503933434
[-8.31083199e-02 9.65000207e-05 6.45338184e-07]
[-8.31083199e-02 9.65000207e-05 6.45338184e-07]
R^2: 0.9616275516077175
R^2: 0.9616275516077175
[7.00655817e-09 5.04472189e-05 6.48443112e-07]
[7.00655817e-09 5.04472189e-05 6.48443112e-07]
R^2: 1.0
R^2: 1.0
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
df =
df =
Q | n | P | H
Q | n | P | H
-------- | -------- | -------- | --
-------- | -------- | -------- | --
0 | 0.35 | 10 | 2
0 | 0.35 | 10 | 2
0.
5 | 0.35 | 15 | 1.8
0.
5 | 0.35 | 15 | 1.8
1 | 0.35 |20| 1.5
1 | 0.35 |20| 1.5
0 | 0.5 | 15 | 2
0 | 0.5 | 15 | 2
0.
5 | 0.5 | 20 | 1.8
0.
5 | 0.5 | 20 | 1.8
1 | 0.5 | 25 | 1.5
1 | 0.5 | 25 | 1.5
```
python
```
python
X
=
numpy
.
array
([
df
.
loc
[:,
'
Q
'
]
**
3
,
df
.
loc
[:,
'
Q
'
]
**
2
*
df
.
loc
[:,
'
n
'
]...)
X
=
numpy
.
array
([
df
.
loc
[:,
'
Q
'
]
**
3
,
df
.
loc
[:,
'
Q
'
]
**
2
*
df
.
loc
[:,
'
n
'
]...)
```
```
anmelden Thesis
Ziel einen Fit mit n als zweite Variable
Ziel einen Fit mit n als zweite Variable
multiple linear REgression
multiple linear REgression
Ziel2 den FST custom stil zum plotten des Kennfelds einbinden
Ziel3 eine Präsi erstellen anhand des Leitfadens im studierende Starterpaket
schritt 4 Profit
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
results
[
'
Q-h_fit
'
]
results
[
'
Q-h_fit
'
]
```
```
%% Output
%% Output
0 LinearRegression(fit_intercept=False)
0 LinearRegression(fit_intercept=False)
1 LinearRegression(fit_intercept=False)
1 LinearRegression(fit_intercept=False)
2 LinearRegression(fit_intercept=False)
2 LinearRegression(fit_intercept=False)
3 LinearRegression(fit_intercept=False)
3 LinearRegression(fit_intercept=False)
4 LinearRegression(fit_intercept=False)
4 LinearRegression(fit_intercept=False)
5 LinearRegression(fit_intercept=False)
5 LinearRegression(fit_intercept=False)
6 LinearRegression(fit_intercept=False)
6 LinearRegression(fit_intercept=False)
7 LinearRegression(fit_intercept=False)
7 LinearRegression(fit_intercept=False)
8 LinearRegression(fit_intercept=False)
8 LinearRegression(fit_intercept=False)
Name: Q-h_fit, dtype: object
Name: Q-h_fit, dtype: object
...
...
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