ec_concat_data_repository - _limit with bbox

12 views
Skip to first unread message

Rune YT

unread,
Aug 23, 2017, 8:22:46 AM8/23/17
to shyft
Hey guys,

having a problem with my script using the above mentioned code (class ECConcatDataRepository, function get_forecasts). I'm using the bbox of our model polygons from GIS-database and it seems to fail for some catchments.

The coordinate system is the same for the data source and GIS-data, and all bboxes are within the dataset extent. The code crashes at line 274 (return statement) because xy_inds is empty.

I'm wondering if the xy_mask assignment in the case of bbox might not work for all cases? That's line 254; xy_mask = ((x_mask)&(y_mask)). That at least seem to yield a mask with just False for the catchments that works causes the error.

Example of catchments that fails; 'LTM1-Atnasjø-002.032', 'LTMS-Gimdalsby-0097'.

We can either look at it at Vang or the week after, will try commit and paste the link to the repo here soon if someone wants to download and try to run the code

Yisak Abdella

unread,
Aug 23, 2017, 8:37:18 AM8/23/17
to shyft
Hi,

This is probably because there were not any EC grid points within the bbox sent in. Remember that you could end up with no points in your bbox even if your bbox is within the extent of the datsaset.

Can u verify this?

If this is the case then we can raise an error when there are no points found within the bbox instead of letting it crash.

Regards

Yisak

Rune YT

unread,
Aug 23, 2017, 8:53:18 AM8/23/17
to shyft
Alright, I'm sure it already checks if the bbox is completely within and dataset, and raises and error if it's not. Will double check the extents and get back to you.

Thanks!

Yisak Abdella

unread,
Aug 23, 2017, 9:11:53 AM8/23/17
to shyft
One more thing. To rule out that the problem lies in the coordinate check done particularly for bbox, you can instead send the polygon of your catchment directly using the {'polygon': <shapley polygon>} option. 

Can you post the one example of a bbox which failed.

Yisak

Rune YT

unread,
Aug 23, 2017, 9:12:23 AM8/23/17
to shyft
So here's the relevant parameters for the function (I think), and their values, for one of the catchments that fails;

x[0] = 929861.943029
x[-1] = 31019.1033129

y[0] = 7862824.07123
y[-1] = 6580058.68192

bbox = [[  360841.4631   431288.8221   431288.8221   360841.4631]
 [ 7023400.9123  7023400.9123  7125008.6417  7125008.6417]]

As far I see, the bbox is well within the dataset boundaries?


On Wednesday, August 23, 2017 at 2:37:18 PM UTC+2, Yisak Abdella wrote:

Yisak Abdella

unread,
Aug 30, 2017, 6:04:01 AM8/30/17
to shyft
Hi

I checked the bbox you posted and verified that there actually is not any point inside that bbox. I have attached images showing your bbox (blue box) and all the available points in the EC dataset (green points). Remember that the EC dataset includes only those points which are within15 km buffer of all SHOP regions.

But I will still fix the limit check so that it raises an informative error when there are no points within the bbox sent in. 

Yisak
EC_whole_norway.PNG
EC_zoomed_to_bbox.PNG

Yisak Abdella

unread,
Aug 30, 2017, 6:15:41 AM8/30/17
to shyft
Hi

Have carried out an additional test to verify that the bbox limit test does not raise an error when no points are found. I just converted you bbox into a shapely polygon and used the {'polygon': <shapely object>} option and run. The polygon based limit test raises a proper error as shown below. Have created a branch (nc_repo_bbox) to implement the fix and will make a PR today.

shyft.repository.netcdf.ec_concat_data_repository.ECConcatDataRepositoryError: Polygon does not intersect with dataset.


Yisak

Yisak Abdella

unread,
Aug 30, 2017, 7:11:36 AM8/30/17
to shyft
Hi


Thanks for reporting the error

Yisak
Reply all
Reply to author
Forward
0 new messages