qua_yrange = u.Quantity([ -11.0, 11.0 ] * u.arcsec)

##############################################################################
# The generated data will consist of a 2D space with 2 Gaussian spots, one
# positive and one negative, on a background of 0.0.
# solarbextrapolation.example_data_generator provides many ways to achieve this,
# including letting it randomly generate the position, magnitude and size of
# each spot/pole.

# To randomly generate 2 poles simply don't add any pole parameters:
arr_Data = generate_example_data(arr_grid_shape, qua_xrange, qua_yrange)
# Note: each time you run this pole positions/magnitudes will change.

##############################################################################
# We can now convert this into a a sunpy map object:
aMap = dummyDataToMap(arr_Data, qua_xrange, qua_yrange)

##############################################################################
# We can see this map using peek:
aMap.peek()

##############################################################################
# To manually position poles, simply build lists of parameters for each pole.
# It's often easiest to use percentage units for location/size, wheer we compare
# to the maps region.
# arrA0 = [ Position, size, Max Magnitude ]
arrA0 = [ u.Quantity([ 25, 25 ] * u.percent), 10.0 * u.percent,  0.2 * u.T ]
arrA1 = [ u.Quantity([ 75, 75 ] * u.percent), 10.0 * u.percent, -0.2 * u.T ]

# To generate and view:
arr_Data = generate_example_data(arr_grid_shape, qua_xrange, qua_yrange, arrA0, arrA1)
        self.meta['preprocessor_routine'] = 'Zeros Preprocessor'

        # Creating the trivial zeros map of the same shape as the input map
        map_output = mp.Map((np.zeros(self.map_input.data.shape),
                                    self.meta))

        # Outputting the map.
        return map_output

###########################################################################
# Make an input map that we will run the preprocessor on.
# This will be changed to using the sample HMI image.
# aMap2D = mp.Map('C://git//solarextrapolation//solarextrapolation//data//example_data_(100x100)__01_hmi.fits')
from solarbextrapolation.example_data_generator import generate_example_data, dummyDataToMap
import astropy.units as u
aMap2D = arr_Data = dummyDataToMap(generate_example_data([ 20, 20 ],u.Quantity([ -10.0, 10.0 ] * u.arcsec),u.Quantity([ -10.0, 10.0 ] * u.arcsec)), u.Quantity([ -10.0, 10.0 ] * u.arcsec), u.Quantity([ -10.0, 10.0 ] * u.arcsec))

###########################################################################
# Instansiate the preprocessor and process the input map.
aPrePro = PreZeros(aMap2D.submap([0, 10]*u.arcsec, [0, 10]*u.arcsec))
aPreProMap = aPrePro.preprocess()


###########################################################################
# You can plot the preprocessed map using peek.
aPreProMap.peek()

###########################################################################
# You can also access the metadata of the preprocessor like any map:
print "preprocessor_routine: " + str(aPreProMap.meta['preprocessor_routine'])
print "preprocessor_duration: " + str(aPreProMap.meta['preprocessor_duration'])
# In this case you will manually define the parameters of each spot as a list,
# using percentage units so that the spots will be inside the given ranges of
# any generated data:

# Manual Pole Details
#arrA# = [ position, size, maximum strength ]
arrA0 = [ u.Quantity([ 25, 25 ] * u.percent), 10.0 * u.percent,  0.2 * u.T ]
arrA1 = [ u.Quantity([ 75, 75 ] * u.percent), 10.0 * u.percent, -0.2 * u.T ]

##############################################################################
# You generate the data using generate_example_data(...) and create a map with
# this using dummyDataToMap(...).

# Generate the data and make into a map
arr_data = generate_example_data(arr_grid_shape[0:2], xrange, yrange, arrA0, arrA1)
map_boundary = dummyDataToMap(arr_data, xrange, yrange)

##############################################################################
# You can check the resulting generated data by using peek().
map_boundary.peek()

##############################################################################
# You now simply want to extrapolate using this boundary data, this is achieved
# by first creating a potential extrapolator object and then by running the
# extrapolate on this to return a Map3D object with the resulting vector field.

# Use potential extrapolator to generate field
aPotExt = PotentialExtrapolator(map_boundary, zshape=arr_grid_shape[2], zrange=zrange)
aMap3D  = aPotExt.extrapolate(enable_numba=True)

# The Extrapolations run time is stored in the meta
Beispiel #4
0
# using percentage units so that the spots will be inside the given ranges of
# any generated data:

# Manual Pole Details
#arrA# = [ position, size, maximum strength ]
arrA0 = [u.Quantity([25, 25] * u.percent), 10.0 * u.percent, 0.2 * u.T]
arrA1 = [u.Quantity([75, 75] * u.percent), 10.0 * u.percent, -0.2 * u.T]

##############################################################################
# You generate the data using generate_example_data(...) and create a map with
# this using dummyDataToMap(...).

# Generate the data and make into a map
arr_data = generate_example_data(arr_grid_shape[0:2], xrange, yrange, arrA0,
                                 arrA1)
map_boundary = dummyDataToMap(arr_data, xrange, yrange)

##############################################################################
# You can check the resulting generated data by using peek().
map_boundary.peek()

##############################################################################
# You now simply want to extrapolate using this boundary data, this is achieved
# by first creating a potential extrapolator object and then by running the
# extrapolate on this to return a Map3D object with the resulting vector field.

# Use potential extrapolator to generate field
aPotExt = PotentialExtrapolator(map_boundary,
                                zshape=arr_grid_shape[2],
                                zrange=zrange)
aMap3D = aPotExt.extrapolate(enable_numba=True)
        # Creating the trivial zeros map of the same shape as the input map
        map_output = mp.Map((np.zeros(self.map_input.data.shape), self.meta))

        # Outputting the map.
        return map_output


###########################################################################
# Make an input map that we will run the preprocessor on.
# This will be changed to using the sample HMI image.
# aMap2D = mp.Map('C://git//solarextrapolation//solarextrapolation//data//example_data_(100x100)__01_hmi.fits')
from solarbextrapolation.example_data_generator import generate_example_data, dummyDataToMap
import astropy.units as u
aMap2D = arr_Data = dummyDataToMap(
    generate_example_data([20, 20], u.Quantity([-10.0, 10.0] * u.arcsec),
                          u.Quantity([-10.0, 10.0] * u.arcsec)),
    u.Quantity([-10.0, 10.0] * u.arcsec), u.Quantity([-10.0, 10.0] * u.arcsec))

###########################################################################
# Instansiate the preprocessor and process the input map.
aPrePro = PreZeros(aMap2D.submap([0, 10] * u.arcsec, [0, 10] * u.arcsec))
aPreProMap = aPrePro.preprocess()

###########################################################################
# You can plot the preprocessed map using peek.
aPreProMap.peek()

###########################################################################
# You can also access the metadata of the preprocessor like any map:
print "preprocessor_routine: " + str(aPreProMap.meta['preprocessor_routine'])
print "preprocessor_duration: " + str(aPreProMap.meta['preprocessor_duration'])
qua_yrange = u.Quantity([-11.0, 11.0] * u.arcsec)

##############################################################################
# The generated data will consist of a 2D space with 2 Gaussian spots, one
# positive and one negative, on a background of 0.0.
# solarbextrapolation.example_data_generator provides many ways to achieve this,
# including letting it randomly generate the position, magnitude and size of
# each spot/pole.

# To randomly generate 2 poles simply don't add any pole parameters:
arr_Data = generate_example_data(arr_grid_shape, qua_xrange, qua_yrange)
# Note: each time you run this pole positions/magnitudes will change.

##############################################################################
# We can now convert this into a a sunpy map object:
aMap = dummyDataToMap(arr_Data, qua_xrange, qua_yrange)

##############################################################################
# We can see this map using peek:
aMap.peek()

##############################################################################
# To manually position poles, simply build lists of parameters for each pole.
# It's often easiest to use percentage units for location/size, wheer we compare
# to the maps region.
# arrA0 = [ Position, size, Max Magnitude ]
arrA0 = [u.Quantity([25, 25] * u.percent), 10.0 * u.percent, 0.2 * u.T]
arrA1 = [u.Quantity([75, 75] * u.percent), 10.0 * u.percent, -0.2 * u.T]

# To generate and view:
arr_Data = generate_example_data(arr_grid_shape, qua_xrange, qua_yrange, arrA0,
# You will create an astropy table to store the runtimes of the extrapolations.

# A table for storing the data
t = Table(names=('grid size', 'time (min)', 'time (ave)', 'time (std)'), meta={'name': 'times tables'}, dtype=('S24', 'f8', 'f8', 'f8'))
t['time (min)'].unit = u.s
t['time (ave)'].unit = u.s
t['time (std)'].unit = u.s

##############################################################################
# You will store all the datasets to test with in a list.
# In this case the datasets will simply be the various generated example
# boundary data maps for the list of grid sizes, which is simply one example.
lis_datasets = []
for shape in lis_grid_shapes:
    lis_datasets.append([ str(shape), shape[2], zrange,
                          dummyDataToMap(generate_example_data(shape[0:2], xrange, yrange, arrA0, arrA1, arrA2, arrA3), xrange, yrange) ])

##############################################################################
# You may wish to run each test more than once, so you can use a parameter to
# autimate this.
int_trials = 1 # The times to repeat each extrapolation.

##############################################################################
# You iterate through the extrapolations on each dataset, adding teh runtime to
# the table.
for extrapolation in lis_datasets:
    # Setup the extrapolator and table
    aPotExt = PotentialExtrapolator(extrapolation[3], zshape=extrapolation[1], zrange=extrapolation[2])

    # List to store the trial
    lis_times = []
Beispiel #8
0
          meta={'name': 'times tables'},
          dtype=('S24', 'f8', 'f8', 'f8'))
t['time (min)'].unit = u.s
t['time (ave)'].unit = u.s
t['time (std)'].unit = u.s

##############################################################################
# You will store all the datasets to test with in a list.
# In this case the datasets will simply be the various generated example
# boundary data maps for the list of grid sizes, which is simply one example.
lis_datasets = []
for shape in lis_grid_shapes:
    lis_datasets.append([
        str(shape), shape[2], zrange,
        dummyDataToMap(
            generate_example_data(shape[0:2], xrange, yrange, arrA0, arrA1,
                                  arrA2, arrA3), xrange, yrange)
    ])

##############################################################################
# You may wish to run each test more than once, so you can use a parameter to
# autimate this.
int_trials = 1  # The times to repeat each extrapolation.

##############################################################################
# You iterate through the extrapolations on each dataset, adding teh runtime to
# the table.
for extrapolation in lis_datasets:
    # Setup the extrapolator and table
    aPotExt = PotentialExtrapolator(extrapolation[3],
                                    zshape=extrapolation[1],