grale.ltparamdesc

This is a module with a helper function to import parametric inversion settings from a Lenstool configuration file. The module itself can also be executed on the command line to generate template inversion scripts based on a Lenstool configuration.

Usage:

python -m grale.ltparamdesc -in mod.par (-out inv.py | -exec)\
      [-outparam desc.py] [-noRAdir] [-force] [-fromimgfile] \
      [-popsize 512] [-mcmcgen 5000] [-outfnsuffix suff] \
      [-refinefactor 0.0001] [-debug] [-nostricimages]

Arguments:

  • -in mod.par: this refers to the Lenstool input file that should be processed.

  • -out inv.py: this specifies the name of the main Python script that is to be generated. The script will contain code to setup the inversion and run it in two steps: in the first part, a good starting point for all the parameters will be determined, using a GA-like approach. In the second step the parameters around this point will be explored using an MCMC technique to reveal information about the uncertainties of the parameters.

  • -exec: if set, the -out option may be omitted and the resulting script will be executed

  • -outparam desc.py: if specified, this optional parameter gives the name of the file that will contain the parametric description that has been derived from the Lenstool input file. See the paramdesc module for an explanation of such a description.

  • -noRAdir: by default, the coordinates in the input file will be converted so that they follow the orientation of the RA axis (so this axis points left). To mirror the coordinates you can specify this flag.

  • -force: by default, the program will halt instead of overwriting one of the output files. To disable this safety you can set this parameter.

  • -fromimgfile: the script that’s generated will again read the same file as specified using the -in option. You can also make it so that the script only reads the images file, by setting this command line option. If no -outparam is specified, then the entire parametric description is stored in the output script. If the -outparam is specified, the generated script is smaller and will read the model from that file.

  • -popsize 512: sets the population size for initial inversion and MCMC parts in the generated script. Defaults to 512

  • -mcmcgen 5000: sets the number of generations/steps to perform during the MCMC exploration, half of this will be considered as burn-in. Defaults to 5000.

  • -outfnsuffix suff: for the output file names in the script, use this as the suffix (default is empty).

  • -refinefactor 0.0001: when the initial inversion has been found, the MCMC phase will start from a narrow region around that model’s parameters. This specifies the fraction of the parameter change that’s used for the initialization of a new set of trial solutions.

  • -debug: if present, more debug output will be shown.

  • -nostrictimages: if set, the input images file is not required to start with ‘#REFERENCE 0’

grale.ltparamdesc.createParametricDescriptionFromLenstoolInput(fileName, useRADirection, parseImages=True, strictImages=True, lensDistanceString='Dd', arcsecString='ANGLE_ARCSEC', degreeString='ANGLE_DEGREE', kpcString='DIST_KPC')

This function analyzes a Lenstool inversion configuration file (e.g. ‘mod.par’) and returns a dictionary with settings that can be used for a parametric inversion. The module itself can also be executed from the command line to generate template inversion files.

The dictionary that is returned has the following entries:

  • "images": this is a list of the images, basically what the readLenstoolInputImagesFile returns for the image file specified in the Lenstool script. Is None in case the parseImages flag was set to False.

  • "imagesFileName": the name of the images file that is stored in the Lenstool script.

  • "cosmology": an instance of Cosmology, based on the settings that were read from the input file.

  • "positionalUncertainty": the uncertainly that is applicable to the input images

  • "zd": the redshift of the lens

  • "center": this should be used as the center of the coordinate system, can be used in a call to readLenstoolInputImagesFile for example.

  • "description": a string containing the parametric description (see module paramdesc). You’ll probably need to ‘eval’ this to be able to actually use it, but the string representation is much more readable.

Arguments:

  • fileName: name of the Lenstool input file that needs to be analyzed

  • useRADirection: if True, coordinates in the Lenstool file are converted so that they use the RA direction (axis points left). To use mirrored coordinates (as Lenstool itself does) you can set this to False

  • parseImages: can be set to False if the specified images file is not processed further, only the file name will be stored.

  • strictImages: by default, the input images file needs to start with ‘#REFERENCE 0’, by setting this flag to False this requirement is relaxed.

  • lensDistanceString: sometimes a conversion may be needed that involves the lens distance. This string is used in the generated output for this.

  • arcsecString: string to be used when expressing something in arcsec

  • degreeString: string to be used when expressing something in degrees

  • kpcString: string to be used when expressing something in kpc.