Skip to content

Commit b542908

Browse files
authored
Merge pull request #17 from EnvModellingGroup/add_real_data_test
Add real data test and deal with minor issues from JOSS review.
2 parents 7c7a095 + 7f05e72 commit b542908

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2854597
-14792
lines changed

README.md

+40-69
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can request a point and hrds will return a value based on
1010
the highest resolution dataset (as defined by the user) available at that point, blending
1111
datasets in a buffer region to ensure consistency.
1212

13-
[![Build Status](https://travis-ci.org/EnvModellingGroup/hdrs.svg?branch=master)](https://travis-ci.org/EnvModellingGroup/hdrs)
13+
[![Build Status](https://travis-ci.org/EnvModellingGroup/hrds.svg?branch=master)](https://travis-ci.org/EnvModellingGroup/hrds)
1414

1515
Current release:
1616
[![DOI](https://zenodo.org/badge/155502078.svg)](https://zenodo.org/badge/latestdoi/155502078)
@@ -65,15 +65,15 @@ import sys
6565
sys.path.insert(0,"../../")
6666
from hrds import HRDS
6767

68-
mesh2d = Mesh('test.msh') # mesh file
68+
mesh2d = Mesh('test_mesh.msh') # mesh file
6969

7070
P1_2d = FunctionSpace(mesh2d, 'CG', 1)
7171
bathymetry2d = Function(P1_2d, name="bathymetry")
7272
bvector = bathymetry2d.dat.data
7373
bathy = HRDS("gebco_uk.tif",
7474
rasters=("emod_utm.tif",
75-
"marine_digimap.tif"),
76-
distances=(10000, 5000))
75+
"inspire_data.tif"),
76+
distances=(700, 200))
7777
bathy.set_bands()
7878
for i, (xy) in enumerate(mesh2d.coordinates.dat.data):
7979
bvector[i] = bathy.get_val(xy)
@@ -84,102 +84,73 @@ This example loads in an XYZ file and obtains data at each point,
8484
replacing the Z value with that from HRDS.
8585

8686
```python
87+
import sys
88+
sys.path.insert(0,"../../")
89+
8790
from hrds import HRDS
8891

8992
points = []
90-
with open("test.xyz",'r') as f:
93+
with open("test_mesh.csv",'r') as f:
9194
for line in f:
92-
row = line.split()
95+
row = line.split(",")
9396
# grab X and Y
9497
points.append([float(row[0]), float(row[1])])
9598

9699
bathy = HRDS("gebco_uk.tif",
97100
rasters=("emod_utm.tif",
98-
"marine_digimap.tif"),
99-
distances=(10000, 5000))
101+
"inspire_data.tif"),
102+
distances=(700, 200))
100103
bathy.set_bands()
101104

105+
print len(points)
106+
102107
with open("output.xyz","w") as f:
103108
for p in points:
104109
f.write(str(p[0])+"\t"+str(p[1])+"\t"+str(bathy.get_val(p))+"\n")
105-
106110
```
107111

108112
This will turn this:
109113
```bash
110-
$ head test.xyz
111-
778000 5960000 0
112-
778000 5955006.00490137 0
113-
778000 5950012.00980273 0
114-
778000 5945018.0147041 0
115-
778000 5940024.01960546 0
116-
778000 5935030.02450683 0
117-
778000 5930036.02940819 0
118-
778000 5925042.03430956 0
119-
778000 5920048.03921092 0
120-
778000 5915054.04411229 0
114+
$ head test_mesh.csv
115+
805390.592314,5864132.9269,0
116+
805658.162910036,5862180.30440542,0
117+
805925.733505999,5860227.68191137,0
118+
806193.304101986,5858275.05941714,0
119+
806460.874698054,5856322.43692232,0
120+
806728.445294035,5854369.81442814,0
121+
806996.015889997,5852417.19193409,0
122+
807263.586486046,5850464.56943942,0
123+
807531.157082069,5848511.94694493,0
124+
807798.727678031,5846559.32445088,0
121125
```
122126

123127
into this:
124128

125129
```bash
126130
$ head output.xyz
127-
778000.0 5960000.0 -23.2977278648
128-
778000.0 5955006.0049 -16.3622326359
129-
778000.0 5950012.0098 -17.8316399298
130-
778000.0 5945018.0147 -12.1837755526
131-
778000.0 5940024.01961 -17.2785563521
132-
778000.0 5935030.02451 -13.0309790235
133-
778000.0 5930036.02941 -11.081550282
134-
778000.0 5925042.03431 -8.37494903047
135-
778000.0 5920048.03921 -18.8159019752
136-
778000.0 5915054.04411 -17.9226424001
131+
805390.592314 5864132.9269 -10.821567728305235
132+
805658.16291 5862180.30441 2.721575532084955
133+
805925.733506 5860227.68191 2.528217188012767
134+
806193.304102 5858275.05942 3.1063558741547865
135+
806460.874698 5856322.43692 5.470234157891056
136+
806728.445294 5854369.81443 1.382685066254607
137+
806996.01589 5852417.19193 1.8997482922322515
138+
807263.586486 5850464.56944 4.0836843606647335
139+
807531.157082 5848511.94694 -2.39508079759155
140+
807798.727678 5846559.32445 -2.401006071401176
137141
```
138142

139-
These images show the original data in QGIS (note the "edges" between rasters,
140-
higlighted by the arrows in the right
141-
hand close-up). The figure also shows the buffer regions created around the
142-
two higher resolution datasets (bottom left). The red line is the boundary of the
143-
mesh used (see figure below).
144-
145-
![Input data](https://github.com/EnvModellingGroup/hdrs/blob/master/docs/original_bathy_data_sml.png)
146-
147-
After running the code above, we produce this blended dataset. The mesh is shown in the
148-
lower left, with a close-up on the right. Mesh varied in resolution from
149-
2000m to 50m. Note the three bathymetric highs (yellow) near the GEBCO label above
150-
are smoothed in the buffer region and there is no longer the obvious line
151-
between the GEBCO data and the EMod data.
143+
These images show the original data in QGIS in the top right, with each data set using a different colour scheme (GEBCO - green-blue; EMOD - grey; UK Gov - plasma - highlighted by the black rectangle).The red line is the boundary of the mesh used (see figure below). Both the EMOD and UK Gov data has NODATA areas, which are shown as transparent here, hence the curved left edge of the EMOD data. The figure also shows the buffer regions created around the two higher resolution datasets (top left), with black showing that data isn't used to white where it is 100% used. The effect of NODATA is clear here. The bottom panel shows a close-up of the UK Gov data with the buffer overlayed as a transparancy from white (not used) to black (100% UK Gov). The coloured polygon is the area of the high resolution mesh (see below).
152144

153-
![Blended bathymetry data on the multiscale mesh](https://github.com/EnvModellingGroup/hdrs/blob/master/docs/blended_rasters_with_mesh_sml.png)
145+
![Input data](https://github.com/EnvModellingGroup/hdrs/blob/master/docs/raster_data_sml.png)
154146

155-
Data availability: Due to licensing, these data cannot be distributied with HRDS. GEBCO can be downloaded here. EMod can be obtained here. Both are available free of charge. The highest resolution data is available from [OceanWise] (https://www.oceanwise.eu/) but charges apply (your institution may have access via Digimap).
147+
After running the code above, we produce this blended dataset. Note the coarse mesh used here - it's not realistic for a model simulation!
156148

157-
The extents of these data are given below in both UTM Zone 30N and Lat/lon.
149+
![Blended bathymetry data on the multiscale mesh](https://github.com/EnvModellingGroup/hdrs/blob/master/docs/mesh_bathy_all.png)
158150

159-
GEBCO:
160-
```
161-
Upper Left ( 766859.683, 5978004.171) ( 1d 3'38.34"E, 53d52'54.13"N)
162-
Lower Left ( 766859.683, 5744003.495) ( 0d52' 9.27"E, 51d46'59.32"N)
163-
Upper Right ( 1097334.321, 5978004.171) ( 6d 2'21.77"E, 53d36'29.76"N)
164-
Lower Right ( 1097334.321, 5744003.495) ( 5d37' 6.72"E, 51d31'46.24"N)
165-
```
166-
EMod:
167-
```
168-
Upper Left ( 837967.380, 5856534.579) ( 2d 0'32.89"E, 52d45' 9.73"N)
169-
Lower Left ( 837967.380, 5757658.491) ( 1d54'35.70"E, 51d52' 1.52"N)
170-
Upper Right ( 921603.168, 5856534.579) ( 3d14'29.46"E, 52d41'38.60"N)
171-
Lower Right ( 921603.168, 5757658.491) ( 3d 7' 5.60"E, 51d48'36.98"N)
172-
Center ( 879785.274, 5807096.535) ( 2d34'10.17"E, 52d16'57.50"N)
173-
```
174-
OceanWise:
175-
```
176-
Upper Left ( 858372.882, 5814203.705) ( 2d15'52.30"E, 52d21'38.28"N)
177-
Lower Left ( 858372.882, 5772942.941) ( 2d13'15.51"E, 51d59'28.40"N)
178-
Upper Right ( 873215.438, 5814203.705) ( 2d28'53.42"E, 52d21' 2.66"N)
179-
Lower Right ( 873215.438, 5772942.941) ( 2d26'10.25"E, 51d58'53.25"N)
180-
```
151+
If we then zoom-in to the high resolution area we can see the high resolution UK Giv data being used and with no obvious lines between datasets.
181152

182-
Place these rasters inside the test/real_data directory as per the filenames in ``test_hrds.py`` and the extended tests will also be run. These are not run by the continuous integration.
153+
![Blended bathymetry data on the multiscale mesh](https://github.com/EnvModellingGroup/hdrs/blob/master/docs/mesh_bathy.png)
183154

184155
Community
185156
-----------

docs/blended_bathy_data.png

-234 KB
Binary file not shown.
-198 KB
Binary file not shown.

docs/blended_bathy_data_with_mesh.png

-374 KB
Binary file not shown.

docs/blended_rasters_with_mesh.png

-4.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)