-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathheaders.py
123 lines (96 loc) · 3.44 KB
/
headers.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
#from pylab import *
import numpy as np
import matplotlib.pyplot as plt
import os
# to copy files
from shutil import copyfile
from scipy import special, optimize, integrate, stats
from scipy.interpolate import UnivariateSpline, RectBivariateSpline, interp1d, interp2d, BarycentricInterpolator
from time import time
import matplotlib.gridspec as gridspec
import matplotlib.ticker as ticker
from matplotlib.colors import LogNorm
import matplotlib.colors as mc
import colorsys
from timeit import timeit
from time import time
from copy import copy
import sys
# For CMB maps
#from enlib import enmap, utils, powspec
from pixell import enmap, utils, powspec, enplot, reproject #, pointsrcs
import healpy as hp
# copy rotfuncs.py somewhere on your python path,
# so you can import it
import rotfuncs
# parallelizing "map"
# version that works when the function is a class module
from pathos.multiprocessing import ProcessingPool as Pool
#from multiprocess import Pool
# Yu Feng's version of multiprocessing, relying on forking rather than pickling
import sharedmem
import vegas # for Monte Carlo integration, for CMB lens reconstruction
#import gvar as gv
from astropy.io import fits # for saving/reeading maps
import colormaps as cmaps # for viridis and plasma colormaps
# to save wav files
from scipy.io import wavfile
# for faster FFT
import pyfftw
pyfftw.interfaces.cache.enable() # so subsequent FFTs use the wisdom from the first one
## however, this wisdom is only kept for 0.1sec, or for x seconds if using:
##pyfftw.interfaces.cache.set_keepalive_time(x)
# neutrino masses: https://github.com/ThomasTram/iCLASS/blob/master/neutrinohierarchy.ipynb
# cosmo doc: https://lesgourg.github.io/class-tour/Narbonne.pdf
#from classy import Class
# http://classylss.readthedocs.io/en/stable/index.html
import classylss
import classylss.binding as CLASS
import healpy as hp
##################################################################################
# for pretty plots
from matplotlib import rc
#rc('font',**{'size':'20','family':'sans-serif','sans-serif':['Computer Modern Sans serif']})
rc('font',**{'size':'22','family':'serif','serif':['CMU serif']})
rc('mathtext', **{'fontset':'cm'})
rc('text', usetex=True)
rc('text.latex', preamble='\usepackage{amsmath}, \usepackage{amssymb}')
#rc('font', size=20)
rc('legend',**{'fontsize':'18'})
# fonty stuffs
#font.serif: CMU Serif
#font.family: serif
#mathtext.fontset: cm
#text.usetex: False
#text.latex.preamble: \usepackage{amsmath}
def darkerLighter(color, amount=0.):
"""
Adapted from https://stackoverflow.com/questions/37765197/darken-or-lighten-a-color-in-matplotlib
Input can be matplotlib color string, hex string, or RGB tuple.
amount=0: color unchanged
amount=-1: returns white
amount=1: returns black
Examples:
>> lighten_color('g', 0.3)
>> lighten_color('#F034A3', 0.6)
>> lighten_color((.3,.55,.1), 0.5)
"""
# force amount between 0. and 1.
amount = min(amount, 1.)
amount = max(amount, -1.)
# read the color
try:
c = mc.cnames[color]
except:
c = color
c = colorsys.rgb_to_hls(*mc.to_rgb(c))
# my Lagrange interpolation polynomial
newC1 = 0.5*amount*(amount-1.) - c[1]*(amount+1.)*(amount-1.)
return colorsys.hls_to_rgb(c[0], newC1, c[2])
##################################################################################
import basic_functions
reload(basic_functions)
from basic_functions import *
import flat_map
reload(flat_map)
from flat_map import *