def _init_psf_phot_process(data, all_positions, all_amplitudes, idx, nidx, psf, amplitudes, positions): """ Global variables for psf photometry processes """ import multiprocessing global gbl_data global gbl_all_positions global gbl_all_amplitudes global gbl_idx global gbl_nidx global gbl_psf global gbl_amplitudes global gbl_positions gbl_data = data gbl_all_positions = all_positions gbl_all_amplitudes = all_amplitudes gbl_idx = idx gbl_nidx = nidx gbl_psf = psf gbl_amplitudes = amplitudes gbl_positions = positions log.info("Initializing process {0}".format( multiprocessing.current_process().name))
def combine_second(self): """ This function ... :return: """ # Inform the user log.info("Doing second combination ...") fltr_a, fltr_b = self.lowest_resolution_filters frames = self.frames[fltr_a, fltr_b] frames.convolve_to_highest_fwhm() frames.rebin_to_highest_pixelscale() frames.convert_to_same_unit(unit="MJy/sr") # here conversion to surface brightness, related to the pixelscale is necessary # Set the frames #self.second = frames frames.convert_to_same_unit(unit="Lsun", density=True, distance=self.distance) # convert to solar luminosity # Now do something self.second = np.random.random() * frames[fltr_a] + np.random.random() * frames[fltr_b] # Set unit self.second.unit = "Lsun"
def extract(self): """ This function ... :return: """ # Inform the user log.info("Extracting the sources ...") # Loop over the images for fltr in self.frames: name = str(fltr) # Inform the user log.info("Extracting the sources for the '" + name + "' image ...") # Settings settings = dict() settings["input"] = self.find_paths[name] settings["output"] = self.extract_paths[name] # Input input_dict = dict() input_dict["frame"] = self.frames[fltr] # Construct the command command = Command("extract", "extract the sources", settings, input_dict) # Run the command extractor = self.run_command(command, remote=self.remote) # Add the extractor self.extractors[fltr] = extractor
def get_frames(self): """ This function ... :return: """ # Inform theb user log.info("Getting the frames ...") # Get the frames #self.frames = self.database.get_framelist_for_filters(self.galaxy_name, filter_names) self.frames = FrameList() # Loop over the filter names for filter_name in filter_names: # Parse filter fltr = parse_filter(filter_name) # Get wcs wcs = get_coordinate_system(fltr) # Generate frame #frame = Frame.random(wcs.shape, wcs=wcs, filter=fltr) frame = Frame.ones(wcs.shape, wcs=wcs, filter=fltr) frame.unit = "Jy" # Add the frame self.frames.append(frame)
def deploy(self): """ This function ... :return: """ # Inform the user log.info("Deploying SKIRT and PTS ...") # Create the deployer deployer = Deployer() # Set the host ids deployer.config.hosts = [self.host] # Set the host id on which PTS should be installed (on the host for extra computations and the fitting hosts # that have a scheduling system to launch the pts run_queue command) #deployer.config.pts_on = self.moderator.all_host_ids # Set #deployer.config.check = self.config.check_versions # Set #deployer.config.update_dependencies = self.config.update_dependencies # Run the deployer deployer.run()
def show_luminosities(sed): """ This function ... :param sed: :return: """ # Get spectral luminosity density lum = sed.photometry_at(fltr_wavelength, unit="W/micron") lum2 = sed.photometry_at(fltr_wavelength, unit="W/micron", interpolate=False) # log.info("Luminosity: " + tostr(lum)) log.info("No interpolation: " + tostr(lum2)) # Convert to solar SPECTRAL luminosity DENSITY at wavelength lum_spectral_solar = lum.to("W/micron").value / solar_wavelength_density.to("W/micron").value # Convert to neutral lum_neutral = lum.to("W", density=True, wavelength=fltr_wavelength) lum_solar = lum.to("Lsun", density=True, wavelength=fltr_wavelength) # Neutral and solar log.info("Luminosity in spectral solar units: " + tostr(lum_spectral_solar) + " Lsun_" + fltr.band) log.info("Luminosity in neutral units: " + tostr(lum_neutral)) log.info("Luminosity in solar units: " + tostr(lum_solar))
def combine_first(self): """ This function ... :return: """ # Inform the user log.info("Doing first combination ...") fltr_a, fltr_b = self.highest_resolution_filters frames = self.frames[fltr_a, fltr_b] frames.convolve_to_highest_fwhm() frames.rebin_to_highest_pixelscale() frames.convert_to_same_unit(unit="W/micron/m2") # here conversion related to frequency/wavelength is necessary frames.convert_to_same_unit(unit="W/m2", density=True) # here conversion from spectral flux density to flux is necessary # Set the frames #self.first = frames # Now do something, like adding them self.first = np.random.random() * frames[fltr_a].get_log10() + np.random.random() * frames[fltr_b].get_log10() # Set the unit self.first.unit = "W/m2"
def create_wcs(self): """ This function ... :return: """ # Inform the user log.info("Creating the WCS ...") min_pixelscale = None # Determine the path to the headers directory headers_path = fs.join(m81_data_path, "headers") # Loop over the header files for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]): # Get the filter fltr = parse_filter(name) filter_name = str(fltr) # Set the path of the file for the filter name self.wcs_paths[filter_name] = path # Get WCS wcs = CoordinateSystem.from_header_file(path) # Adjust the pixelscale if min_pixelscale is None: min_pixelscale = wcs.pixelscale self.wcs = wcs elif min_pixelscale > wcs.pixelscale: min_pixelscale = wcs.pixelscale self.wcs = wcs
def write_frame(self): """ This function ... :return: """ # Inform the user log.info("Saving the result ...") # Determine the path path = self.output_path_file(self.image_name) # Check if already existing if fs.is_file(path): if self.config.replace: if self.config.backup: fs.backup_file(path, suffix=self.config.backup_suffix) fs.remove_file(path) else: #raise ValueError("The image already exists") path = self.output_path_file("result.fits") # Save self.frame.saveto(path, header=self.header)
def find(self): """ This function ... :return: """ # Inform the user log.info("Finding the sources ...") # Settings settings = dict() # settings["input"] = settings["output"] = self.find_path settings["nprocesses"] = self.config.nprocesses # Input input_dict = dict() input_dict["dataset"] = self.dataset #input_dict["extended_source_catalog"] = self.extended_source_catalog input_dict["point_source_catalog"] = self.point_source_catalog input_dict["output_paths"] = self.find_paths # Construct the command command = Command("find_sources", "find sources", settings, input_dict) # Run the command self.finder = self.run_command(command)
def make_animation(self): """ This function ... :return: """ # Inform the user log.info("Making animation ...") # Get the best best = self.optimizer.best # Determine path temp_path = self.optimizer.config.path filepath = fs.join(temp_path, "best.png") # Make plot of best # Create animated gif animation = Animation() # Open the images present in the directory for path in fs.files_in_path(temp_path, extension="png", exact_not_name="best"): # Add frame to the animation animation.add_frame_from_file(path) # Save the animation animation_path = fs.join(temp_path, "animation.gif") animation.saveto(animation_path)
def attach(self): """ This function ... :return: """ # Inform the user log.info("Attaching to the screen session '" + self.screen_name + "' ...") # Tmux or screen if self.tmux: self.remote.execute("tmux a -t " + self.screen_name, expect=">>>") else: #self.remote.execute("screen -r " + self.screen_name, expect=">>>") self.remote.ssh.sendline("screen -r " + self.screen_name) while True: index = self.remote.ssh.expect([">>>", pexpect.TIMEOUT]) if index == 1: break # Set attached flag self.attached = True # Set displayhook to default self.remote.execute("sys.displayhook = sys.__displayhook__", expect=">>>")
def create_coordinate_systems(self): """ This function ... :return: """ # Inform the user log.info("Creating the coordinate systems ...") # Loop over the number of frames for index in range(self.config.nframes): # Get the next filter fltr = parse_filter(filter_names[index]) # Set properties size = Extent(self.config.npixels, self.config.npixels) center_pixel = size * 0.5 pixelscale = Pixelscale(1.0, unit="arcsec") # Create the coordinate system wcs = CoordinateSystem.from_properties(size, center_pixel, self.center, pixelscale) # Add the wcs self.coordinate_systems.append(wcs, fltr)
def create_wavelength_grid(self): """ This function ... :return: """ # Inform the user log.info("Creating the wavelength grid ...") # Create the wavelength generator generator = WavelengthGridGenerator() # Set input input_dict = dict() input_dict["ngrids"] = 1 input_dict["npoints"] = self.config.nwavelengths input_dict["fixed"] = [self.i1_filter.pivot, self.fuv_filter.pivot] input_dict["add_emission_lines"] = True input_dict["lines"] = ["Halpha"] # only the H-alpha line is of importance input_dict["min_wavelength"] = self.config.wavelength_range.min input_dict["max_wavelength"] = self.config.wavelength_range.max input_dict["filters"] = [parse_filter(string) for string in fitting_filter_names] # Run the generator generator.run(**input_dict) # Set the wavelength grid self.wavelength_grid = generator.single_grid
def set_bulge(self): """ This function ... :return: """ # Inform the user log.info("Setting the old stellar bulge component ...") # Get the title for this component title = titles["bulge"] # Create the new component self.ski.create_new_stellar_component(title) # Set the geometry self.ski.set_stellar_component_geometry(title, self.bulge) # Set the SED # component_id, template, age, metallicity self.ski.set_stellar_component_sed(title, bulge_template, bulge_age, bulge_metallicity) # Convert the flux density into a spectral luminosity luminosity = bulge_fluxdensity.to("W/micron", fltr=self.i1_filter, distance=self.galaxy_distance) # Set the normalization # luminosity, filter_or_wavelength=None self.ski.set_stellar_component_luminosity(title, luminosity, self.i1_filter.pivot)
def test_brightness(self): """ This function ... :return: """ # Inform the user log.info("Testing surface brightness units ...") units = [u("Jy"), u("W/micron"), u("Lsun"), u("erg/s/Hz"), u("W/sr"), u("Lsun/pc2", brightness=True), u("W/m2/micron")] print("") for unit in units: print(str(unit)) print("") print(" - symbol: " + unit.symbol) print(" - physical type: " + unit.physical_type) print(" - base physical type: " + unit.base_physical_type) print(" - base unit: " + str(unit.base_unit)) print(" - density: " + str(unit.density)) print(" - brightness: " + str(unit.brightness)) angular_area_unit = unit.corresponding_angular_area_unit #print(angular_area_unit) intrinsic_area_unit = unit.corresponding_intrinsic_area_unit print(" - corresponding angular area unit: " + str(angular_area_unit)) print(" - corresponding intrinsic area unit: " + str(intrinsic_area_unit)) print("")
def create_deprojections(self): """ This function ... :return: """ # Inform the user log.info("Creating the deprojections ...") # Set deprojection of old stars wcs = self.maps["old"].wcs if wcs is None: raise IOError("The map of old stars has no WCS information") self.deprojections["old"] = DeprojectionModel3D.from_wcs(wcs, self.galaxy_center, self.galaxy_distance, self.galaxy_position_angle, self.galaxy_inclination, old_filename, old_scale_height) # Set deprojection of young stars wcs = self.maps["young"].wcs if wcs is None: raise IOError("The map of young stars has no WCS information") self.deprojections["young"] = DeprojectionModel3D.from_wcs(wcs, self.galaxy_center, self.galaxy_distance, self.galaxy_position_angle, self.galaxy_inclination, young_filename, young_scale_height) # Set deprojection of ionizing stars wcs = self.maps["ionizing"].wcs if wcs is None: raise IOError("The map of ionizing stars has no WCS information") self.deprojections["ionizing"] = DeprojectionModel3D.from_wcs(wcs, self.galaxy_center, self.galaxy_distance, self.galaxy_position_angle, self.galaxy_inclination, ionizing_filename, ionizing_scale_height) # Set deprojection of dust map wcs = self.maps["dust"].wcs if wcs is None: raise IOError("The map of old stars has no WCS information") self.deprojections["dust"] = DeprojectionModel3D.from_wcs(wcs, self.galaxy_center, self.galaxy_distance, self.galaxy_position_angle, self.galaxy_inclination, dust_filename, dust_scale_height)
def restore_chi_squared(self): """ This function ... :return: """ # Inform the user log.info("Restoring the chi squared tables ...") # Loop over the generations for generation_name in self.generation_names: # Has generation? if not self.has_generation(generation_name): continue # Debugging log.debug("Creating backup of chi squared table for generation '" + generation_name + "' ...") # Get the generation generation = self.generations[generation_name] # Get the generation path generation_path = self.get_generation_restore_path(generation_name) # Determine the filepath filepath = fs.join(generation_path, "chi_squared.dat") # Copy the file fs.copy_file(filepath, generation.chi_squared_table_path)
def setup_modelling(self): """ This fucntion ... :return: """ # Inform the user log.info("Setting up the modelling ...") # Settings settings_setup = dict() settings_setup["type"] = "sed" settings_setup["name"] = self.modeling_name settings_setup["fitting_host_ids"] = self.moderator.host_ids_for_ensemble("fitting", none_if_none=True) # Create input dict for setup input_setup = dict() input_setup["sed"] = self.observed_sed input_setup["ski"] = self.ski_template #input_setup["ski_input"] = self.required_input_files input_setup["ski_input"] = self.all_input_files # Important so that the fittinginitializer can choose the number # of wavelengths for the fitting based on what the user used as a wavelength grid file for the ski file # Create object config object_config = dict() # object_config["ski"] = ski_path input_setup["object_config"] = object_config # Construct the command stp = Command("setup", "setup the modeling", settings_setup, input_setup, cwd=".") # Call the command tool = self.run_command(stp)
def make_sky(self): """ This function ... :return: """ # Inform the user log.info("Adding sky ...") # Loop over the frames for fltr in self.frames: # Get the frame frame = self.frames[fltr] # Determine random sky level sky_level = np.random.uniform(0.0, 10.) # Create sky gradient y, x = np.mgrid[:frame.ysize, :frame.xsize] sky_gradient = x * y # Normalize so that the maximal sky is 20% sky_gradient = sky_gradient / np.max(sky_gradient) * 20 # Add the sky frame += sky_level + sky_gradient # Mask frame[self.rotation_masks[fltr]] = 0.0
def test_dust_mass(self): """ This function ... :return: """ # Inform the user log.info("Testing the dust mass ...") ndigits = 4 nbits = numbers.binary_digits_for_significant_figures(ndigits) print(str(nbits) + " bits for " + str(ndigits) + " digits") mass_range = parsing.quantity_range("1500000.0 Msun > 300000000.0 Msun") unit = "Msun" minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value value = parse_quantity("1.5e7 Msun").to(unit).value # Test : ROUNDING IN TEST BUT NOT IN BETWEEN CONVERSION!! if light_test_from_number_rounding(value, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
def set_old(self): """ This function ... :return: """ # Inform the user log.info("Setting the old stellar disk component ...") # Get the title title = titles["old"] # Create the new component self.ski.create_new_stellar_component(title) # Set the geometry self.ski.set_stellar_component_geometry(title, self.deprojections["old"]) # Set the SED self.ski.set_stellar_component_sed(title, disk_template, disk_age, disk_metallicity) # Convert the flux density into a spectral luminosity luminosity = old_fluxdensity.to("W/micron", fltr=self.i1_filter, distance=self.galaxy_distance) # Set the normalization self.ski.set_stellar_component_luminosity(title, luminosity, self.i1_filter.pivot)
def make_sources(self): """ This function ... :return: """ # Inform the user log.info("Making the sources ...") flux_range = [self.config.flux_range.min, self.config.flux_range.max] xmean_range = [0, self.config.shape[1]] ymean_range = [0, self.config.shape[0]] # Ranges of sigma xstddev_range = [self.sources_sigma, self.sources_sigma] ystddev_range = [self.sources_sigma, self.sources_sigma] table = make_random_gaussians(self.config.nsources, flux_range, xmean_range, ymean_range, xstddev_range, ystddev_range, random_state=12345) self.source_table = table data = make_gaussian_sources(self.config.shape, table) self.sources = Frame(data) # mask self.sources[self.rotation_mask] = 0.0 if self.config.plot: plotting.plot_box(self.sources, title="sources")
def set_ionizing(self): """ This function ... :return: """ # Inform the user log.info("Setting the ionizing stellar disk component ...") # Get the title title = titles["ionizing"] # Create the new component self.ski.create_new_stellar_component(title) # Set the geometry self.ski.set_stellar_component_geometry(title, self.deprojections["ionizing"]) # Set the SED # metallicity, compactness, pressure, covering_factor self.ski.set_stellar_component_mappingssed(title, ionizing_metallicity, ionizing_compactness, ionizing_pressure, ionizing_covering_factor) # Set the normalization self.ski.set_stellar_component_luminosity(title, fuv_ionizing, self.fuv_filter.pivot)
def start_session(self, python_command="python"): """ This function ... :param python_command: :return: """ # Inform the user log.info("Starting session for python ...") # Construct the command if self.tmux: command = "tmux new -d -s " + self.screen_name + " " + python_command elif self.output_path is not None: command = "screen -dmS " + self.screen_name + " -L" else: command = "screen -dmS " + self.screen_name # Debugging log.debug("Starting session with the command:") log.debug(command) # Execute the command self.remote.execute(command, show_output=True, cwd=self.output_path) # Using screen if not self.tmux: start_python_command = "screen -S " + self.screen_name + " -p 0 -X stuff '" + python_command + "\n'" self.remote.execute(start_python_command)
def setup_modelling(self): """ This function ... :return: """ # Inform the user log.info("Setting up the modelling ...") # Settings settings_setup = dict() settings_setup["type"] = "galaxy" settings_setup["name"] = self.modeling_name settings_setup["fitting_host_ids"] = None # Create input dict for setup input_setup = dict() input_setup["ngc_name"] = self.properties.ngc_name input_setup["hyperleda_name"] = self.properties.hyperleda_name # Construct the command stp = Command("setup", "setup the modeling", settings_setup, input_setup, cwd=".") # Call the command tool = self.run_command(stp)
def load_i1(self): """ This function ... :return: """ # Inform the user log.info("Loading the IRAC 3.6 micron image ...") # Determine the path to the truncated 3.6 micron image #path = fs.join(truncation_path, "IRAC I1.fits") path = fs.join(self.prep_path, "IRAC I1", "result.fits") frame = Frame.from_file(path) # Convert the frame to Jy/pix conversion_factor = 1.0 conversion_factor *= 1e6 # Convert the 3.6 micron image from Jy / sr to Jy / pixel pixelscale = frame.average_pixelscale pixel_factor = (1.0/pixelscale**2).to("pix2/sr").value conversion_factor /= pixel_factor frame *= conversion_factor frame.unit = "Jy" # Set the frame self.i1_jy = frame
def initialize_frames(self): """ This function ... :return: """ # Inform the user log.info("Initializing the frames ...") # Loop over the filters for fltr in self.coordinate_systems.filters: # Debugging log.debug("Initializing the '" + str(fltr) + "' frame ...") # Get the wcs wcs = self.coordinate_systems[fltr] # Create new frame frame = Frame.zeros(wcs.shape) # Add the wcs frame.wcs = wcs # Set the filter frame.filter = fltr # Set the unit frame.unit = "Jy" # Add the frame self.frames[fltr] = frame
def create_dataset(self, masks=None): """ This function ... :param masks: :return: """ # Inform the user log.info("Creating the dataset ...") # Initialize self.dataset = DataSet() # Add the frames for fltr in self.frames: # Determine name for the image name = str(fltr) # Determine path for this frame path = fs.join(self.data_frames_path, name + ".fits") # Debugging log.debug("Saving the frame ...") # Save the frame self.frames[fltr].saveto(path) # Debugging log.debug("Adding the '" + name + "' image to the dataset ...") # Add the frame to the dataset self.dataset.add_path(name, path) # Determine the path for the mask mask_path = fs.join(self.data_masks_path, name + ".fits") # Mask if masks is not None and fltr in masks: # Debugging log.debug("Saving the mask ...") # Save masks[fltr].saveto(mask_path) # Debugging log.debug("Adding mask ...") # Add the mask self.dataset.add_mask_path(name, mask_path) # Determine database path path = fs.join(self.path, "database.dat") # Write the dataset self.dataset.saveto(path)
def write(self): """ This function ... :return: """ # Inform the user log.info("Writing ...")
def load_model(self): """ This function ... :return: """ # Inform the user log.info("Loading the model image ...") # Determine the path to the truncated model image path = fs.join(self.components_images_path, "model.fits") self.model_jy = Frame.from_file(path)
def load_bulge2d(self): """ This function ... :return: """ # Inform the user log.info("Loading the bulge 2D image ...") # Determine the path to the bulge 2D image path = fs.join(self.components_images_path, "bulge2D.fits") self.bulge2d_jy = Frame.from_file(path)
def show(self): """ This function ... :return: """ # Inform the user log.info("Showing the pages ...") # Open browser.open_path(self.environment.html_status_path)
def load_disk(self): """ This function ... :return: """ # Inform the user log.info("Loading the disk image ...") # Determine the path to the disk image path = fs.join(self.components_images_path, "disk.fits") self.disk_jy = Frame.from_file(path)
def get_image(self): """ This function ... :return: """ # Inform the user log.info("Getting the image ...") # Get the image self.frame = get_image(self.config.galaxy_name, self.config.filter, self.config.year)
def create_progression(self): """ This function ... :return: """ # Inform the user log.info("Creating the modeling progression ...") # Create self.progression = create_modeling_progression(self.config.path)
def load_images(self): """ This function ... :return: """ # Inform the user log.info("Loading the images ...") # The common wcs of the images wcs = None # Loop over the images in the data directory for path, filename in fs.files_in_path(self.data_path, extension="fits", returns=["path", "name"]): # Load the frame frame = Frame.from_file(path) # Set filter previous_filter = frame.filter frame.filter = parse_filter(filename.split("_norm")[0]) if previous_filter != frame.filter: frame.save() # Check filter if str(frame.filter) not in [ str(fltr) for fltr in self.config.fitting_filters ]: continue # Determine name name = str(frame.filter) # Check wcs if wcs is None: wcs = frame.wcs elif wcs == frame.wcs: pass else: raise IOError("The coordinate system of image '" + filename + "' does not match that of other images") # Debugging log.debug("Adding frame '" + filename + "' ...") # Add to dictionary self.images[name] = frame # Set original path self.image_paths[name] = path # Set the wcs self.wcs = wcs
def test_gray_conversion_dynamic(self): """ This function ... :return: """ # Inform the user log.info("Testing the Gray code conversions (dynamic nbits) ...") max_number = 15 if check_gray_conversion(max_number): log.success("Test succeeded") else: log.error("Test failed")
def make_point_sources(self): """ This function ... :return: """ # Inform the user log.info("Making point sources ...") # Call the appropriate function if self.config.vary_fwhm: self.make_point_sources_variable_fwhm() else: self.make_point_sources_fixed_fwhm()
def reference(self): """ This function ... :return: """ # Inform the user log.info("Estimating background with photutils ...") # Plot total mask if self.config.plot: plotting.plot_mask(self.total_mask, title="total mask") integer_aperture_radius = int(math.ceil(self.aperture_radius)) box_shape = (integer_aperture_radius, integer_aperture_radius) filter_size = (3, 3) # Estimate the background sigma_clip = SigmaClip(sigma=3., iters=10) #bkg_estimator = MedianBackground() bkg_estimator = SExtractorBackground() bkg = Background2D(self.frame.data, box_shape, filter_size=filter_size, sigma_clip=sigma_clip, bkg_estimator=bkg_estimator, mask=self.total_mask.data) # Statistics #print("median background", bkg.background_median) #print("rms background", bkg.background_rms_median) self.statistics.reference = Map() self.statistics.reference.median = bkg.background_median self.statistics.reference.rms = bkg.background_rms_median # Plot if self.config.plot: plotting.plot_box(bkg.background, title="background from photutils") # Set the sky self.reference_sky = Frame(bkg.background) # Set bkg object self.photutils_bkg = bkg # Plot if self.config.plot: plotting.plot_box(self.reference_sky, title="reference sky")
def write_reference(self): """ This function ... :return: """ # Inform the user log.info("Writing ...") # Write the ski file self.write_ski() # Write the input self.write_input()
def write_subtracted(self): """ This function ... :return: """ # Inform the user log.info("Writing the sky-subtracted frame ...") # Determine the path path = fs.join(self.path, "subtracted.fits") # Save self.subtracted.saveto(path)
def plot_reference(self): """ This function ... :return: """ # Inform the user log.info("Plotting ...") # Plot the wavelengths self.plot_wavelengths() # Plot the filters self.plot_filters()
def write_reference_sky(self): """ This function ... :return: """ # Inform the user log.info("Writing the reference sky map ...") # Determine the path path = fs.join(self.path, "reference_sky.fits") # Save self.reference_sky.saveto(path)
def write_estimated_sky(self): """ This function ... :return: """ # Inform the user log.info("Writing the estimated sky map ...") # Determine the path path = fs.join(self.path, "estimated_sky.fits") # Save self.estimated_sky.saveto(path)
def test(self): """ This function ... :return: """ # Inform the user log.info("Testing ...") # Check the best value #self.check_best() # CANNOT CHECK ANYMORE TEMPORARILY BECAUSE OF RECURRENCE # Check the database self.check_database()
def write_galaxy_mask(self): """ This function ... :return: """ # Inform the user log.info("Writing the galaxy mask ...") # Determine the path path = fs.join(self.path, "galaxy_mask.fits") # Save self.galaxy_mask.saveto(path)
def make_attenuation_maps(self): """ This function ... :return: """ # Inform the user log.info("Making attenuation maps ...") # Make FUV attenuation map self.make_attenuation_maps_fuv() # Make NUV attenuation map self.make_attenuation_maps_nuv()
def create_catalog(self): """ This function ... :return: """ # Inform the user log.info("Creating the catalog ...") # Initialize catalogs self.initialize_catalog() # Add random sources self.create_random_sources()
def make_sky(self): """ This function ... :return: """ # Inform the user log.info("Making sky ...") # make constant sky self.make_constant_sky() # Make gradient sky self.make_gradient_sky()
def make_constant_sky(self): """ This function .. :return: """ # Inform the user log.info("Making constant sky ...") self.constant_sky = Frame.filled_like(self.sources, self.config.constant_sky) # Mask self.constant_sky[self.rotation_mask] = 0.0
def write_statistics(self): """ This function ... :return: """ # Inform the user log.info("Writing the statistics ...") # Determine the path path = fs.join(self.path, "statistics.dat") # Write save_mapping(path, self.statistics)
def write_residual(self): """ This function ... :return: """ # Inform the user log.info("Writing the residual map ...") # Determine the path path = fs.join(self.path, "residual.fits") # Save self.sky_residual.saveto(path)
def create_instrument(self): """ This function ... :return: """ # Inform the user log.info("Creating the instrument ...") # Create a full instrument # center, distance, inclination, azimuth, position_angle azimuth = 0.0 self.instrument = FullInstrument.from_wcs(self.wcs, self.galaxy_center, self.galaxy_distance, self.galaxy_inclination, azimuth, self.galaxy_position_angle)
def make_dust_maps(self): """ This function ... :return: """ # Inform the user log.info("Making dust maps ...") # Diffuse dust through attenuation self.make_diffuse_dust_maps() # Hot dust self.make_hot_dust_maps()
def write_frame(self): """ This function ... :return: """ # Inform the user log.info("Writing the frame ...") # Determine the path path = fs.join(self.path, "frame.fits") # SAve the frame self.frame.saveto(path)
def write_sources(self): """ THis function ... :return: """ # Inform the user log.info("Writing the sources frame with noise ...") # Determine the path path = fs.join(self.path, "sources_noise.fits") # Save the frame self.sources_with_noise.saveto(path)
def make_tir_maps(self): """ This function ... :return: """ # Inform the user log.info("Making TIR maps ...") # Make TIR maps based on single bands self.make_tir_maps_single() # Make TIR maps based on multiple bands self.make_tir_maps_multi()
def make_old_stars_maps(self): """ This function ... :return: """ # Inform the user log.info("Making old stellar maps ...") # Make bulge map self.make_old_stars_maps_bulge() # Make disk map self.make_old_stars_maps_disk()
def setup_modelling(self): """ This function ... :return: """ # Inform the user log.info("Setting up the modeling ...") # Settings settings_setup = dict() settings_setup["type"] = "sed" settings_setup["name"] = "SN1987A" settings_setup["fitting_host_ids"] = None # ----------------------------------------------------------------- # Input # Construct the observed SED sed = ObservedSED(photometry_unit="Jy") sed.add_point("Pacs 70", 0.0455 * u("Jy"), 0.0034 * u("Jy")) sed.add_point("Pacs 100", 0.0824 * u("Jy"), 0.0045 * u("Jy")) sed.add_point("Pacs 160", 0.1530 * u("Jy"), 0.0090 * u("Jy")) sed.add_point("SPIRE 250", 0.1107 * u("Jy"), 0.0252 * u("Jy")) sed.add_point("SPIRE 350", 0.0693 * u("Jy"), 0.0228 * u("Jy")) sed.add_point("ALMA 440um", 0.0500 * u("Jy"), 0.0150 * u("Jy")) sed.add_point("ALMA 870um", 0.0050 * u("Jy"), 0.0010 * u("Jy")) # Create object config object_config = dict() ski_path = fs.join(this_dir_path, "SN1987A.ski") object_config["ski"] = ski_path # Create input dict for setup input_setup = dict() input_setup["object_config"] = object_config input_setup["sed"] = sed # Construct the command setup_command = Command("setup", "setup the modelling", settings_setup, input_setup, cwd=".") # Add the command #commands.append(setup_command) tool = self.run_command(setup_command)