Skip to content

Commit 19f2743

Browse files
vatch123nabobalis
authored andcommitted
Implemented the Fourier Normalizing Radial Gradient Filter (#17)
* Implemented the Fourier Normailizing Radial Gradient Filter * Updated the variable name * Added the attenuation coefficients * Updated the docstrings * Updated docs, Added tests * added the changelog file * Fixed PEP8 issues * Update sunkit_image/offlimb_enhance.py Co-Authored-By: vatch123 <39871718+vatch123@users.noreply.github.com> * Update sunkit_image/offlimb_enhance.py Co-Authored-By: vatch123 <39871718+vatch123@users.noreply.github.com> * Update sunkit_image/offlimb_enhance.py Co-Authored-By: vatch123 <39871718+vatch123@users.noreply.github.com> * Update sunkit_image/offlimb_enhance.py Co-Authored-By: vatch123 <39871718+vatch123@users.noreply.github.com> * Apply suggestions from code review Co-Authored-By: vatch123 <39871718+vatch123@users.noreply.github.com> * Updated the tests * Changed the test images to ones with radial profiles * Added one more test to NRGF * Spelling Corrected * Minor fixes * Tests added to FNRGF * Apply suggestions from code review Co-Authored-By: Nabil Freij <nabil.freij@gmail.com> * Changed the way test maps are created * Fixed the confest.py * Modules and functions renamed * FIxed a corner case * Added examples * FIxed the docs file of offlimb * Fixed the doc file again * Minor fixes * Applied the suggestion * Fixed the examples * Removed offlimb_enhance * fixed indentation and tests * Added figure tests * marker for future tests * Minor changes * Capitalized "Fourier" * Apply suggestions from code review Co-Authored-By: Nabil Freij <nabil.freij@gmail.com> * Made changes to the offlimb file Co-Authored-By: Nabil Freij <nabil.freij@gmail.com> * CHanged to radial * Renamed test file * Added test for helpers * Fixed the examples and figure hashes * fixed hash value * Docs fixed * Apply suggestions from code review Co-Authored-By: Nabil Freij <nabil.freij@gmail.com> * added tests * Apply suggestions from code review Co-Authored-By: Nabil Freij <nabil.freij@gmail.com> * Added the coefficient function and doc changes * Docs formatting done * Added tests for warning
1 parent 1184476 commit 19f2743

File tree

12 files changed

+899
-296
lines changed

12 files changed

+899
-296
lines changed

changelog/17.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a new function (`sunkit_image.radial.fnrgf`) to normalize the radial brightness gradient using a Fourier approximation.

docs/code_ref/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Code Reference
88
:maxdepth: 2
99

1010
sunkit_image
11-
offlimb_enhance
11+
radial
1212
utils

docs/code_ref/offlimb_enhance.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/code_ref/radial.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
******
2+
radial
3+
******
4+
5+
This package implements radial enhancement routines for solar physics data.
6+
7+
.. automodapi:: sunkit_image.radial
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
=======================
3+
Radial Gradient Filters
4+
=======================
5+
6+
This example applies both the normalizing radial gradient (`sunkit_image.radial.nrgf`) filter and Fourier
7+
normalizing radial gradient filter (`sunkit_image.radial.fnrgf`) to a sunpy map.
8+
"""
9+
# sphinx_gallery_thumbnail_number = 3
10+
11+
import numpy as np
12+
import matplotlib.pyplot as plt
13+
14+
import astropy.units as u
15+
16+
import sunpy.map
17+
import sunpy.data.sample
18+
19+
import sunkit_image.radial as radial
20+
from sunkit_image.utils import equally_spaced_bins
21+
22+
###########################################################################
23+
# Sunpy's sample data contain a number of suitable FITS files for this purpose.
24+
aia_map = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
25+
26+
# The original image is plotted to showcase the difference.
27+
fig = plt.figure()
28+
ax = plt.subplot(projection=aia_map)
29+
aia_map.plot()
30+
31+
###########################################################################
32+
# Both the NRGF and FNRGF work on radial segments above their application radius.
33+
# Here we create those segments radial segments. Each segment created will be of
34+
# equal dimensions radially. The distance between 1 solar radii and 2 solar radii
35+
# is divided into 100 equal parts by the following two lines.
36+
radial_bin_edges = equally_spaced_bins()
37+
radial_bin_edges *= u.R_sun
38+
39+
# The NRGF filter is applied after it.
40+
out1 = radial.nrgf(aia_map, radial_bin_edges)
41+
42+
# The NRGF filtered map is plotted.
43+
# The image seems a little washed out so you may need to change some plotting settings
44+
# for a clearer output.
45+
fig = plt.figure()
46+
ax = plt.subplot(projection=out1)
47+
out1.plot()
48+
49+
###########################################################################
50+
# We will need to work out a few parameters for the FNRGF.
51+
# Order is the number of Fourier coefficients to be used in the approximation.
52+
# The attentuation coefficient are calculated to be linearly decreasing, you should
53+
# choose them according to your requirements.
54+
order = 20
55+
attenuation_coefficients = radial.set_attenuation_coefficients(order)
56+
57+
# The FNRGF filter is applied after it.
58+
out2 = radial.fnrgf(aia_map, radial_bin_edges, order, attenuation_coefficients)
59+
60+
# The FNRGF filtered map is plotted.
61+
fig = plt.figure()
62+
ax = plt.subplot(projection=out2)
63+
out2.plot()
64+
65+
# All the figures are plotted.
66+
plt.show()

sunkit_image/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import tempfile
55
import warnings
66
import importlib
7-
from sys import version_info
87

98
import pytest
109

sunkit_image/offlimb_enhance.py

Lines changed: 0 additions & 284 deletions
This file was deleted.

0 commit comments

Comments
 (0)