forked from sunpy/eitwave
/
test_transforms.py
134 lines (98 loc) · 3.44 KB
/
test_transforms.py
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
# Load in multiple noisy realizations of a given simulated wave, and
# characterize the performance of AWARE on detecting the wave
#
import os
import cPickle as pickle
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
import copy
# Main AWARE processing and detection code
import aware
import util
# AWARE utilities
import aware_utils
# Wave simulation code
import test_wave2d
# Simulated wave parameters
import swave_params
# Mapcube handling tools
import mapcube_tools
# Simulated data
# TODO - run the same analysis on multiple noisy realizations of the simulated
# TODO - data. Generate average result plots over the multiple realizations
# TODO - either as relative error or absolute error as appropriate.
# TODO - First mode: use multiple noisy realizations of the same model.
# TODO - Second mode: choose a bunch of simulated data parameters, and then
# TODO - randomly select values for them (within reason).
# TODO - The recovered parameters should be reasonably close to the simulated
# TODO - parameters.
#
#
random_seed = 42
np.random.seed(random_seed)
# Select the wave
#example = 'wavenorm4_slow'
example = 'no_noise_no_solar_rotation_slow'
# What type of output do we want to analyze
mctype = 'finalmaps'
# Number of images
max_steps = 2
# Accumulation in the time direction
accum = 2
# Summing in the spatial directions
spatial_summing = [4, 4]*u.pix
# Radii of the morphological operations
radii = [[5, 5], [11, 11], [22, 22]]
# Position measuring choices
position_choice = 'average'
error_choice = 'width'
# Degree of polynomial to fit
n_degree = 1
# Unraveling factor
unraveling_factor = 1.0
# Output directory
output = '~/eitwave/'
# Output types
otypes = ['img', 'pkl']
# RANSAC
ransac_kwargs = {"random_state": random_seed}
# Special designation: an extra description added to the file and directory
# names in order to differentiate between experiments on the same example wave.
special_designation = ''
# Output directories and filename
odir = os.path.expanduser(output)
otypes_dir = {}
otypes_filename = {}
# Morphological radii
sradii = ''
for r in radii:
for v in r:
sradii = sradii + str(v) + '_'
sradii = sradii[0: -1]
# Load in the wave params
params = swave_params.waves(lon_start=-180 * u.degree + 0.0 * u.degree)[example]
# Unraveling params are different compared to the wave definition params
params_unravel = copy.deepcopy(params)
# Sum over many of the original bins used to create the wave in an attempt to
# beat down transform artifacts
params_unravel['lon_bin'] = unraveling_factor * params['lon_bin']
params_unravel['lat_bin'] = unraveling_factor * params['lat_bin']
# Move zero location of longitudinal reconstruction relative to the
# wavefront
# params_unravel['lon_min'] = params_unravel['lon_min']
# params_unravel['lon_max'] = params_unravel['lon_max']
# Storage for the results
results = []
# Go through all the test waves, and apply AWARE.
# Let the user which trial is happening
print('\nSimulating %s ' % example)
print(' - position choice = %s' % position_choice)
print(' - error choice = %s' % error_choice)
print(' - unraveling factor = %f' % unraveling_factor)
# Simulate the wave and return a dictionary
out = test_wave2d.simulate_wave2d(params=params, max_steps=max_steps,
verbose=True, output=['raw', 'transformed', 'noise', 'finalmaps'])
t0 = out['transformed'][0]
b0 = util.map_hpc_to_hg_rotate(t0, epi_lon=0, epi_lat=0.0, lon_bin=1.0, lat_bin=1.0)