How to use jwql - 10 common examples

To help you get started, we’ve selected a few jwql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacetelescope / jwql / jwql / jwql_monitors / generate_preview_images.py View on Github external
identifier = os.path.basename(filename).split('.fits')[0]

        preview_output_directory = os.path.join(preview_image_filesystem, identifier)
        thumbnail_output_directory = os.path.join(thumbnail_filesystem, identifier)

        # Check to see if the preview images already exist and skip
        # if they do
        file_exists = check_existence(file_list, preview_output_directory)
        if file_exists:
            logging.info("JPG already exists for {}, skipping.".format(filename))
            continue

        # Create the output directories if necessary
        if not os.path.exists(preview_output_directory):
            os.makedirs(preview_output_directory)
            permissions.set_permissions(preview_output_directory)
            logging.info('Created directory {}'.format(preview_output_directory))
        if not os.path.exists(thumbnail_output_directory):
            os.makedirs(thumbnail_output_directory)
            permissions.set_permissions(thumbnail_output_directory)
            logging.info('Created directory {}'.format(thumbnail_output_directory))

        # If the exposure contains more than one file (because more
        # than one detector was used), then create a mosaic
        max_size = 8
        numfiles = len(file_list)
        if numfiles != 1:
            try:
                mosaic_image, mosaic_dq = create_mosaic(file_list)
                logging.info('Created mosiac for:')
                for item in file_list:
                    logging.info('\t{}'.format(item))
github spacetelescope / jwql / jwql / website / apps / jwql / monitor_pages / monitor_mast_bokeh.py View on Github external
def pre_init(self):
        self._embed = True
        
        #App design
        self.format_string = None
        self.interface_file = os.path.join(script_dir, 'yaml',
                                           "monitor_mast_interface.yaml")
        
        self.settings = get_config()
        self.output_dir = self.settings['outputs']
        
        self.read_new_data()
        
        self.cache_time = Time(0., format='unix')
        
        self.jwst_bar_colors = self.caom_bar_colors = 3
        self.jwst_datacols = []
        self.caom_datacols = []
github spacetelescope / jwql / jwql / website / apps / jwql / data_containers.py View on Github external
``False`` if not.

    Returns
    -------
    image_info : dict
        A dictionary containing various information for the given
        ``file_root``.
    """

    # Initialize dictionary to store information
    image_info = {}
    image_info['all_jpegs'] = []
    image_info['suffixes'] = []
    image_info['num_ints'] = {}

    preview_dir = os.path.join(get_config()['jwql_dir'], 'preview_images')

    # Find all of the matching files
    dirname = file_root[:7]
    search_filepath = os.path.join(FILESYSTEM_DIR, dirname, file_root + '*.fits')
    image_info['all_files'] = glob.glob(search_filepath)

    for file in image_info['all_files']:

        # Get suffix information
        suffix = os.path.basename(file).split('_')[4].split('.')[0]
        image_info['suffixes'].append(suffix)

        # Determine JPEG file location
        jpg_dir = os.path.join(preview_dir, dirname)
        jpg_filename = os.path.basename(os.path.splitext(file)[0] + '_integ0.jpg')
        jpg_filepath = os.path.join(jpg_dir, jpg_filename)
github spacetelescope / jwql / jwql / website / apps / jwql / bokeh_containers.py View on Github external
number of files.

    Parameters
    ----------
    filepaths : list
        A list of full paths to files of interest.

    Returns
    -------
    proposal_info : dict
        A dictionary containing various information about the
        proposal(s) and files corresponding to the given ``filepaths``.
    """

    proposals = list(set([f.split('/')[-1][2:7] for f in filepaths]))
    thumbnail_dir = os.path.join(get_config()['jwql_dir'], 'thumbnails')
    thumbnail_paths = []
    num_files = []
    for proposal in proposals:
        thumbnail_search_filepath = os.path.join(thumbnail_dir, 'jw{}'.format(proposal), 'jw{}*rate*.thumb'.format(proposal))
        thumbnail = glob.glob(thumbnail_search_filepath)
        if len(thumbnail) > 0:
            thumbnail = thumbnail[0]
            thumbnail = '/'.join(thumbnail.split('/')[-2:])
        thumbnail_paths.append(thumbnail)

        fits_search_filepath = os.path.join(FILESYSTEM_DIR, 'jw{}'.format(proposal), 'jw{}*.fits'.format(proposal))
        num_files.append(len(glob.glob(fits_search_filepath)))

    # Put the various information into a dictionary of results
    proposal_info = {}
    proposal_info['num_proposals'] = len(proposals)
github spacetelescope / jwql / jwql / website / apps / jwql / views.py View on Github external
Returns
    -------
    HttpResponse object
        Outgoing response sent to the webpage
    """

    # Check if GET or POST request
    if request.method == 'POST':

        # Connect to databas
        __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
        package_dir = __location__.split('website')[0]
        database_location = os.path.join(package_dir, 'database')
        database_file = os.path.join(database_location, 'miri_database.db')
        conn = sql.create_connection(database_file)

        c = conn.cursor()

        # check if new item or delete item
        if '_newItem' in request.POST:

            # gat form
            formAdd = addAnomalyForm_Miri(request.POST)
            if formAdd.is_valid():
                Autor = str(formAdd.cleaned_data['name'])
                start = str(formAdd.cleaned_data['starttime'])
                end = str(formAdd.cleaned_data['endtime'])
                plot = str(formAdd.cleaned_data['select_plot'])
                comment = str(formAdd.cleaned_data['comment'])

                # convert time
github spacetelescope / jwql / jwql / website / apps / jwql / views.py View on Github external
elif '_deleteItem' in request.POST:

            # gat form
            formDelete = deleteAnomalyForm(request.POST)
            if formDelete.is_valid():
                ID_delete = str(formDelete.cleaned_data['ID'])

                # delete dataset
                try:
                    c.execute('DELETE FROM nirspecAnomaly WHERE id=' + ID_delete)
                except:
                    print(request, 'Delete ID=' + ID_delete + ' failed')

        conn.commit()
        sql.close_connection(conn)

    # overrite form with empty form
    formAdd = addAnomalyForm_nir()
    formDelete = deleteAnomalyForm()

    # get bokeh tabs
    template = "nirspec_data_trending.html"
    dash = nirspec_trending()

    # define html context
    context = {
        'dashboard': dash,
        'inst': '',  # Leave as empty string or instrument name; Required for navigation bar
        'inst_list': JWST_INSTRUMENT_NAMES_MIXEDCASE,  # Do not edit; Required for navigation bar
        'tools': MONITORS,  # Do not edit; Required for navigation bar
        'user': None,  # Do not edit; Required for authentication
github spacetelescope / jwql / jwql / instrument_monitors / miri_monitors / data_trending / dashboard.py View on Github external
------
    plot_data : list
        A list containing the JavaScript and HTML content for the dashboard
    variables : dict
        no use
    """

    __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
    PACKAGE_DIR = __location__.split('instrument_monitors')[0]

    # connect to database
    # DATABASE_LOCATION = os.path.join(get_config()['jwql_dir'], 'database')
    DATABASE_LOCATION = os.path.join(PACKAGE_DIR, 'database')
    DATABASE_FILE = os.path.join(DATABASE_LOCATION, 'miri_database.db')

    conn = sql.create_connection(DATABASE_FILE)

    # some variables can be passed to the template via following
    variables = dict(init=1)

    # some variables can be passed to the template via following
    variables = dict(init=1)

    # add tabs to dashboard
    tab1 = power_plots(conn, start, end)
    tab2 = volt_plots(conn, start, end)
    tab3 = fpe_plots(conn, start, end)
    tab4 = temperature_plots(conn, start, end)
    tab5 = bias_plots(conn, start, end)
    tab6 = wheel_ratios(conn, start, end)

    # build dashboard
github spacetelescope / jwql / jwql / website / apps / jwql / views.py View on Github external
request : HttpRequest object
        Incoming request from the webpage

    Returns
    -------
    HttpResponse object
        Outgoing response sent to the webpage
    """

    # Check if GET or POST request
    if request.method == 'POST':
        __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
        package_dir = __location__.split('website')[0]
        database_location = os.path.join(package_dir, 'database')
        database_file = os.path.join(database_location, 'nirspec_database.db')
        conn = sql.create_connection(database_file)  # get variables
        c = conn.cursor()

        # check if new item or delete item
        if '_newItem' in request.POST:

            # gat form
            formAdd = addAnomalyForm_nir(request.POST)
            if formAdd.is_valid():
                Autor = str(formAdd.cleaned_data['name'])
                start = str(formAdd.cleaned_data['starttime'])
                end = str(formAdd.cleaned_data['endtime'])
                plot = str(formAdd.cleaned_data['select_plot'])
                comment = str(formAdd.cleaned_data['comment'])

                # convert time
                start = float(Time(start, format='iso').mjd)
github spacetelescope / jwql / jwql / instrument_monitors / nirspec_monitors / data_trending / plots / temperature_tab.py View on Github external
# create a new plot with a title and axis labels
    p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",
                toolbar_location = "above",
                plot_width = 1120,
                plot_height = 700,
                x_axis_type = 'datetime',
                output_backend = "webgl",
                x_axis_label = 'Date', y_axis_label='Temperature (K)')

    p.grid.visible = True
    p.title.text = "Box Temperatures"
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p, "ALG_TEMP", "IGDP_NRSD_ALG_TEMP", start, end, conn, color = "red")
    b = pf.add_to_plot(p, "HK_TEMP1", "INRSH_HK_TEMP1", start, end, conn, color = "green")
    c = pf.add_to_plot(p, "HK_TEMP2", "INRSH_HK_TEMP2", start, end, conn, color = "blue")

    pf.add_hover_tool(p,[a,b,c])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"
    p.legend.orientation = "horizontal"

    return p
github spacetelescope / jwql / jwql / instrument_monitors / nirspec_monitors / data_trending / plots / msa_mce_tab.py View on Github external
p = figure( tools = "pan,wheel_zoom,box_zoom,reset,save",
                toolbar_location = "above",
                plot_width = 560,
                plot_height = 700,
                x_axis_type = 'datetime',
                output_backend = "webgl",
                x_axis_label = 'Date', y_axis_label='Voltage (V)')

    p.grid.visible = True
    p.title.text = "MCE Board 1 (AIC)"
    p.add_layout(Title(text="Voltages", text_font_style="italic", text_font_size="12pt"), 'above')
    pf.add_basic_layout(p)

    a = pf.add_to_plot(p, "1R5_V", "INRSM_MCE_AIC_1R5_V", start, end, conn, color = "red")
    b = pf.add_to_plot(p, "3R3_V", "INRSM_MCE_AIC_3R3_V", start, end, conn, color = "orange")
    c = pf.add_to_plot(p, "5_V", "INRSM_MCE_AIC_5_V", start, end, conn, color = "brown")
    d = pf.add_to_plot(p, "P12_V", "INRSM_MCE_AIC_P12_V", start, end, conn, color = "burlywood")
    e = pf.add_to_plot(p, "N12_V", "INRSM_MCE_AIC_N12_V", start, end, conn, color = "darkmagenta")

    pf.add_hover_tool(p,[a,b,c,d,e])

    p.legend.location = "bottom_right"
    p.legend.click_policy = "hide"

    return p

jwql

The James Webb Space Telescope Quicklook Project

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis

Popular jwql functions