def _extrapolation(self):
        # Adding in custom parameters to the meta
        self.meta['extrapolator_routine'] = 'Ones Extrapolator'

        #arr_4d = np.ones([self.map_boundary_data.data.shape[0], self.map_boundary_data.data.shape[0], self.z, 3])
        arr_4d = np.ones(self.shape.tolist() + [3])
        return Map3D(arr_4d, self.meta)
Example #2
0
    def _extrapolation(self, **kwargs):
        """
        The method for running an extrapolation routine.
        This is the primary method to be edited in subclasses for specific
        extrapolation routine implementations.
        """
        # Add some type checking, we want a map object, check for .unit attribute.
        # Extrapolation code goes here.
        arr_4d = np.zeros([
            self.map_boundary_data.data.shape[0],
            self.map_boundary_data.data.shape[1], 1, 3
        ])

        # Calculate the ranges in each dimension in length units (meters)
        x_range = self._angle_to_length(self.xrange)
        y_range = self._angle_to_length(self.yrange)
        z_range = self.zrange

        # Turn the 4D array into a Map3D object.
        map_output = Map3D(arr_4d,
                           self.meta,
                           xrange=x_range,
                           yrange=y_range,
                           zrange=z_range,
                           xobsrange=self.xobsrange,
                           yobsrange=self.yobsrange)

        return map_output
Example #3
0
    def __init__(self, **kwargs):
        # Default grid shape and physical ranges for the volume the model covers.
        self.shape = kwargs.get('shape',
                                u.Quantity([5, 5, 5] * u.pixel))  # (x,y,z)
        self.xrange = kwargs.get('xrange', u.Quantity([-10, 10] * u.Mm))
        self.yrange = kwargs.get('yrange', u.Quantity([-10, 10] * u.Mm))
        self.yrange = kwargs.get('zrange', u.Quantity([0, 20] * u.Mm))

        # Metadata
        self.meta = {
            'ZNAXIS': 3,
            'ZNAXIS1': self.shape[0].value,
            'ZNAxXIS2': self.shape[0].value,
            'ZNAXIS3': self.shape[0].value
        }
        self.meta['analytical_model_notes'] = kwargs.get('notes', '')
        self.meta['BUNIT'] = kwargs.get('bunit', u.T)
        # CRVALn, CDELTn and NAXIS (alreadu in meta) used for storing range in 2D fits files.
        self.filepath = kwargs.get('filepath', None)
        self.routine = kwargs.get('analytical_model_routine', type(self))

        # Default 3D magnetic field
        #X,Y,Z = np.zeros(self.shape.value), np.zeros(self.shape.value), np.zeros(self.shape.value)
        npField = np.zeros([3] + self.shape.value)
        self.field = Map3D(npField, self.meta)

        # Default magnetic field on boundary
        magnetogram = np.zeros(self.shape[0:2].value)
        magnetogram_header = {
            'ZNAXIS': 2,
            'ZNAXIS1': self.shape[0].value,
            'ZNAXIS2': self.shape[1].value
        }
        self.magnetogram = sunpy.map.Map((magnetogram, magnetogram_header))
Example #4
0
        def _generate_field(self, **kwargs):
            # Adding in custom parameters to the metadata
            self.meta['analytical_model_routine'] = 'Ones Model'

            # Generate a trivial field and return (X,Y,Z,Vec)
            arr_4d = np.ones(self.shape.value.tolist() + [3])
            return Map3D(arr_4d, self.meta)
    def _extrapolation(self, enable_numba=True, **kwargs):
        """
        Override the primary execution method from the extrapolation class.
        The process is to extrapolate the potential (scalar) field (phi) and
        then use numerical differentiation (gradient) to find the vector field
        (Bxyz).
        """

        if enable_numba:
            # Test that numba and the numba'ed extrpolator can be imported
            try:
                import numba
                from potential_field_extrapolator_numba import phi_extrapolation_numba
            except ImportError:
                enable_numba = False

        phi = self._extrapolate_phi(enable_numba, **kwargs)

        if enable_numba:
            from numba.decorators import autojit
            determine_vec = autojit(self._determine_vec)
        else:
            determine_vec = self._determine_vec

        npmVecSpace = np.zeros(list(phi.shape) +
                               [3])  # in Order XYZC (C = component directions)
        Bxyz = determine_vec(phi, 1, npmVecSpace)

        return Map3D(Bxyz,
                     self.meta,
                     xrange=self.xrange,
                     yrange=self.yrange,
                     zrange=self.zrange)
Example #6
0
    def _generate_field(self, **kwargs):
        # Adding in custom parameters to the metadata
        self.meta['analytical_model_routine'] = 'Ones Model'

        # Generate a trivial field and return (X,Y,Z,Vec)
        arr_4d = np.ones(self.shape.value.tolist() + [3])
        self.field = arr_4d

        # Extract the LoS Magnetogram from this:
        self.magnetogram.data = arr_4d[:, :, 0, 2]

        # Now return the vector field.
        return Map3D(arr_4d, self.meta)
Example #7
0
    def _generate_field(self, **kwargs):
        """
        The method for running a model to generate the field.
        This is the primary method to be edited in subclasses for specific
        model implementations.
        """
        # Model code goes here.
        arr_4d = np.zeros([
            self.map_boundary_data.data.shape[0],
            self.map_boundary_data.data.shape[1], 1, 3
        ])

        # Turn the 4D array into a Map3D object.
        map_output = Map3D(arr_4d,
                           self.meta,
                           xrange=self.xrange,
                           yrange=self.yrange,
                           zrange=self.zrange,
                           xobsrange=self.xrange,
                           yobsrange=self.yrange)

        return map_output
def test_create_vector_Map3d():
     aNumpyArray = np.zeros((2,2,2,2))
     aMetaDict = { 'file': 'test Map3D object'}
     aMap3D = Map3D(aNumpyArray, aMetaDict)
     assert not is_scalar
     return aMap3D
        def _extrapolation(self):
            # Adding in custom parameters to the meta
            self.meta['extrapolator_routine'] = 'Zeros Extrapolator'

            arr_4d = np.zeros([self.map_boundary_data.data.shape[0], self.map_boundary_data.data.shape[0], self.z, 3])
            return Map3D( arr_4d, self.meta )