-
-
Notifications
You must be signed in to change notification settings - Fork 7
Adaption of example plotting open closed #112
Description
Provide a general description of the issue or problem.
Hi,
I have been working with the PFSS model, and the example showing the open closed flux (https://docs.sunpy.org/projects/sunkit-magex/en/stable/generated/gallery/using_sunkit_magex_pfss/open_closed_field_map.html) led to an issue, which took me some time to figure out.
The issue is the open closed flux map is not on the same grid as the gong map. This make direct comparision of the two, e.g., overplotting of contours, complicated. There is an easy fix that can align the two, which I think would make it clearer.
I would suggest changing the example.
The new portion of the code is (without imports):
pfss_in = pfss.Input(gong_map, nrho, rss)
pfss_out = pfss.pfss(pfss_in)
# Here the gong coordinates are used to make the seeds
coords = all_coordinates_from_map(gong_map)
hgc = coords.transform_to('heliographic_carrington')
lon2d = hgc.lon.wrap_at(360*u.deg)
lat2d = hgc.lat
r = np.full(ny*nx, 1.01) * u.solRad
seeds = SkyCoord(lon2d.ravel(), lat2d.ravel(), r, frame=pfss_out.coordinate_frame)
tracer = tracing.PerformanceTracer()
field_lines = tracer.trace(seeds, pfss_out)
pols = field_lines.polarities.reshape(ny,nx)
wcs_header = gong_map.wcs.to_header(relax=True)
wcs_header['NAXIS'] = 2
wcs_header['NAXIS1'] = pols.shape[1]
wcs_header['NAXIS2'] = pols.shape[0]
wcs_header['BTYPE'] = 'polarity'
wcs_header['BUNIT'] = ''
pols_map = sunpy.map.Map(pols.astype(float), wcs_header)
pols_map.plot_settings['cmap'] = mcolor.ListedColormap(['tab:red', 'black', 'tab:blue'])
This leads to a polarity map that follows the gong map, enabling direction comparison. Some of this code might be superfluous.
Maybe I have missed the intention of the example. Let me know what you think.
Richard