Example #1
0
File: test.py Project: rag9704/PTS
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
Example #2
0
File: test.py Project: SKIRT/PTS
# 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
Example #3
0
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)
Example #4
0
# -----------------------------------------------------------------

# 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
Example #5
0
# -----------------------------------------------------------------

# 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
Example #6
0
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)