File: coordinates.py

package info (click to toggle)
sunpy 7.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,592 kB
  • sloc: python: 41,765; ansic: 1,710; makefile: 39
file content (85 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from asv_runner.benchmarks.mark import SkipNotImplemented

import astropy.units as u
from astropy.coordinates import HCRS, ITRS, HeliocentricMeanEcliptic, SphericalRepresentation

import sunpy.coordinates.frames as f


class TransformationHeliographic:
    frame_names = ['HCRS', 'HGS', 'HGC', 'HCC', 'HPC', 'HPR', 'HCI']

    params = (frame_names, frame_names)
    param_names = ['src', 'dest']

    def setup_cache(self):
        obstime = '2023-01-01'
        vect = SphericalRepresentation(0*u.deg, 0*u.deg, 1*u.AU)
        observer = f.HeliographicStonyhurst(vect, obstime=obstime)
        frames = {
            'HCRS': HCRS(vect, obstime=obstime),
            'HGS': f.HeliographicStonyhurst(vect, obstime=obstime),
            'HGC': f.HeliographicCarrington(vect, obstime=obstime, observer=observer),
            'HCC': f.Heliocentric(vect, obstime=obstime, observer=observer),
            'HPC': f.Helioprojective(vect, obstime=obstime, observer=observer),
            'HPR': f.HelioprojectiveRadial(vect, obstime=obstime, observer=observer),
            'HCI': f.HeliocentricInertial(vect, obstime=obstime),
        }
        return frames

    def setup(self, frames, src, dest):
        if src == dest:
            raise SkipNotImplemented

    def time_transform(self, frames, src, dest):
        frames[src].transform_to(frames[dest])


class TransformationEcliptic:
    frame_names = ['HAE', 'HEE', 'GSE', 'GEI']

    params = (frame_names, frame_names)
    param_names = ['src', 'dest']

    def setup_cache(self):
        obstime = '2023-01-01'
        vect = SphericalRepresentation(0*u.deg, 0*u.deg, 1*u.AU)
        frames = {
            'HAE': HeliocentricMeanEcliptic(vect, obstime=obstime, equinox='J2000'),
            'HEE': f.HeliocentricEarthEcliptic(vect, obstime=obstime),
            'GSE': f.GeocentricSolarEcliptic(vect, obstime=obstime),
            'GEI': f.GeocentricEarthEquatorial(vect, obstime=obstime, equinox='J2000'),
        }
        return frames

    def setup(self, frames, src, dest):
        if src == dest:
            raise SkipNotImplemented

    def time_transform(self, frames, src, dest):
        frames[src].transform_to(frames[dest])


class TransformationMagnetic:
    frame_names = ['GEO', 'MAG', 'SM', 'GSM']

    params = (frame_names, frame_names)
    param_names = ['src', 'dest']

    def setup_cache(self):
        obstime = '2023-01-01'
        vect = SphericalRepresentation(0*u.deg, 0*u.deg, 1*u.AU)
        frames = {
            'GEO': ITRS(vect, obstime=obstime),
            'MAG': f.Geomagnetic(vect, obstime=obstime),
            'SM': f.SolarMagnetic(vect, obstime=obstime),
            'GSM': f.GeocentricSolarMagnetospheric(vect, obstime=obstime),
        }
        return frames

    def setup(self, frames, src, dest):
        if src == dest:
            raise SkipNotImplemented

    def time_transform(self, frames, src, dest):
        frames[src].transform_to(frames[dest])