PFSS model in python

527 views
Skip to first unread message

Mayur Ingale

unread,
Aug 23, 2016, 6:57:27 AM8/23/16
to SunPy
PFSS (Potential Field Source Surface) model takes synoptic magnetogram with source surface (typically 2.5 Radius of Sun) and returns the 3D magnetic field, so called hairy ball Sun. This package is available with SSW-IDL. Is there similar package available with Python (Sunpy) ?

Alex Hamilton

unread,
Aug 23, 2016, 7:46:07 AM8/23/16
to SunPy
Hiya,
For coronal magnetic field extrapolation we have an affiliated package on GitHub:
https://github.com/sunpy/solarbextrapolation
This however is only currently designed to work with small regions on the Sun, where the volume is approximated cuboid voxels (with euclidean coordinates) over a magnetogram.
Will this do what you want or are you looking at a full-surface version?

Mayur Ingale

unread,
Aug 24, 2016, 1:52:48 AM8/24/16
to SunPy
HI, 
thank you Alex

I have gone through solarbextrapolation and it will be good if i can get some detailed documentation for how to use it (I have necessary packages installed - mayavi, sunpy, solarbextrapolation). 

It is helpful but yea I am looking for full surface version, where synoptic magnetograms are the input to extrapolate magnetic field (potential field)

Alex Hamilton

unread,
Aug 24, 2016, 6:49:09 PM8/24/16
to SunPy
I'm sorry to say ATM it's not capable of the full surface extrapolation, it was a restriction on the project.

WRT documentation, there is a comprehensive set of examples here:
https://github.com/sunpy/solarbextrapolation/tree/master/examples
I suggest you start by trying some of those and I can answer any specific questions or changes needed.

I'll look into writing up a guide in the next few days if that helps?

Thanks
    Alex

Mayur Ingale

unread,
Aug 26, 2016, 12:05:14 PM8/26/16
to SunPy
Hi, Thanks Alex, I am going through the examples and looking forward to further communication.

David Stansby

unread,
Sep 4, 2018, 5:12:39 PM9/4/18
to SunPy
I've just been looking around for PFSS extrapolations in python; it looks like Anthony Yeats from Durham has produced a python implementation in the last couple of years: https://github.com/antyeates1983/pfss , which might be of interest.

Will Barnes

unread,
Sep 6, 2018, 7:08:25 PM9/6/18
to SunPy
Thanks for posting this David. I was not aware of that implementation. Having a well-maintained field extrapolation framework in Python would be of huge benefit to the community. This is the intent behind the solarbextrapolation package, but it has fallen a bit by the wayside.

Mohamed Nedal

unread,
Jun 13, 2020, 1:19:29 AM6/13/20
to SunPy
Hi, I intend to use the PFSS package in a paper and I would like to understand it. I would appreciate if you could help me with the following questions. 

In the example code "Overplotting field lines on AIA maps" (https://pfsspy.readthedocs.io/en/stable/auto_examples/using_pfsspy/plot_aia_overplotting.html#sphx-glr-auto-examples-using-pfsspy-plot-aia-overplotting-py): 

1. The "output" object, which contains the PFSS solution, has these parameters (alr, als, alp, al, bc, bg). I don't really understand what they actually refer to. I looked into the documentation here (https://pfsspy.readthedocs.io/en/stable/api/pfsspy.Output.html#pfsspy.Output.bc), but I didn't get their meaning and how we can use them afterwards. 

2. "bc" is a tuple with three elements; the size of bc[0] is (360,180,26); the size of bc[1] is (360,181,25); and the size of bc[2] is (361,180,25); What are these numbers? 

3. In the "fline" object, What do the following three paths mean (fline._x, fline._y, fline._z)? 

4. In the "flines" object: 
    4.1. Does this path "flines.field_lines" refer to the number of the created field lines? 
    4.2. Does this path "flines.open_field_lines" refer to the number of open field lines? 
    4.3. Does this path "flines.closed_field_lines" refer to the number of closed field lines? 

5. How can I extract B(x, y, z) and the coordinates (lat, lon, height) for each field line? 

Thank you very much for your time and I'm looking forward to your answers. 

David Stansby

unread,
Jun 16, 2020, 5:47:26 AM6/16/20
to su...@googlegroups.com
Hi Mohamed,

Thanks for the feedback, it's always helpful to find out what is and isn't obvious to others! To answer your questions:

1. alr, als, alp are more implementation details as opposed to useful user facing variables. I'll hide the al property from the docs to avoid this confusion in future. bc and bg are the magnetic field values that are calculated by the solver. bc is the magnetic field on the centers of the solution grid faces, and bg is the magnetic field on the corners of the grid.

2. I think I changed this recently to remove ghost cells, and make each one of these have the same size - if you update pfsspy to the latest version are they still different shapes? The numbers index the different dimensions (phi, s, r) in the computed solution. You can get the physical locations of each point in the array using the Input.grid attribute: thttps://pfsspy.readthedocs.io/en/stable/api/pfsspy.Grid.html#pfsspy.Grid.

3. Variables/properties with an underscore are generally considered 'private' or not user facing in python, so I wouldn't recommend using these.

4. I don't think flines has a field_lines property, so I'm confused by this? The open_field_lines and closed_field_lines properties store the subset of field lines within the original flines object that are open/closed respectively.

5. To get the coordinates of each field line, you can do fline.coords, which will return an astropy coordinates object. There is more information on how to use those here: https://docs.astropy.org/en/stable/coordinates/index.html. It is currently not possible to get B(x, y, z) along a field line; if this is functionality you would be interested in, then please do open an issue at https://github.com/dstansby/pfsspy/issues.

I hope that helps? If anything is unclear or you have more questions let me know!

Cheers,
David

--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sunpy/35343bd2-8352-4bb6-919e-398cd7743ea9o%40googlegroups.com.

Mohamed Nedal

unread,
Jun 20, 2020, 1:18:39 AM6/20/20
to SunPy
Hi Dr. David, 

I have added a few modifications to the main example code, kindly find the attached file. 

1. Understood. 

2. Partially understood. 
    2.1. I have the latest version of pfsspy (0.5.2), however, the three elements of the 'bc' tuple still have different shapes. 
    2.2. At line 228, I have added some lines to plot 'bc'. It gives a series of plots for each tuple inside 'bc', very similar to the synoptic map. I think the number of the generated plots is the same as the number of grid points in 'rho', but I don't know what is their meaning. Do the colors refer to the distribution of the magnetic field strength? and Why does the color distribution vary with the progression of the for-loop? 
    2.3. What is the physical meaning of (phi, s, rho); rho = ln(r)? 

3. Understood. 

4. Partially understood. 
    4.1. I checked 'flines' and it does have a parameter called 'field_lines', which's the list of `FieldLine`. I noted that it's the same number as 'nrho', so does it refer to the number of the generated field lines in the computational grid? 
    4.2. Could you elaborate on 'open_field_lines' and 'closed_field_lines' properties? 

5. Partially understood. 
    5.1. I didn't get how 'fline.coords' gives the coordinates of each field line. 
    5.2. At line 253, I put this line: flines_coords = [Lat, Long, Radial_distance], and I noted that the 3 elements have the same length of 19, so what does this number refer to? 
    5.3. I have opened a new issue regarding B(x,y,z): https://github.com/dstansby/pfsspy/issues/201 

Thank you so much for your help and I look forward to your comments. 

Best regards, 
Mohamed 

On Tuesday, June 16, 2020 at 11:47:26 AM UTC+2, David Stansby wrote:
Hi Mohamed,

Thanks for the feedback, it's always helpful to find out what is and isn't obvious to others! To answer your questions:

1. alr, als, alp are more implementation details as opposed to useful user facing variables. I'll hide the al property from the docs to avoid this confusion in future. bc and bg are the magnetic field values that are calculated by the solver. bc is the magnetic field on the centers of the solution grid faces, and bg is the magnetic field on the corners of the grid.

2. I think I changed this recently to remove ghost cells, and make each one of these have the same size - if you update pfsspy to the latest version are they still different shapes? The numbers index the different dimensions (phi, s, r) in the computed solution. You can get the physical locations of each point in the array using the Input.grid attribute: thttps://pfsspy.readthedocs.io/en/stable/api/pfsspy.Grid.html#pfsspy.Grid.

3. Variables/properties with an underscore are generally considered 'private' or not user facing in python, so I wouldn't recommend using these.

4. I don't think flines has a field_lines property, so I'm confused by this? The open_field_lines and closed_field_lines properties store the subset of field lines within the original flines object that are open/closed respectively.

5. To get the coordinates of each field line, you can do fline.coords, which will return an astropy coordinates object. There is more information on how to use those here: https://docs.astropy.org/en/stable/coordinates/index.html. It is currently not possible to get B(x, y, z) along a field line; if this is functionality you would be interested in, then please do open an issue at https://github.com/dstansby/pfsspy/issues.

I hope that helps? If anything is unclear or you have more questions let me know!

Cheers,
David

On Sat, 13 Jun 2020 at 06:19, Mohamed Nedal <mohamed....@gmail.com> wrote:
Hi, I intend to use the PFSS package in a paper and I would like to understand it. I would appreciate if you could help me with the following questions. 

In the example code "Overplotting field lines on AIA maps" (https://pfsspy.readthedocs.io/en/stable/auto_examples/using_pfsspy/plot_aia_overplotting.html#sphx-glr-auto-examples-using-pfsspy-plot-aia-overplotting-py): 

1. The "output" object, which contains the PFSS solution, has these parameters (alr, als, alp, al, bc, bg). I don't really understand what they actually refer to. I looked into the documentation here (https://pfsspy.readthedocs.io/en/stable/api/pfsspy.Output.html#pfsspy.Output.bc), but I didn't get their meaning and how we can use them afterwards. 

2. "bc" is a tuple with three elements; the size of bc[0] is (360,180,26); the size of bc[1] is (360,181,25); and the size of bc[2] is (361,180,25); What are these numbers? 

3. In the "fline" object, What do the following three paths mean (fline._x, fline._y, fline._z)? 

4. In the "flines" object: 
    4.1. Does this path "flines.field_lines" refer to the number of the created field lines? 
    4.2. Does this path "flines.open_field_lines" refer to the number of open field lines? 
    4.3. Does this path "flines.closed_field_lines" refer to the number of closed field lines? 

5. How can I extract B(x, y, z) and the coordinates (lat, lon, height) for each field line? 

Thank you very much for your time and I'm looking forward to your answers. 

On Tuesday, August 23, 2016 at 12:57:27 PM UTC+2, Mayur Ingale wrote:
PFSS (Potential Field Source Surface) model takes synoptic magnetogram with source surface (typically 2.5 Radius of Sun) and returns the 3D magnetic field, so called hairy ball Sun. This package is available with SSW-IDL. Is there similar package available with Python (Sunpy) ?

--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to su...@googlegroups.com.
plot_aia_overplotting_Modified.py
Reply all
Reply to author
Forward
0 new messages