Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GeoPEAS
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
Container registry
Model registry
Operate
Environments
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
esde
toar-data
GeoPEAS
Commits
0dcb054a
Commit
0dcb054a
authored
5 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
rice service uses now the new CommonView class
parent
b2e0f040
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rice_production/serializers.py
+19
-10
19 additions, 10 deletions
rice_production/serializers.py
rice_production/views.py
+7
-4
7 additions, 4 deletions
rice_production/views.py
with
26 additions
and
14 deletions
rice_production/serializers.py
+
19
−
10
View file @
0dcb054a
...
...
@@ -46,6 +46,17 @@ class AggSerializer(BaseSerializer):
vlength
=
1
# TODO: check units below
if
vlength
>
1
:
if
obj
[
'
direction
'
]
is
None
:
properties
=
OrderedDict
([
(
'
agg_function
'
,
agg_function
),
(
'
many
'
,
True
),
(
agg_function
,
OrderedDict
([
(
d
,
v
)
for
d
,
v
in
zip
(
range
(
vlength
),
val
)
])),
(
'
units
'
,
'
kt
'
),
(
'
radius
'
,
obj
[
'
radius
'
]),
])
else
:
properties
=
OrderedDict
([
(
'
agg_function
'
,
agg_function
),
(
'
many
'
,
True
),
...
...
@@ -55,8 +66,6 @@ class AggSerializer(BaseSerializer):
(
'
units
'
,
'
kt
'
),
(
'
radius
'
,
obj
[
'
radius
'
]),
])
if
obj
[
'
direction
'
]
is
None
:
properties
.
pop
(
'
direction
'
)
else
:
properties
=
OrderedDict
([
(
'
agg_function
'
,
agg_function
),
...
...
This diff is collapsed.
Click to expand it.
rice_production/views.py
+
7
−
4
View file @
0dcb054a
...
...
@@ -7,7 +7,7 @@ from rest_framework.response import Response
from
toar_location_services.settings
import
DEBUG
from
.rice_file_extraction
import
read_proxydata
from
.serializers
import
AggSerializer
from
utils.views_commons
import
get_query_params
,
get_agg_function
from
utils.views_commons
import
CommonViews
from
utils.geoutils
import
Directions
from
utils.extraction_tools
import
extract_value
,
extract_value_stats
...
...
@@ -19,13 +19,16 @@ if DEBUG:
print
(
"
File %s successfully loaded
"
%
FILENAME
,
datainfo
)
class
RiceView
(
APIView
):
class
RiceView
(
APIView
,
CommonViews
):
def
__init__
(
self
):
CommonViews
.
__init__
(
self
)
def
_extract
(
self
,
lat
,
lon
,
radius
,
agg
,
direction
,
by_direction
):
"""
perform actual extraction of desired quantity
"""
print
(
'
**by_direction:
'
,
by_direction
,
'
** radius, agg =
'
,
radius
,
agg
)
if
agg
is
not
None
and
radius
is
not
None
and
radius
>
0.
:
agg_function
=
get_agg_function
(
agg
)
agg_function
=
self
.
get_agg_function
(
agg
)
min_angle
=
None
max_angle
=
None
if
by_direction
:
...
...
@@ -77,7 +80,7 @@ class RiceView(APIView):
by_direction: if True, data are returned as vector with one value aggregated
over each of 16 wind directions.
"""
lat
,
lon
,
radius
,
agg
,
direction
,
by_direction
=
get_query_params
(
request
.
query_params
,
lat
,
lon
,
radius
,
agg
,
direction
,
by_direction
=
self
.
get_query_params
(
request
.
query_params
,
[
'
lat
'
,
'
lon
'
,
'
radius
'
,
'
agg
'
,
'
direction
'
,
'
by_direction
'
])
result
,
agg
,
direction
=
self
.
_extract
(
lat
,
lon
,
radius
,
agg
,
direction
,
by_direction
)
...
...
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