コード例 #1
0
colour_table = allskyColour.default(image_histogram, thresholds)


# Apply the colour mappings we have just created
false_colour_image = green_image.applyColourTable(colour_table)


# Apply the absolute calibration to the image. This converts
# the pixel values into Rayleighs. However, it is a lazy
# operation so don't expect the values in the file to be in
# Rayleighs! The calibration is only done when the image is
# plotted. The const_factor argument is used to account for
# transmission through the instrument dome.
print("Calibrating intensities to Rayleighs")
factor = 1.4E-3  # counts per second per Rayleigh
exptime = 20.0  # exposure time in seconds
dome_tansmission = 0.96  # transmission through instrument dome
calibrated_image = false_colour_image.absoluteCalibration(
    factor, exptime, const_factor=1.0 / dome_tansmission)


# Plot the image using the allskyPlot module. The returned
# object is a matplotlib figure object - see the matplotlib
# documentation for details of all the things you can do with
# this!
print("Plotting image")
calibrated_image.title = "Example Calibrated Image"
figure = allskyPlot.plot([calibrated_image])
figure.savefig("calibrated_example.png")
print("Done! Calibrated image is stored in calibrated_example.png")
コード例 #2
0
ファイル: outputs.py プロジェクト: paalge/pysces-asi
def realtime_keogram(image, output, settings_manager):

    # see if a realtime keogram has been created yet
    log.info("starting keogram")
    try:
        filename = settings_manager.get(
            ['user_rt_keo_name'])['user_rt_keo_name']
    except KeyError:
        filename = None
    image = image.resize((500, 500))

    if filename is None or not os.path.exists(filename):
        settings_manager.set(
            {'output': "OutputTaskHandler> Creating new realtime keogram."})
        # work out the start and end times for the keogram based on the setting
        # in the settings file
        end_time = datetime.datetime.utcnow()
        time_span = datetime.timedelta(hours=output.time_range)
        start_time = end_time - time_span

        keo = allskyKeo.new([image], output.angle, start_time, end_time, strip_width=output.strip_width,
                            data_spacing=output.data_spacing, keo_fov_angle=output.fov_angle)

        try:
            keo.save(os.path.expanduser('~') + "/realtime_keogram")
            settings_manager.create('user_rt_keo_name', os.path.expanduser(
                '~') + "/realtime_keogram", persistant=True)
        except ValueError:
            # value already exists - just update it to the new value
	    print("Unexpected error:", sys.exc_info()[0])
            settings_manager.set(
                {'user_rt_keo_name': os.path.expanduser('~') + "/realtime_keogram"})
    else:
        log.info("Opening keogram")
        try:
            keo = allskyKeo.load(filename)
	except IOError: 
	    print("Unexpected error:", sys.exc_info()[0])
	    print(filename)
        except:
            print("Unexpected error:", sys.exc_info()[0])
        settings_manager.set(
            {'output': "OutputTaskHandler> Adding image to realtime keogram."})

        # check that the image (and output settings) is actually compatible with the current
        # keogram - for example if the FOV has changed we don't want the range on the keogram
        # to always be out of date.

        if check_keo_compatibility(keo, image, output):
            keo = keo.roll([image])
            try:
                keo.save(filename)
            except:
                print("Unexpected error:", sys.exc_info()[0])
        else:
            # some of the settings must have changed - time to start a new
            # keogram
            settings_manager.set(
                {'user_rt_keo_name': None, 'output': "OutputTaskHandler> New image is not compatible with existing keogram."})
            return realtime_keogram(image, output, settings_manager)
        log.info("made keogram")

    return allskyPlot.plot([keo], size=(9, 3.7))
コード例 #3
0
ファイル: keo_create.py プロジェクト: paalge/paskil
    sys.exit(0)

if not os.path.isdir(sys.argv[1]):
    print "keo_create: \""+sys.argv[1]+"\" is not a directory."
    print""
    print "Usage: keo_create [DIRECTORY]"
    sys.exit(0)
    
# Import the PASKIL modules needed to create keograms
from PASKIL import allskyData, allskyKeo, allskyPlot

# create a dataset object containing all the images of
# the correct type and wavelength in the specified folder
dataset = allskyData.new(sys.argv[1], IMAGE_WAVELENGTH, IMAGE_FILE_TYPES)

# create a keogram from the dataset
keogram = allskyKeo.new(dataset, ANGLE, strip_width=STRIP_WIDTH, 
                        data_spacing=DATA_SPACING, keo_type=KEO_TYPE,
                        keo_fov_angle=KEO_FOV_ANGLE)

# save the keogram object so that it can be opened/edited in future
keo_obj_filename = os.path.normpath(sys.argv[1]+"/keogram_object")
keogram.save(keo_obj_filename)

# plot the keogram and save the plot
keo_plot_filename = os.path.normpath(sys.argv[1]+"/keogram_plot.png")
plotted_keo = allskyPlot.plot([keogram])
plotted_keo.savefig(keo_plot_filename)