plot_test.py 2.23 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.

18
19
20
21
22
23
import nifty5 as ift
import numpy as np


def plot_test():
    rg_space1 = ift.makeDomain(ift.RGSpace((100,)))
Martin Reinecke's avatar
Martin Reinecke committed
24
    rg_space2 = ift.makeDomain(ift.RGSpace((80, 60), distances=1))
25
26
27
28
29
    hp_space = ift.makeDomain(ift.HPSpace(64))
    gl_space = ift.makeDomain(ift.GLSpace(128))

    fft = ift.FFTOperator(rg_space2)

Martin Reinecke's avatar
tweaks    
Martin Reinecke committed
30
31
32
    field_rg1_1 = ift.Field.from_global_data(rg_space1, np.random.randn(100))
    field_rg1_2 = ift.Field.from_global_data(rg_space1, np.random.randn(100))
    field_rg2 = ift.Field.from_global_data(
Martin Reinecke's avatar
Martin Reinecke committed
33
        rg_space2, np.random.randn(80*60).reshape((80, 60)))
Martin Reinecke's avatar
tweaks    
Martin Reinecke committed
34
35
    field_hp = ift.Field.from_global_data(hp_space, np.random.randn(12*64**2))
    field_gl = ift.Field.from_global_data(gl_space, np.random.randn(32640))
36
37
    field_ps = ift.power_analyze(fft.times(field_rg2))

Martin Reinecke's avatar
Martin Reinecke committed
38
    # Start various plotting tests
39

40
41
42
43
44
45
46
47
    plot = ift.Plot()
    plot.add(field_rg1_1, title='Single plot')
    plot.output()

    plot = ift.Plot()
    plot.add(field_rg2, title='2d rg')
    plot.add([field_rg1_1, field_rg1_2], title='list 1d rg', label=['1', '2'])
    plot.add(field_rg1_2, title='1d rg, xmin, ymin', xmin=0.5, ymin=0.,
Martin Reinecke's avatar
tweaks    
Martin Reinecke committed
48
             xlabel='xmin=0.5', ylabel='ymin=0')
49
50
51
52
53
54
55
56
57
    plot.output(title='Three plots')

    plot = ift.Plot()
    plot.add(field_hp, title='HP planck-color', colormap='Planck-like')
    plot.add(field_rg1_2, title='1d rg')
    plot.add(field_ps)
    plot.add(field_gl, title='GL')
    plot.add(field_rg2, title='2d rg')
    plot.output(nx=2, ny=3, title='Five plots')
58

Martin Reinecke's avatar
Martin Reinecke committed
59

60
61
if __name__ == '__main__':
    plot_test()