Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
stw
wt
exercisemodel
Commits
8673d807
Commit
8673d807
authored
Dec 12, 2017
by
Tomas Pettersson
🏸
Browse files
testing displaced points
parent
6082ac97
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
exercisemodel/__init__.py
View file @
8673d807
...
...
@@ -62,11 +62,11 @@ def writeStatus(status):
def
run
():
try
:
# writeStatus
("INITIAL")
print
(
"INITIAL"
)
strtree
=
STRtree
(
pickle
.
load
(
pkg_resources
.
resource_stream
(
__name__
,
'/'
.
join
((
'resources'
,
'strtree.pickle'
)))))
m
=
Model
()()
with
open
(
'input.json'
,
"r"
)
as
inputfile
:
# writeStatus
("PARTIAL")
print
(
"PARTIAL"
)
inputfeaturecollection
=
json
.
load
(
inputfile
)
output
=
{}
multipointoutlet
=
{}
...
...
@@ -87,13 +87,12 @@ def run():
Cloudtrack
.
write
(
outputfeaturecollection
)
Particletrack
.
write
(
outputfeaturecollection
)
# Output.write(outputfeaturecollection)
# writeStatus("COMPLETE")
print
(
"COMPLETE"
)
sys
.
exit
(
0
)
except
Exception
as
error
:
print_exc
()
#
writeStatus("ERROR")
writeStatus
(
"ERROR"
)
sys
.
exit
(
1
)
'''
To run in terminal call with python __init__.py
...
...
exercisemodel/model.py
View file @
8673d807
...
...
@@ -86,7 +86,7 @@ class Model(object):
def
createOutlet
(
self
,
geom
):
nrOfParticles
=
5
00
nrOfParticles
=
1
00
center
=
geom
.
centroid
points
=
[]
depth
=
[]
...
...
@@ -151,9 +151,9 @@ class Model(object):
minoverlap
=
[
float
(
'Inf'
)]
*
len
(
points
)
radius
=
[
0
]
*
len
(
points
)
for
i
in
range
(
len
(
points
)):
radius
[
i
]
=
0.0
3
5
*
random
.
uniform
(
0.1
,
1
)
radius
[
i
]
=
0.0
01
5
*
random
.
uniform
(
0.1
,
1
)
while
(
p
<
len
(
points
)):
pn
=
p
+
1
pn
=
0
while
(
pn
<
len
(
points
)):
dx
=
points
[
p
][
0
]
-
points
[
pn
][
0
]
dy
=
points
[
p
][
1
]
-
points
[
pn
][
1
]
...
...
@@ -215,10 +215,11 @@ class Model(object):
mp
=
multipoint
linestring
=
geometry
.
shape
(
exercisefeature
[
'geometry'
])
for
i
,
coord
in
enumerate
(
linestring
.
coords
):
print
(
mp
.
centroid
)
points
=
self
.
centerPoints
(
coord
,
mp
.
centroid
,
mp
.
geoms
)
#
displacedpoints = self.displacePoints(points)
displacedpoints
=
self
.
displacePoints
(
points
)
# onlandpoints = self.onlandPoints(displacedpoints,strtree)
mp
=
geometry
.
MultiPoint
(
points
)
mp
=
geometry
.
MultiPoint
(
displaced
points
)
level
=
[
0
]
*
len
(
mp
.
geoms
)
category
=
[
2
]
*
len
(
mp
.
geoms
)
properties
=
self
.
createProperties
((
i
+
2
),
time
[
i
],
mp
.
centroid
,
level
,
category
)
...
...
@@ -226,6 +227,5 @@ class Model(object):
if
(
i
%
10
==
0
):
Cloudtrack
.
write
(
featurecollection
)
Particletrack
.
write
(
featurecollection
)
# Output.write(featurecollection)
return
featurecollection
input.json
View file @
8673d807
{
"type"
:
"FeatureCollection"
,
"features"
:
[{
"type"
:
"Feature"
,
"properties"
:
{
"simulation"
:
{
"forwardCalculation"
:
true
,
"startDate"
:
1512655200000
,
"stopDate"
:
1512828000000
,
"oilclass"
:
"Oil classes"
,
"substance"
:
"Medium oils (100-1000 cSt)"
,
"fresh"
:
true
,
"amount"
:
"60"
,
"amountUnit"
:
"m3"
,
"uncertainty"
:
false
,
"mode"
:
"Normal"
},
"primary"
:
"PADM"
,
"type"
:
"exercise"
,
"subtype"
:
"instant"
,
"meanLat"
:
58.50445618690192
,
"meanLng"
:
19.563903808593754
,
"observation"
:
[{
"id"
:
null
,
"provider"
:
"USER"
,
"providerDataRef"
:
null
,
"providerImgRef"
:
null
,
"providerType"
:
null
,
"type"
:
"MANUAL"
,
"date"
:
1512655200000
}],
"domain"
:
"HELCOM"
,
"model"
:
"NEMO"
},
"geometry"
:
{
"type"
:
"Polygon"
,
"coordinates"
:
[
[
[
19.533691406250004
,
58.504457242628554
],
[
19.539184570312504
,
58.50804431680734
],
[
19.54605102539063
,
58.510913712234455
],
[
19.555664062500004
,
58.513065604861715
],
[
19.566650390625004
,
58.513065604861715
],
[
19.57626342773438
,
58.513065604861715
],
[
19.585876464843754
,
58.510913712234455
],
[
19.59274291992188
,
58.50804431680734
],
[
19.594116210937504
,
58.50373978380493
],
[
19.58999633789063
,
58.49943472293242
],
[
19.58175659179688
,
58.49728199453231
],
[
19.572143554687504
,
58.496564389069675
],
[
19.56253051757813
,
58.49584676894213
],
[
19.552917480468754
,
58.49584676894213
],
[
19.54605102539063
,
58.49584676894213
],
[
19.533691406250004
,
58.504457242628554
]
]
]
}
},
{
"type"
:
"Feature"
,
"properties"
:
{
"auxiliary"
:
"exercise"
,
"time"
:
[
1512656100000
,
1512657000000
,
1512657900000
,
1512658800000
,
1512659700000
,
1512660600000
,
1512661500000
,
1512662400000
,
1512663300000
,
1512664200000
,
1512665100000
,
1512666000000
,
1512666900000
,
1512667800000
,
1512668700000
,
1512669600000
,
1512670500000
,
1512671400000
,
1512672300000
,
1512673200000
,
1512674100000
,
1512675000000
,
1512675900000
,
1512676800000
,
1512677700000
,
1512678600000
,
1512679500000
,
1512680400000
,
1512681300000
,
1512682200000
,
1512683100000
,
1512684000000
,
1512684900000
,
1512685800000
,
1512686700000
,
1512687600000
,
1512688500000
,
1512689400000
,
1512690300000
,
1512691200000
,
1512692100000
,
1512693000000
,
1512693900000
,
1512694800000
,
1512695700000
,
1512696600000
,
1512697500000
,
1512698400000
,
1512699300000
,
1512700200000
,
1512701100000
,
1512702000000
,
1512702900000
,
1512703800000
,
1512704700000
,
1512705600000
,
1512706500000
,
1512707400000
,
1512708300000
,
1512709200000
,
1512710100000
,
1512711000000
,
1512711900000
,
1512712800000
,
1512713700000
,
1512714600000
,
1512715500000
,
1512716400000
,
1512717300000
,
1512718200000
,
1512719100000
,
1512720000000
,
1512720900000
,
1512721800000
,
1512722700000
,
1512723600000
,
1512724500000
,
1512725400000
,
1512726300000
,
1512727200000
,
1512728100000
,
1512729000000
,
1512729900000
,
1512730800000
,
1512731700000
,
1512732600000
,
1512733500000
,
1512734400000
,
1512735300000
,
1512736200000
,
1512737100000
,
1512738000000
,
1512738900000
,
1512739800000
,
1512740700000
,
1512741600000
,
1512742500000
,
1512743400000
,
1512744300000
,
1512745200000
,
1512746100000
,
1512747000000
,
1512747900000
,
1512748800000
,
1512749700000
,
1512750600000
,
1512751500000
,
1512752400000
,
1512753300000
,
1512754200000
,
1512755100000
,
1512756000000
,
1512756900000
,
1512757800000
,
1512758700000
,
1512759600000
,
1512760500000
,
1512761400000
,
1512762300000
,
1512763200000
,
1512764100000
,
1512765000000
,
1512765900000
,
1512766800000
,
1512767700000
,
1512768600000
,
1512769500000
,
1512770400000
,
1512771300000
,
1512772200000
,
1512773100000
,
1512774000000
,
1512774900000
,
1512775800000
,
1512776700000
,
1512777600000
,
1512778500000
,
1512779400000
,
1512780300000
,
1512781200000
,
1512782100000
,
1512783000000
,
1512783900000
,
1512784800000
,
1512785700000
,
1512786600000
,
1512787500000
,
1512788400000
,
1512789300000
,
1512790200000
,
1512791100000
,
1512792000000
,
1512792900000
,
1512793800000
,
1512794700000
,
1512795600000
,
1512796500000
,
1512797400000
,
1512798300000
,
1512799200000
,
1512800100000
,
1512801000000
,
1512801900000
,
1512802800000
,
1512803700000
,
1512804600000
,
1512805500000
,
1512806400000
,
1512807300000
,
1512808200000
,
1512809100000
,
1512810000000
,
1512810900000
,
1512811800000
,
1512812700000
,
1512813600000
,
1512814500000
,
1512815400000
,
1512816300000
,
1512817200000
,
1512818100000
,
1512819000000
,
1512819900000
,
1512820800000
,
1512821700000
,
1512822600000
,
1512823500000
,
1512824400000
,
1512825300000
,
1512826200000
,
1512827100000
,
1512828000000
]
},
"geometry"
:
{
"type"
:
"LineString"
,
"coordinates"
:
[
[
19.567337036132816
,
58.502663568076194
],
[
19.569396972656254
,
58.5005110376406
],
[
19.572143554687504
,
58.498717161463496
],
[
19.575576782226566
,
58.49728199453231
],
[
19.579010009765625
,
58.49584676894213
],
[
19.583129882812504
,
58.49512913414949
],
[
19.58724975585938
,
58.49441148469153
],
[
19.591369628906254
,
58.49405265446298
],
[
19.596862792968754
,
58.49405265446298
],
[
19.60166931152344
,
58.49405265446298
],
[
19.605789184570312
,
58.49441148469153
],
[
19.60922241210938
,
58.49584676894213
],
[
19.61196899414063
,
58.49764079176431
],
[
19.614028930664066
,
58.49979349816783
],
[
19.614028930664066
,
58.50230482216832
],
[
19.614028930664066
,
58.50481596654177
],
[
19.613342285156254
,
58.50696823304234
],
[
19.61265563964844
,
58.509120367582995
],
[
19.61265563964844
,
58.51163102443782
],
[
19.61265563964844
,
58.51414150169539
],
[
19.61265563964844
,
58.51701039865656
],
[
19.61265563964844
,
58.51952049108999
],
[
19.610595703125
,
58.52167185596512
],
[
19.60716247558594
,
58.52310602592301
],
[
19.603042602539066
,
58.52454013724891
],
[
19.59892272949219
,
58.52525717092532
],
[
19.594802856445312
,
58.52561568226698
],
[
19.59068298339844
,
58.52633269395731
],
[
19.586563110351566
,
58.527049690990474
],
[
19.58175659179688
,
58.52740818401066
],
[
19.57695007324219
,
58.52812515905846
],
[
19.572143554687504
,
58.52812515905846
],
[
19.567337036132816
,
58.52848364108607
],
[
19.563217163085938
,
58.52884211944955
],
[
19.556350708007816
,
58.52884211944955
],
[
19.55154418945313
,
58.52884211944955
],
[
19.54605102539063
,
58.52884211944955
],
[
19.54124450683594
,
58.52884211944955
],
[
19.53643798828125
,
58.52884211944955
],
[
19.531631469726566
,
58.52884211944955
],
[
19.52682495117188
,
58.52884211944955
],
[
19.52133178710938
,
58.52884211944955
],
[
19.51652526855469
,
58.52884211944955
],
[
19.511718750000004
,
58.52884211944955
],
[
19.506912231445316
,
58.52884211944955
],
[
19.50210571289063
,
58.52884211944955
],
[
19.49729919433594
,
58.52884211944955
],
[
19.492492675781254
,
58.52812515905846
],
[
19.48837280273438
,
58.52776667336668
],
[
19.484252929687504
,
58.527049690990474
],
[
19.479446411132816
,
58.526691194306004
],
[
19.47463989257813
,
58.526691194306004
],
[
19.46983337402344
,
58.526691194306004
],
[
19.465026855468754
,
58.526691194306004
],
[
19.460220336914066
,
58.526691194306004
],
[
19.45610046386719
,
58.52633269395731
],
[
19.451980590820312
,
58.525974189944286
],
[
19.44786071777344
,
58.52561568226698
],
[
19.443740844726566
,
58.52454013724891
],
[
19.43962097167969
,
58.52346455925118
],
[
19.43618774414063
,
58.52167185596512
],
[
19.434814453125004
,
58.51952049108999
],
[
19.43344116210938
,
58.51736899428439
],
[
19.432754516601566
,
58.51521736554333
],
[
19.432067871093754
,
58.51270696525352
],
[
19.432067871093754
,
58.51019638536994
],
[
19.432067871093754
,
58.50768562588452
],
[
19.43344116210938
,
58.505533403371146
],
[
19.43344116210938
,
58.50302231031824
],
[
19.432754516601566
,
58.50015226973721
],
[
19.430694580078125
,
58.49799958533018
],
[
19.42794799804688
,
58.49620558083903
],
[
19.42588806152344
,
58.49405265446298
],
[
19.424514770507816
,
58.49189959609669
],
[
19.42314147949219
,
58.489746405735104
],
[
19.421768188476566
,
58.48759308337315
],
[
19.421768188476566
,
58.48508070711037
],
[
19.421768188476566
,
58.48256815116553
],
[
19.42314147949219
,
58.48041438876595
],
[
19.424514770507816
,
58.47826049434411
],
[
19.42588806152344
,
58.47610646789501
],
[
19.42794799804688
,
58.47395230941355
],
[
19.430694580078125
,
58.472157076484024
],
[
19.432754516601566
,
58.470002675930196
],
[
19.43344116210938
,
58.467848143329725
],
[
19.43344116210938
,
58.46497522778118
],
[
19.43412780761719
,
58.46282038705229
],
[
19.435501098632812
,
58.46066541425993
],
[
19.43687438964844
,
58.45815111241527
],
[
19.43893432617188
,
58.455995853468124
],
[
19.440994262695312
,
58.453840462441555
],
[
19.44236755371094
,
58.451325672636784
],
[
19.443740844726566
,
58.44881070304238
],
[
19.44511413574219
,
58.44665487171463
],
[
19.44511413574219
,
58.44413956820389
],
[
19.44511413574219
,
58.440905342331796
],
[
19.445800781250004
,
58.43874902660803
],
[
19.445800781250004
,
58.436233157945246
],
[
19.445800781250004
,
58.43335765926364
],
[
19.44442749023438
,
58.430481925680056
],
[
19.443054199218754
,
58.42796546609197
],
[
19.44168090820313
,
58.42544882663992
],
[
19.440994262695312
,
58.42329156394648
],
[
19.43962097167969
,
58.42113416909718
],
[
19.438247680664066
,
58.418976642086974
],
[
19.438247680664066
,
58.416459360198274
],
[
19.437561035156254
,
58.41430154682212
],
[
19.437561035156254
,
58.41034521233622
],
[
19.437561035156254
,
58.40674815907979
],
[
19.437561035156254
,
58.402790976372856
],
[
19.43687438964844
,
58.400632325791555
],
[
19.43687438964844
,
58.398113733015876
],
[
19.43687438964844
,
58.39559496028138
],
[
19.43687438964844
,
58.393076007580135
],
[
19.43687438964844
,
58.39055687490412
],
[
19.43687438964844
,
58.38767764574403
],
[
19.43687438964844
,
58.38515812738093
],
[
19.43618774414063
,
58.38299839694763
],
[
19.43618774414063
,
58.380478544292686
],
[
19.434814453125004
,
58.377958511623056
],
[
19.43344116210938
,
58.37579834033745
],
[
19.43138122558594
,
58.373638036785266
],
[
19.429321289062504
,
58.37111751546407
],
[
19.427261352539066
,
58.36859681409852
],
[
19.42588806152344
,
58.365715792065174
],
[
19.424514770507816
,
58.36355487120244
],
[
19.42245483398438
,
58.36139381804461
],
[
19.42039489746094
,
58.35887242214752
],
[
19.418334960937504
,
58.35671108233314
],
[
19.41696166992188
,
58.35454961020779
],
[
19.414215087890625
,
58.352388005766436
],
[
19.41146850585938
,
58.35022626900405
],
[
19.407348632812504
,
58.34806439991561
],
[
19.40322875976563
,
58.34662308033968
],
[
19.399795532226566
,
58.3448213481606
],
[
19.39567565917969
,
58.34374026474048
],
[
19.391555786132816
,
58.3422987687142
],
[
19.38674926757813
,
58.34085721386817
],
[
19.38125610351563
,
58.33977600913228
],
[
19.37576293945313
,
58.33797392771086
],
[
19.371643066406254
,
58.33725306940686
],
[
19.366836547851562
,
58.336171754376615
],
[
19.36203002929688
,
58.33472994953
],
[
19.35722351074219
,
58.33364855728952
],
[
19.35173034667969
,
58.332567131957916
],
[
19.347610473632816
,
58.331485673534544
],
[
19.34349060058594
,
58.33076468286767
],
[
19.339370727539066
,
58.329683169289964
],
[
19.33456420898438
,
58.32860162261882
],
[
19.330444335937504
,
58.32788057311919
],
[
19.324264526367188
,
58.32679897129091
],
[
19.3194580078125
,
58.326438429993736
],
[
19.314651489257816
,
58.326438429993736
],
[
19.30984497070313
,
58.32607788501928
],
[
19.30503845214844
,
58.32607788501928
],
[
19.300918579101566
,
58.325717336367546
],
[
19.295425415039066
,
58.324996228032155
],
[
19.289932250976566
,
58.32391453794888
],
[
19.284439086914066
,
58.323553967233
],
[
19.27963256835938
,
58.32283281476884
],
[
19.275512695312504
,
58.32211164759474
],
[
19.270019531250004
,
58.32175105849138
],
[
19.264526367187504
,
58.32175105849138
],
[
19.259719848632816
,
58.32175105849138
],
[
19.25491333007813
,
58.32175105849138
],
[
19.250106811523438
,
58.32175105849138
],
[
19.245300292968754
,
58.32175105849138
],
[
19.23912048339844
,
58.32175105849138
],
[
19.235000610351566
,
58.321390465710444
],
[
19.229507446289066
,
58.321390465710444
],
[
19.22470092773438
,
58.321390465710444
],
[
19.21920776367188
,
58.321390465710444
],
[
19.21440124511719
,
58.321390465710444
],
[
19.207534790039062
,
58.321390465710444
],
[
19.202041625976562
,
58.32211164759474
],
[
19.196548461914066
,
58.32247223302053
],
[
19.191741943359375
,
58.32283281476884
],
[
19.186248779296875
,
58.32391453794888
],
[
19.182128906250004
,
58.32463566834844
],
[
19.17800903320313
,
58.325356784038526
],
[
19.17320251464844
,
58.326438429993736
],
[
19.169082641601566
,
58.32715950891086
],
[
19.16427612304688
,
58.32860162261882
],
[
19.16015625
,
58.329683169289964
],
[
19.1546630859375
,
58.33112518003958
],
[
19.149169921875
,
58.33292761074528
],
[
19.144363403320312
,
58.334369489126594
],
[
19.140930175781254
,
58.336171754376615
],
[
19.13681030273438
,
58.33797392771086
],
[
19.13406372070313
,
58.34013641438728
],
[
19.132690429687504
,
58.3422987687142
],
[
19.13131713867188
,
58.34446099069667
]
]
}
}]
}
\ No newline at end of file
{
"type"
:
"FeatureCollection"
,
"features"
:[{
"type"
:
"Feature"
,
"properties"
:{
"simulation"
:{
"forwardCalculation"
:
true
,
"startDate"
:
1513080000000
,
"stopDate"
:
1513083600000
,
"oilclass"
:
"Oil classes"
,
"substance"
:
"Medium oils (100-1000 cSt)"
,
"fresh"
:
true
,
"amount"
:
"10"
,
"amountUnit"
:
"m3"
,
"uncertainty"
:
false
,
"mode"
:
"Normal"
},
"primary"
:
"PADM"
,
"type"
:
"exercise"
,
"subtype"
:
"instant"
,
"meanLat"
:
56.95620768360087
,
"meanLng"
:
20.06515502929688
,
"observation"
:[{
"id"
:
null
,
"provider"
:
"USER"
,
"providerDataRef"
:
null
,
"providerImgRef"
:
null
,
"providerType"
:
null
,
"type"
:
"MANUAL"
,
"date"
:
1513080000000
}],
"domain"
:
"HELCOM"
,
"model"
:
"NEMO"
},
"geometry"
:{
"type"
:
"Polygon"
,
"coordinates"
:[[[
20.055541992187504
,
56.962947135260585
],[
20.0775146484375
,
56.962947135260585
],[
20.085754394531254
,
56.953961741347385
],[
20.069274902343754
,
56.95096612859506
],[
20.052795410156254
,
56.94946823194116
],[
20.044555664062504
,
56.95845470910799
],[
20.047302246093754
,
56.95995224466898
],[
20.055541992187504
,
56.962947135260585
]]]}},{
"type"
:
"Feature"
,
"properties"
:{
"auxiliary"
:
"exercise"
,
"time"
:[
1513080900000
,
1513081800000
,
1513082700000
,
1513083600000
]},
"geometry"
:{
"type"
:
"LineString"
,
"coordinates"
:[[
20.06584167480469
,
56.953961741347385
],[
20.06584167480469
,
56.95227673879617
],[
20.06584167480469
,
56.95059166007404
],[
20.06584167480469
,
56.94928099062754
]]}}]}
\ No newline at end of file
output.json
View file @
8673d807
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