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
22c0ff59
Commit
22c0ff59
authored
5 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
added automatic flip after check, missing values, check plot
parent
e8461adf
No related branches found
No related tags found
2 merge requests
!5
New App; stable_night_lights
,
!2
Resolve "TOPOGRAPHY: Correct missing value handling, add check plots, automatic data flip"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
topography-tandem-x/tests.py
+6
-0
6 additions, 0 deletions
topography-tandem-x/tests.py
topography-tandem-x/topography_file_extraction.py
+15
-8
15 additions, 8 deletions
topography-tandem-x/topography_file_extraction.py
with
21 additions
and
8 deletions
topography-tandem-x/tests.py
+
6
−
0
View file @
22c0ff59
from
django.test
import
TestCase
# Create your tests here.
from
topography_file_extraction
import
read_proxydata
FILENAME
=
"
greater_harz.tif
"
read_proxydata
(
FILENAME
)
This diff is collapsed.
Click to expand it.
topography-tandem-x/topography_file_extraction.py
+
15
−
8
View file @
22c0ff59
...
...
@@ -10,10 +10,7 @@ import numpy as np
import
os
from
toar_location_services.settings
import
DATA_DIR
,
DEBUG
,
USE_DUMMY_TOPOGRAPHY_TANDEM_DATA
from
django.contrib.gis.gdal
import
GDALRaster
# import matplotlib.pyplot as plt
import
matplotlib.pyplot
as
plt
def
read_proxydata
(
filename
,
dummy
=
DEBUG
and
USE_DUMMY_TOPOGRAPHY_TANDEM_DATA
):
...
...
@@ -41,17 +38,27 @@ def read_proxydata(filename, dummy=DEBUG and USE_DUMMY_TOPOGRAPHY_TANDEM_DATA):
# rst.width*xscale + xmin == xmax
# construct data array and lonvec, latvec
data
=
rst
.
bands
[
0
].
data
()
data
=
rst
.
bands
[
0
].
data
().
astype
(
np
.
float
)
nodata_value
=
rst
.
bands
[
0
].
nodata_value
data
[
data
==
nodata_value
]
=
np
.
nan
lonvec
=
np
.
linspace
(
xmin
,
xmax
,
cols
)
latvec
=
np
.
linspace
(
ymin
,
ymax
,
rows
)
# data are flipped, therefore reverse latitudes
# trick from http://stackoverflow.com/questions/6771428/most-efficient-way-to-reverse-a-numpy-array
latvec
=
np
.
fliplr
(
np
.
atleast_2d
(
latvec
))[
0
]
# check if data is flipped
lat1
=
lat0
+
dlat
*
rows
if
lat1
<
lat0
:
lat0
,
lat1
=
lat1
,
lat0
latvec
=
np
.
flipud
(
latvec
)
# set metadata
boundingbox
=
[
lon0
,
latvec
.
min
(),
lonvec
.
max
(),
lat0
]
if
DEBUG
:
plt
.
contourf
(
lonvec
,
latvec
,
data
)
plt
.
savefig
(
'
../plots/topography.png
'
)
plt
.
close
()
#
datainfo
=
{
'
size
'
:
(
rows
,
cols
),
'
resolution
'
:
(
np
.
abs
(
dlon
),
np
.
abs
(
dlat
)),
'
boundingbox
'
:
boundingbox
}
...
...
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