Example #1
0
    def reference_sheval(cls, coords):
        coords_dipole = convert_to_dipole(
            coords, cls.lat_ngp, cls.lon_ngp, cls.source_coordinate_system
        )
        potential = empty(coords_dipole.shape[:-1])
        gradient = empty(coords_dipole.shape)

        iterator = nditer(
            [
                potential,
                gradient[..., 0],
                gradient[..., 1],
                gradient[..., 2],
                coords_dipole[..., 0],
                coords_dipole[..., 1],
                coords_dipole[..., 2],
            ],
            op_flags=[
                ['writeonly'], ['writeonly'], ['writeonly'], ['writeonly'],
                ['readonly'], ['readonly'], ['readonly'],
            ],
        )

        for pot, grd_n, grd_e, grd_r, lat, lon, rad in iterator:
            pot[...], grd_n[...], grd_e[...], grd_r[...] = (
                cls._spherical_harmonics(lat, lon, rad)
            )

        gradient = cls._rotate_gradient(gradient, coords_dipole, coords)

        potential *= cls.scale_potential
        for idx, scale in enumerate(cls.scale_gradient):
            gradient[..., idx] *= scale

        return potential, gradient
Example #2
0
 def reference_vrot_from_dipole(cls, vectors, coords, latitude, longitude):
     coords = asarray(coords)
     rotation_matrix = get_dipole_rotation_matrix(latitude, longitude)
     coords_dipole = convert_to_dipole(coords, latitude, longitude)
     lat_dipole = coords_dipole[..., 0]
     lon_dipole = coords_dipole[..., 1]
     vectors = vrot_sph2cart(vectors, lat_dipole, lon_dipole)
     vectors = dot(vectors, rotation_matrix.transpose())
     if cls.target_coords_type != GEOCENTRIC_CARTESIAN:
         coords_out = convert(
             coords, GEOCENTRIC_SPHERICAL, cls.target_coords_type
         )
         lat_out = coords_out[..., 0]
         lon_out = coords_out[..., 1]
         vectors = vrot_cart2sph(vectors, lat_out, lon_out)
     return vectors
Example #3
0
    def eval_vrot_from_dipole(cls, vectors, coords, latitude, longitude):
        coords = asarray(coords)
        coords_dipole = convert_to_dipole(coords, latitude, longitude)
        lat_dipole = coords_dipole[..., 0]
        lon_dipole = coords_dipole[..., 1]

        if cls.target_coords_type != GEOCENTRIC_CARTESIAN:
            coords_out = convert(
                coords, GEOCENTRIC_SPHERICAL, cls.target_coords_type
            )
            lat_out = coords_out[..., 0]
            lon_out = coords_out[..., 1]
        else:
            lat_out, lon_out = None, None

        return vrot_from_dipole(
            vectors, latitude, longitude, lat_dipole, lon_dipole,
            lat_out, lon_out, cls.target_coords_type
        )
    def reference_sheval(cls, coords):
        coords_dipole = convert_to_dipole(coords, cls.lat_ngp, cls.lon_ngp,
                                          cls.source_coordinate_system)
        potential = empty(coords_dipole.shape[:-1])
        gradient = empty(coords_dipole.shape)

        iterator = nditer(
            [
                potential,
                gradient[..., 0],
                gradient[..., 1],
                gradient[..., 2],
                coords_dipole[..., 0],
                coords_dipole[..., 1],
                coords_dipole[..., 2],
            ],
            op_flags=[
                ['writeonly'],
                ['writeonly'],
                ['writeonly'],
                ['writeonly'],
                ['readonly'],
                ['readonly'],
                ['readonly'],
            ],
        )

        for pot, grd_n, grd_e, grd_r, lat, lon, rad in iterator:
            pot[...], grd_n[...], grd_e[...], grd_r[...] = (
                cls._spherical_harmonics(lat, lon, rad))

        gradient = cls._rotate_gradient(gradient, coords_dipole, coords)

        potential *= cls.scale_potential
        for idx, scale in enumerate(cls.scale_gradient):
            gradient[..., idx] *= scale

        return potential, gradient
 def ref_mjd2000_to_magnetic_universal_time(cls, time, lat_ngp, lon_ngp):
     lat_sol, lon_sol = cls.sunpos(time)
     _, subsol_dip_lon, _ = convert_to_dipole([lat_sol, lon_sol, 1.0],
                                              lat_ngp, lon_ngp)
     return (180.0 - subsol_dip_lon) / 15.0
Example #6
0
 def ref_mjd2000_to_magnetic_universal_time(cls, time, lat_ngp, lon_ngp):
     lat_sol, lon_sol = cls.sunpos(time)
     _, subsol_dip_lon, _ = convert_to_dipole(
         [lat_sol, lon_sol, 1.0], lat_ngp, lon_ngp
     )
     return (180.0 - subsol_dip_lon) / 15.0
Example #7
0
 def eval_convert_to_dipole(coords, latitude, longitude):
     # to avoid pole longitude ambiguity compare Cartesian coordinates
     return convert(
         convert_to_dipole(coords, latitude, longitude),
         GEOCENTRIC_SPHERICAL, GEOCENTRIC_CARTESIAN
     )