@@ -98,12 +98,14 @@ def from_file(cls, filename):
98
98
99
99
return instance
100
100
101
- def raster_data_at_points (self , lon , lat ):
101
+ def raster_data_at_points (self , lon , lat , scaling_factor = None ):
102
102
"""
103
103
Get data at lat lon points of the raster.
104
104
105
105
:param lon: A 1D array of the longitude of the points.
106
106
:param lat: A 1D array of the latitude of the points.
107
+ :param scaling_factor: An optional scaling factor to
108
+ apply to the values.
107
109
:returns: A numpy array, First dimension being the points/sites.
108
110
"""
109
111
@@ -150,6 +152,9 @@ def read_cell(i, x, y):
150
152
values = numpy .where (values == self .no_data_value , numpy .nan ,
151
153
values )
152
154
155
+ if scaling_factor :
156
+ values *= scaling_factor
157
+
153
158
return values
154
159
155
160
def extent (self ):
@@ -166,13 +171,14 @@ def extent(self):
166
171
return min_long , min_lat , max_long , max_lat
167
172
168
173
169
- def files_raster_data_at_points (lon , lat , files ):
174
+ def files_raster_data_at_points (lon , lat , files , scaling_factor = None ):
170
175
"""
171
176
Get data at lat lon points, based on a set of files
172
177
173
178
:param files: A list of files.
174
179
:param lon: A 1D array of the longitude of the points.
175
180
:param lat: A 1d array of the latitude of the points.
181
+ :param scaling_factor: An optional scaling factor to apply to the values.
176
182
:returns: reshaped_data, max_extent
177
183
reshaped_data: A numpy array, shape (sites, hazards) or shape (sites),
178
184
for one hazard.
@@ -185,7 +191,7 @@ def files_raster_data_at_points(lon, lat, files):
185
191
max_extent = None
186
192
for filename in files :
187
193
a_raster = Raster .from_file (filename )
188
- results = a_raster .raster_data_at_points (lon , lat )
194
+ results = a_raster .raster_data_at_points (lon , lat , scaling_factor )
189
195
data .append (results )
190
196
191
197
# Working out the maximum extent
0 commit comments