Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
exercisemodel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stw
wt
exercisemodel
Commits
e6ba8756
Commit
e6ba8756
authored
Nov 29, 2017
by
Tomas Pettersson
🏸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now writes cloudtrack and particletrack files
parent
17806c08
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
18 deletions
+45
-18
exercisemodel/__init__.py
exercisemodel/__init__.py
+7
-10
exercisemodel/__init__.pyc
exercisemodel/__init__.pyc
+0
-0
exercisemodel/model.py
exercisemodel/model.py
+3
-3
exercisemodel/model.pyc
exercisemodel/model.pyc
+0
-0
exercisemodel/output.py
exercisemodel/output.py
+34
-4
exercisemodel/particletrack.pyc
exercisemodel/particletrack.pyc
+0
-0
output.json
output.json
+1
-1
No files found.
exercisemodel/__init__.py
View file @
e6ba8756
...
...
@@ -8,7 +8,9 @@ import pickle
import
pkg_resources
from
traceback
import
print_exc
from
model
import
Model
from
particletrack
import
Particletrack
from
output
import
Output
from
output
import
Particletrack
from
output
import
Cloudtrack
from
shapely
import
geometry
from
shapely.geometry
import
LineString
from
shapely.strtree
import
STRtree
...
...
@@ -56,7 +58,7 @@ def writeStatus(status):
if
props
.
has_key
(
"status"
):
props
[
'status'
]
=
status
write_properties
(
'taskinfo.properties'
,
props
)
print
(
status
)
def
run
():
try
:
...
...
@@ -84,14 +86,9 @@ def run():
outputfeaturecollection
[
'properties'
][
'status'
]
=
'COMPLETE'
outputfeaturecollection
[
'properties'
][
'simulation'
]
=
outletproperties
[
'simulation'
]
for
outputfeature
in
outputfeaturecollection
[
'features'
]:
Particletrack
.
write
(
outputfeature
)
with
open
(
'output.json'
,
"w"
)
as
outputfile
:
json
.
dump
(
outputfeaturecollection
,
outputfile
)
Cloudtrack
.
write
(
outputfeaturecollection
)
Particletrack
.
write
(
outputfeaturecollection
)
Output
.
write
(
outputfeaturecollection
)
writeStatus
(
"COMPLETE"
)
sys
.
exit
(
0
)
...
...
exercisemodel/__init__.pyc
deleted
100644 → 0
View file @
17806c08
File deleted
exercisemodel/model.py
View file @
e6ba8756
...
...
@@ -33,7 +33,7 @@ class Model(object):
center
=
[
centroid
.
x
,
centroid
.
y
]
for
point
in
points
:
latlng
=
[
point
.
x
,
point
.
y
]
centered
.
append
(
self
.
centerPoint
(
newLatLng
,
center
,
latlng
))
centered
.
append
(
self
.
centerPoint
(
newLatLng
,
center
,
latlng
))
return
centered
def
centerPoint
(
self
,
newCenter
,
oldCenter
,
latlng
):
...
...
@@ -111,7 +111,7 @@ class Model(object):
if
(
lvl
>
100
):
break
print
counter
print
(
"Outlet particles count: "
+
str
(
counter
))
return
geometry
.
MultiPoint
(
points
)
...
...
@@ -131,7 +131,7 @@ class Model(object):
def
onlandPoints
(
self
,
points
,
strtree
):
result
=
list
(
points
)
print
(
"On land calculated"
)
return
result
...
...
exercisemodel/model.pyc
deleted
100644 → 0
View file @
17806c08
File deleted
exercisemodel/
particletrack
.py
→
exercisemodel/
output
.py
View file @
e6ba8756
...
...
@@ -2,17 +2,27 @@
import
json
from
datetime
import
datetime
class
Output
:
@
staticmethod
def
write
(
featurecollection
):
with
open
(
'output.json'
,
"w"
)
as
outputfile
:
json
.
dump
(
featurecollection
,
outputfile
)
class
Particletrack
:
@
staticmethod
def
write
(
feature
):
def
write
feature
(
feature
):
p
=
feature
[
'properties'
]
category
=
p
[
'category'
]
level
=
p
[
'level'
]
coords
=
feature
[
'geometry'
][
'coordinates'
]
step
=
str
(
p
[
'nStep'
])
meanlon
=
str
(
p
[
'meanLon'
])
meanlat
=
str
(
p
[
'meanLat'
])
meanlon
=
"{:10.4f}"
.
format
(
p
[
'meanLon'
])
meanlat
=
"{:10.4f}"
.
format
(
p
[
'meanLat'
])
utcdatetime
=
datetime
.
utcfromtimestamp
(
p
[
'time'
]
/
1000
)
timestring
=
utcdatetime
.
strftime
(
'%Y-%m-%d-%H-%M'
)
with
open
(
'particletrack-'
+
step
+
'-'
+
timestring
+
'.dat'
,
"w"
)
as
particlefile
:
...
...
@@ -20,6 +30,26 @@ class Particletrack:
for
key
,
coord
in
enumerate
(
coords
):
particlefile
.
write
(
" "
+
"{:10.4f}"
.
format
(
coord
[
0
])
+
" "
+
"{:10.4f}"
.
format
(
coord
[
1
])
+
" "
+
"{:1.1f}"
.
format
(
level
[
key
])
+
" T T F "
+
str
(
category
[
key
])
+
" 0.000 0.000 0.000
\n
"
)
@
staticmethod
def
write
(
featurecollection
):
for
outputfeature
in
featurecollection
[
'features'
]:
Particletrack
.
writefeature
(
outputfeature
)
class
Cloudtrack
:
@
staticmethod
def
write
(
featurecollection
):
features
=
featurecollection
[
'features'
]
with
open
(
'cloudtrack.dat'
,
"w"
)
as
cloudfile
:
for
feature
in
features
:
p
=
feature
[
'properties'
]
meanlon
=
"{:10.4f}"
.
format
(
p
[
'meanLon'
])
meanlat
=
"{:10.4f}"
.
format
(
p
[
'meanLat'
])
utcdatetime
=
datetime
.
utcfromtimestamp
(
p
[
'time'
]
/
1000
)
cloudfile
.
write
(
utcdatetime
.
strftime
(
'%Y-%m-%d %H:%M'
)
+
" "
+
meanlon
+
" "
+
meanlat
+
" "
+
"0.0000
\n
"
)
'''
...
...
@@ -28,4 +58,4 @@ class Particletrack:
if
__name__
==
"__main__"
:
with
open
(
'../output.json'
,
"r"
)
as
outputfile
:
outputfeaturecollection
=
json
.
load
(
outputfile
)
Particletrack
.
write
(
outputfeaturecollection
[
'features'
][
0
])
\ No newline at end of file
Particletrack
.
writefeature
(
outputfeaturecollection
[
'features'
][
0
])
\ No newline at end of file
exercisemodel/particletrack.pyc
deleted
100644 → 0
View file @
17806c08
File deleted
output.json
View file @
e6ba8756
This diff is collapsed.
Click to expand it.
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