0

I am trying to find a way to apply the inverse of the Nightshade feature to a map to shade daylight instead of night. enter image description here

Have tried with Basemap and now Cartopy and am having no luck figuring out a way to input date and time and get a daylight shade.

  • See the [docs](https://scitools.org.uk/cartopy/docs/latest/reference/generated/cartopy.feature.nightshade.Nightshade.html#cartopy.feature.nightshade.Nightshade), use argument `date` in `Nightshade` – Wakeme UpNow Feb 21 '23 at 18:30
  • @WakemeUpNow, unless I am misunderstanding, this appears to still be strictly for nighttime shading. – snhousseal Feb 21 '23 at 18:55
  • I misunderstood then. But I think you can still define your own class ([see](https://scitools.org.uk/cartopy/docs/latest/_modules/cartopy/feature/nightshade.html#Nightshade)). Notice that the important part is `geom` definition (which is a `Polygon`). You can invert the polygon by [subtracting](https://stackoverflow.com/questions/61930060/how-to-use-shapely-for-subtracting-two-polygons) the whole square map – Wakeme UpNow Feb 21 '23 at 19:11

1 Answers1

0

As @WakemeUpNow already mentioned in the comments, inverting the current result would do it. It would be nice if the Nighshade class had the position as a method, that would make subclassing real easy, since all it takes is move the position of the sun to the opposite side of the earth.

It isn't now, but you could still copy the entire class and only modify that part. The rest of the implementation, using the RotatedPole projection, is very nice since it allows the coordinates of the boundary to always be the same.

lat, lon = _solar_position(date)

# move "solar" position to the opposite side        
lat = -lat
lon = ((lon + 360) % 360) - 180.

And probably also flip the sign of the (default) refraction keyword if that matter for the application.

enter image description here

Rutger Kassies
  • 61,630
  • 17
  • 112
  • 97