-
Notifications
You must be signed in to change notification settings - Fork 6
Fix JWST spectra plotting #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
52b90b2
6450fff
630d4bc
7d5b038
b6ed6df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,7 @@ def normalise() -> np.ndarray: | |
| db = SimpleDB(db_file) # open database | ||
| t_spectra: Table = db.query(db.Spectra).\ | ||
| filter(db.Spectra.c.source == query).\ | ||
| table(spectra=['access_url']) | ||
| table() # do not use spectra=['access_url'] here, it will try to read the spectra as Spectrum objects | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was missing and is required to prevent astrodbkit from auto-converting the spectra, that is done manually now in line 178 |
||
|
|
||
| # initialise plot | ||
| n_fail, fail_string_list = 0, [] | ||
|
|
@@ -173,7 +173,12 @@ def normalise() -> np.ndarray: | |
|
|
||
| # checking each spectra in table | ||
| for spec in t_spectra: | ||
| spectrum: Spectrum1D = spec['access_url'] | ||
| try: | ||
| # Manually convert the spectrum to a Spectrum object | ||
| spectrum = Spectrum.read(spec['access_url'], cache=True) | ||
| except Exception as e: | ||
| print(f"Unable to read {spec['access_url']} as Spectrum. Error: {e}") | ||
| continue | ||
|
|
||
| # checking spectrum has good units and not only NaNs or 0s | ||
| try: | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes here were Ruff import sorting. I did explicitly add |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,69 @@ | ||
| """ | ||
| Importing all packages | ||
| """ | ||
| # external packages | ||
|
|
||
| import argparse # parsing the arguments given with file | ||
| import os # operating system | ||
| import sys # system arguments | ||
| from copy import deepcopy # memory control | ||
| from difflib import get_close_matches # for redirecting bad file paths | ||
| from io import BufferedIOBase, BytesIO, StringIO # writing files without saving to disk | ||
| from shutil import copy # copying files | ||
| from sqlite3 import Warning as SqliteWarning # errors from sqlite | ||
| from time import localtime, strftime # time stuff for naming files | ||
| from typing import Dict, Generator, List, Optional, Tuple, Union # type hinting (good in IDEs) | ||
| from urllib.parse import quote # handling strings into url friendly form | ||
| from zipfile import ZipFile # zipping files together | ||
|
|
||
| import astropy.units as u # units | ||
| import multiprocess as mp # multiprocessing for efficiency | ||
| import numpy as np # numerical python | ||
| import pandas as pd # running dataframes | ||
| import pytest # testing | ||
| import requests # accessing internet | ||
| from astrodbkit.astrodb import Database # used for pulling out database and querying | ||
| from astropy.coordinates import SkyCoord # coordinates | ||
| from astropy.io import fits # handling fits files | ||
| import astropy.units as u # units | ||
| from astropy.table import Table # tables in astropy | ||
| from bokeh.embed import components # converting python bokeh to javascript | ||
| from bokeh.layouts import row, column # bokeh displaying nicely | ||
| from bokeh.models import ColumnDataSource, Range1d, CustomJS, \ | ||
| Select, Toggle, TapTool, OpenURL, HoverTool, Span, RangeSlider, Label, ColorBar, FixedTicker # bokeh models | ||
| from bokeh.layouts import column, row # bokeh displaying nicely | ||
| from bokeh.models import ( | ||
| ColorBar, | ||
| ColumnDataSource, | ||
| CustomJS, | ||
| FixedTicker, | ||
| HoverTool, | ||
| Label, | ||
| OpenURL, | ||
| Range1d, | ||
| RangeSlider, | ||
| Select, # bokeh models | ||
| Span, | ||
| TapTool, | ||
| Toggle, | ||
| ) | ||
| from bokeh.palettes import Colorblind8, Turbo256 # plotting palettes | ||
| from bokeh.plotting import figure, curdoc # bokeh plotting | ||
| from bokeh.plotting import curdoc, figure # bokeh plotting | ||
| from bokeh.resources import CDN # resources for webpage | ||
| from bokeh.themes import built_in_themes, Theme # appearance of bokeh glyphs | ||
| from bokeh.themes import Theme, built_in_themes # appearance of bokeh glyphs | ||
| from bokeh.transform import linear_cmap # making colour maps | ||
| from flask import (Flask, render_template, jsonify, send_from_directory, redirect, url_for, | ||
| Response, abort, request, session) # website | ||
| from flask import ( | ||
| Flask, | ||
| Response, # website | ||
| abort, | ||
| jsonify, | ||
| redirect, | ||
| render_template, | ||
| request, | ||
| send_from_directory, | ||
| session, | ||
| url_for, | ||
| ) | ||
| from flask_cors import CORS # cross origin fix (aladin mostly) | ||
| from flask_wtf import FlaskForm # web forms | ||
| from markdown2 import markdown # using markdown formatting | ||
| import numpy as np # numerical python | ||
| import pandas as pd # running dataframes | ||
| import pytest # testing | ||
| from specutils import Spectrum1D # spectrum objects | ||
| from sqlalchemy.exc import ResourceClosedError, OperationalError, ProgrammingError # errors from sqlalchemy | ||
| from sqlite3 import Warning as SqliteWarning # errors from sqlite | ||
| from specutils import Spectrum | ||
| from sqlalchemy.exc import OperationalError, ProgrammingError, ResourceClosedError # errors from sqlalchemy | ||
| from tqdm import tqdm # progress bars | ||
| from werkzeug.exceptions import HTTPException # underlying http | ||
| from wtforms import StringField, SubmitField, TextAreaField, ValidationError # web forms | ||
|
|
||
| # internal packages | ||
| import argparse # parsing the arguments given with file | ||
| from copy import deepcopy # memory control | ||
| from difflib import get_close_matches # for redirecting bad file paths | ||
| from io import StringIO, BytesIO, BufferedIOBase # writing files without saving to disk | ||
| import multiprocess as mp # multiprocessing for efficiency | ||
| import os # operating system | ||
| import requests # accessing internet | ||
| from shutil import copy # copying files | ||
| import sys # system arguments | ||
| from time import strftime, localtime # time stuff for naming files | ||
| from typing import Tuple, Optional, List, Union, Dict, Generator # type hinting (good in IDEs) | ||
| from urllib.parse import quote # handling strings into url friendly form | ||
| from zipfile import ZipFile # zipping files together |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWST spectra was still not working with 2.0.0, but 2.2.0 works well