Commit 5a9c380e authored by bepinat's avatar bepinat

Bug correction in multi-components fitting

parent 06bcf6a8
Pipeline #1076 failed with stages
......@@ -854,6 +854,7 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal
contind = [i for i in range(len(parinfo), len(parinfo) + conf['DGCTNUM'] + 1)]
for i in range(conf['DGCTNUM'] + 1):
parinfo.append(copy.deepcopy(parbase))
components = np.append(components, -1)
params = np.zeros(len(parinfo), dtype='>f4')
for i in range(len(parinfo)):
params[i] = parinfo[i]['value']
......@@ -901,10 +902,10 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal
#Parameters initialisation
p = np.copy(params)
#Line intensity initisalisation
#Line intensity initialisation
for i in intind:
if parinfo[i]['fixed'] == 0:
p[i] = 5 * std * 10 ** (- components[i] + 1)
p[i] = 5 * std * 10 ** (- components[i] + 1.)
#for i in range(els.index):
#if parinfo[2 * els.index + i]['fixed'] == 0: p[2 * els.index + i] = 2 * std
......@@ -1207,6 +1208,8 @@ def camel(filename, plot=False, debug=False, free_ratio=False, multi_comp=1, mul
#Reading of configuration file
logger.info("Reading configuration file " + filename)
try:
if filename == '':
filename = None
conf = readconfig(filename, config)
except:
logger.info("Configuration file problem")
......
......@@ -33,7 +33,7 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T
lines: string
indicates which lines to fit: 'ha' for Halpha, 'hb' for Hbeta, 'hg' for Hgamma, 'hd' for Hdelta, 'n2' for NII6548 and NII6583, 's2' for SII6716 and SII6731, 'o2' for OII, 'o3' for OIII4959 and OIII5007. The concatenation of several lines is possible to fit several lines.
suffixeout: string
suffixe for the output configartion file name
suffixe for the output configuration file name
commonw: bool
specifies if a common width has to be used for the various lines
dz: float
......@@ -53,13 +53,13 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T
sclip: int
sigma clipping threshold (sclip * sigma) to clean the cube
xyclip: int
size of the local bos for the sigma-clipping (in pixels)
size of the local box for the sigma-clipping (in pixels)
nclip: int
number of pass for the sigma-clipping
number of passes for the sigma-clipping
wsmooth: int
spectral smooth method
ssmooth: float
gaussian spatial smooth FWHM in pixels
Gaussian spatial smooth FWHM in pixels
'''
#ipdb.set_trace()
......@@ -174,6 +174,8 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T
fo.write('REDMIN = ' + str(line['Z'] - dz) + ' / minimum redshift\n')
fo.write('REDMAX = ' + str(line['Z'] + dz) + ' / maximum redshift\n')
else:
fo.write('REDMIN = ' + str(line['Z'] - 0.1) + ' / minimum redshift\n')
fo.write('REDMAX = ' + str(line['Z'] + 0.1) + ' / maximum redshift\n')
logger.error('dz must be not None and non-zero')
fo.write('INITW = ' + str(initw) + ' / initial linewidth in km/s during the line fitting process \n')
......
......@@ -654,7 +654,7 @@ def buildmaps(conf, data, hdr, var=None, plot=False, debug=False, free_ratio=Fal
linewaves = np.append(linewaves, linewave)
components = np.append(components, np.ones(len(parinfom), dtype='i') * (comp + 1))
#Continuum parametres
#Continuum parameters
parbase = {'value': 0., 'fixed': 0, 'limited': [0, 0], 'limits': [0., 0.], 'tied': '', 'mpmaxstep': 0, 'mpminstep': 0, 'parname': ''}
if conf['DGCTNUM'] == -1: # case without continuum
conf['DGCTNUM'] = 0
......@@ -665,6 +665,7 @@ def buildmaps(conf, data, hdr, var=None, plot=False, debug=False, free_ratio=Fal
contind = [i for i in range(len(parinfo), len(parinfo) + conf['DGCTNUM'] + 1)]
for i in range(conf['DGCTNUM'] + 1):
parinfo.append(copy.deepcopy(parbase))
components = np.append(components, -1)
params = np.zeros(len(parinfo), dtype='>f4')
for i in range(len(parinfo)):
params[i] = parinfo[i]['value']
......@@ -699,12 +700,12 @@ def buildmaps(conf, data, hdr, var=None, plot=False, debug=False, free_ratio=Fal
#Parameters initialisation
p = np.copy(params)
#Line intensity initisalisation
#Line intensity initialisation
for i in intind:
if parinfo[i]['fixed'] == 0:
p[i] = 5 * std * 10 ** (- components[i] + 1)
p[i] = 5 * std * 10 ** (- components[i] + 1.)
#Inititalisation of continuum (degree 0)
#Initialisation of continuum (degree 0)
if not contfixed:
p[contind[0]] = np.median(fa['spectrum'])
for z in np.arange(zzmin, zzmax, zstep):
......@@ -881,8 +882,8 @@ def buildmaps(conf, data, hdr, var=None, plot=False, debug=False, free_ratio=Fal
for comp in range(multi_comp):
count = 0
print('Component %5i' % (comp + 1))
print('Redshfit: %5.2f' % (zmap[comp * els.index + comind]))
print('Redshfit error: %5.2f' % (ezmap[comp * els.index + comind]))
print('Redshift: %5.5f' % (zmap[comp * els.index + comind]))
print('Redshift error: %5.5f' % (ezmap[comp * els.index + comind]))
print('Velocity: %5.2f' % (rvmap[comp * els.index + comind]))
print('Velocity error: %5.2f' % (ervmap[comp * els.index + comind]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment