Closed agstephens closed 5 years ago
This makes sure the gridlines are where we want them to be.
It might be best if EITHER we switch off trying to plot gridlines if the plot is less than 3 (?) grid widths across OR we adjust the gridline spacing if the plot is less than 3 (?) grid widths across
I can't remember if the grid spacing is set by the user - if not, then we might want to adjust it automatically. But the easiest thing might be to just switch them off when they're likely to cause trouble.
I think this is due to the last minute change to using projection_x_coordinate and projection_y_coordinate in place of lat and long. The previous lines assume lat and long
xgridpts = [xgridpt for xgridpt in xgridpts if ( xgridpt >= -180 and xgridpt <= 360)] ygridpts = [ygridpt for ygridpt in ygridpts if ( ygridpt >= -90 and ygridpt <= 90)]
Also looks like I made a mistake trying to switch the grid lines off elsewhere. If I fix that then this issue goes away (tested on demo)
@antony-wilson : good stuff. If you send me the fix I can try it on my version.
replace lines50 and 51 https://github.com/ukcp-data/ukcp-data-processor/blob/master/ukcp_dp/plotters/_map_plotter.py#50 with plot_settings.gridlcol = None
my mistake, you still need lines 50 and 51, just add in the extra line
@antony-wilson : Works for me on the wps-dev
version. I'll leave it to you to test if there are any side-effects and how it gets rolled out. Thanks :-)
fixed by commit 2e9019f9dc57aad40e72078fc13c4ccac3c8fa6c
Hi @antony-wilson ,
I have found where the error lies for our request:
https://ukcp18-wps-demo.ceda.ac.uk/submit/form?TemporalAverage=aug&amp;Collection=land-prob&amp;Baseline=b8100&amp;Scenario=rcp85&amp;ImageFormat=png&amp;Area=bbox%7C54400.05%7C-42266.67%7C449066.65%7C437733.33&amp;SpatialSelectionType=bbox&amp;TimeSliceDuration=20y&amp;DataFormat=csv&amp;FontSize=m&amp;TimeSlice=2080-2099&amp;Variable=tasminAnom&amp;proc_id=LS1_Maps_01&amp;ImageSize=1200
The
ukcp_dp
library sets thexlocator
andylocator
attributes of theGridliner
object in cartopy:https://github.com/ukcp-data/ukcp-data-processor/blob/master/ukcp_dp/plotters/utils/_map_utils.py#L431
It copes if a big chunk of the map is selected but if you select a subset, e.g. the size of Wales: then you get this error:
This occurs when the
Gridliner._add_gridline_label()
method is called and the code starts to loop through theself.xlines
andself.ylines
. At this point it finds out thatx_ticks
(and presumably, if too small)y_ticks
is an empty Array - and it fails when callingmin(x_ticks)
.I have worked out how it is possible to get the plots out by unsetting the
xlocator
property. Howevre, there are likely to be side-effects and I'm not sure where the appropriate fix is for this.@antony-wilson: do you know why we needed to set the
xlocator
andylocator
properties of theGridliner
objects?