[mnseg] improve load option

This commit is contained in:
Noe Brucy
2021-06-25 11:58:33 +02:00
parent a493839f4b
commit a50fb60663
+14 -11
View File
@@ -1,4 +1,4 @@
from pywavan import powspec, nb_scale from pywavan import powspec, fan_trans, nb_scale
from astropy.io import fits from astropy.io import fits
import numpy as np import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
@@ -236,7 +236,7 @@ def load_results(label):
return wav_k, S1a, wt, S11a, q return wav_k, S1a, wt, S11a, q
def analyse_sim(im): def analyse_sim(im, load=False):
""" Do the MnGseg analysis """ """ Do the MnGseg analysis """
meanim = np.mean(im) meanim = np.mean(im)
imzm = im - meanim imzm = im - meanim
@@ -247,16 +247,19 @@ def analyse_sim(im):
label = "final" # label to identify parameter setup label = "final" # label to identify parameter setup
# after a lot of trials I found a fixed q=2 is a good value # after a lot of trials I found a fixed q=2 is a good value
q = [2.0] * nb_scale(imzm.shape) if not load:
# wt, S11a, wav_k, S1a, q = fan_trans(imzm, reso=1, q=q, qdyn=False) q = [2.0] * nb_scale(imzm.shape)
# alternatively you can let pywavan determine it automatically by setting skewl wt, S11a, wav_k, S1a, q = fan_trans(imzm, reso=1, q=q, qdyn=False)
# q=[3.0]*nb_scale(imzm.shape) # alternatively you can let pywavan determine it automatically by setting skewl
# wt, S11a, wav_k, S1a, q = fan_trans(imzm, reso=1, q=q, qdyn=True, skewl=0.4) q = [3.0] * nb_scale(imzm.shape)
# print(q) wt, S11a, wav_k, S1a, q = fan_trans(imzm, reso=1, q=q, qdyn=True, skewl=0.4)
print(q)
# save results because it can be long to calculate (especially if qdyn=True). Remark that wt and S11a are quite big # save results because it can be long to calculate (especially if qdyn=True).
# save_results(wt, S11a, wav_k, S1a, q, label) # Remark that wt and S11a are quite big
wav_k, S1a, wt, S11a, q = load_results(label) save_results(wt, S11a, wav_k, S1a, q, label)
if load:
wav_k, S1a, wt, S11a, q = load_results(label)
# make images of the Gaussian and coherent part # make images of the Gaussian and coherent part
make_images(im, wt, M, meanim, label) make_images(im, wt, M, meanim, label)