dstansby / pfsspy

Potential Field Source Surface model package for Python
https://pfsspy.readthedocs.io/
Other
40 stars 17 forks source link

θ and φ coordinates of the magnetic field #329

Closed ckar30 closed 2 years ago

ckar30 commented 2 years ago

How can I get the θ/φ coordinates of the magnetic field and plot a sunpy map object?

dstansby commented 2 years ago

Sorry for taking so long to reply to this! The code inside source_surface_br should help:

# Get radial component at the top
        br = self.bc[0][:, :, -1].to_value(self.bunit)
        # Remove extra ghost cells off the edge of the grid
        m = sunpy.map.Map((br.T, self._wcs_header()))
        if 'bunit' in self.input_map.meta:
            m.meta['bunit'] = self.input_map.meta['bunit']
        vlim = np.max(np.abs(br))
        m.plot_settings['cmap'] = _MAG_CMAP
        m.plot_settings['vmin'] = -vlim
        m.plot_settings['vmax'] = vlim
        return m

If you replace self.bc[0] with 1 or 2 these will be the theta and phi components respectively. I'd be open to adding helper methods similar to source_surface_br() (source_surface_btheta() and source_surface_bphi()) if that would be helpful for you?

ckar30 commented 2 years ago

Thank you very much. That is what I did back then and it worked well. Again thanks for your help.