コード例 #1
0
ファイル: cluster.py プロジェクト: jpbreuer/ClusterPyXT
    def get_cluster_info_from_user(self):
        self.name = io.get_user_input("Enter the cluster name: ", "cluster name")
        self.data_directory = os.path.normpath(config.data_directory())

        self.observation_ids = get_observation_ids()
        self.observations = [Observation(obsid=x, cluster=self) for x in self.observation_ids]
        print()
        get_fitting_values = \
            io.check_yes_no("Enter values for fitting (nH, z, abundance) now? [y/n]")
        if get_fitting_values:
            self.hydrogen_column_density = io.get_user_input(
                "Enter the hydrogen column density for {} (on order of 10^22, e.g. 0.052 for 5.2e20): ".format(self.name),
                "hydrogen column density")
            self.redshift = io.get_user_input("Enter the redshift of {}: ".format(self.name), "redshift")

            self.abundance = io.get_user_input("Enter the abundance: ", "abundance")
        else:
            print("Before completing the ACB portion of the pypeline, you need "
                  "to edit the configuration file ({config}) "
                  "and update the values for hydrogen column density, redshift, "
                  "and abundance.".format(config=self.configuration_filename))
            self.hydrogen_column_density = "Update me! (on order of 10^22 e.g. 0.052 for 5.2e20)"
            self.redshift = "Update me! (e.g. 0.192)"
            self.abundance = "Update me! (e.g. 0.2)"
        self._last_step_completed = 1


        return
コード例 #2
0
    fits.writeto(clstr.entropy_map_filename, norm_K, header=clstr.temperature_map_header, overwrite=True)  
    

if __name__ == '__main__':
    args, parser = get_arguments()

    if args.cluster_config is not None:
        clstr = cluster.load_cluster(args.cluster_config)

        if args.commands:
            make_commands_lis(clstr, args.resolution)
        if args.eff_times_fits:
            eff_times_to_fits(clstr)
        elif args.temperature_map:
            print("Creating temperature map.")
            make_temperature_map(clstr, args.resolution)
        elif args.pressure:
            make_pressure_map(clstr)
        elif args.entropy:
            make_entropy_map(clstr)
        elif args.shock:
            import shockfinder

            if io.check_yes_no("This is likely not going to work. Continue?"):
                shockfinder.find_shock_in(clstr)
        else:
            fitting_preparation(clstr, args)
    else:
        parser.print_help()
コード例 #3
0
ファイル: ciao.py プロジェクト: wanglei773778083/ClusterPyXT
def lightcurves_with_exclusion(cluster):
    for observation in cluster.observations:


        # data_nosrc_hiEfilter = "{}/acisI_nosrc_fullE.fits".format(obs_analysis_dir)

        data_nosrc_hiEfilter = "{}/acisI_nosrc_hiEfilter.fits".format(observation.analysis_directory)

        print("Creating the image with sources removed")

        data = observation.acis_nosrc_filename

        image_nosrc = "{}/img_acisI_nosrc_fullE.fits".format(observation.analysis_directory)

        if io.file_exists(observation.exclude_file):
            print("Removing sources from event file to be used in lightcurve")

            infile = "{}[exclude sky=region({})]".format(data_nosrc_hiEfilter, observation.exclude)
            outfile = "{}/acisI_lcurve.fits".format(observation.analysis_directory)
            clobber = True

            rt.dmcopy.punlearn()
            rt.dmcopy(infile=infile, outfile=outfile, clobber=clobber)

            data_lcurve = "{}/acisI_lcurve.fits".format(observation.analysis_directory)
        else:
            yes_or_no = io.check_yes_no(
                "Are there sources to be excluded from observation {} while making the lightcurve? ".format(observation.id))

            if yes_or_no:  # yes_or_no == True
                print("Create the a region file with the region to be excluded and save it as {}".format(observation.exclude_file))
            else:
                data_lcurve = data_nosrc_hiEfilter

        backbin = 259.28

        echo = True
        tstart = rt.dmkeypar(infile=data_nosrc_hiEfilter, keyword="TSTART", echo=echo)
        tstop = rt.dmkeypar(infile=data_nosrc_hiEfilter, keyword="TSTOP", echo=echo)

        print("Creating lightcurve from the events list with dmextract")

        infile = "{}[bin time={}:{}:{}]".format(data_lcurve, tstart, tstop, backbin)
        outfile = "{}/acisI_lcurve.lc".format(observation.analysis_directory)
        opt = "ltc1"

        rt.dmextract.punlearn()
        rt.dmextract(infile=infile, outfile=outfile, opt=opt, clobber=clobber)

        lcurve = outfile

        print("Cleaning the lightcurve by removing flares with deflare. Press enter to continue.")

        rt.deflare.punlearn()
        infile = lcurve
        outfile = "{}/acisI_gti.gti".format(observation.analysis_directory)
        method = "clean"
        save = "{}/acisI_lcurve".format(observation.analysis_directory)

        rt.deflare(infile=infile, outfile=outfile, method=method, save=save)

        gti = outfile

        print("filtering the event list using GTI info just obtained.")

        infile = "{}[@{}]".format(data_nosrc_hiEfilter, gti)
        outfile = observation.clean
        clobber = True

        rt.dmcopy(infile=infile, outfile=outfile, clobber=clobber)

        data_clean = outfile

        print("Don't forget to check the light curves!")