Closed billetd closed 7 months ago
Test code for MultiLineStrings: it's more on the user right now to figure out how to put data into the functions. If in the future we decide to include the 50m option of plotting for cartopy coastlines in a function we will have to add something similar into the functions, for now this is fine and when we come across that bridge this comment is here.
# Use case with cartopy installed
import cartopy.feature as cfeature
import datetime as dt
from pydarn.plotting.projections import convert_geo_coastline_to_mag
from shapely.geometry import mapping
# Set a time, required for the magnetic conversion
time = dt.datetime(2024, 1, 18, 0 ,0)
# Read in the geometry object of the coastlines
cc = cfeature.NaturalEarthFeature('physical', 'coastline', '50m',
color='k', zorder=2.0)
# Iterate over the geometry objects (with coordinates in geographic) and send them to get converted
for geom in cc.geometries():
if geom.__class__.__name__ == 'MultiLineString':
for g in geom.geoms:
coastline_mlt = convert_geo_coastline_to_mag(g, time)
coastline_mlon = convert_geo_coastline_to_mag(g, time, mag_lon=True)
mlt, mlat = coastline_mlt.coords.xy[0], coastline_mlt.coords.xy[1]
mlon, mlat = coastline_mlon.coords.xy[0], coastline_mlon.coords.xy[1]
else:
coastline_mlt = convert_geo_coastline_to_mag(geom, time)
coastline_mlon = convert_geo_coastline_to_mag(geom, time, mag_lon=True)
mlt, mlat = coastline_mlt.coords.xy[0], coastline_mlt.coords.xy[1]
mlon, mlat = coastline_mlon.coords.xy[0], coastline_mlon.coords.xy[1]
Happy to merge when above suggestions are resolved.
Scope
This PR adds an option for outputting coastlines in geomagnetic longitude. Previously,
convert_geo_coastline_to_mag
(Cartopy version) andconvert_coastline_list_to_mag
(non-Cartopy) could only produce mlat-MLT coordinates. Now there is an option to not do the MLT rotation and produce mlat-mlon coordinates. It is off by default to not disrupt default plotting.As there is currently no polar projections which use magnetic longitude, this currently has no default use in pyDARN. When/if projections using mlon are set up, these can be used to get coastlines correctly.
Test