Commit 33c16356 authored by bepinat's avatar bepinat

Add an option (ZRMIN, ZRMAX) in both create_config, camel and samel to...

Add an option (ZRMIN, ZRMAX) in both create_config, camel and samel to distinguish between the range for searching the redshift of the spectrum and the spectral range considered around lines, currently in the _test version
parent c08b2f43
...@@ -80,13 +80,13 @@ def compute_fwhm(dz, z=None, zcosmo=0): ...@@ -80,13 +80,13 @@ def compute_fwhm(dz, z=None, zcosmo=0):
def readconfig(filename, config): def readconfig(filename, config):
"""This function reads the configuration file and returns a configuration dictionnary """This function reads the configuration file and returns a configuration dictionary
Parameters Parameters
---------- ----------
filename: string filename: string
name of the configuration file name of the configuration file
config: dictionnary config: dictionary
contains options with priority on the configuration file contains options with priority on the configuration file
""" """
...@@ -135,7 +135,7 @@ def readconfig(filename, config): ...@@ -135,7 +135,7 @@ def readconfig(filename, config):
else: else:
conf[key] = value conf[key] = value
# add input options to configuration dictionnary + check needed keywords # add input options to configuration dictionary + check needed keywords
if config is not None: if config is not None:
for key in config: for key in config:
if config[key] is not None: if config[key] is not None:
...@@ -166,7 +166,7 @@ def readcubes(conf, multi_ext=False): ...@@ -166,7 +166,7 @@ def readcubes(conf, multi_ext=False):
Parameters Parameters
---------- ----------
conf: configuration dictionnary conf: configuration dictionary
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
...@@ -302,7 +302,7 @@ def cutcube(cube, hdr, conf): ...@@ -302,7 +302,7 @@ def cutcube(cube, hdr, conf):
input data cube or variance array input data cube or variance array
hdr: fits header hdr: fits header
input data cube header input data cube header
conf: configuration dictionnary conf: configuration dictionary
""" """
...@@ -472,7 +472,7 @@ class line: ...@@ -472,7 +472,7 @@ class line:
class lines: class lines:
"""This class enables to deal with lines. A dictionnary stored in lines will contain informations on each lines. """This class enables to deal with lines. A dictionary stored in lines will contain informations on each lines.
""" """
...@@ -600,6 +600,7 @@ def build_parinfo_lines(els, linename, conf, free_ratio, comind, multi_comp=1): ...@@ -600,6 +600,7 @@ def build_parinfo_lines(els, linename, conf, free_ratio, comind, multi_comp=1):
zcosmo = conf['REDSHIFT'] zcosmo = conf['REDSHIFT']
zmax = conf['REDMAX'] zmax = conf['REDMAX']
zmin = conf['REDMIN'] zmin = conf['REDMIN']
#xxx ICI redefinir zmin et zmax avec le nouveau mot clé pour définir les limites et idem utiliser ce nouveau zmin, zmax pour explorer en z les parametres initiaux
parbase = {'value': 0., 'fixed': 1, 'limited': [0, 0], 'limits': [0., 0.], 'tied': '', 'mpmaxstep': 0, 'mpminstep': 0, 'parname': ''} parbase = {'value': 0., 'fixed': 1, 'limited': [0, 0], 'limits': [0., 0.], 'tied': '', 'mpmaxstep': 0, 'mpminstep': 0, 'parname': ''}
parinfo = [] parinfo = []
...@@ -742,6 +743,7 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal ...@@ -742,6 +743,7 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal
#Condition on the wavelength to be within the redshift cuts #Condition on the wavelength to be within the redshift cuts
#XXX try zmin > zmax? #XXX try zmin > zmax?
#xxx CES zmin, zmax sont bien ceux à utiliser pour les bornes en lbda
zcosmo = conf['REDSHIFT'] zcosmo = conf['REDSHIFT']
zmax = conf['REDMAX'] zmax = conf['REDMAX']
zmin = conf['REDMIN'] zmin = conf['REDMIN']
...@@ -824,6 +826,7 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal ...@@ -824,6 +826,7 @@ def buildmaps(conf, cube, hdr, var=None, plot=False, debug=False, free_ratio=Fal
zmean = (zmax + zmin) / 2. zmean = (zmax + zmin) / 2.
zzmax = zmean + np.floor((zmax - zmean) / zstep + 1) * zstep zzmax = zmean + np.floor((zmax - zmean) / zstep + 1) * zstep
zzmin = zmean + np.ceil((zmin - zmean) / zstep) * zstep zzmin = zmean + np.ceil((zmin - zmean) / zstep) * zstep
#xxx ici utiliser le nouveau zmin, zmax (nouveau mot clé), car cela définit les bornes de l'exploration en z
#Parameters contraints and informations: each line has z, sigma, intensity and ratio constraint #Parameters contraints and informations: each line has z, sigma, intensity and ratio constraint
...@@ -1202,8 +1205,8 @@ def camel(filename, plot=False, debug=False, free_ratio=False, multi_comp=1, mul ...@@ -1202,8 +1205,8 @@ def camel(filename, plot=False, debug=False, free_ratio=False, multi_comp=1, mul
keyword to indicate the number of components to be adjusted keyword to indicate the number of components to be adjusted
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
config: dictionnary config: dictionary
optional dictionnary that contains options usually stored in the configuration file optional dictionary that contains options usually stored in the configuration file
""" """
# XXX gérer message d'erreur si on trouve pas le fichier d'input, s'il n'y a aucune raie, si un paramètre a un problème (e.g. de formatage)... # XXX gérer message d'erreur si on trouve pas le fichier d'input, s'il n'y a aucune raie, si un paramètre a un problème (e.g. de formatage)...
...@@ -1326,8 +1329,8 @@ def usage(): ...@@ -1326,8 +1329,8 @@ def usage():
keyword to allow unconstrained line ratio keyword to allow unconstrained line ratio
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
config: dictionnary config: dictionary
optional dictionnary that contains options usually stored in the configuration file optional dictionary that contains options usually stored in the configuration file
####################### #######################
...@@ -1417,7 +1420,7 @@ def main(argv): ...@@ -1417,7 +1420,7 @@ def main(argv):
if np.size(argv) < 1: if np.size(argv) < 1:
sys.exit(2) sys.exit(2)
opts = vars(options) # this is a dictionnary opts = vars(options) # this is a dictionary
opts['OII3726'] = opts['OII3729'] opts['OII3726'] = opts['OII3729']
camel(options.filename, plot=options.plot, debug=options.debug, free_ratio=options.free_ratio, multi_comp=options.multi_comp, multi_ext=options.multi_ext, ftol=options.ftol, xtol=options.xtol, gtol=options.gtol, maxiter=options.maxiter, factor=options.factor, config=opts, cut=options.cut, clip=options.clip, smooth=options.smooth) camel(options.filename, plot=options.plot, debug=options.debug, free_ratio=options.free_ratio, multi_comp=options.multi_comp, multi_ext=options.multi_ext, ftol=options.ftol, xtol=options.xtol, gtol=options.gtol, maxiter=options.maxiter, factor=options.factor, config=opts, cut=options.cut, clip=options.clip, smooth=options.smooth)
return return
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ import logging ...@@ -17,7 +17,7 @@ import logging
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('CAMEL') logger = logging.getLogger('CAMEL')
def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=True, dv=1000., dxy=15, initw=50., wmin=30., wmax=250., dfit=100., degcont=0, sclip=10, xyclip=3, nclip=3, wsmooth=0, ssmooth=2.): def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=True, dv=1000., dxy=15, deltav=500., initw=50., wmin=30., wmax=250., dfit=100., degcont=0, sclip=10, xyclip=3, nclip=3, wsmooth=0, ssmooth=2.):
''' '''
This function enables to create a configuration file for camel. This function enables to create a configuration file for camel.
...@@ -41,6 +41,8 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T ...@@ -41,6 +41,8 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T
interval of velocity around the systemic redshift (from the catalogue) to search for lines and for cutting the cube spectrally interval of velocity around the systemic redshift (from the catalogue) to search for lines and for cutting the cube spectrally
dxy: int dxy: int
spatial extent around the object for cutting the cube (in pixels) spatial extent around the object for cutting the cube (in pixels)
deltav: float
velocity range in km/s to determine redshift range for fit
initw: float initw: float
initial guess for the line width (dispersion) in km/s initial guess for the line width (dispersion) in km/s
wmin: float wmin: float
...@@ -210,7 +212,7 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T ...@@ -210,7 +212,7 @@ def create_config(path, cubefile, varfile, catfile, lines, suffixeout, commonw=T
fo.write('YMIN = None / Y minimum value for spatial cut of the input cube (pixel)\n') fo.write('YMIN = None / Y minimum value for spatial cut of the input cube (pixel)\n')
fo.write('YMAX = None / Y maximum value for spatial cut of the input cube (pixel)\n') fo.write('YMAX = None / Y maximum value for spatial cut of the input cube (pixel)\n')
if dv is not None: if dv is not None:
minlbda = np.min(np.array(lbda)) * (1 + line['Z'] - 1.5 * dz) minlbda = np.min(np.array(lbda)) * (1 + line['Z'] - 1.5 * dz) # XXX VERIFIER QUE CAMEL FAIT CA POUR DETERMINER LE LBDA RANGE AUTOURS DES RAIES: PAS TOUT A FAIT. CAMEL FAIT ~ 2 x dz. Il faudrait faire la même chose. En fait idéalmement, zmin, zmax devraient donner directement le bon résusltat, sans facteur 1.5 ou 2...
maxlbda = np.max(np.array(lbda)) * (1 + line['Z'] + 1.5 * dz) maxlbda = np.max(np.array(lbda)) * (1 + line['Z'] + 1.5 * dz)
zmin = np.round((minlbda - crval) / cdelt + crpix - 1) zmin = np.round((minlbda - crval) / cdelt + crpix - 1)
zmax = np.round((maxlbda - crval) / cdelt + crpix - 1) zmax = np.round((maxlbda - crval) / cdelt + crpix - 1)
...@@ -252,8 +254,9 @@ def main(argv): ...@@ -252,8 +254,9 @@ def main(argv):
#parser.add_argument('--dxy', action="store", dest="dxy", default='15', help="size in pixels around the center") #parser.add_argument('--dxy', action="store", dest="dxy", default='15', help="size in pixels around the center")
parser.add_argument('--commonw', action="store", dest="commonw", default='True', help="parameter to use a common width in velocity for the various lines") parser.add_argument('--commonw', action="store", dest="commonw", default='True', help="parameter to use a common width in velocity for the various lines")
parser.add_argument('--dv', action="store", dest="dv", default='1000.', help="velocity difference in km/s to determine redshift range for fit") parser.add_argument('--dv', action="store", dest="dv", default='1000.', help="velocity difference in km/s to determine spectral range considered around lines")
parser.add_argument('--dxy', action="store", dest="dxy", default='15', help="size in pixels around the center") parser.add_argument('--dxy', action="store", dest="dxy", default='15', help="size in pixels around the center")
parser.add_argument('--deltav', action="store", dest="deltav", default='400.', help="velocity range in km/s to determine redshift range for fit")
parser.add_argument('--initw', action="store", dest="initw", default='50.', help="initial guess for the line width (dispersion) in km/s") parser.add_argument('--initw', action="store", dest="initw", default='50.', help="initial guess for the line width (dispersion) in km/s")
parser.add_argument('--wmin', action="store", dest="wmin", default='30.', help="minimum width allowed in km/s") parser.add_argument('--wmin', action="store", dest="wmin", default='30.', help="minimum width allowed in km/s")
parser.add_argument('--wmax', action="store", dest="wmax", default='250.', help="maximum width allowed in km/s") parser.add_argument('--wmax', action="store", dest="wmax", default='250.', help="maximum width allowed in km/s")
...@@ -279,15 +282,17 @@ def main(argv): ...@@ -279,15 +282,17 @@ def main(argv):
#create_config(opts['pathb'], opts['cubefile'], opts['varfile'], opts['catfile'], opts['lines'], opts['suffixeout'], dv=float(opts['dv']), dxy=int(opts['dxy'])) #create_config(opts['pathb'], opts['cubefile'], opts['varfile'], opts['catfile'], opts['lines'], opts['suffixeout'], dv=float(opts['dv']), dxy=int(opts['dxy']))
create_config(opts['pathb'], opts['cubefile'], opts['varfile'], opts['catfile'], opts['lines'], opts['suffixeout'], create_config(opts['pathb'], opts['cubefile'], opts['varfile'], opts['catfile'], opts['lines'], opts['suffixeout'],
commonw=(opts['commonw'] == 'True'), dv=float(opts['dv']), dxy=int(opts['dxy']), dv=float(opts['dv']), dxy=int(opts['dxy']),
deltav=float(opts['deltav']), dfit=float(opts['dfit']), commonw=(opts['commonw'] == 'True'),
initw=float(opts['initw']), wmin=float(opts['wmin']), wmax=float(opts['wmax']), initw=float(opts['initw']), wmin=float(opts['wmin']), wmax=float(opts['wmax']),
dfit=float(opts['dfit']), degcont=int(opts['degcont']), degcont=int(opts['degcont']),
sclip=int(opts['sclip']), xyclip=int(opts['xyclip']), nclip=int(opts['nclip']), sclip=int(opts['sclip']), xyclip=int(opts['xyclip']), nclip=int(opts['nclip']),
wsmooth=int(opts['wsmooth']), ssmooth=float(opts['ssmooth']) wsmooth=int(opts['wsmooth']), ssmooth=float(opts['ssmooth'])
) )
# Faire un REDMIN, REDMAX (VELMIN/VELMAX, VLOTH/VUPTH, ...) pour les pixels spectraux à considérer autours des raies et utiliser un VMIN, VMAX ou DV pour les bornes du fit. Du coup, y aurait plus besoin de faire la conversion DV -> Redmin, Redmax dans create_config. # Faire un REDMIN, REDMAX (VELMIN/VELMAX, VLOTH/VUPTH, ...) pour les pixels spectraux à considérer autours des raies et utiliser un VMIN, VMAX ou DV pour les bornes du fit. Du coup, y aurait plus besoin de faire la conversion DV -> Redmin, Redmax dans create_config.
#Eventuellement faire une condition dans CAMEL: si on a qu'un des deux paramètres (REDMIN/REDMAX ou VMIN/VMAX ou peu importe le choix de nom final) faire une condition telle qu'actuellement #Eventuellement faire une condition dans CAMEL: si on a qu'un des deux paramètres (REDMIN/REDMAX ou VMIN/VMAX ou peu importe le choix de nom final) faire une condition telle qu'actuellement
# Du coup, il vaut probablement mieux laisser un REDMIN/REDMAX relié au DV (pour que ça marche encore avec les anciennes versions des programmes/config files) et définir un nouveau VELMIN, VELMAX pour le bornes spectrales
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1:]) main(sys.argv[1:])
......
This diff is collapsed.
...@@ -81,13 +81,13 @@ def compute_fwhm(dz, z=None, zcosmo=0): ...@@ -81,13 +81,13 @@ def compute_fwhm(dz, z=None, zcosmo=0):
def readconfig(filename, config): def readconfig(filename, config):
"""This function reads the configuration file and returns a configuration dictionnary """This function reads the configuration file and returns a configuration dictionary
Parameters Parameters
---------- ----------
filename: string filename: string
name of the configuration file name of the configuration file
config: dictionnary config: dictionary
contains options with priority on the configuration file contains options with priority on the configuration file
""" """
...@@ -136,7 +136,7 @@ def readconfig(filename, config): ...@@ -136,7 +136,7 @@ def readconfig(filename, config):
else: else:
conf[key] = value conf[key] = value
# add input options to configuration dictionnary + check needed keywords # add input options to configuration dictionary + check needed keywords
if config is not None: if config is not None:
for key in config: for key in config:
if config[key] is not None: if config[key] is not None:
...@@ -166,7 +166,7 @@ def readdata(conf, multi_ext=False): ...@@ -166,7 +166,7 @@ def readdata(conf, multi_ext=False):
Parameters Parameters
---------- ----------
conf: configuration dictionnary conf: configuration dictionary
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
...@@ -252,7 +252,7 @@ def cutspectrum(data, hdr, conf): ...@@ -252,7 +252,7 @@ def cutspectrum(data, hdr, conf):
input data spectrum or variance input data spectrum or variance
hdr: fits header hdr: fits header
input data header input data header
conf: configuration dictionnary conf: configuration dictionary
""" """
...@@ -315,7 +315,7 @@ class line: ...@@ -315,7 +315,7 @@ class line:
class lines: class lines:
"""This class enables to deal with lines. A dictionnary stored in lines will contain informations on each lines. """This class enables to deal with lines. A dictionary stored in lines will contain informations on each lines.
""" """
...@@ -961,8 +961,8 @@ def samel(filename, plot=False, debug=False, free_ratio=False, multi_comp=1, mul ...@@ -961,8 +961,8 @@ def samel(filename, plot=False, debug=False, free_ratio=False, multi_comp=1, mul
keyword to indicate the number of components to be adjusted keyword to indicate the number of components to be adjusted
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
config: dictionnary config: dictionary
optional dictionnary that contains options usually stored in the configuration file optional dictionary that contains options usually stored in the configuration file
""" """
# XXX gérer message d'erreur si on trouve pas le fichier d'input, s'il n'y a aucune raie, si un paramètre a un problème (e.g. de formatage)... # XXX gérer message d'erreur si on trouve pas le fichier d'input, s'il n'y a aucune raie, si un paramètre a un problème (e.g. de formatage)...
...@@ -1058,8 +1058,8 @@ def usage(): ...@@ -1058,8 +1058,8 @@ def usage():
keyword to allow unconstrained line ratio keyword to allow unconstrained line ratio
multi_ext: bool multi_ext: bool
keyword to indicate if input fits has multiple extensions keyword to indicate if input fits has multiple extensions
config: dictionnary config: dictionary
optional dictionnary that contains options usually stored in the configuration file optional dictionary that contains options usually stored in the configuration file
####################### #######################
...@@ -1140,7 +1140,7 @@ def main(argv): ...@@ -1140,7 +1140,7 @@ def main(argv):
if np.size(argv) < 1: if np.size(argv) < 1:
sys.exit(2) sys.exit(2)
opts = vars(options) # this is a dictionnary opts = vars(options) # this is a dictionary
opts['OII3726'] = opts['OII3729'] opts['OII3726'] = opts['OII3729']
samel(options.filename, plot=options.plot, debug=options.debug, free_ratio=options.free_ratio, multi_comp=options.multi_comp, multi_ext=options.multi_ext, ftol=options.ftol, xtol=options.xtol, gtol=options.gtol, maxiter=options.maxiter, factor=options.factor, config=opts, cut=options.cut, smooth=options.smooth) samel(options.filename, plot=options.plot, debug=options.debug, free_ratio=options.free_ratio, multi_comp=options.multi_comp, multi_ext=options.multi_ext, ftol=options.ftol, xtol=options.xtol, gtol=options.gtol, maxiter=options.maxiter, factor=options.factor, config=opts, cut=options.cut, smooth=options.smooth)
return return
......
This diff is collapsed.
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