Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
456c2400
Commit
456c2400
authored
Mar 25, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The KE tool main script of this example ammended to call the JSONOutput object
parent
9e448f6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
20 deletions
+17
-20
dream/KnowledgeExtraction/KEtool_examples/ParallelStations_withfailures/ParallelStations_example.py
...ParallelStations_withfailures/ParallelStations_example.py
+17
-20
No files found.
dream/KnowledgeExtraction/KEtool_examples/ParallelStations_withfailures/ParallelStations_example.py
View file @
456c2400
...
...
@@ -26,9 +26,9 @@ from Transformations import BasicTransformations
from
DistributionFitting
import
DistFittest
from
DistributionFitting
import
Distributions
from
ExcelOutput
import
Output
from
JSONOutput
import
JSONOutput
import
ImportDatabase
import
json
#================================= Extract data from the database ==========================================#
cnxn
=
ImportDatabase
.
ConnectionData
(
seekName
=
'ServerData'
,
implicitExt
=
'txt'
,
number_of_cursors
=
3
)
...
...
@@ -126,25 +126,22 @@ distMTTR_MILL2 = dist_MTTR.Poisson_distrfit(MTTR_MILL2)
jsonFile
=
open
(
'JSON_example.json'
,
'r'
)
#It opens the JSON file
data
=
json
.
load
(
jsonFile
)
#It loads the file
jsonFile
.
close
()
nodes
=
data
.
get
(
'nodes'
,[])
#It creates a variable that holds the 'nodes' dictionary
for
element
in
nodes
:
processingTime
=
nodes
[
element
].
get
(
'processingTime'
,{})
#It creates a variable that gets the element attribute 'processingTime'
MTTF_Nodes
=
nodes
[
element
].
get
(
'MTTF'
,{})
#It creates a variable that gets the element attribute 'MTTF'
MTTR_Nodes
=
nodes
[
element
].
get
(
'MTTR'
,{})
#It creates a variable that gets the element attribute 'MTTR'
if
element
==
'M1'
:
nodes
[
'M1'
][
'processingTime'
]
=
distProcTime_MILL1
#It checks using if syntax if the element is 'M1'
nodes
[
'M1'
][
'failures'
][
'MTTF'
]
=
distMTTF_MILL1
nodes
[
'M1'
][
'failures'
][
'MTTR'
]
=
distMTTR_MILL1
elif
element
==
'M2'
:
nodes
[
'M2'
][
'processingTime'
]
=
distProcTime_MILL2
#It checks using if syntax if the element is 'M2'
nodes
[
'M2'
][
'failures'
][
'MTTF'
]
=
distMTTF_MILL2
nodes
[
'M2'
][
'failures'
][
'MTTR'
]
=
distMTTR_MILL2
exportJSON
=
JSONOutput
()
stationId1
=
'M1'
stationId2
=
'M2'
data1
=
exportJSON
.
ProcessingTimes
(
data
,
stationId1
,
distProcTime_MILL1
)
data2
=
exportJSON
.
ProcessingTimes
(
data1
,
stationId2
,
distProcTime_MILL2
)
data3
=
exportJSON
.
TTF
(
data2
,
stationId1
,
distMTTF_MILL1
)
data4
=
exportJSON
.
TTR
(
data3
,
stationId1
,
distMTTR_MILL1
)
data5
=
exportJSON
.
TTF
(
data4
,
stationId2
,
distMTTF_MILL2
)
data6
=
exportJSON
.
TTR
(
data5
,
stationId2
,
distMTTR_MILL2
)
jsonFile
=
open
(
'JSON_ParallelStations_Output.json'
,
"w"
)
#It opens the JSON file
jsonFile
.
write
(
json
.
dumps
(
data
,
indent
=
True
))
#It writes the updated data to the JSON file
jsonFile
.
close
()
#It closes the file
jsonFile
=
open
(
'JSON_ParallelStations_Output.json'
,
"w"
)
#It opens the JSON file
jsonFile
.
write
(
json
.
dumps
(
data6
,
indent
=
True
))
#It writes the updated data to the JSON file
jsonFile
.
close
()
#It closes the file
#=================== Calling the ExcelOutput object, outputs the outcomes of the statistical analysis in xls files ==========================#
export
=
Output
()
...
...
@@ -161,4 +158,4 @@ export.PrintDistributionFit(procTime_MILL2,'procTimeMILL2_DistFitResults.xls')
export
.
PrintDistributionFit
(
MTTF_MILL1
,
'MTTFMILL1_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTF_MILL2
,
'MTTFMILL2_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTR_MILL1
,
'MTTRMILL1_DistFitResults.xls'
)
export
.
PrintDistributionFit
(
MTTR_MILL2
,
'MTTRMILL2_DistFitResults.xls'
)
\ No newline at end of file
export
.
PrintDistributionFit
(
MTTR_MILL2
,
'MTTRMILL2_DistFitResults.xls'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment