import math import inspect import numpy as np from matplotlib import pyplot as plt # Import the relevant PTS classes and modules from pts.core.tools import filesystem as fs from pts.do.commandline import Command from pts.core.basics.range import RealRange from pts.evolve.core import reference from pts.evolve.optimize.optimizer import show_best from pts.core.test.implementation import TestImplementation # ----------------------------------------------------------------- this_path = fs.absolute_path(inspect.stack()[0][1]) this_dir_path = fs.directory_of(this_path) # ----------------------------------------------------------------- description = "optimizing the Rastrigin function, a deceptive function" # ----------------------------------------------------------------- # Define properties #nparameters = 20 nparameters = 2 nindividuals = 80 parameter_range = RealRange(-5.2, 5.30) best_raw_score = 0.0 round_decimal = None
# Import the relevant PTS classes and modules from pts.core.tools import filesystem as fs from pts.do.commandline import Command from pts.evolve.core import reference from pts.evolve.optimize.optimizer import show_best from pts.evolve.core.crossovers import G1DListCrossoverOX from pts.evolve.core.mutators import G1DListMutatorSwap from pts.core.basics.animation import Animation from pts.core.basics.range import RealRange from pts.core.test.implementation import TestImplementation from pts.core.basics.log import log # ----------------------------------------------------------------- this_path = fs.absolute_path(inspect.stack()[0][1]) this_dir_path = fs.directory_of(this_path) # ----------------------------------------------------------------- description = "finding the maximum of the function defined by Charbonneau (1995)" # ----------------------------------------------------------------- # Define properties #nparameters = 20 nparameters = 2 nindividuals = 80 parameter_range = RealRange(0., 1.) #best_raw_score = float('inf') best_raw_score = 100
from pts.core.tools import introspection from pts.core.data.sed import SED, ObservedSED from pts.core.plot.sed import SEDPlotter # ----------------------------------------------------------------- # Set the log level level = "DEBUG" # Initialize the logger log = logging.setup_log(level=level) log.start("Starting compare_sed ...") # ----------------------------------------------------------------- fit_path = fs.absolute_path("../../../../../") modeling_path = fs.directory_of(fit_path) galaxy_name = fs.name(modeling_path) # ----------------------------------------------------------------- # Create the plotter plotter = SEDPlotter() # Add the SEDs filename = galaxy_name + "_earth_sed.dat" sed = SED.from_skirt(filename) # Load the reference SED reference_sed_path = fs.join(modeling_path, "sed.dat") reference_sed = ObservedSED.from_file(reference_sed_path)
# ----------------------------------------------------------------- # Inform the user log.info("Loading the FITS file ...") # Load the FITS file frame = Frame.from_file(config.filename) # ----------------------------------------------------------------- if config.output is not None: filepath = fs.absolute_or_in(config.output, fs.cwd()) else: # Determine the path name = fs.strip_extension(fs.name(config.filename)) filepath = fs.absolute_path(name + ".png") # ----------------------------------------------------------------- # Max npixels if config.max_npixels is not None: # Determine downsample factor if frame.xsize > config.max_npixels or frame.ysize > config.max_npixels: factor = max(frame.xsize, frame.ysize) / float(config.max_npixels) # Make integer #numbers.round_up_to_int(factor) #if factor < 2.: factor = 2 config.downsample = factor
# ----------------------------------------------------------------- # Inform the user log.info("Loading the FITS file ...") # Load the FITS file frame = Frame.from_file(config.filename) # ----------------------------------------------------------------- if config.output is not None: filepath = fs.absolute_or_in(config.output, fs.cwd()) else: # Determine the path name = fs.strip_extension(fs.name(config.filename)) filepath = fs.absolute_path(name + ".png") # ----------------------------------------------------------------- # Max npixels if config.max_npixels is not None: # Determine downsample factor if frame.xsize > config.max_npixels or frame.ysize > config.max_npixels: factor = max(frame.xsize, frame.ysize) / float(config.max_npixels) # Make integer #numbers.round_up_to_int(factor) #if factor < 2.: factor = 2 config.downsample = factor
from pts.core.tools import introspection from pts.core.data.sed import SED, ObservedSED from pts.core.plot.sed import SEDPlotter # ----------------------------------------------------------------- # Set the log level level = "DEBUG" # Initialize the logger log = logging.setup_log(level=level) log.start("Starting compare_sed ...") # ----------------------------------------------------------------- fit_path = fs.absolute_path("../../../../../") modeling_path = fs.directory_of(fit_path) galaxy_name = fs.name(modeling_path) # ----------------------------------------------------------------- # Create the plotter plotter = SEDPlotter() # Add the SEDs filename = galaxy_name + "_earth_sed.dat" sed = SED.from_skirt(filename) # Load the reference SED reference_sed_path = fs.join(modeling_path, "sed.dat") reference_sed = ObservedSED.from_file(reference_sed_path)